Metadata-Version: 2.1
Name: cobwood
Version: 0.1.3
Summary: Python package that implements a Cobweb version of the Global Forest Trade Model
Author-email: Paul Rougieux <paul.rougieux@ec.europa.eu>, Sarah Mubareka <sarah.mubareka@ec.europa.eu>
Maintainer-email: Sarah Mubareka <sarah.mubareka@ec.europa.eu>, Selene Patani <selene.patani@ext.ec.europa.eu>
License: The MIT License
        
        Copyright (c) 2024 European Union
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: Homepage, https://gitlab.com/bioeconomy/cobwood/cobwood
Project-URL: Bug Reports, https://gitlab.com/bioeconomy/cobwood/cobwood/-/issues
Project-URL: Source, https://gitlab.com/bioeconomy/cobwood/cobwood
Keywords: cobweb,global forest sector,GFPMX,modeling
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: NOTICE.txt
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: urllib
Requires-Dist: xarray
Requires-Dist: seaborn
Requires-Dist: tqdm
Requires-Dist: urllib
Provides-Extra: notebooks
Requires-Dist: matplotlib; extra == "notebooks"
Requires-Dist: biotrade; extra == "notebooks"
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"


This package implements a Cobweb version of the Global Forest Trade Model.

# Model Formulation

The model formulation is based on GFPMX: "A Cobweb Model of the Global Forest Sector,
with an Application to the Impact of the COVID-19 Pandemic" by Joseph Buongiorno
https://doi.org/10.3390/su13105507

The GFPMX input data and parameters are available as a spreadsheet at:
https://buongiorno.russell.wisc.edu/gfpm/


# Data

The data is based on the FAOSTAT forestry production and trade data set available at:
http://www.fao.org/faostat/en/#data/FO/visualize


# Xarray

An equation typically runs for 180 countries over 80 years. We implement each equation
over 2 dimensional data arrays where country names represent the first dimension (also
called coordinate) and years constitute the second dimension. Xarray data arrays can be
converted to a format similar to the original GFPMx spreadsheet with countries in rows
and years in columns. For example the following code uses `DataArray.to_pandas()` to
convert the pulp import array to a csv file using the pandas to_csv() method:

    from cobwood.gfpmx_data import GFPMXData
    gfpmx_data = GFPMXData(data_dir="gfpmx_8_6_2021", base_year = 2018)
    pulp = gfpmx_data.convert_sheets_to_dataset("pulp")
    pulp["imp"].to_pandas().to_csv("/tmp/pulp_imp.csv")

Example table containing the first few lines and columns:

| country | 2019 | 2020 | 2021 |
|---------|------|------|------|
| Algeria | 66   | 61   | 56   |
| Angola  | 0    | 0    | 0    |
| Benin   | 0    | 0    | 0    |

The `DataArray.to_dataframe()` method converts an array and its coordinates into a tidy
pandas.DataFrame in long format, starting with a country and a year column on the left.

    pulp["imp"].to_dataframe().to_csv("/tmp/pulp_imp_long.csv")

Example table containing the first few lines and columns:

| country | year | imp |
|---------|------|-----|
| Algeria | 2019 | 66  |
| Algeria | 2020 | 61  |
| Algeria | 2021 | 56  |

