Name | cobwood JSON |
Version |
0.1.4
JSON |
| download |
home_page | None |
Summary | Python package that implements a Cobweb version of the Global Forest Trade Model |
upload_time | 2024-12-31 09:15:08 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
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. |
keywords |
cobweb
global forest sector
gfpmx
modeling
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Cobwood is a Python package designed to analyse global forest products markets.
Key Features:
- **Panel Data Structure**: The package employs panel data formatted with multiple years
and countries, enabling comprehensive time-series and cross-sectional analysis.
- **Data Handling with Xarray**: Utilizes Xarray datasets to efficiently manage and
manipulate multi-dimensional data structures.
# Model Formulation
The core implementation serves as a foundation for developing various versions of global
forest sector models. The data structure is intended to enable users to extend, or
customize the model to fit specific research or policy questions.
The first 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/
## Equations
Equations are defined using Xarray time and country indexes so that they appear similar
to mathematical equations used in the papers describing the model. For example, the
consumption equation in `cobwood/gfpmx_equations.py` takes a dataset and a specific time
`t` as input and returns a data array as output. The input dataset `ds` contains price
and GDP data for all time steps and all countries, as well as price and GDP
elasticities. The computation at a given time and for a given set of countries is done
by using the time index `t` and the country index `ds.c` (which represents all
countries in the dataset) as follows:
def consumption(ds: xarray.Dataset, t: int) -> xarray.DataArray:
"""Compute consumption equation 1"""
return (
ds["cons_constant"]
* pow(ds["price"].loc[ds.c, t - 1], ds["cons_price_elasticity"])
* pow(ds["gdp"].loc[ds.c, t], ds["cons_gdp_elasticity"])
)
# 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
Cobwood implements simulations of the Global Forest Products Market (GFPM), covering
data for 180 countries over 80 years. Each equation within the model is structured over
two-dimensional Xarray data arrays, where:
- Countries form the first dimension (or coordinate), allowing for cross-sectional
analysis.
- Years constitute the second dimension, facilitating time-series insights.
**Data Manipulation and Export**. 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 long
format also called a tidy format with one observation per row.
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 |
Raw data
{
"_id": null,
"home_page": null,
"name": "cobwood",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Sarah Mubareka <sarah.mubareka@ec.europa.eu>, Selene Patani <selene.patani@ext.ec.europa.eu>",
"keywords": "cobweb, global forest sector, GFPMX, modeling",
"author": null,
"author_email": "Paul Rougieux <paul.rougieux@ec.europa.eu>, Sarah Mubareka <sarah.mubareka@ec.europa.eu>",
"download_url": "https://files.pythonhosted.org/packages/7c/05/1afa697bc71eaab39f6f8f5a5702317214318cb2fa342fe98e548931837f/cobwood-0.1.4.tar.gz",
"platform": null,
"description": "Cobwood is a Python package designed to analyse global forest products markets.\n\nKey Features:\n\n- **Panel Data Structure**: The package employs panel data formatted with multiple years\n and countries, enabling comprehensive time-series and cross-sectional analysis.\n\n- **Data Handling with Xarray**: Utilizes Xarray datasets to efficiently manage and\n manipulate multi-dimensional data structures.\n\n\n# Model Formulation\n\nThe core implementation serves as a foundation for developing various versions of global\nforest sector models. The data structure is intended to enable users to extend, or\ncustomize the model to fit specific research or policy questions.\n\nThe first model formulation is based on GFPMX: \"A Cobweb Model of the Global Forest\nSector, with an Application to the Impact of the COVID-19 Pandemic\" by Joseph Buongiorno\nhttps://doi.org/10.3390/su13105507\n\nThe GFPMX input data and parameters are available as a spreadsheet at:\nhttps://buongiorno.russell.wisc.edu/gfpm/\n\n\n## Equations\n\nEquations are defined using Xarray time and country indexes so that they appear similar\nto mathematical equations used in the papers describing the model. For example, the\nconsumption equation in `cobwood/gfpmx_equations.py` takes a dataset and a specific time\n`t` as input and returns a data array as output. The input dataset `ds` contains price\nand GDP data for all time steps and all countries, as well as price and GDP\nelasticities. The computation at a given time and for a given set of countries is done\nby using the time index `t` and the country index `ds.c` (which represents all\ncountries in the dataset) as follows:\n\n def consumption(ds: xarray.Dataset, t: int) -> xarray.DataArray:\n \"\"\"Compute consumption equation 1\"\"\"\n return (\n ds[\"cons_constant\"]\n * pow(ds[\"price\"].loc[ds.c, t - 1], ds[\"cons_price_elasticity\"])\n * pow(ds[\"gdp\"].loc[ds.c, t], ds[\"cons_gdp_elasticity\"])\n )\n\n\n# Data\n\nThe data is based on the FAOSTAT forestry production and trade data set available at:\nhttp://www.fao.org/faostat/en/#data/FO/visualize\n\n\n# Xarray\n\nCobwood implements simulations of the Global Forest Products Market (GFPM), covering\ndata for 180 countries over 80 years. Each equation within the model is structured over\ntwo-dimensional Xarray data arrays, where:\n\n- Countries form the first dimension (or coordinate), allowing for cross-sectional\n analysis.\n- Years constitute the second dimension, facilitating time-series insights.\n\n**Data Manipulation and Export**. Xarray data arrays can be converted to a format\nsimilar to the original GFPMx spreadsheet with countries in rows and years in columns.\nFor example the following code uses `DataArray.to_pandas()` to convert the pulp import\narray to a csv file using the pandas to_csv() method:\n\n from cobwood.gfpmx_data import GFPMXData\n gfpmx_data = GFPMXData(data_dir=\"gfpmx_8_6_2021\", base_year = 2018)\n pulp = gfpmx_data.convert_sheets_to_dataset(\"pulp\")\n pulp[\"imp\"].to_pandas().to_csv(\"/tmp/pulp_imp.csv\")\n\nExample table containing the first few lines and columns:\n\n| country | 2019 | 2020 | 2021 |\n|---------|------|------|------|\n| Algeria | 66 | 61 | 56 |\n| Angola | 0 | 0 | 0 |\n| Benin | 0 | 0 | 0 |\n\nThe `DataArray.to_dataframe()` method converts an array and its coordinates into a long\nformat also called a tidy format with one observation per row.\n\n pulp[\"imp\"].to_dataframe().to_csv(\"/tmp/pulp_imp_long.csv\")\n\nExample table containing the first few lines and columns:\n\n| country | year | imp |\n|---------|------|-----|\n| Algeria | 2019 | 66 |\n| Algeria | 2020 | 61 |\n| Algeria | 2021 | 56 |\n\n",
"bugtrack_url": null,
"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 \u201cSoftware\u201d), 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 \u201cAS IS\u201d, 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.",
"summary": "Python package that implements a Cobweb version of the Global Forest Trade Model",
"version": "0.1.4",
"project_urls": {
"Bug Reports": "https://gitlab.com/bioeconomy/cobwood/cobwood/-/issues",
"Homepage": "https://gitlab.com/bioeconomy/cobwood/cobwood",
"Source": "https://gitlab.com/bioeconomy/cobwood/cobwood"
},
"split_keywords": [
"cobweb",
" global forest sector",
" gfpmx",
" modeling"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a563599b6d3cb973ae34dd5b9f1adf71c911318ba85b886a5aafbd3b6ab2d4e",
"md5": "f5b75e6da945560dad4a34bdc648de95",
"sha256": "3ad9490646d742a625f00487fdfe15ea7ccaa244a32e3541f7176bbabb58733a"
},
"downloads": -1,
"filename": "cobwood-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f5b75e6da945560dad4a34bdc648de95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 32927,
"upload_time": "2024-12-31T09:15:05",
"upload_time_iso_8601": "2024-12-31T09:15:05.490538Z",
"url": "https://files.pythonhosted.org/packages/5a/56/3599b6d3cb973ae34dd5b9f1adf71c911318ba85b886a5aafbd3b6ab2d4e/cobwood-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c051afa697bc71eaab39f6f8f5a5702317214318cb2fa342fe98e548931837f",
"md5": "855bab2c8e0896b94fa4af52fd6bf385",
"sha256": "bba250479fec6f16668f894c56ee71a33512fd93470d58078f1e97a1e8d65991"
},
"downloads": -1,
"filename": "cobwood-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "855bab2c8e0896b94fa4af52fd6bf385",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 65551,
"upload_time": "2024-12-31T09:15:08",
"upload_time_iso_8601": "2024-12-31T09:15:08.270206Z",
"url": "https://files.pythonhosted.org/packages/7c/05/1afa697bc71eaab39f6f8f5a5702317214318cb2fa342fe98e548931837f/cobwood-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-31 09:15:08",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "bioeconomy",
"gitlab_project": "cobwood",
"lcname": "cobwood"
}