Hestia's Distribution library
Project description
Hestia Data Utils
Utils library to manipulate distributions on the Hestia platform
Install
pip install hestia_earth.distribution
Usage
By default, all output files will be stored under ./data folder.
You can set the env variable DISTRIBUTION_DATA_FOLDER
to store in a different folder.
To get posterior distribution:
from hestia_earth.distribution.posterior_yield import get_post
# get a single posterior distribution, run:
mu_ensemble, sd_ensemble = get_post('GADM-GBR', 'wheatGrain')
# Or, if only instrested in the mean of the mu and sd values, run:
mu, sd = get_esemble_means(*get_post('GADM-GBR', 'wheatGrain'))
Generate prior distribution
To generate yield prior file for all products:
python generate_prior_yield.py --overwrite=True
For more information, run python generate_prior_yield.py --help
.
Generate likelihood data
In order to generate likelihood data (a spreadsheet of crop yield and fertiliser data) for a specific product and a specific country, run:
python generate_likelihood.py --product-id="wheatGrain" --country-id="GADM-GBR" --limit=1000
For more information, run python generate_likelihood.py --help
.
Generate posterior distribution
- In order to generate posterior distribution (for Bayesian statistics) for a specific product and a specific country, run:
python generate_posterior_yield.py --product-id="wheatGrain" --country-id="GADM-GBR"
- In order to generate posterior distribution for a specific product (for all countries), run:
python generate_posterior_yield.py --product-id="wheatGrain"
- In order to generate posterior distribution for a specific country (for all products), run:
python generate_posterior_yield.py --country-id="GADM-GBR"
- In order to generate posterior distribution for all products and all countries, run:
python generate_posterior_yield.py
Plotting
Prior Yield
To plot prior distribution by product by country:
python plot_prior_yield.py --country-id='GADM-GBR' --product-id='wheatGrain' --output-file='prior.png'
To plot FAO annual yield data, change --type
parameter to one of the four options: fao_per_country
, fao_per_product
, fao_per_country_per_product
, world_mu_signma
. Example:
python plot_prior_yield.py --country-id='GADM-GBR' --output-file='fao-yield-gbr-allProducts.png' --type='fao_per_country'
For more information, run python plot_prior_yield.py --help
.
Cycle Yield
To plot the bivariate distribution of yield data for Wheat, grain in United Kingdom:
python plot_cycle_yield.py --product-id=wheatGrain" --country-id="GADM-GBR" --limit=100
This will take a sample size of 100
and create a result.png
file with the distribution.
For more information, run python plot_cycle_yield.py --help
.
Posterior Yield
In order to plot the posterior distribution for a specific product and a specific country, run:
python plot_posterior_yield.py --country-id="GADM-GBR" --product-id="wheatGrain" --output-file="post.png"
For more information, run python plot_posterior_yield.py --help
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for hestia-earth-distribution-0.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f84a9163e7f5b7d7e7941c5ce1702865939eb6faf8e5910a224ed48a4be6e79c |
|
MD5 | 43e31bfa7b3544e8eea8d043a3b746e8 |
|
BLAKE2b-256 | 3b75f078cc8772a49f3e30ecba02f6489c2d8a745809724bdb3a1d580d0f7a96 |
Hashes for hestia_earth_distribution-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9600cb257a22be6afdb9fa5dbb173c3b547b6d85b2277ffff1bb637394d241bf |
|
MD5 | 4a61a73c8b7b122c8002b249cb8f0d17 |
|
BLAKE2b-256 | bed6288aec981210e2c8be5e99a1bc5b59c791ea36fc8779f05fbc75f44f66fa |