Raw values for production, animal usage, burning and other uses of crop residues. These are then combined and made consistent in the notebook crop_residue_analysis.ipynb
# load packages
import numpy as np
import pandas as pd
import xarray as xr
import math
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import matplotlib
import datetime
import rasterio
import itertools
import h5py
Datasets that need to be downloaded before running the script:
Global Distribution of Ruminant Livestock Production Systems (GRPS 5) https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/WPDSZE
Gridded Livestock of the World (GLW 3) https://dataverse.harvard.edu/dataverse/glw_3
SPAM 2010 (production and harvested area) https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/PRFF8V
#methods used to calculate residue production
residue_methods = ['RPR','bentsen','fischer']
#methods used to calculate residues used for livestock feed
#note that mekonnen only provides FCR numbers, and crop residue percentages are copied from herrero
FCR_res_list = ['herrero','mekonnen','mottet']
# location of datasets
# frequently used folders
resources_folder = '/Users/smerald-a/ldndc/resources/'
data_folder = './input_data/'
livestock_folder = resources_folder + 'livestock_production_systems/'
#location of conversion tables between different country identification codes (ISO3, M49...)
country_code_loc = data_folder + 'FAO_country_codes.csv'
#location of netcdf file linking grid cells (0.5 deg) with country
country_grid_loc = data_folder + 'global_country_grid.txt'
#regions as used in Herrero et al 2013
region_herrero_loc = data_folder + 'countries.csv'
#livestock production systems
livestock_prod_sys_loc = livestock_folder + 'GLPS_2011/ps_cmb/w001001x.adf'
#animal numbers
cattle_no_loc = livestock_folder + 'cattle/5_Ct_2010_Da.tif'
goat_no_loc = livestock_folder + 'goats/5_Gt_2010_Da.tif'
sheep_no_loc = livestock_folder + 'sheep/6_Sh_2010_Aw.tif'
horse_no_loc = livestock_folder + 'horses/5_Ho_2010_Da.tif'
pig_no_loc = livestock_folder + 'pigs/5_Pg_2010_Da.tif'
#spam crop production
spam_prod_loc = resources_folder + 'SPAM/spam2010v2r0_global_prod/spam2010V2r0_global_P_TA.csv'
#spam harvested area
spam_harv_area_loc = resources_folder + 'SPAM/spam2010v2r0_global_harv_area/spam2010V2r0_global_H_TA.csv'
#FAO cereal harvested areas and production (per country)
FAO_ha_loc = data_folder + 'FAO_cereal_ha.csv'
FAO_prod_loc = data_folder + 'FAO_cereal_production.csv'
#residue production ratios
RPR_loc = data_folder + 'RPR_updated_long.csv'
#FAO meat and milk production
FAO_meat_milk_loc = data_folder + 'FAO_meat_milk_production.csv'
#crop residue percentages in animal feed (by weight)
crop_res_perc_stem = data_folder + f'crop_residue_perc_'
#feed conversion ratios
FCR_stem = data_folder + f'FCR_'
#GFED4s
GFED4s_stem = resources_folder + 'fire/GFED4s/GFED4.1s_'
#FINN
FINN_loc = resources_folder + 'fire/FINN/FINN_crop_burning.nc'
#GDP (from FAO, 2015 dollars)
GDP_loc = data_folder + 'GDP.csv'
#location of of output
data_out_folder = resources_folder + 'crop_residues/intermediate_datasets/'
#additional datasets stored as dictionaries
# dictionary of parameters for equation linking crop yield (Y) to residue yield taken from bentsen14 and ronzon17
bentsen_dict = {'Barley' : {'a' : 1.822, 'b' : -0.149},
'Maize' : {'a' : 2.656, 'b' : -0.103},
'Rice' : {'a' : 2.45, 'b' : -0.084},
'Wheat' : {'a' : 2.183, 'b' : -0.127},
'Millet' : {'a' : 1.9, 'b' : -0.250},
'Sorghum' : {'a' : 2.302, 'b' : -0.100},
'Other cereals' : {'a' : 1.9, 'b' : -0.250}}
# dictionary of parameters for equation linking crop yield (Y) to residue yield taken from Fischer07 (via ronzon17)
fischer_dict = {'Barley' : {'a' : 2.77, 'b' : 0.27},
'Maize' : {'a' : 2.2, 'b' : 0.13},
'Rice' : {'a' : 2.56, 'b' : 0.22},
'Wheat' : {'a' : 1.96, 'b' : 0.14},
'Millet' : {'a' : 4.38, 'b' : 0.95},
'Sorghum' : {'a' : 4.55, 'b' : 0.55},
'Other cereals' : {'a' : 2.7, 'b' : 0.2}}
#protein content from herrero 2013 table S9
protein_dict = {'cattle' : {'meat' : 0.138, 'milk' : 0.033},
'goat' : {'meat' : 0.137, 'milk' : 0.033},
'sheep' : {'meat' : 0.137, 'milk' : 0.033}}
#choose years consistent with input datasets
start_year = 1997
end_year = 2021
year_list = list(np.arange(start_year,end_year+1))
# print options for DataFrames
pd.set_option("max_rows", 350)
pd.set_option("max_columns", 100)
pd.options.display.max_colwidth = 100
def isNaN(string): #tests if string is nan
return string != string
#regrid dataarray to coarser grid using the most common value within a coarse grid cell (useful for qualitative data such as livestock production systems)
#current_grid_width
def regridder_most_common(dA,initial_cell_width,regrid_fac):
#no of original lat and lon points
lat_no_in = 180/initial_cell_width
lon_no_in = 360/initial_cell_width
#build regridded numpy array
arr_new = np.empty([int(lat_no_in/regrid_fac),int(lon_no_in/regrid_fac)])
arr = dA.values
for x in range(0,arr_new.shape[1]):
for y in range(0,arr_new.shape[0]):
arr_min = arr[regrid_fac*y:regrid_fac*y+regrid_fac,regrid_fac*x:regrid_fac*x+regrid_fac]
values, counts = np.unique(arr_min, return_counts=True)
#print(values,counts)
ind = np.nanargmax(counts)
#print(values[ind])
arr_new[y,x] = values[ind]
#convert back to dataarray
cell_width = initial_cell_width * regrid_fac #degrees
#print('old cell width = %.4f degrees' % initial_cell_width)
#print('new cell width = %.4f degrees' % cell_width)
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(90 - cell_width/2, -90 + cell_width/2, int(180/cell_width))
return xr.DataArray(arr_new, coords=[lat, lon], dims=["lat", "lon"])
#regrid dataarray to coarser grid using the sum of values within the coarser grid (useful e.g. for grain production)
#current_grid_width
def regridder_sum(dA,initial_cell_width,regrid_fac):
#no of original lat and lon points
lat_no_in = 180/initial_cell_width
lon_no_in = 360/initial_cell_width
#build regridded numpy array
arr_new = np.empty([int(lat_no_in/regrid_fac),int(lon_no_in/regrid_fac)])
arr = dA.values
for x in range(0,arr_new.shape[1]):
for y in range(0,arr_new.shape[0]):
arr_min = arr[regrid_fac*y:regrid_fac*y+regrid_fac,regrid_fac*x:regrid_fac*x+regrid_fac]
arr_new[y,x] = np.nansum(arr_min)
#convert back to dataarray
cell_width = initial_cell_width * regrid_fac #degrees
#print('old cell width = %.4f degrees' % initial_cell_width)
#print('new cell width = %.4f degrees' % cell_width)
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(90 - cell_width/2, -90 + cell_width/2, int(180/cell_width))
dA2 = xr.DataArray(arr_new, coords=[lat, lon], dims=["lat", "lon"])
return dA2.where(dA2>0)
#conversion tables between different country identification codes (ISO3, M49...)
country_codes_df = pd.read_csv(country_code_loc)
country_codes_df = country_codes_df.rename(columns={"Country Code": "Area Code"})
#country_codes_df.loc[country_codes_df['Country'] == 'China, mainland','ISO3 Code'] = 'CHN'
#sort out China
country_codes_df = country_codes_df[country_codes_df['Area Code'] != 41]
country_codes_df = country_codes_df[country_codes_df['Area Code'] != 96]
country_codes_df = country_codes_df[country_codes_df['Area Code'] != 128]
country_codes_df = country_codes_df[country_codes_df['Area Code'] != 214]
country_codes_df.loc[country_codes_df['Area Code']==351, 'M49 Code'] = 159
country_codes_df
#dictionary linking ISO3 and M49 codes
ISO3_M49_dict = dict(zip(country_codes_df['ISO3 Code'], country_codes_df['M49 Code']))
ISO3_M49_dict = {k: ISO3_M49_dict[k] for k in ISO3_M49_dict if not isNaN(k)}
ISO3_M49_dict
country_codes_df
Area Code | Country | M49 Code | ISO2 Code | ISO3 Code | Start Year | End Year | |
---|---|---|---|---|---|---|---|
0 | 2 | Afghanistan | 4.0 | AF | AFG | NaN | NaN |
1 | 5100 | Africa | 2.0 | NaN | X06 | NaN | NaN |
2 | 284 | ?land Islands | 248.0 | NaN | ALA | NaN | NaN |
3 | 3 | Albania | 8.0 | AL | ALB | NaN | NaN |
4 | 4 | Algeria | 12.0 | DZ | DZA | NaN | NaN |
5 | 5 | American Samoa | 16.0 | AS | ASM | NaN | NaN |
6 | 5200 | Americas | 19.0 | NaN | X21 | NaN | NaN |
7 | 6 | Andorra | 20.0 | AD | AND | NaN | NaN |
8 | 7 | Angola | 24.0 | AO | AGO | NaN | NaN |
9 | 258 | Anguilla | 660.0 | AI | AIA | NaN | NaN |
10 | 5848 | Annex I countries | NaN | NaN | NaN | NaN | NaN |
11 | 5600 | Antarctic Region | NaN | NaN | NaN | NaN | NaN |
12 | 30 | Antarctica | 10.0 | AQ | ATA | NaN | NaN |
13 | 8 | Antigua and Barbuda | 28.0 | AG | ATG | NaN | NaN |
14 | 9 | Argentina | 32.0 | AR | ARG | NaN | NaN |
15 | 1 | Armenia | 51.0 | AM | ARM | 1992.0 | NaN |
16 | 22 | Aruba | 533.0 | AW | ABW | NaN | NaN |
17 | 5300 | Asia | 142.0 | NaN | NaN | NaN | NaN |
18 | 10 | Australia | 36.0 | AU | AUS | NaN | NaN |
19 | 5501 | Australia and New Zealand | 53.0 | NaN | NaN | NaN | NaN |
20 | 11 | Austria | 40.0 | AT | AUT | NaN | NaN |
21 | 52 | Azerbaijan | 31.0 | AZ | AZE | 1992.0 | NaN |
22 | 12 | Bahamas | 44.0 | BS | BHS | NaN | NaN |
23 | 13 | Bahrain | 48.0 | BH | BHR | NaN | NaN |
24 | 16 | Bangladesh | 50.0 | BD | BGD | NaN | NaN |
25 | 14 | Barbados | 52.0 | BB | BRB | NaN | NaN |
26 | 57 | Belarus | 112.0 | BY | BLR | 1992.0 | NaN |
27 | 255 | Belgium | 56.0 | BE | BEL | 2000.0 | NaN |
28 | 15 | Belgium-Luxembourg | 58.0 | NaN | NaN | NaN | 1999.0 |
29 | 23 | Belize | 84.0 | BZ | BLZ | NaN | NaN |
30 | 53 | Benin | 204.0 | BJ | BEN | NaN | NaN |
31 | 17 | Bermuda | 60.0 | BM | BMU | NaN | NaN |
32 | 18 | Bhutan | 64.0 | BT | BTN | NaN | NaN |
33 | 19 | Bolivia (Plurinational State of) | 68.0 | BO | BOL | NaN | NaN |
34 | 278 | Bonaire, Sint Eustatius and Saba | 535.0 | NaN | BES | 2011.0 | NaN |
35 | 80 | Bosnia and Herzegovina | 70.0 | BA | BIH | 1992.0 | NaN |
36 | 20 | Botswana | 72.0 | BW | BWA | NaN | NaN |
37 | 31 | Bouvet Island | 74.0 | BV | BVT | NaN | NaN |
38 | 21 | Brazil | 76.0 | BR | BRA | NaN | NaN |
39 | 239 | British Virgin Islands | 92.0 | VG | VGB | NaN | NaN |
40 | 26 | Brunei Darussalam | 96.0 | BN | BRN | NaN | NaN |
41 | 27 | Bulgaria | 100.0 | BG | BGR | NaN | NaN |
42 | 233 | Burkina Faso | 854.0 | BF | BFA | NaN | NaN |
43 | 29 | Burundi | 108.0 | BI | BDI | NaN | NaN |
44 | 35 | Cabo Verde | 132.0 | CV | CPV | NaN | NaN |
45 | 115 | Cambodia | 116.0 | KH | KHM | NaN | NaN |
46 | 32 | Cameroon | 120.0 | CM | CMR | NaN | NaN |
47 | 33 | Canada | 124.0 | CA | CAN | NaN | NaN |
48 | 5206 | Caribbean | 29.0 | NaN | NaN | NaN | NaN |
49 | 36 | Cayman Islands | 136.0 | KY | CYM | NaN | NaN |
50 | 37 | Central African Republic | 140.0 | CF | CAF | NaN | NaN |
51 | 5204 | Central America | 13.0 | NaN | NaN | NaN | NaN |
52 | 5301 | Central Asia | 143.0 | NaN | NaN | NaN | NaN |
53 | 5306 | Central Asia and Southern Asia | 62.0 | NaN | NaN | NaN | NaN |
54 | 39 | Chad | 148.0 | TD | TCD | NaN | NaN |
55 | 24 | Chagos Archipelago | 86.0 | IO | IOT | NaN | NaN |
56 | 259 | Channel Islands | 830.0 | NaN | CHA | NaN | NaN |
57 | 40 | Chile | 152.0 | CL | CHL | NaN | NaN |
58 | 351 | China | 159.0 | NaN | CHN | NaN | NaN |
63 | 42 | Christmas Island | 162.0 | CX | CXR | NaN | NaN |
64 | 43 | Cocos (Keeling) Islands | 166.0 | CC | CCK | NaN | NaN |
65 | 44 | Colombia | 170.0 | CO | COL | NaN | NaN |
66 | 45 | Comoros | 174.0 | KM | COM | NaN | NaN |
67 | 46 | Congo | 178.0 | CG | COG | NaN | NaN |
68 | 47 | Cook Islands | 184.0 | CK | COK | NaN | NaN |
69 | 48 | Costa Rica | 188.0 | CR | CRI | NaN | NaN |
70 | 107 | C?te d'Ivoire | 384.0 | CI | CIV | NaN | NaN |
71 | 98 | Croatia | 191.0 | HR | HRV | 1992.0 | NaN |
72 | 49 | Cuba | 192.0 | CU | CUB | NaN | NaN |
73 | 279 | Cura?ao | 531.0 | NaN | CUW | 2011.0 | NaN |
74 | 50 | Cyprus | 196.0 | CY | CYP | NaN | NaN |
75 | 167 | Czechia | 203.0 | CZ | CZE | 1993.0 | NaN |
76 | 51 | Czechoslovakia | 200.0 | NaN | NaN | NaN | 1992.0 |
77 | 116 | Democratic People's Republic of Korea | 408.0 | KP | PRK | NaN | NaN |
78 | 250 | Democratic Republic of the Congo | 180.0 | CD | COD | NaN | NaN |
79 | 54 | Denmark | 208.0 | DK | DNK | NaN | NaN |
80 | 72 | Djibouti | 262.0 | DJ | DJI | NaN | NaN |
81 | 55 | Dominica | 212.0 | DM | DMA | NaN | NaN |
82 | 56 | Dominican Republic | 214.0 | DO | DOM | NaN | NaN |
83 | 5854 | East Asia (excluding China) | NaN | NaN | NaN | NaN | NaN |
84 | 5101 | Eastern Africa | 14.0 | NaN | NaN | NaN | NaN |
85 | 5302 | Eastern Asia | 30.0 | NaN | NaN | NaN | NaN |
86 | 5307 | Eastern Asia and South-eastern Asia | 753.0 | NaN | NaN | NaN | NaN |
87 | 5401 | Eastern Europe | 151.0 | NaN | NaN | NaN | NaN |
88 | 58 | Ecuador | 218.0 | EC | ECU | NaN | NaN |
89 | 59 | Egypt | 818.0 | EG | EGY | NaN | NaN |
90 | 60 | El Salvador | 222.0 | SV | SLV | NaN | NaN |
91 | 61 | Equatorial Guinea | 226.0 | GQ | GNQ | NaN | NaN |
92 | 178 | Eritrea | 232.0 | ER | ERI | 1993.0 | NaN |
93 | 63 | Estonia | 233.0 | EE | EST | 1992.0 | NaN |
94 | 209 | Eswatini | 748.0 | SZ | SWZ | NaN | NaN |
95 | 238 | Ethiopia | 231.0 | ET | ETH | 1993.0 | NaN |
96 | 62 | Ethiopia PDR | 230.0 | NaN | NaN | NaN | 1992.0 |
97 | 5400 | Europe | 150.0 | NaN | NaN | NaN | NaN |
98 | 5707 | European Union (27) | NaN | NaN | NaN | NaN | NaN |
99 | 5707 | European Union (27) | 97.0 | NaN | NaN | NaN | NaN |
100 | 5706 | European Union (28) | NaN | NaN | NaN | NaN | NaN |
101 | 5706 | European Union (28) | 97.0 | NaN | NaN | NaN | NaN |
102 | 65 | Falkland Islands (Malvinas) | 238.0 | FK | FLK | NaN | NaN |
103 | 64 | Faroe Islands | 234.0 | FO | FRO | NaN | NaN |
104 | 66 | Fiji | 242.0 | FJ | FJI | NaN | NaN |
105 | 67 | Finland | 246.0 | FI | FIN | NaN | NaN |
106 | 68 | France | 250.0 | FR | FRA | NaN | NaN |
107 | 69 | French Guyana | 254.0 | GF | GUF | NaN | NaN |
108 | 70 | French Polynesia | 258.0 | PF | PYF | NaN | NaN |
109 | 71 | French Southern Territories | 260.0 | TF | ATF | NaN | NaN |
110 | 74 | Gabon | 266.0 | GA | GAB | NaN | NaN |
111 | 75 | Gambia | 270.0 | GM | GMB | NaN | NaN |
112 | 73 | Georgia | 268.0 | GE | GEO | 1992.0 | NaN |
113 | 79 | Germany | 276.0 | DE | DEU | NaN | NaN |
114 | 78 | Germany Fr | 280.0 | NaN | NaN | NaN | NaN |
115 | 77 | Germany Nl | 278.0 | NaN | NaN | NaN | NaN |
116 | 81 | Ghana | 288.0 | GH | GHA | NaN | NaN |
117 | 82 | Gibraltar | 292.0 | GI | GIB | NaN | NaN |
118 | 84 | Greece | 300.0 | GR | GRC | NaN | NaN |
119 | 85 | Greenland | 304.0 | GL | GRL | NaN | NaN |
120 | 86 | Grenada | 308.0 | GD | GRD | NaN | NaN |
121 | 87 | Guadeloupe | 312.0 | GP | GLP | NaN | NaN |
122 | 88 | Guam | 316.0 | GU | GUM | NaN | NaN |
123 | 89 | Guatemala | 320.0 | GT | GTM | NaN | NaN |
124 | 90 | Guinea | 324.0 | GN | GIN | NaN | NaN |
125 | 175 | Guinea-Bissau | 624.0 | GW | GNB | NaN | NaN |
126 | 91 | Guyana | 328.0 | GY | GUY | NaN | NaN |
127 | 93 | Haiti | 332.0 | HT | HTI | NaN | NaN |
128 | 92 | Heard and McDonald Islands | 334.0 | HM | HMD | NaN | NaN |
129 | 9010 | High-income economies | 903.0 | NaN | NaN | NaN | NaN |
130 | 94 | Holy See | 336.0 | VA | VAT | NaN | NaN |
131 | 95 | Honduras | 340.0 | HN | HND | NaN | NaN |
132 | 97 | Hungary | 348.0 | HU | HUN | NaN | NaN |
133 | 99 | Iceland | 352.0 | IS | ISL | NaN | NaN |
134 | 100 | India | 356.0 | IN | IND | NaN | NaN |
135 | 101 | Indonesia | 360.0 | ID | IDN | NaN | NaN |
136 | 102 | Iran (Islamic Republic of) | 364.0 | IR | IRN | NaN | NaN |
137 | 103 | Iraq | 368.0 | IQ | IRQ | NaN | NaN |
138 | 104 | Ireland | 372.0 | IE | IRL | NaN | NaN |
139 | 264 | Isle of Man | 833.0 | IM | IMN | NaN | NaN |
140 | 105 | Israel | 376.0 | IL | ISR | NaN | NaN |
141 | 106 | Italy | 380.0 | IT | ITA | NaN | NaN |
142 | 109 | Jamaica | 388.0 | JM | JAM | NaN | NaN |
143 | 110 | Japan | 392.0 | JP | JPN | NaN | NaN |
144 | 283 | Jersey | 832.0 | NaN | JEY | NaN | NaN |
145 | 111 | Johnston Island | 396.0 | JT | JTN | NaN | NaN |
146 | 112 | Jordan | 400.0 | JO | JOR | NaN | NaN |
147 | 108 | Kazakhstan | 398.0 | KZ | KAZ | 1992.0 | NaN |
148 | 114 | Kenya | 404.0 | KE | KEN | NaN | NaN |
149 | 83 | Kiribati | 296.0 | KI | KIR | NaN | NaN |
150 | 118 | Kuwait | 414.0 | KW | KWT | NaN | NaN |
151 | 113 | Kyrgyzstan | 417.0 | KG | KGZ | 1992.0 | NaN |
152 | 5802 | Land Locked Developing Countries | 432.0 | NaN | NaN | NaN | NaN |
153 | 120 | Lao People's Democratic Republic | 418.0 | LA | LAO | NaN | NaN |
154 | 5205 | Latin America and the Caribbean | 419.0 | NaN | NaN | NaN | NaN |
155 | 119 | Latvia | 428.0 | LV | LVA | 1992.0 | NaN |
156 | 5801 | Least Developed Countries | 199.0 | NaN | NaN | NaN | NaN |
157 | 121 | Lebanon | 422.0 | LB | LBN | NaN | NaN |
158 | 122 | Lesotho | 426.0 | LS | LSO | NaN | NaN |
159 | 123 | Liberia | 430.0 | LR | LBR | NaN | NaN |
160 | 124 | Libya | 434.0 | LY | LBY | NaN | NaN |
161 | 125 | Liechtenstein | 438.0 | LI | LIE | NaN | NaN |
162 | 126 | Lithuania | 440.0 | LT | LTU | 1992.0 | NaN |
163 | 5858 | Low income economies | 904.0 | NaN | NaN | NaN | NaN |
164 | 5815 | Low Income Food Deficit Countries | NaN | NaN | NaN | NaN | NaN |
165 | 5815 | Low Income Food Deficit Countries | 901.0 | NaN | NaN | NaN | NaN |
166 | 5859 | Lower-middle-income economies | 905.0 | NaN | NaN | NaN | NaN |
167 | 256 | Luxembourg | 442.0 | LU | LUX | 2000.0 | NaN |
168 | 129 | Madagascar | 450.0 | MG | MDG | NaN | NaN |
169 | 130 | Malawi | 454.0 | MW | MWI | NaN | NaN |
170 | 131 | Malaysia | 458.0 | MY | MYS | NaN | NaN |
171 | 132 | Maldives | 462.0 | MV | MDV | NaN | NaN |
172 | 133 | Mali | 466.0 | ML | MLI | NaN | NaN |
173 | 134 | Malta | 470.0 | MT | MLT | NaN | NaN |
174 | 127 | Marshall Islands | 584.0 | MH | MHL | 1991.0 | NaN |
175 | 135 | Martinique | 474.0 | MQ | MTQ | NaN | NaN |
176 | 136 | Mauritania | 478.0 | MR | MRT | NaN | NaN |
177 | 137 | Mauritius | 480.0 | MU | MUS | NaN | NaN |
178 | 270 | Mayotte | 175.0 | YT | MYT | NaN | NaN |
179 | 5502 | Melanesia | 54.0 | NaN | NaN | NaN | NaN |
180 | 138 | Mexico | 484.0 | MX | MEX | NaN | NaN |
181 | 5503 | Micronesia | 57.0 | NaN | NaN | NaN | NaN |
182 | 145 | Micronesia (Federated States of) | 583.0 | FM | FSM | 1991.0 | NaN |
183 | 5102 | Middle Africa | 17.0 | NaN | NaN | NaN | NaN |
184 | 139 | Midway Island | 488.0 | MI | MID | NaN | NaN |
185 | 140 | Monaco | 492.0 | MC | MCO | NaN | NaN |
186 | 141 | Mongolia | 496.0 | MN | MNG | NaN | NaN |
187 | 273 | Montenegro | 499.0 | ME | MNE | 2006.0 | NaN |
188 | 142 | Montserrat | 500.0 | MS | MSR | NaN | NaN |
189 | 143 | Morocco | 504.0 | MA | MAR | NaN | NaN |
190 | 144 | Mozambique | 508.0 | MZ | MOZ | NaN | NaN |
191 | 28 | Myanmar | 104.0 | MM | MMR | NaN | NaN |
192 | 147 | Namibia | 516.0 | NaN | NAM | NaN | NaN |
193 | 148 | Nauru | 520.0 | NR | NRU | NaN | NaN |
194 | 149 | Nepal | 524.0 | NP | NPL | NaN | NaN |
195 | 5817 | Net Food Importing Developing Countries | NaN | NaN | NaN | NaN | NaN |
196 | 5817 | Net Food Importing Developing Countries | 902.0 | NaN | NaN | NaN | NaN |
197 | 150 | Netherlands | 528.0 | NL | NLD | NaN | NaN |
198 | 151 | Netherlands Antilles (former) | 530.0 | AN | ANT | NaN | 2010.0 |
199 | 153 | New Caledonia | 540.0 | NC | NCL | NaN | NaN |
200 | 156 | New Zealand | 554.0 | NZ | NZL | NaN | NaN |
201 | 157 | Nicaragua | 558.0 | NI | NIC | NaN | NaN |
202 | 158 | Niger | 562.0 | NE | NER | NaN | NaN |
203 | 159 | Nigeria | 566.0 | NG | NGA | NaN | NaN |
204 | 160 | Niue | 570.0 | NU | NIU | NaN | NaN |
205 | 5849 | Non-Annex I countries | NaN | NaN | NaN | NaN | NaN |
206 | 161 | Norfolk Island | 574.0 | NF | NFK | NaN | NaN |
207 | 429 | North Africa (excluding Sudan) | 746.0 | NaN | NaN | NaN | NaN |
208 | 154 | North Macedonia | 807.0 | MK | MKD | 1992.0 | NaN |
209 | 5103 | Northern Africa | 15.0 | NaN | NaN | NaN | NaN |
210 | 5203 | Northern America | 21.0 | NaN | NaN | NaN | NaN |
211 | 5208 | Northern America and Europe | 513.0 | NaN | NaN | NaN | NaN |
212 | 5402 | Northern Europe | 154.0 | NaN | NaN | NaN | NaN |
213 | 163 | Northern Mariana Islands | 580.0 | MP | MNP | 1991.0 | NaN |
214 | 162 | Norway | 578.0 | NO | NOR | NaN | NaN |
215 | 5500 | Oceania | 9.0 | NaN | NaN | NaN | NaN |
216 | 5807 | Oceania excluding Australia and New Zealand | 543.0 | NaN | NaN | NaN | NaN |
217 | 5873 | OECD | 198.0 | NaN | NaN | NaN | NaN |
218 | 221 | Oman | 512.0 | OM | OMN | NaN | NaN |
219 | 164 | Pacific Islands Trust Territory | 582.0 | NaN | NaN | NaN | 1990.0 |
220 | 165 | Pakistan | 586.0 | PK | PAK | NaN | NaN |
221 | 180 | Palau | 585.0 | PW | PLW | 1991.0 | NaN |
222 | 299 | Palestine | 275.0 | NaN | PSE | NaN | NaN |
223 | 166 | Panama | 591.0 | PA | PAN | NaN | NaN |
224 | 168 | Papua New Guinea | 598.0 | PG | PNG | NaN | NaN |
225 | 169 | Paraguay | 600.0 | PY | PRY | NaN | NaN |
226 | 170 | Peru | 604.0 | PE | PER | NaN | NaN |
227 | 171 | Philippines | 608.0 | PH | PHL | NaN | NaN |
228 | 172 | Pitcairn | 612.0 | PN | PCN | NaN | NaN |
229 | 173 | Poland | 616.0 | PL | POL | NaN | NaN |
230 | 5504 | Polynesia | 61.0 | NaN | NaN | NaN | NaN |
231 | 174 | Portugal | 620.0 | PT | PRT | NaN | NaN |
232 | 177 | Puerto Rico | 630.0 | PR | PRI | NaN | NaN |
233 | 179 | Qatar | 634.0 | QA | QAT | NaN | NaN |
234 | 117 | Republic of Korea | 410.0 | KR | KOR | NaN | NaN |
235 | 146 | Republic of Moldova | 498.0 | MD | MDA | 1992.0 | NaN |
236 | 182 | R?union | 638.0 | RE | REU | NaN | NaN |
237 | 183 | Romania | 642.0 | RO | ROU | NaN | NaN |
238 | 185 | Russian Federation | 643.0 | RU | RUS | 1992.0 | NaN |
239 | 184 | Rwanda | 646.0 | RW | RWA | NaN | NaN |
240 | 282 | Saint Barth?lemy | 652.0 | NaN | BLM | 2011.0 | NaN |
241 | 187 | Saint Helena, Ascension and Tristan da Cunha | 654.0 | SH | SHN | NaN | NaN |
242 | 188 | Saint Kitts and Nevis | 659.0 | KN | KNA | NaN | NaN |
243 | 189 | Saint Lucia | 662.0 | LC | LCA | NaN | NaN |
244 | 190 | Saint Pierre and Miquelon | 666.0 | PM | SPM | NaN | NaN |
245 | 191 | Saint Vincent and the Grenadines | 670.0 | VC | VCT | NaN | NaN |
246 | 281 | Saint-Martin (French part) | 663.0 | NaN | MAF | 2011.0 | NaN |
247 | 244 | Samoa | 882.0 | WS | WSM | NaN | NaN |
248 | 192 | San Marino | 674.0 | SM | SMR | NaN | NaN |
249 | 193 | Sao Tome and Principe | 678.0 | ST | STP | NaN | NaN |
250 | 194 | Saudi Arabia | 682.0 | SA | SAU | NaN | NaN |
251 | 195 | Senegal | 686.0 | SN | SEN | NaN | NaN |
252 | 272 | Serbia | 688.0 | RS | SRB | 2006.0 | NaN |
253 | 286 | Serbia (excluding Kosovo) | NaN | NaN | NaN | NaN | NaN |
254 | 186 | Serbia and Montenegro | 891.0 | CS | SCG | 1992.0 | 2005.0 |
255 | 196 | Seychelles | 690.0 | SC | SYC | NaN | NaN |
256 | 197 | Sierra Leone | 694.0 | SL | SLE | NaN | NaN |
257 | 200 | Singapore | 702.0 | SG | SGP | NaN | NaN |
258 | 280 | Sint Maarten (Dutch part) | 534.0 | NaN | SXM | 2011.0 | NaN |
259 | 199 | Slovakia | 703.0 | SK | SVK | 1993.0 | NaN |
260 | 198 | Slovenia | 705.0 | SI | SVN | 1992.0 | NaN |
261 | 5803 | Small Island Developing States | 722.0 | NaN | NaN | NaN | NaN |
262 | 25 | Solomon Islands | 90.0 | SB | SLB | NaN | NaN |
263 | 201 | Somalia | 706.0 | SO | SOM | NaN | NaN |
264 | 202 | South Africa | 710.0 | ZA | ZAF | NaN | NaN |
265 | 5207 | South America | 5.0 | NaN | NaN | NaN | NaN |
266 | 5855 | South Asia (excluding India) | 127.0 | NaN | NaN | NaN | NaN |
267 | 271 | South Georgia and the South Sandwich Islands | 239.0 | GS | SGS | NaN | NaN |
268 | 277 | South Sudan | 728.0 | SS | SSD | 2012.0 | NaN |
269 | 5304 | South-eastern Asia | 35.0 | NaN | NaN | NaN | NaN |
270 | 5104 | Southern Africa | 18.0 | NaN | NaN | NaN | NaN |
271 | 5303 | Southern Asia | 34.0 | NaN | NaN | NaN | NaN |
272 | 5403 | Southern Europe | 39.0 | NaN | NaN | NaN | NaN |
273 | 203 | Spain | 724.0 | ES | ESP | NaN | NaN |
274 | 38 | Sri Lanka | 144.0 | LK | LKA | NaN | NaN |
275 | 420 | Sub-Saharan Africa | 202.0 | NaN | NaN | NaN | NaN |
276 | 5810 | Sub-Saharan Africa (including Sudan) | 738.0 | NaN | NaN | NaN | NaN |
277 | 276 | Sudan | 729.0 | SD | SDN | 2012.0 | NaN |
278 | 206 | Sudan (former) | 736.0 | NaN | NaN | NaN | 2011.0 |
279 | 206 | Sudan (former) | 736.0 | SD | NaN | NaN | 2011.0 |
280 | 207 | Suriname | 740.0 | SR | SUR | NaN | NaN |
281 | 260 | Svalbard and Jan Mayen Islands | 744.0 | SJ | SJM | NaN | NaN |
282 | 210 | Sweden | 752.0 | SE | SWE | NaN | NaN |
283 | 211 | Switzerland | 756.0 | CH | CHE | NaN | NaN |
284 | 212 | Syrian Arab Republic | 760.0 | SY | SYR | NaN | NaN |
285 | 208 | Tajikistan | 762.0 | TJ | TJK | 1992.0 | NaN |
286 | 216 | Thailand | 764.0 | TH | THA | NaN | NaN |
287 | 176 | Timor-Leste | 626.0 | TL | TLS | NaN | NaN |
288 | 217 | Togo | 768.0 | TG | TGO | NaN | NaN |
289 | 218 | Tokelau | 772.0 | TK | TKL | NaN | NaN |
290 | 219 | Tonga | 776.0 | TO | TON | NaN | NaN |
291 | 220 | Trinidad and Tobago | 780.0 | TT | TTO | NaN | NaN |
292 | 222 | Tunisia | 788.0 | TN | TUN | NaN | NaN |
293 | 223 | Turkey | 792.0 | TR | TUR | NaN | NaN |
294 | 213 | Turkmenistan | 795.0 | TM | TKM | 1992.0 | NaN |
295 | 224 | Turks and Caicos Islands | 796.0 | TC | TCA | NaN | NaN |
296 | 227 | Tuvalu | 798.0 | TV | TUV | NaN | NaN |
297 | 226 | Uganda | 800.0 | UG | UGA | NaN | NaN |
298 | 230 | Ukraine | 804.0 | UA | UKR | 1992.0 | NaN |
299 | 225 | United Arab Emirates | 784.0 | AE | ARE | NaN | NaN |
300 | 229 | United Kingdom of Great Britain and Northern Ireland | 826.0 | GB | GBR | NaN | NaN |
301 | 215 | United Republic of Tanzania | 834.0 | TZ | TZA | NaN | NaN |
302 | 232 | United States Minor Outlying Islands | 581.0 | UM | UMI | NaN | NaN |
303 | 231 | United States of America | 840.0 | US | USA | NaN | NaN |
304 | 240 | United States Virgin Islands | 850.0 | VI | VIR | NaN | NaN |
305 | 9011 | Upper-middle-income economies | 906.0 | NaN | NaN | NaN | NaN |
306 | 234 | Uruguay | 858.0 | UY | URY | NaN | NaN |
307 | 228 | USSR | 810.0 | NaN | NaN | NaN | 1991.0 |
308 | 235 | Uzbekistan | 860.0 | UZ | UZB | 1992.0 | NaN |
309 | 155 | Vanuatu | 548.0 | VU | VUT | NaN | NaN |
310 | 236 | Venezuela (Bolivarian Republic of) | 862.0 | VE | VEN | NaN | NaN |
311 | 237 | Viet Nam | 704.0 | VN | VNM | NaN | NaN |
312 | 242 | Wake Island | 872.0 | WK | WAK | NaN | NaN |
313 | 243 | Wallis and Futuna Islands | 876.0 | WF | WLF | NaN | NaN |
314 | 5105 | Western Africa | 11.0 | NaN | NaN | NaN | NaN |
315 | 5305 | Western Asia | 145.0 | NaN | NaN | NaN | NaN |
316 | 5308 | Western Asia and Northern Africa | 747.0 | NaN | NaN | NaN | NaN |
317 | 5404 | Western Europe | 155.0 | NaN | NaN | NaN | NaN |
318 | 205 | Western Sahara | 732.0 | EH | ESH | NaN | NaN |
319 | 5000 | World | 1.0 | NaN | X01 | NaN | NaN |
320 | 249 | Yemen | 887.0 | YE | YEM | NaN | NaN |
321 | 246 | Yemen Ar Rp | 886.0 | NaN | NaN | NaN | NaN |
322 | 247 | Yemen Dem | 720.0 | NaN | NaN | NaN | NaN |
323 | 248 | Yugoslav SFR | 890.0 | NaN | NaN | NaN | 1991.0 |
324 | 251 | Zambia | 894.0 | ZM | ZMB | NaN | NaN |
325 | 181 | Zimbabwe | 716.0 | ZW | ZWE | NaN | NaN |
# link grid cell (0.5 deg) to country
country_grid_df = pd.read_csv(country_grid_loc, sep=' ')
country_grid_df = country_grid_df.drop(columns='number')
country_grid_df = country_grid_df.rename(columns={"Area Code": "ISO3 Code"})
#country_grid_df = country_grid_df.merge(country_codes_df[['ISO3 Code','M49 Code']],on='ISO3 Code',how='left')
country_grid_df['M49 Code'] = country_grid_df['ISO3 Code']
country_grid_df['M49 Code'] = country_grid_df['M49 Code'].map(ISO3_M49_dict)
#combine South Sudan and Sudan
country_grid_df['M49 Code'] = country_grid_df['M49 Code'].replace(728,729)
country_grid_df['ISO3 Code'] = country_grid_df['ISO3 Code'].replace('SSD','SDN')
country_grid_df
lon | lat | ISO3 Code | M49 Code | |
---|---|---|---|---|
0 | -179.75 | 89.75 | NaN | NaN |
1 | -179.25 | 89.75 | NaN | NaN |
2 | -178.75 | 89.75 | NaN | NaN |
3 | -178.25 | 89.75 | NaN | NaN |
4 | -177.75 | 89.75 | NaN | NaN |
... | ... | ... | ... | ... |
259195 | 177.75 | -89.75 | ATA | 10.0 |
259196 | 178.25 | -89.75 | ATA | 10.0 |
259197 | 178.75 | -89.75 | ATA | 10.0 |
259198 | 179.25 | -89.75 | ATA | 10.0 |
259199 | 179.75 | -89.75 | ATA | 10.0 |
259200 rows × 4 columns
#regions as defined by Herrero (used for feed conversion ratios)
regions_df = pd.read_csv(region_herrero_loc,encoding='latin1')
regions_df = regions_df[['AreaName','D','Herrero_group']]
regions_df = regions_df.rename(columns={'D':'M49 Code'})
regions_df.loc[regions_df['AreaName']=='China','M49 Code'] = 159
regions_df = regions_df.drop_duplicates()
CIS_regions = ['Armenia', 'Azerbaijan', 'Belarus', 'Georgia', 'Kazakhstan', 'Kyrgyzstan', 'Moldova', 'Russian Federation', 'Tajikistan', 'Turkmenistan', 'Ukraine', 'Uzbekistan']
regions_df.loc[regions_df['AreaName'].isin(CIS_regions),'Herrero_group'] = 'CIS'
regions_df = regions_df.reset_index(drop=True)
regions_df.loc[len(regions_df.index)] = ['Sudan (former)', 736, 'SSA']
regions_df
AreaName | M49 Code | Herrero_group | |
---|---|---|---|
0 | Afghanistan | 4 | SAS |
1 | Albania | 8 | EUR |
2 | Algeria | 12 | MNA |
3 | Andorra | 20 | EUR |
4 | Angola | 24 | SSA |
5 | Anguilla | 660 | LAM |
6 | Antigua and Barbuda | 28 | LAM |
7 | Argentina | 32 | LAM |
8 | Armenia | 51 | CIS |
9 | Aruba | 533 | LAM |
10 | Australia | 36 | OCE |
11 | Austria | 40 | EUR |
12 | Azerbaijan | 31 | CIS |
13 | Bahamas | 44 | LAM |
14 | Bahrain | 48 | MNA |
15 | Bangladesh | 50 | SAS |
16 | Barbados | 52 | LAM |
17 | Belarus | 112 | CIS |
18 | Belgium | 56 | EUR |
19 | Belize | 84 | LAM |
20 | Benin | 204 | SSA |
21 | Bermuda | 60 | NAM |
22 | Bhutan | 64 | SAS |
23 | Bolivia (Plurinat.State) | 68 | LAM |
24 | Bosnia and Herzegovina | 70 | EUR |
25 | Botswana | 72 | SSA |
26 | Brazil | 76 | LAM |
27 | British Virgin Islands | 92 | LAM |
28 | Brunei Darussalam | 96 | SEA |
29 | Bulgaria | 100 | EUR |
30 | Burkina Faso | 854 | SSA |
31 | Burundi | 108 | SSA |
32 | Cabo Verde | 132 | SSA |
33 | Cambodia | 116 | SEA |
34 | Cameroon | 120 | SSA |
35 | Canada | 124 | NAM |
36 | Cayman Islands | 136 | LAM |
37 | Central African Republic | 140 | SSA |
38 | Chad | 148 | SSA |
39 | Chile | 152 | LAM |
40 | China | 159 | EAS |
41 | China, Hong Kong SAR | 344 | EAS |
42 | China, Macao SAR | 446 | EAS |
43 | Colombia | 170 | LAM |
44 | Comoros | 174 | SSA |
45 | Congo | 178 | SSA |
46 | Congo, Dem. Rep. of the | 180 | SSA |
47 | Cook Islands | 184 | OCE |
48 | Costa Rica | 188 | LAM |
49 | Côte d'Ivoire | 384 | SSA |
50 | Croatia | 191 | EUR |
51 | Cuba | 192 | LAM |
52 | Cyprus | 196 | EUR |
53 | Czechia | 203 | EUR |
54 | Denmark | 208 | EUR |
55 | Djibouti | 262 | SSA |
56 | Dominica | 212 | LAM |
57 | Dominican Republic | 214 | LAM |
58 | Ecuador | 218 | LAM |
59 | Egypt | 818 | MNA |
60 | El Salvador | 222 | LAM |
61 | Equatorial Guinea | 226 | SSA |
62 | Eritrea | 232 | SSA |
63 | Estonia | 233 | EUR |
64 | Ethiopia | 231 | SSA |
65 | Falkland Is.(Malvinas) | 238 | LAM |
66 | Faroe Islands | 234 | EUR |
67 | Fiji | 242 | OCE |
68 | Finland | 246 | EUR |
69 | France | 250 | EUR |
70 | French Polynesia | 258 | OCE |
71 | Gabon | 266 | SSA |
72 | Gambia | 270 | SSA |
73 | Georgia | 268 | CIS |
74 | Germany | 276 | EUR |
75 | Ghana | 288 | SSA |
76 | Greece | 300 | EUR |
77 | Greenland | 304 | NAM |
78 | Grenada | 308 | LAM |
79 | Guatemala | 320 | LAM |
80 | Guinea | 324 | SSA |
81 | Guinea-Bissau | 624 | SSA |
82 | Guyana | 328 | LAM |
83 | Haiti | 332 | LAM |
84 | Honduras | 340 | LAM |
85 | Hungary | 348 | EUR |
86 | Iceland | 352 | EUR |
87 | India | 356 | SAS |
88 | Indonesia | 360 | SEA |
89 | Iran (Islamic Rep. of) | 364 | SAS |
90 | Iraq | 368 | MNA |
91 | Ireland | 372 | EUR |
92 | Israel | 376 | MNA |
93 | Italy | 380 | EUR |
94 | Jamaica | 388 | LAM |
95 | Japan | 392 | EAS |
96 | Jordan | 400 | MNA |
97 | Kazakhstan | 398 | CIS |
98 | Kenya | 404 | SSA |
99 | Kiribati | 296 | OCE |
100 | Korea, Dem. People's Rep | 408 | SEA |
101 | Korea, Republic of | 410 | EAS |
102 | Kuwait | 414 | SEA |
103 | Kyrgyzstan | 417 | CIS |
104 | Lao People's Dem. Rep. | 418 | SEA |
105 | Latvia | 428 | EUR |
106 | Lebanon | 422 | MNA |
107 | Lesotho | 426 | SSA |
108 | Liberia | 430 | SSA |
109 | Libya | 434 | MNA |
110 | Lithuania | 440 | EUR |
111 | Luxembourg | 442 | EUR |
112 | Madagascar | 450 | SSA |
113 | Malawi | 454 | SSA |
114 | Malaysia | 458 | SEA |
115 | Maldives | 462 | SAS |
116 | Mali | 466 | SSA |
117 | Malta | 470 | EUR |
118 | Marshall Islands | 584 | OCE |
119 | Mauritania | 478 | SSA |
120 | Mauritius | 480 | SSA |
121 | Mayotte | 175 | SSA |
122 | Mexico | 484 | LAM |
123 | Micronesia, Fed.States of | 583 | OCE |
124 | Moldova, Republic of | 498 | EUR |
125 | Mongolia | 496 | SEA |
126 | Montenegro | 499 | EUR |
127 | Montserrat | 500 | LAM |
128 | Morocco | 504 | MNA |
129 | Mozambique | 508 | SSA |
130 | Myanmar | 104 | SEA |
131 | Namibia | 516 | SSA |
132 | Nepal | 524 | SAS |
133 | Netherlands | 528 | EUR |
134 | Netherlands Antilles | 530 | LAM |
135 | New Caledonia | 540 | OCE |
136 | New Zealand | 554 | OCE |
137 | Nicaragua | 558 | LAM |
138 | Niger | 562 | SSA |
139 | Nigeria | 566 | SSA |
140 | Norway | 578 | EUR |
141 | Oman | 512 | MNA |
142 | Pakistan | 586 | SAS |
143 | Palau | 585 | OCE |
144 | Palestine | 275 | MNA |
145 | Panama | 591 | LAM |
146 | Papua New Guinea | 598 | OCE |
147 | Paraguay | 600 | LAM |
148 | Peru | 604 | LAM |
149 | Philippines | 608 | SEA |
150 | Poland | 616 | EUR |
151 | Portugal | 620 | EUR |
152 | Qatar | 634 | MNA |
153 | Romania | 642 | EUR |
154 | Russian Federation | 643 | CIS |
155 | Rwanda | 646 | SSA |
156 | Saint Helena | 654 | SSA |
157 | Saint Kitts and Nevis | 659 | LAM |
158 | Saint Lucia | 662 | LAM |
159 | Saint Vincent/Grenadines | 670 | LAM |
160 | Samoa | 882 | OCE |
161 | Sao Tome and Principe | 678 | SSA |
162 | Saudi Arabia | 682 | MNA |
163 | Senegal | 686 | SSA |
164 | Serbia | 688 | EUR |
165 | Seychelles | 690 | SSA |
166 | Sierra Leone | 694 | SSA |
167 | Singapore | 702 | SEA |
168 | Slovakia | 703 | EUR |
169 | Slovenia | 705 | EUR |
170 | Solomon Islands | 90 | OCE |
171 | Somalia | 706 | SSA |
172 | South Africa | 710 | SSA |
173 | South Sudan | 728 | MNA |
174 | Spain | 724 | EUR |
175 | Sri Lanka | 144 | SAS |
176 | St. Pierre and Miquelon | 666 | NAM |
177 | Sudan | 729 | MNA |
178 | Suriname | 740 | LAM |
179 | Sweden | 752 | EUR |
180 | Switzerland | 756 | EUR |
181 | Syrian Arab Republic | 760 | MNA |
182 | Tajikistan | 762 | CIS |
183 | Tanzania, United Rep. of | 834 | SSA |
184 | Thailand | 764 | SEA |
185 | Timor-Leste | 626 | SEA |
186 | Togo | 768 | SSA |
187 | Tonga | 776 | OCE |
188 | Trinidad and Tobago | 780 | LAM |
189 | Tunisia | 788 | MNA |
190 | Turkey | 792 | MNA |
191 | Turkmenistan | 795 | CIS |
192 | Turks and Caicos Is. | 796 | LAM |
193 | Tuvalu | 798 | OCE |
194 | Uganda | 800 | SSA |
195 | Ukraine | 804 | CIS |
196 | United Arab Emirates | 784 | MNA |
197 | United Kingdom | 826 | EUR |
198 | United States of America | 840 | NAM |
199 | Uruguay | 858 | LAM |
200 | US Virgin Islands | 850 | LAM |
201 | Uzbekistan | 860 | CIS |
202 | Vanuatu | 548 | OCE |
203 | Venezuela, Boliv Rep of | 862 | LAM |
204 | Viet Nam | 704 | SEA |
205 | Wallis and Futuna Is. | 876 | OCE |
206 | Yemen | 887 | MNA |
207 | Zambia | 894 | SSA |
208 | Zimbabwe | 716 | SSA |
209 | Sudan (former) | 736 | SSA |
#livestock production systems of world
#convert such as consistent with Herrero 2013
livestock_sys = rasterio.open(livestock_prod_sys_loc)
livestock_sys = livestock_sys.read(1)
print(livestock_sys.shape)
# 1 = LG Rangelands Hyperarid -> LGA
# 2 = LG Rangelands Arid -> LGA
# 3 = LG Rangelands Humid -> LGH
# 4 = LG Rangelands Temperate -> LGT
# 5 = MR Mixed Rainfed Hyperarid -> MA
# 6 = MR Mixed RainfedArid -> MA
# 7 = MR Mixed Rainfed Humid -> MH
# 8 = MR Mixed Rainfed Temperate -> MT
# 9 = MI Mixed Irrigated Hyperarid -> MA
# 10 = MI Mixed Irrigated Arid -> MA
# 11 = MI Mixed Irrigated Humid -> MH
# 12 = MI Mixed Irrigated Temperate -> MT
# 13 = Urban
# 14 = Other
conversion_dict = {1 : 'LGA',
2 : 'LGA',
3 : 'LGH',
4 : 'LGT',
5 : 'MA',
6 : 'MA',
7 : 'MH',
8 : 'MT',
9 : 'MA',
10 : 'MA',
11 : 'MH',
12 : 'MT',
13 : 'Urban',
14 : 'Other'}
conversion_dict2 = {'LGA' : 101,
'LGH' : 102,
'LGT' : 103,
'MA' : 104,
'MH' : 105,
'MT' : 106,
'Urban' : 107,
'Other' : 108,}
conversion_dict2_inv = {v: k for k, v in conversion_dict2.items()}
for i in range(1,15):
print(f'number of "{i}" =',np.count_nonzero(livestock_sys == i))
np.place(livestock_sys, livestock_sys==i, conversion_dict2[conversion_dict[i]])
(21600, 43200) number of "1" = 4980817 number of "2" = 41816332 number of "3" = 5614667 number of "4" = 44474725 number of "5" = 22000 number of "6" = 9734713 number of "7" = 10534141 number of "8" = 13875069 number of "9" = 8135 number of "10" = 2062147 number of "11" = 1081726 number of "12" = 1753115 number of "13" = 5653256 number of "14" = 75249009
#global longitude and latitude coordinates
cell_width = 0.5/60 #degrees
print(cell_width)
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(90 - cell_width/2, -90 + cell_width/2, int(180/cell_width))
0.008333333333333333
#convert to xarray
livestock_sys_ds = xr.DataArray(livestock_sys, coords=[lat, lon], dims=["lat", "lon"])
livestock_sys_ds = livestock_sys_ds.where(livestock_sys_ds<200)
#regrid to 0.5 deg
livestock_sys_ds2 = regridder_most_common(livestock_sys_ds,1/120,60)
#plot livestock systems
col_dict={101 :"darkkhaki",
102 :"forestgreen",
103 :"lawngreen",
104 :"cyan",
105 :"deepskyblue",
106 :"darkblue",
107 :"red",
108 :"lightgray"}
cm = matplotlib.colors.ListedColormap([col_dict[x] for x in col_dict.keys()])
labels = np.array(list(conversion_dict2.keys()))
len_lab = len(labels)
# prepare normalizer
## Prepare bins for the normalizer
norm_bins = np.sort([*col_dict.keys()]) + 0.5
norm_bins = np.insert(norm_bins, 0, np.min(norm_bins) - 1.0)
#print(norm_bins)
## Make normalizer and formatter
norm = matplotlib.colors.BoundaryNorm(norm_bins, len_lab, clip=True)
fmt = matplotlib.ticker.FuncFormatter(lambda x, pos: labels[norm(x)])
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
im = livestock_sys_ds2.plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cm, norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title('Livestock systems',fontsize=30)
diff = norm_bins[1:] - norm_bins[:-1]
tickz = norm_bins[:-1] + diff / 2
cb = fig.colorbar(im, fraction=0.0235,pad=0.01, format=fmt, ticks=tickz)
cb.ax.tick_params(labelsize=28)
#plt.savefig(save_folder + f'yield_{crop}.png',bbox_inches='tight',dpi=500)
plt.show()
#gridded livestock numbers circa 2010
cattle_no = rasterio.open(cattle_no_loc)
cattle_no = cattle_no.read(1)
cattle_no.shape
goat_no = rasterio.open(goat_no_loc)
goat_no = goat_no.read(1)
goat_no.shape
sheep_no = rasterio.open(sheep_no_loc)
sheep_no = sheep_no.read(1)
sheep_no.shape
horse_no = rasterio.open(horse_no_loc)
horse_no = horse_no.read(1)
horse_no.shape
pig_no = rasterio.open(pig_no_loc)
pig_no = pig_no.read(1)
pig_no.shape
(2160, 4320)
#global longitude and latitude coordinates for 0.5° grid
cell_width = 0.5/6 #degrees
print(cell_width)
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(90 - cell_width/2, -90 + cell_width/2, int(180/cell_width))
0.08333333333333333
#print out numbers as check
cattle_no_ds = xr.DataArray(cattle_no, coords=[lat, lon], dims=["lat", "lon"])
cattle_no_ds = cattle_no_ds.where(cattle_no_ds>-1)
print('total number of cattle = %.0f' % cattle_no_ds.sum())
goat_no_ds = xr.DataArray(goat_no, coords=[lat, lon], dims=["lat", "lon"])
goat_no_ds = goat_no_ds.where(goat_no_ds>-1)
print('total number of goats = %.0f' % goat_no_ds.sum())
sheep_no_ds = xr.DataArray(sheep_no, coords=[lat, lon], dims=["lat", "lon"])
sheep_no_ds = sheep_no_ds.where(sheep_no_ds>-1)
print('total number of sheep = %.0f' % sheep_no_ds.sum())
horse_no_ds = xr.DataArray(horse_no, coords=[lat, lon], dims=["lat", "lon"])
horse_no_ds = horse_no_ds.where(horse_no_ds>-1)
print('total number of horses = %.0f' % horse_no_ds.sum())
pig_no_ds = xr.DataArray(pig_no, coords=[lat, lon], dims=["lat", "lon"])
pig_no_ds = pig_no_ds.where(pig_no_ds>-1)
print('total number of pigs = %.0f' % pig_no_ds.sum())
total number of cattle = 1457227527 total number of goats = 957171467 total number of sheep = 1152468158 total number of horses = 61993460 total number of pigs = 975946969
#regrid to 0.5 deg
cattle_no_ds2 = regridder_sum(cattle_no_ds,1/12,6)
goat_no_ds2 = regridder_sum(goat_no_ds,1/12,6)
sheep_no_ds2 = regridder_sum(sheep_no_ds,1/12,6)
horse_no_ds2 = regridder_sum(horse_no_ds,1/12,6)
pig_no_ds2 = regridder_sum(pig_no_ds,1/12,6)
anim_no_ds_dict = {'cattle' : cattle_no_ds2,
'goat' : goat_no_ds2,
'sheep' : sheep_no_ds2,
'horse' : horse_no_ds2,
'pig' : pig_no_ds2}
animal_list2 = list(anim_no_ds_dict.keys())
#plot
def plot_anim_no(ds,title):
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,1000,5000,10000,20000,50000,100000,250000,10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = ds.plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(title,fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
for animal in animal_list2:
plot_anim_no(anim_no_ds_dict[animal],f'{animal} number')
#determine proportion of ruminants in mixed systems (most important systems for crop residue usage)
for animal in animal_list2:
if animal != 'pig': #pigs are not ruminants
glob_no = anim_no_ds_dict[animal].sum().values
print(f'total number of {animal} = %.0f' % glob_no)
MA_no = anim_no_ds_dict[animal].where(livestock_sys_ds2==104).sum().values
MH_no = anim_no_ds_dict[animal].where(livestock_sys_ds2==105).sum().values
MT_no = anim_no_ds_dict[animal].where(livestock_sys_ds2==106).sum().values
print(f'total number of {animal} in mixed systems = %.0f' % (MA_no + MH_no + MT_no))
print(f'fraction of {animal} in mixed systems = %.3f' % ((MA_no + MH_no + MT_no)/glob_no))
total number of cattle = 1457227527 total number of cattle in mixed systems = 903386108 fraction of cattle in mixed systems = 0.620 total number of goat = 957171467 total number of goat in mixed systems = 592008314 fraction of goat in mixed systems = 0.618 total number of sheep = 1152468158 total number of sheep in mixed systems = 539498519 fraction of sheep in mixed systems = 0.468 total number of horse = 61993460 total number of horse in mixed systems = 26805307 fraction of horse in mixed systems = 0.432
#units kg/km^2
#NOTE!! for pork need to copy some of the ancillary files from beef to get it to work
#africa_pork = rasterio.open('/Users/smerald-a/ldndc/resources/livestock_production_systems/Production/Africa_Pork/AF_Pork_Production00/prk_prod00/w001001.adf')
#africa_beef = rasterio.open('/Users/smerald-a/ldndc/resources/livestock_production_systems/Production/Africa_Beef/AF_Beef_Production00/beef_prod00/w001001.adf')
#africa_beef = africa_beef.read(1)
#africa_beef
#dictionary determining which crops to consider
spam_RPR_dict = {'whea_a' : 'Wheat',
'rice_a' : 'Rice',
'maiz_a' : 'Maize',
'barl_a' : 'Barley',
'mill_a' : 'Millet',
'sorg_a' : 'Sorghum',
'ocer_a' : 'Other cereals'}
spam_crop_list = list(spam_RPR_dict.keys())
print(spam_crop_list)
crop_list = list(spam_RPR_dict.values())
['whea_a', 'rice_a', 'maiz_a', 'barl_a', 'mill_a', 'sorg_a', 'ocer_a']
#import spam production data and select portion of interest
# data is at 1/12 degree resolution
spam_prod_df = pd.read_csv(spam_prod_loc,encoding='latin1')
spam_prod_df = spam_prod_df.rename(columns={'x':'lon','y':'lat'})
spam_prod_df['lat'] = round(spam_prod_df['lat'], 6)
spam_prod_df['lon'] = round(spam_prod_df['lon'], 6)
spam_prod_df['mill_a'] = spam_prod_df['pmil_a'] + spam_prod_df['smil_a']
spam_prod_df = spam_prod_df.drop(columns=['pmil_a','smil_a'])
spam_prod_df = spam_prod_df[['lon','lat'] + spam_crop_list]
spam_prod_df = spam_prod_df.rename(columns=spam_RPR_dict)
#spam_prod_df
#spam_prod_df.loc[spam_prod_df['iso3']=='GBR']
#print(f'Wheat production = %.2f Tg' % (spam_prod_df['whea_a'].sum()*10**-6))
#import spam harvested area data and select portion of interest
# data is at 1/12 degree resolution
rename_dict = {}
for key in spam_RPR_dict.keys():
rename_dict[key] = spam_RPR_dict[key] + ' ha'
#import spam harvested area data
spam_ha_df = pd.read_csv(spam_harv_area_loc,encoding='latin1')
spam_ha_df = spam_ha_df.rename(columns={'x':'lon','y':'lat'})
spam_ha_df['lat'] = round(spam_ha_df['lat'], 6)
spam_ha_df['lon'] = round(spam_ha_df['lon'], 6)
spam_ha_df['mill_a'] = spam_ha_df['pmil_a'] + spam_ha_df['smil_a']
spam_ha_df = spam_ha_df.drop(columns=['pmil_a','smil_a'])
spam_ha_df = spam_ha_df[['lon','lat'] + spam_crop_list]
spam_ha_df = spam_ha_df.rename(columns=rename_dict)
#spam_ha_df
#combine production and harvested area data
spam_df = pd.merge(spam_prod_df,spam_ha_df,on=['lon','lat'])
spam_df
lon | lat | Wheat | Rice | Maize | Barley | Millet | Sorghum | Other cereals | Wheat ha | Rice ha | Maize ha | Barley ha | Millet ha | Sorghum ha | Other cereals ha | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 123.291667 | 53.541667 | 0.0 | 0.0 | 4.3 | 0.0 | 0.0 | 0.0 | 1.4 | 0.0 | 0.0 | 1.1 | 0.0 | 0.0 | 0.0 | 1.3 |
1 | 122.208333 | 53.458333 | 0.0 | 0.0 | 3.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.8 | 0.0 | 0.0 | 0.0 | 0.0 |
2 | 122.291667 | 53.458333 | 0.0 | 0.0 | 8.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2.4 | 0.0 | 0.0 | 0.0 | 0.0 |
3 | 122.375000 | 53.458333 | 18.3 | 0.0 | 9.2 | 0.0 | 0.0 | 0.0 | 2.4 | 7.5 | 0.0 | 2.9 | 0.0 | 0.0 | 0.0 | 3.8 |
4 | 123.041667 | 53.458333 | 3.7 | 0.0 | 7.5 | 0.0 | 0.0 | 0.0 | 0.9 | 1.5 | 0.0 | 2.3 | 0.0 | 0.0 | 0.0 | 1.2 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
832822 | -155.625000 | 19.125000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
832823 | -155.541667 | 19.125000 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
832824 | -155.708333 | 19.041667 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
832825 | -155.625000 | 19.041667 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
832826 | -155.625000 | 18.958333 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
832827 rows × 16 columns
#put spam data on a global grid with 1/12 degree resolution (5 arcminutes)
cell_width = 1/12 #degrees
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(90 - cell_width/2, -90 + cell_width/2, int(180/cell_width))
grid_list = []
for latval in lat:
for lonval in lon:
grid_list.append([lonval,latval])
grid_df = pd.DataFrame(np.array(grid_list),columns=['lon', 'lat'])
grid_df['lat'] = round(grid_df['lat'], 6)
grid_df['lon'] = round(grid_df['lon'], 6)
grid_df
crop_prod_df = pd.merge(grid_df,spam_df,how='left',on=['lon','lat'])
#crop_prod_df = crop_prod_df.drop(columns=['iso3','tech_type','prod_level','alloc_key','cell5m','rec_type','unit','crea_date','year_data','source','name_cntr','name_adm1','name_adm2'])
crop_prod_df
lon | lat | Wheat | Rice | Maize | Barley | Millet | Sorghum | Other cereals | Wheat ha | Rice ha | Maize ha | Barley ha | Millet ha | Sorghum ha | Other cereals ha | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -179.958333 | 89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | -179.875000 | 89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | -179.791667 | 89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | -179.708333 | 89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | -179.625000 | 89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
9331195 | 179.625000 | -89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9331196 | 179.708333 | -89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9331197 | 179.791667 | -89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9331198 | 179.875000 | -89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9331199 | 179.958333 | -89.958333 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
9331200 rows × 16 columns
crop_prod_ds = crop_prod_df.set_index(["lat", "lon"]).to_xarray()
#regrid from 1/12 to 1/2 degree resolution
def regridder_sum2(dA,initial_cell_width,regrid_fac):
#no of original lat and lon points
lat_no_in = 180/initial_cell_width
lon_no_in = 360/initial_cell_width
#build regridded numpy array
arr_new = np.empty([int(lat_no_in/regrid_fac),int(lon_no_in/regrid_fac)])
arr = dA.values
for x in range(0,arr_new.shape[1]):
for y in range(0,arr_new.shape[0]):
arr_min = arr[regrid_fac*y:regrid_fac*y+regrid_fac,regrid_fac*x:regrid_fac*x+regrid_fac]
arr_new[y,x] = np.nansum(arr_min)
#convert back to dataarray
cell_width = initial_cell_width * regrid_fac #degrees
#print('old cell width = %.4f degrees' % initial_cell_width)
#print('new cell width = %.4f degrees' % cell_width)
lon = np.linspace(-180 + cell_width/2, 180 - cell_width/2, int(360/cell_width))
lat = np.linspace(-90 + cell_width/2, 90 - cell_width/2, int(180/cell_width))
dA2 = xr.DataArray(arr_new, coords=[lat, lon], dims=["lat", "lon"])
return dA2.where(dA2>0)
dA_list = []
for key in list(crop_prod_ds.keys()):
dA_list.append( regridder_sum2(crop_prod_ds[key],1/12,6).rename(key) )
crop_prod_ds2 = xr.merge(dA_list)
crop_prod_ds2
array([-89.75, -89.25, -88.75, ..., 88.75, 89.25, 89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]])
#plot regridded spam data as check
var = 'Wheat'
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,5000,10000,20000,50000,100000,200000,500000,1000000]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = crop_prod_ds2[var].plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'{var} production (circa 2010)',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
#determine production in each grid cell as a fraction of total production for the country
crop_prod_frac_df = crop_prod_ds2.to_dataframe().reset_index()
crop_prod_frac_df = crop_prod_frac_df.merge(country_grid_df[['lat','lon','M49 Code']],how='left',on=['lat','lon'])
crop_prod_country_df = crop_prod_frac_df.groupby(['M49 Code']).sum().reset_index()
crop_prod_country_df = crop_prod_country_df.drop(columns=['lat','lon'])
crop_prod_country_df
for key in list(crop_prod_ds2.keys()):
factor_dict = {}
for m49 in pd.unique(crop_prod_country_df['M49 Code']):
x = (crop_prod_country_df.loc[(crop_prod_country_df['M49 Code']==m49), key] ).values
try:
factor_dict[m49] = x[0]
except:
pass
factor_dict[-1] = 0
def func(prod,m49):
try:
return prod / factor_dict[m49]
except:
return 0
crop_prod_frac_df[f'{key} country fraction'] = list(map(func, crop_prod_frac_df[key], crop_prod_frac_df['M49 Code'].fillna(-1)))
crop_prod_frac_df
crop_prod_country_df
#factor_dict
#crop_prod_frac_df.loc[crop_prod_frac_df['M49 Code']==159,'Wheat country fraction'].sum()
crop_prod_frac_df
lat | lon | Wheat | Rice | Maize | Barley | Millet | Sorghum | Other cereals | Wheat ha | Rice ha | Maize ha | Barley ha | Millet ha | Sorghum ha | Other cereals ha | M49 Code | Wheat country fraction | Rice country fraction | Maize country fraction | Barley country fraction | Millet country fraction | Sorghum country fraction | Other cereals country fraction | Wheat ha country fraction | Rice ha country fraction | Maize ha country fraction | Barley ha country fraction | Millet ha country fraction | Sorghum ha country fraction | Other cereals ha country fraction | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -89.75 | -179.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 10.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | -89.75 | -179.25 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 10.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | -89.75 | -178.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 10.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | -89.75 | -178.25 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 10.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | -89.75 | -177.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 10.0 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
259195 | 89.75 | 177.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259196 | 89.75 | 178.25 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259197 | 89.75 | 178.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259198 | 89.75 | 179.25 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259199 | 89.75 | 179.75 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259200 rows × 31 columns
#import FAO data for harvested area and cereal production
FAO_ha_df = pd.read_csv(FAO_ha_loc,encoding='latin1')
FAO_cereal_prod_df = pd.read_csv(FAO_prod_loc,encoding='latin1')
FAO_dict = {'Wheat' : 'Wheat',
'Rice' : 'Rice',
'Maize (corn)' : 'Maize',
'Barley' : 'Barley',
'Millet' : 'Millet',
'Sorghum' : 'Sorghum',
'Oats' : 'Other cereals',
'Rye' : 'Other cereals',
'Cereals n.e.c.' : 'Other cereals'
}
#get FAO dataframes into usable state
def FAO_transform(df,variable_name):
df = df[['Area Code (M49)','Area','Item Code (CPC)','Item','Year','Value']]
df = df.rename(columns={"Value": variable_name})
# sum different regions of China to be consistent with elsewhere
China_df = df.loc[df['Area Code (M49)'].isin([156,446,158,344])].copy()
China_df = China_df.groupby(['Item Code (CPC)','Item','Year']).sum().reset_index()
China_df['Area Code (M49)'] = 159
China_df['Area'] = 'China'
df = df[df['Area Code (M49)'] != 156] #China, mainland
df = df[df['Area Code (M49)'] != 446] #Macao
df = df[df['Area Code (M49)'] != 158] #Taiwan
df = df[df['Area Code (M49)'] != 344] #Hong Kong
df = pd.concat([df,China_df])
#Combine Sudan
Sudan_df = df.loc[df['Area Code (M49)'].isin([728,729,736])].copy()
Sudan_df = Sudan_df.groupby(['Item Code (CPC)','Item','Year']).sum().reset_index()
Sudan_df['Area Code (M49)'] = 729
Sudan_df['Area'] = 'Sudan'
df = df[df['Area Code (M49)'] != 728] #South Sudan (2012-)
df = df[df['Area Code (M49)'] != 729] # Sudan (2012-)
df = df[df['Area Code (M49)'] != 736] # Sudan (former) (-2011)
df = pd.concat([df,Sudan_df])
df = df.rename(columns={'Area Code (M49)':'M49 Code'})
df = df.replace({"Item": FAO_dict})
df = df.drop(columns='Item Code (CPC)')
df = df.groupby(['M49 Code','Area','Item','Year']).sum().reset_index()
return df
FAO_ha_df = FAO_transform(FAO_ha_df, 'harvested area (ha)')
FAO_cereal_prod_df = FAO_transform(FAO_cereal_prod_df, 'production (Mg)')
FAO_cereal_df = pd.merge(FAO_cereal_prod_df,FAO_ha_df,on=['M49 Code','Area','Item','Year'],how='inner')
FAO_cereal_df.loc[FAO_cereal_df['Area']=='Sudan']
M49 Code | Area | Item | Year | production (Mg) | harvested area (ha) | |
---|---|---|---|---|---|---|
18354 | 729 | Sudan | Barley | 2012 | 0.00 | 0 |
18355 | 729 | Sudan | Barley | 2013 | 0.00 | 0 |
18356 | 729 | Sudan | Barley | 2014 | 0.00 | 0 |
18357 | 729 | Sudan | Barley | 2015 | 0.00 | 0 |
18358 | 729 | Sudan | Barley | 2016 | 0.00 | 0 |
18359 | 729 | Sudan | Barley | 2017 | 0.00 | 0 |
18360 | 729 | Sudan | Barley | 2018 | 0.00 | 0 |
18361 | 729 | Sudan | Barley | 2019 | 0.00 | 0 |
18362 | 729 | Sudan | Barley | 2020 | 0.00 | 0 |
18363 | 729 | Sudan | Barley | 2021 | 0.00 | 0 |
18364 | 729 | Sudan | Maize | 1995 | 21000.00 | 36540 |
18365 | 729 | Sudan | Maize | 1996 | 54000.00 | 83160 |
18366 | 729 | Sudan | Maize | 1997 | 52000.00 | 80000 |
18367 | 729 | Sudan | Maize | 1998 | 42000.00 | 63840 |
18368 | 729 | Sudan | Maize | 1999 | 37000.00 | 63420 |
18369 | 729 | Sudan | Maize | 2000 | 53000.00 | 71820 |
18370 | 729 | Sudan | Maize | 2001 | 53000.00 | 71820 |
18371 | 729 | Sudan | Maize | 2002 | 53000.00 | 63420 |
18372 | 729 | Sudan | Maize | 2003 | 53000.00 | 71820 |
18373 | 729 | Sudan | Maize | 2004 | 60000.00 | 58380 |
18374 | 729 | Sudan | Maize | 2005 | 60000.00 | 60000 |
18375 | 729 | Sudan | Maize | 2006 | 109000.00 | 104167 |
18376 | 729 | Sudan | Maize | 2007 | 70000.00 | 36667 |
18377 | 729 | Sudan | Maize | 2008 | 62000.00 | 30672 |
18378 | 729 | Sudan | Maize | 2009 | 66000.00 | 37083 |
18379 | 729 | Sudan | Maize | 2010 | 35000.00 | 26460 |
18380 | 729 | Sudan | Maize | 2011 | 42000.00 | 31080 |
18381 | 729 | Sudan | Maize | 2012 | 183000.00 | 316660 |
18382 | 729 | Sudan | Maize | 2013 | 214000.00 | 348880 |
18383 | 729 | Sudan | Maize | 2014 | 316000.00 | 323200 |
18384 | 729 | Sudan | Maize | 2015 | 231589.00 | 240984 |
18385 | 729 | Sudan | Maize | 2016 | 214613.00 | 223368 |
18386 | 729 | Sudan | Maize | 2017 | 169314.00 | 184813 |
18387 | 729 | Sudan | Maize | 2018 | 195611.00 | 206674 |
18388 | 729 | Sudan | Maize | 2019 | 194427.00 | 216776 |
18389 | 729 | Sudan | Maize | 2020 | 194589.96 | 223952 |
18390 | 729 | Sudan | Maize | 2021 | 198817.99 | 237748 |
18391 | 729 | Sudan | Millet | 1995 | 385000.00 | 2418360 |
18392 | 729 | Sudan | Millet | 1996 | 440000.00 | 1633380 |
18393 | 729 | Sudan | Millet | 1997 | 643000.00 | 2809000 |
18394 | 729 | Sudan | Millet | 1998 | 670000.00 | 2762000 |
18395 | 729 | Sudan | Millet | 1999 | 499000.00 | 2393580 |
18396 | 729 | Sudan | Millet | 2000 | 496000.00 | 2087000 |
18397 | 729 | Sudan | Millet | 2001 | 578000.00 | 2586000 |
18398 | 729 | Sudan | Millet | 2002 | 581000.00 | 2437000 |
18399 | 729 | Sudan | Millet | 2003 | 784000.00 | 2570000 |
18400 | 729 | Sudan | Millet | 2004 | 281000.00 | 1285000 |
18401 | 729 | Sudan | Millet | 2005 | 745000.00 | 2243000 |
18402 | 729 | Sudan | Millet | 2006 | 675000.00 | 2233333 |
18403 | 729 | Sudan | Millet | 2007 | 796000.00 | 2322500 |
18404 | 729 | Sudan | Millet | 2008 | 721000.00 | 2332500 |
18405 | 729 | Sudan | Millet | 2009 | 630000.00 | 2357917 |
18406 | 729 | Sudan | Millet | 2010 | 471000.00 | 2016000 |
18407 | 729 | Sudan | Millet | 2011 | 634000.00 | 2451960 |
18408 | 729 | Sudan | Millet | 2012 | 438000.00 | 1367840 |
18409 | 729 | Sudan | Millet | 2013 | 1097000.00 | 2792080 |
18410 | 729 | Sudan | Millet | 2014 | 1257551.00 | 3162151 |
18411 | 729 | Sudan | Millet | 2015 | 546362.00 | 1770889 |
18412 | 729 | Sudan | Millet | 2016 | 1503123.00 | 3068766 |
18413 | 729 | Sudan | Millet | 2017 | 928079.00 | 2568595 |
18414 | 729 | Sudan | Millet | 2018 | 2690616.00 | 3810572 |
18415 | 729 | Sudan | Millet | 2019 | 1166558.00 | 3054551 |
18416 | 729 | Sudan | Millet | 2020 | 457958.00 | 2465208 |
18417 | 729 | Sudan | Millet | 2021 | 1547851.00 | 2856452 |
18418 | 729 | Sudan | Rice | 1995 | 1200.00 | 1630 |
18419 | 729 | Sudan | Rice | 1996 | 2000.00 | 2940 |
18420 | 729 | Sudan | Rice | 1997 | 2000.00 | 2940 |
18421 | 729 | Sudan | Rice | 1998 | 2000.00 | 3780 |
18422 | 729 | Sudan | Rice | 1999 | 11000.00 | 9240 |
18423 | 729 | Sudan | Rice | 2000 | 8000.00 | 5460 |
18424 | 729 | Sudan | Rice | 2001 | 11000.00 | 6160 |
18425 | 729 | Sudan | Rice | 2002 | 8000.00 | 4762 |
18426 | 729 | Sudan | Rice | 2003 | 15748.00 | 8000 |
18427 | 729 | Sudan | Rice | 2004 | 36000.00 | 7560 |
18428 | 729 | Sudan | Rice | 2005 | 20000.00 | 5880 |
18429 | 729 | Sudan | Rice | 2006 | 26000.00 | 7083 |
18430 | 729 | Sudan | Rice | 2007 | 23000.00 | 6250 |
18431 | 729 | Sudan | Rice | 2008 | 30000.00 | 6722 |
18432 | 729 | Sudan | Rice | 2009 | 22500.00 | 6303 |
18433 | 729 | Sudan | Rice | 2010 | 23350.00 | 6400 |
18434 | 729 | Sudan | Rice | 2011 | 25000.00 | 6720 |
18435 | 729 | Sudan | Rice | 2012 | 24000.00 | 7560 |
18436 | 729 | Sudan | Rice | 2013 | 25000.00 | 7562 |
18437 | 729 | Sudan | Rice | 2014 | 16900.00 | 15618 |
18438 | 729 | Sudan | Rice | 2015 | 47695.00 | 24859 |
18439 | 729 | Sudan | Rice | 2016 | 42073.00 | 23148 |
18440 | 729 | Sudan | Rice | 2017 | 45022.00 | 26470 |
18441 | 729 | Sudan | Rice | 2018 | 42821.00 | 26418 |
18442 | 729 | Sudan | Rice | 2019 | 56555.00 | 39426 |
18443 | 729 | Sudan | Rice | 2020 | 60365.33 | 41355 |
18444 | 729 | Sudan | Rice | 2021 | 51024.00 | 39231 |
18445 | 729 | Sudan | Sorghum | 1995 | 2450000.00 | 5045000 |
18446 | 729 | Sudan | Sorghum | 1996 | 4179000.00 | 6552840 |
18447 | 729 | Sudan | Sorghum | 1997 | 2870000.00 | 6556000 |
18448 | 729 | Sudan | Sorghum | 1998 | 4284000.00 | 6314000 |
18449 | 729 | Sudan | Sorghum | 1999 | 2347000.00 | 4529600 |
18450 | 729 | Sudan | Sorghum | 2000 | 2488000.00 | 4195000 |
18451 | 729 | Sudan | Sorghum | 2001 | 4394000.00 | 5742240 |
18452 | 729 | Sudan | Sorghum | 2002 | 2825000.00 | 5003000 |
18453 | 729 | Sudan | Sorghum | 2003 | 5188000.00 | 7081000 |
18454 | 729 | Sudan | Sorghum | 2004 | 2704000.00 | 3819000 |
18455 | 729 | Sudan | Sorghum | 2005 | 5002000.00 | 9864960 |
18456 | 729 | Sudan | Sorghum | 2006 | 4327000.00 | 6485420 |
18457 | 729 | Sudan | Sorghum | 2007 | 4999000.00 | 6522920 |
18458 | 729 | Sudan | Sorghum | 2008 | 3869000.00 | 6619330 |
18459 | 729 | Sudan | Sorghum | 2009 | 4192000.00 | 6652500 |
18460 | 729 | Sudan | Sorghum | 2010 | 2630000.00 | 5612880 |
18461 | 729 | Sudan | Sorghum | 2011 | 4605000.00 | 7256760 |
18462 | 729 | Sudan | Sorghum | 2012 | 2899000.00 | 4946400 |
18463 | 729 | Sudan | Sorghum | 2013 | 5244000.00 | 7920583 |
18464 | 729 | Sudan | Sorghum | 2014 | 7271000.00 | 9102100 |
18465 | 729 | Sudan | Sorghum | 2015 | 3405356.00 | 5926001 |
18466 | 729 | Sudan | Sorghum | 2016 | 7058998.00 | 9832219 |
18467 | 729 | Sudan | Sorghum | 2017 | 4662649.59 | 7096675 |
18468 | 729 | Sudan | Sorghum | 2018 | 5973957.00 | 8680007 |
18469 | 729 | Sudan | Sorghum | 2019 | 4304947.00 | 7498654 |
18470 | 729 | Sudan | Sorghum | 2020 | 3639998.00 | 6506288 |
18471 | 729 | Sudan | Sorghum | 2021 | 4121004.00 | 7620041 |
18472 | 729 | Sudan | Wheat | 1995 | 448000.00 | 278040 |
18473 | 729 | Sudan | Wheat | 1996 | 527000.00 | 297780 |
18474 | 729 | Sudan | Wheat | 1997 | 642000.00 | 329280 |
18475 | 729 | Sudan | Wheat | 1998 | 585000.00 | 255000 |
18476 | 729 | Sudan | Wheat | 1999 | 172000.00 | 142000 |
18477 | 729 | Sudan | Wheat | 2000 | 214000.00 | 91980 |
18478 | 729 | Sudan | Wheat | 2001 | 303000.00 | 120120 |
18479 | 729 | Sudan | Wheat | 2002 | 247000.00 | 115500 |
18480 | 729 | Sudan | Wheat | 2003 | 332000.00 | 169000 |
18481 | 729 | Sudan | Wheat | 2004 | 435000.00 | 180000 |
18482 | 729 | Sudan | Wheat | 2005 | 416000.00 | 169000 |
18483 | 729 | Sudan | Wheat | 2006 | 669000.00 | 174583 |
18484 | 729 | Sudan | Wheat | 2007 | 803000.00 | 284167 |
18485 | 729 | Sudan | Wheat | 2008 | 587000.00 | 301680 |
18486 | 729 | Sudan | Wheat | 2009 | 641695.00 | 400000 |
18487 | 729 | Sudan | Wheat | 2010 | 403000.00 | 224700 |
18488 | 729 | Sudan | Wheat | 2011 | 292000.00 | 182700 |
18489 | 729 | Sudan | Wheat | 2012 | 324000.00 | 187320 |
18490 | 729 | Sudan | Wheat | 2013 | 265000.00 | 135660 |
18491 | 729 | Sudan | Wheat | 2014 | 473000.00 | 222916 |
18492 | 729 | Sudan | Wheat | 2015 | 778600.00 | 226380 |
18493 | 729 | Sudan | Wheat | 2016 | 516000.00 | 216720 |
18494 | 729 | Sudan | Wheat | 2017 | 463000.00 | 172200 |
18495 | 729 | Sudan | Wheat | 2018 | 702000.00 | 286860 |
18496 | 729 | Sudan | Wheat | 2019 | 726000.00 | 303660 |
18497 | 729 | Sudan | Wheat | 2020 | 717578.00 | 321444 |
18498 | 729 | Sudan | Wheat | 2021 | 600000.00 | 260000 |
#import residue production ratio data
#RPR's are defined on a sub-continental scale and are independent of yield
RPR_df = pd.read_csv(RPR_loc,encoding='latin1')
#pd.unique(RPR_df['HI_region'])
RPR_df = RPR_df.merge(country_codes_df[['Area Code','M49 Code']],how='left',on='Area Code')
RPR_df = RPR_df[RPR_df['M49 Code'].notna()]
RPR_df.loc[(RPR_df['Item']=='Wheat') & (RPR_df['HI_region']=='South America & Carib.')]
pd.unique(RPR_df['HI_region'])
#pd.unique(RPR_df['Item'])
array(['South America & Carib.', 'Oceania', 'India', 'East Asia', 'Middle East & N Africa', 'Europe excl Russia', 'Sub-Saharan Africa', 'Central Asia', 'North America', 'South Asia', 'Russia', 'Brazil', 'USA', 'China', nan], dtype=object)
# function linking crop yield (Y) to residue yield taken from bentsen14 and ronzon17
def bentsen_func(Y,crop):
a = bentsen_dict[crop]['a']
b = bentsen_dict[crop]['b']
if np.isfinite(Y):
if Y < -1/b:
return Y * a * np.exp(b*Y)
else:
return -a / (b * np.exp(1))
# function linking crop yield (Y) to residue yield taken from Fischer07 (via ronzon17)
def fischer_func(Y,crop):
a = fischer_dict[crop]['a']
b = fischer_dict[crop]['b']
if np.isfinite(Y):
return Y * (a - b*Y)
#fischer_func(2,'Millet')
#scale grid cell production according to production in country
crop_prod_dict = {}
for year in year_list:
crop_prod_dict[year] = {}
for crop in crop_list:
#print(crop)
#calculate grid cell based grain production
prod_dict = {}
ha_dict = {}
for m49 in pd.unique(FAO_cereal_df['M49 Code']):
prod = (FAO_cereal_df.loc[(FAO_cereal_df['Item'] == crop) & (FAO_cereal_df['Year'] == year) & (FAO_cereal_df['M49 Code'] == m49), 'production (Mg)']).values
ha = (FAO_cereal_df.loc[(FAO_cereal_df['Item'] == crop) & (FAO_cereal_df['Year'] == year) & (FAO_cereal_df['M49 Code'] == m49), 'harvested area (ha)']).values
try:
prod_dict[m49] = prod[0]
except:
pass
try:
ha_dict[m49] = ha[0]
except:
pass
prod_dict[-1] = 0
ha_dict[-1] = 0
def prod_func(prod_frac,m49):
try:
return prod_frac * prod_dict[m49]
except:
return 0
def ha_func(ha_frac,m49):
try:
return ha_frac * ha_dict[m49]
except:
return 0
crop_prod_dict[year][crop] = crop_prod_frac_df[['lat','lon','M49 Code',f'{crop} country fraction', f'{crop} ha country fraction']].copy()
crop_prod_dict[year][crop][crop] = list(map(prod_func, crop_prod_dict[year][crop][f'{crop} country fraction'], crop_prod_dict[year][crop]['M49 Code'].fillna(-1)))
crop_prod_dict[year][crop][f'{crop} ha'] = list(map(ha_func, crop_prod_dict[year][crop][f'{crop} ha country fraction'], crop_prod_dict[year][crop]['M49 Code'].fillna(-1)))
crop_prod_dict[year][crop][f'{crop} yield'] = crop_prod_dict[year][crop][crop]/crop_prod_dict[year][crop][f'{crop} ha']
if year % 5 == 0:
print(f'{crop} grain production in {year} = %.2f Tg' % (crop_prod_dict[year][crop][crop].sum() * 10**-6))
#calculate grid cell based residue production based on fixed, regional RPR
factor_dict = {}
for m49 in pd.unique(RPR_df['M49 Code']):
x = (RPR_df.loc[(RPR_df['M49 Code']==m49) & (RPR_df['Item']== crop),'RPR'] * RPR_df.loc[(RPR_df['M49 Code']==m49) & (RPR_df['Item']== crop),'Dry_matter']).values
try:
factor_dict[m49] = x[0]
except:
pass
factor_dict[-1] = 0
def func(prod,m49):
try:
return prod * factor_dict[m49]
except:
return prod
crop_prod_dict[year][crop][f'{crop}_residue_RPR (Mg)'] = list(map(func, crop_prod_dict[year][crop][crop], crop_prod_dict[year][crop]['M49 Code'].fillna(-1)))
#calculate grid cell based residue production based on yield dependent exponential function (Bentsen14/Ronzon17)
crop_prod_dict[year][crop]['crop_name'] = crop
crop_prod_dict[year][crop][f'{crop}_residue_bentsen (Mg)'] = list(map(bentsen_func, crop_prod_dict[year][crop][f'{crop} yield'], crop_prod_dict[year][crop]['crop_name']))
crop_prod_dict[year][crop][f'{crop}_residue_bentsen (Mg)'] *= crop_prod_dict[year][crop][f'{crop} ha']
#calculate grid cell based residue production based on yield dependent linear function (Fischer07/Ronzon17)
crop_prod_dict[year][crop]['crop_name'] = crop
crop_prod_dict[year][crop][f'{crop}_residue_fischer (Mg)'] = list(map(fischer_func, crop_prod_dict[year][crop][f'{crop} yield'], crop_prod_dict[year][crop]['crop_name']))
crop_prod_dict[year][crop][f'{crop}_residue_fischer (Mg)'] *= crop_prod_dict[year][crop][f'{crop} ha']
crop_prod_dict[year][crop]['Year'] = year
#if year % 5 == 0:
print(f'{crop} residue production in {year} (RPR) = %.2f Tg-DM' % (crop_prod_dict[year][crop][f'{crop}_residue_RPR (Mg)'].sum()*10**-6))
print(f'{crop} residue production in {year} (bentsen) = %.2f Tg-DM' % (crop_prod_dict[year][crop][f'{crop}_residue_bentsen (Mg)'].sum()*10**-6))
print(f'{crop} residue production in {year} (fischer) = %.2f Tg-DM' % (crop_prod_dict[year][crop][f'{crop}_residue_fischer (Mg)'].sum()*10**-6))
if year % 5 == 0:
print('*********************')
crop_prod_dict[2015]['Wheat']
Wheat residue production in 1997 (RPR) = 662.72 Tg-DM Wheat residue production in 1997 (bentsen) = 862.69 Tg-DM Wheat residue production in 1997 (fischer) = 885.83 Tg-DM Rice residue production in 1997 (RPR) = 636.78 Tg-DM Rice residue production in 1997 (bentsen) = 954.87 Tg-DM Rice residue production in 1997 (fischer) = 859.70 Tg-DM Maize residue production in 1997 (RPR) = 800.56 Tg-DM Maize residue production in 1997 (bentsen) = 847.48 Tg-DM Maize residue production in 1997 (fischer) = 806.67 Tg-DM Barley residue production in 1997 (RPR) = 159.35 Tg-DM Barley residue production in 1997 (bentsen) = 173.31 Tg-DM Barley residue production in 1997 (fischer) = 282.23 Tg-DM Millet residue production in 1997 (RPR) = 36.24 Tg-DM Millet residue production in 1997 (bentsen) = 39.82 Tg-DM Millet residue production in 1997 (fischer) = 90.49 Tg-DM Sorghum residue production in 1997 (RPR) = 144.59 Tg-DM Sorghum residue production in 1997 (bentsen) = 106.04 Tg-DM Sorghum residue production in 1997 (fischer) = 179.83 Tg-DM Other cereals residue production in 1997 (RPR) = 78.71 Tg-DM Other cereals residue production in 1997 (bentsen) = 62.06 Tg-DM Other cereals residue production in 1997 (fischer) = 129.35 Tg-DM Wheat residue production in 1998 (RPR) = 634.11 Tg-DM Wheat residue production in 1998 (bentsen) = 821.13 Tg-DM Wheat residue production in 1998 (fischer) = 841.79 Tg-DM Rice residue production in 1998 (RPR) = 639.44 Tg-DM Rice residue production in 1998 (bentsen) = 959.61 Tg-DM Rice residue production in 1998 (fischer) = 865.84 Tg-DM Maize residue production in 1998 (RPR) = 836.92 Tg-DM Maize residue production in 1998 (bentsen) = 855.31 Tg-DM Maize residue production in 1998 (fischer) = 813.62 Tg-DM Barley residue production in 1998 (RPR) = 140.97 Tg-DM Barley residue production in 1998 (bentsen) = 153.56 Tg-DM Barley residue production in 1998 (fischer) = 249.44 Tg-DM Millet residue production in 1998 (RPR) = 38.38 Tg-DM Millet residue production in 1998 (bentsen) = 41.54 Tg-DM Millet residue production in 1998 (fischer) = 92.71 Tg-DM Sorghum residue production in 1998 (RPR) = 153.20 Tg-DM Sorghum residue production in 1998 (bentsen) = 108.22 Tg-DM Sorghum residue production in 1998 (fischer) = 181.96 Tg-DM Other cereals residue production in 1998 (RPR) = 64.76 Tg-DM Other cereals residue production in 1998 (bentsen) = 51.51 Tg-DM Other cereals residue production in 1998 (fischer) = 106.48 Tg-DM Wheat residue production in 1999 (RPR) = 624.08 Tg-DM Wheat residue production in 1999 (bentsen) = 805.92 Tg-DM Wheat residue production in 1999 (fischer) = 826.10 Tg-DM Rice residue production in 1999 (RPR) = 675.52 Tg-DM Rice residue production in 1999 (bentsen) = 1009.26 Tg-DM Rice residue production in 1999 (fischer) = 908.77 Tg-DM Maize residue production in 1999 (RPR) = 834.70 Tg-DM Maize residue production in 1999 (bentsen) = 852.36 Tg-DM Maize residue production in 1999 (fischer) = 810.71 Tg-DM Barley residue production in 1999 (RPR) = 131.76 Tg-DM Barley residue production in 1999 (bentsen) = 143.33 Tg-DM Barley residue production in 1999 (fischer) = 232.19 Tg-DM Millet residue production in 1999 (RPR) = 36.06 Tg-DM Millet residue production in 1999 (bentsen) = 39.91 Tg-DM Millet residue production in 1999 (fischer) = 90.49 Tg-DM Sorghum residue production in 1999 (RPR) = 147.61 Tg-DM Sorghum residue production in 1999 (bentsen) = 105.84 Tg-DM Sorghum residue production in 1999 (fischer) = 178.65 Tg-DM Other cereals residue production in 1999 (RPR) = 62.24 Tg-DM Other cereals residue production in 1999 (bentsen) = 50.03 Tg-DM Other cereals residue production in 1999 (fischer) = 102.56 Tg-DM Wheat grain production in 2000 = 585.71 Tg Wheat residue production in 2000 (RPR) = 634.78 Tg-DM Wheat residue production in 2000 (bentsen) = 815.64 Tg-DM Wheat residue production in 2000 (fischer) = 836.82 Tg-DM Rice grain production in 2000 = 598.63 Tg Rice residue production in 2000 (RPR) = 662.45 Tg-DM Rice residue production in 2000 (bentsen) = 990.42 Tg-DM Rice residue production in 2000 (fischer) = 893.74 Tg-DM Maize grain production in 2000 = 589.03 Tg Maize residue production in 2000 (RPR) = 818.75 Tg-DM Maize residue production in 2000 (bentsen) = 835.58 Tg-DM Maize residue production in 2000 (fischer) = 791.98 Tg-DM Barley grain production in 2000 = 131.15 Tg Barley residue production in 2000 (RPR) = 133.86 Tg-DM Barley residue production in 2000 (bentsen) = 144.55 Tg-DM Barley residue production in 2000 (fischer) = 234.46 Tg-DM Millet grain production in 2000 = 27.67 Tg Millet residue production in 2000 (RPR) = 36.53 Tg-DM Millet residue production in 2000 (bentsen) = 40.59 Tg-DM Millet residue production in 2000 (fischer) = 92.39 Tg-DM Sorghum grain production in 2000 = 55.81 Tg Sorghum residue production in 2000 (RPR) = 139.10 Tg-DM Sorghum residue production in 2000 (bentsen) = 100.14 Tg-DM Sorghum residue production in 2000 (fischer) = 172.26 Tg-DM Other cereals grain production in 2000 = 48.42 Tg Other cereals residue production in 2000 (RPR) = 63.91 Tg-DM Other cereals residue production in 2000 (bentsen) = 51.45 Tg-DM Other cereals residue production in 2000 (fischer) = 105.87 Tg-DM ********************* Wheat residue production in 2001 (RPR) = 636.93 Tg-DM Wheat residue production in 2001 (bentsen) = 823.21 Tg-DM Wheat residue production in 2001 (fischer) = 844.66 Tg-DM Rice residue production in 2001 (RPR) = 665.25 Tg-DM Rice residue production in 2001 (bentsen) = 991.77 Tg-DM Rice residue production in 2001 (fischer) = 895.59 Tg-DM Maize residue production in 2001 (RPR) = 845.53 Tg-DM Maize residue production in 2001 (bentsen) = 860.50 Tg-DM Maize residue production in 2001 (fischer) = 817.69 Tg-DM Barley residue production in 2001 (RPR) = 145.13 Tg-DM Barley residue production in 2001 (bentsen) = 155.55 Tg-DM Barley residue production in 2001 (fischer) = 252.70 Tg-DM Millet residue production in 2001 (RPR) = 38.15 Tg-DM Millet residue production in 2001 (bentsen) = 41.27 Tg-DM Millet residue production in 2001 (fischer) = 93.39 Tg-DM Sorghum residue production in 2001 (RPR) = 149.36 Tg-DM Sorghum residue production in 2001 (bentsen) = 107.37 Tg-DM Sorghum residue production in 2001 (fischer) = 184.69 Tg-DM Other cereals residue production in 2001 (RPR) = 69.53 Tg-DM Other cereals residue production in 2001 (bentsen) = 54.19 Tg-DM Other cereals residue production in 2001 (fischer) = 113.21 Tg-DM Wheat residue production in 2002 (RPR) = 642.68 Tg-DM Wheat residue production in 2002 (bentsen) = 823.86 Tg-DM Wheat residue production in 2002 (fischer) = 844.36 Tg-DM Rice residue production in 2002 (RPR) = 631.34 Tg-DM Rice residue production in 2002 (bentsen) = 944.99 Tg-DM Rice residue production in 2002 (fischer) = 853.10 Tg-DM Maize residue production in 2002 (RPR) = 842.28 Tg-DM Maize residue production in 2002 (bentsen) = 857.46 Tg-DM Maize residue production in 2002 (fischer) = 817.55 Tg-DM Barley residue production in 2002 (RPR) = 146.94 Tg-DM Barley residue production in 2002 (bentsen) = 157.62 Tg-DM Barley residue production in 2002 (fischer) = 256.52 Tg-DM Millet residue production in 2002 (RPR) = 31.62 Tg-DM Millet residue production in 2002 (bentsen) = 34.95 Tg-DM Millet residue production in 2002 (fischer) = 78.85 Tg-DM Sorghum residue production in 2002 (RPR) = 136.99 Tg-DM Sorghum residue production in 2002 (bentsen) = 97.37 Tg-DM Sorghum residue production in 2002 (fischer) = 169.30 Tg-DM Other cereals residue production in 2002 (RPR) = 65.00 Tg-DM Other cereals residue production in 2002 (bentsen) = 51.08 Tg-DM Other cereals residue production in 2002 (fischer) = 106.80 Tg-DM Wheat residue production in 2003 (RPR) = 600.97 Tg-DM Wheat residue production in 2003 (bentsen) = 774.66 Tg-DM Wheat residue production in 2003 (fischer) = 794.66 Tg-DM Rice residue production in 2003 (RPR) = 652.24 Tg-DM Rice residue production in 2003 (bentsen) = 972.60 Tg-DM Rice residue production in 2003 (fischer) = 881.69 Tg-DM Maize residue production in 2003 (RPR) = 897.05 Tg-DM Maize residue production in 2003 (bentsen) = 901.38 Tg-DM Maize residue production in 2003 (fischer) = 855.72 Tg-DM Barley residue production in 2003 (RPR) = 142.66 Tg-DM Barley residue production in 2003 (bentsen) = 155.50 Tg-DM Barley residue production in 2003 (fischer) = 253.59 Tg-DM
Millet residue production in 2003 (RPR) = 45.96 Tg-DM Millet residue production in 2003 (bentsen) = 48.21 Tg-DM Millet residue production in 2003 (fischer) = 108.11 Tg-DM Sorghum residue production in 2003 (RPR) = 151.32 Tg-DM Sorghum residue production in 2003 (bentsen) = 107.28 Tg-DM Sorghum residue production in 2003 (fischer) = 187.02 Tg-DM Other cereals residue production in 2003 (RPR) = 56.76 Tg-DM Other cereals residue production in 2003 (bentsen) = 45.41 Tg-DM Other cereals residue production in 2003 (fischer) = 94.01 Tg-DM Wheat residue production in 2004 (RPR) = 688.81 Tg-DM Wheat residue production in 2004 (bentsen) = 854.25 Tg-DM Wheat residue production in 2004 (fischer) = 878.73 Tg-DM Rice residue production in 2004 (RPR) = 672.17 Tg-DM Rice residue production in 2004 (bentsen) = 993.52 Tg-DM Rice residue production in 2004 (fischer) = 888.93 Tg-DM Maize residue production in 2004 (RPR) = 993.03 Tg-DM Maize residue production in 2004 (bentsen) = 949.45 Tg-DM Maize residue production in 2004 (fischer) = 887.21 Tg-DM Barley residue production in 2004 (RPR) = 161.93 Tg-DM Barley residue production in 2004 (bentsen) = 167.38 Tg-DM Barley residue production in 2004 (fischer) = 270.29 Tg-DM Millet residue production in 2004 (RPR) = 39.12 Tg-DM Millet residue production in 2004 (bentsen) = 41.38 Tg-DM Millet residue production in 2004 (fischer) = 92.84 Tg-DM Sorghum residue production in 2004 (RPR) = 145.36 Tg-DM Sorghum residue production in 2004 (bentsen) = 102.47 Tg-DM Sorghum residue production in 2004 (fischer) = 172.66 Tg-DM Other cereals residue production in 2004 (RPR) = 62.22 Tg-DM Other cereals residue production in 2004 (bentsen) = 46.55 Tg-DM Other cereals residue production in 2004 (fischer) = 99.48 Tg-DM Wheat grain production in 2005 = 625.00 Tg Wheat residue production in 2005 (RPR) = 682.14 Tg-DM Wheat residue production in 2005 (bentsen) = 858.95 Tg-DM Wheat residue production in 2005 (fischer) = 883.30 Tg-DM Rice grain production in 2005 = 634.19 Tg Rice residue production in 2005 (RPR) = 703.55 Tg-DM Rice residue production in 2005 (bentsen) = 1036.41 Tg-DM Rice residue production in 2005 (fischer) = 928.15 Tg-DM Maize grain production in 2005 = 707.04 Tg Maize residue production in 2005 (RPR) = 988.30 Tg-DM Maize residue production in 2005 (bentsen) = 946.95 Tg-DM Maize residue production in 2005 (fischer) = 895.60 Tg-DM Barley grain production in 2005 = 136.42 Tg Barley residue production in 2005 (RPR) = 142.58 Tg-DM Barley residue production in 2005 (bentsen) = 151.62 Tg-DM Barley residue production in 2005 (fischer) = 245.39 Tg-DM Millet grain production in 2005 = 31.00 Tg Millet residue production in 2005 (RPR) = 40.92 Tg-DM Millet residue production in 2005 (bentsen) = 43.50 Tg-DM Millet residue production in 2005 (fischer) = 97.53 Tg-DM Sorghum grain production in 2005 = 59.55 Tg Sorghum residue production in 2005 (RPR) = 156.74 Tg-DM Sorghum residue production in 2005 (bentsen) = 107.25 Tg-DM Sorghum residue production in 2005 (fischer) = 183.88 Tg-DM Other cereals grain production in 2005 = 42.74 Tg Other cereals residue production in 2005 (RPR) = 56.41 Tg-DM Other cereals residue production in 2005 (bentsen) = 45.25 Tg-DM Other cereals residue production in 2005 (fischer) = 93.41 Tg-DM ********************* Wheat residue production in 2006 (RPR) = 670.29 Tg-DM Wheat residue production in 2006 (bentsen) = 840.36 Tg-DM Wheat residue production in 2006 (fischer) = 865.26 Tg-DM Rice residue production in 2006 (RPR) = 711.45 Tg-DM Rice residue production in 2006 (bentsen) = 1044.06 Tg-DM Rice residue production in 2006 (fischer) = 932.47 Tg-DM Maize residue production in 2006 (RPR) = 996.13 Tg-DM Maize residue production in 2006 (bentsen) = 963.53 Tg-DM Maize residue production in 2006 (fischer) = 911.40 Tg-DM Barley residue production in 2006 (RPR) = 152.09 Tg-DM Barley residue production in 2006 (bentsen) = 162.33 Tg-DM Barley residue production in 2006 (fischer) = 264.17 Tg-DM Millet residue production in 2006 (RPR) = 42.24 Tg-DM Millet residue production in 2006 (bentsen) = 44.74 Tg-DM Millet residue production in 2006 (fischer) = 100.14 Tg-DM Sorghum residue production in 2006 (RPR) = 157.49 Tg-DM Sorghum residue production in 2006 (bentsen) = 105.71 Tg-DM Sorghum residue production in 2006 (fischer) = 184.56 Tg-DM Other cereals residue production in 2006 (RPR) = 52.17 Tg-DM Other cereals residue production in 2006 (bentsen) = 42.39 Tg-DM Other cereals residue production in 2006 (fischer) = 86.91 Tg-DM Wheat residue production in 2007 (RPR) = 660.30 Tg-DM Wheat residue production in 2007 (bentsen) = 833.56 Tg-DM Wheat residue production in 2007 (fischer) = 859.24 Tg-DM Rice residue production in 2007 (RPR) = 726.45 Tg-DM Rice residue production in 2007 (bentsen) = 1056.47 Tg-DM Rice residue production in 2007 (fischer) = 936.69 Tg-DM Maize residue production in 2007 (RPR) = 1090.28 Tg-DM Maize residue production in 2007 (bentsen) = 1052.85 Tg-DM Maize residue production in 2007 (fischer) = 993.18 Tg-DM Barley residue production in 2007 (RPR) = 136.36 Tg-DM Barley residue production in 2007 (bentsen) = 147.88 Tg-DM Barley residue production in 2007 (fischer) = 241.02 Tg-DM Millet residue production in 2007 (RPR) = 44.44 Tg-DM Millet residue production in 2007 (bentsen) = 46.08 Tg-DM Millet residue production in 2007 (fischer) = 102.97 Tg-DM Sorghum residue production in 2007 (RPR) = 163.25 Tg-DM Sorghum residue production in 2007 (bentsen) = 112.05 Tg-DM Sorghum residue production in 2007 (fischer) = 190.85 Tg-DM Other cereals residue production in 2007 (RPR) = 57.63 Tg-DM Other cereals residue production in 2007 (bentsen) = 45.35 Tg-DM Other cereals residue production in 2007 (fischer) = 95.15 Tg-DM Wheat residue production in 2008 (RPR) = 733.81 Tg-DM Wheat residue production in 2008 (bentsen) = 895.89 Tg-DM Wheat residue production in 2008 (fischer) = 926.25 Tg-DM Rice residue production in 2008 (RPR) = 760.92 Tg-DM Rice residue production in 2008 (bentsen) = 1097.53 Tg-DM Rice residue production in 2008 (fischer) = 965.78 Tg-DM Maize residue production in 2008 (RPR) = 1177.59 Tg-DM Maize residue production in 2008 (bentsen) = 1096.56 Tg-DM Maize residue production in 2008 (fischer) = 1035.41 Tg-DM Barley residue production in 2008 (RPR) = 158.33 Tg-DM Barley residue production in 2008 (bentsen) = 163.46 Tg-DM Barley residue production in 2008 (fischer) = 264.75 Tg-DM Millet residue production in 2008 (RPR) = 45.41 Tg-DM Millet residue production in 2008 (bentsen) = 46.89 Tg-DM Millet residue production in 2008 (fischer) = 104.89 Tg-DM Sorghum residue production in 2008 (RPR) = 170.90 Tg-DM Sorghum residue production in 2008 (bentsen) = 117.85 Tg-DM Sorghum residue production in 2008 (fischer) = 200.61 Tg-DM Other cereals residue production in 2008 (RPR) = 63.70 Tg-DM Other cereals residue production in 2008 (bentsen) = 47.92 Tg-DM Other cereals residue production in 2008 (fischer) = 102.94 Tg-DM Wheat residue production in 2009 (RPR) = 745.17 Tg-DM Wheat residue production in 2009 (bentsen) = 913.54 Tg-DM Wheat residue production in 2009 (fischer) = 942.38 Tg-DM Rice residue production in 2009 (RPR) = 754.85 Tg-DM Rice residue production in 2009 (bentsen) = 1086.70 Tg-DM Rice residue production in 2009 (fischer) = 952.77 Tg-DM Maize residue production in 2009 (RPR) = 1153.58 Tg-DM Maize residue production in 2009 (bentsen) = 1064.82 Tg-DM Maize residue production in 2009 (fischer) = 993.73 Tg-DM Barley residue production in 2009 (RPR) = 157.71 Tg-DM Barley residue production in 2009 (bentsen) = 162.57 Tg-DM Barley residue production in 2009 (fischer) = 261.87 Tg-DM Millet residue production in 2009 (RPR) = 34.20 Tg-DM Millet residue production in 2009 (bentsen) = 37.80 Tg-DM Millet residue production in 2009 (fischer) = 86.22 Tg-DM Sorghum residue production in 2009 (RPR) = 148.14 Tg-DM Sorghum residue production in 2009 (bentsen) = 101.44 Tg-DM Sorghum residue production in 2009 (fischer) = 173.02 Tg-DM Other cereals residue production in 2009 (RPR) = 60.74 Tg-DM Other cereals residue production in 2009 (bentsen) = 44.87 Tg-DM Other cereals residue production in 2009 (fischer) = 96.91 Tg-DM Wheat grain production in 2010 = 640.79 Tg
Wheat residue production in 2010 (RPR) = 694.61 Tg-DM Wheat residue production in 2010 (bentsen) = 859.45 Tg-DM Wheat residue production in 2010 (fischer) = 887.93 Tg-DM Rice grain production in 2010 = 694.45 Tg Rice residue production in 2010 (RPR) = 771.70 Tg-DM Rice residue production in 2010 (bentsen) = 1111.52 Tg-DM Rice residue production in 2010 (fischer) = 977.41 Tg-DM Maize grain production in 2010 = 852.74 Tg Maize residue production in 2010 (RPR) = 1227.97 Tg-DM Maize residue production in 2010 (bentsen) = 1125.33 Tg-DM Maize residue production in 2010 (fischer) = 1064.15 Tg-DM Barley grain production in 2010 = 123.46 Tg Barley residue production in 2010 (RPR) = 128.32 Tg-DM Barley residue production in 2010 (bentsen) = 135.71 Tg-DM Barley residue production in 2010 (fischer) = 219.43 Tg-DM Millet grain production in 2010 = 32.80 Tg Millet residue production in 2010 (RPR) = 43.30 Tg-DM Millet residue production in 2010 (bentsen) = 45.86 Tg-DM Millet residue production in 2010 (fischer) = 103.24 Tg-DM Sorghum grain production in 2010 = 60.18 Tg Sorghum residue production in 2010 (RPR) = 157.39 Tg-DM Sorghum residue production in 2010 (bentsen) = 105.96 Tg-DM Sorghum residue production in 2010 (fischer) = 177.64 Tg-DM Other cereals grain production in 2010 = 36.78 Tg Other cereals residue production in 2010 (RPR) = 48.54 Tg-DM Other cereals residue production in 2010 (bentsen) = 38.23 Tg-DM Other cereals residue production in 2010 (fischer) = 79.74 Tg-DM ********************* Wheat residue production in 2011 (RPR) = 761.33 Tg-DM Wheat residue production in 2011 (bentsen) = 926.51 Tg-DM Wheat residue production in 2011 (fischer) = 961.57 Tg-DM Rice residue production in 2011 (RPR) = 800.23 Tg-DM Rice residue production in 2011 (bentsen) = 1138.77 Tg-DM Rice residue production in 2011 (fischer) = 990.03 Tg-DM Maize residue production in 2011 (RPR) = 1278.59 Tg-DM Maize residue production in 2011 (bentsen) = 1176.34 Tg-DM Maize residue production in 2011 (fischer) = 1116.21 Tg-DM Barley residue production in 2011 (RPR) = 140.03 Tg-DM Barley residue production in 2011 (bentsen) = 145.83 Tg-DM Barley residue production in 2011 (fischer) = 238.35 Tg-DM Millet residue production in 2011 (RPR) = 35.71 Tg-DM Millet residue production in 2011 (bentsen) = 37.92 Tg-DM Millet residue production in 2011 (fischer) = 84.73 Tg-DM Sorghum residue production in 2011 (RPR) = 152.04 Tg-DM Sorghum residue production in 2011 (bentsen) = 102.48 Tg-DM Sorghum residue production in 2011 (fischer) = 176.40 Tg-DM Other cereals residue production in 2011 (RPR) = 53.89 Tg-DM Other cereals residue production in 2011 (bentsen) = 40.92 Tg-DM Other cereals residue production in 2011 (fischer) = 87.49 Tg-DM Wheat residue production in 2012 (RPR) = 732.39 Tg-DM Wheat residue production in 2012 (bentsen) = 891.00 Tg-DM Wheat residue production in 2012 (fischer) = 923.51 Tg-DM Rice residue production in 2012 (RPR) = 809.62 Tg-DM Rice residue production in 2012 (bentsen) = 1142.85 Tg-DM Rice residue production in 2012 (fischer) = 985.77 Tg-DM Maize residue production in 2012 (RPR) = 1297.54 Tg-DM Maize residue production in 2012 (bentsen) = 1226.03 Tg-DM Maize residue production in 2012 (fischer) = 1175.71 Tg-DM Barley residue production in 2012 (RPR) = 138.27 Tg-DM Barley residue production in 2012 (bentsen) = 144.34 Tg-DM Barley residue production in 2012 (fischer) = 233.16 Tg-DM Millet residue production in 2012 (RPR) = 35.23 Tg-DM Millet residue production in 2012 (bentsen) = 37.93 Tg-DM Millet residue production in 2012 (fischer) = 84.92 Tg-DM Sorghum residue production in 2012 (RPR) = 149.10 Tg-DM Sorghum residue production in 2012 (bentsen) = 102.51 Tg-DM Sorghum residue production in 2012 (fischer) = 175.20 Tg-DM Other cereals residue production in 2012 (RPR) = 54.27 Tg-DM Other cereals residue production in 2012 (bentsen) = 40.36 Tg-DM Other cereals residue production in 2012 (fischer) = 86.77 Tg-DM Wheat residue production in 2013 (RPR) = 771.54 Tg-DM Wheat residue production in 2013 (bentsen) = 923.56 Tg-DM Wheat residue production in 2013 (fischer) = 959.19 Tg-DM Rice residue production in 2013 (RPR) = 814.50 Tg-DM Rice residue production in 2013 (bentsen) = 1151.98 Tg-DM Rice residue production in 2013 (fischer) = 995.92 Tg-DM Maize residue production in 2013 (RPR) = 1457.27 Tg-DM Maize residue production in 2013 (bentsen) = 1302.56 Tg-DM Maize residue production in 2013 (fischer) = 1229.25 Tg-DM Barley residue production in 2013 (RPR) = 150.46 Tg-DM Barley residue production in 2013 (bentsen) = 151.55 Tg-DM Barley residue production in 2013 (fischer) = 244.65 Tg-DM Millet residue production in 2013 (RPR) = 34.88 Tg-DM Millet residue production in 2013 (bentsen) = 36.79 Tg-DM Millet residue production in 2013 (fischer) = 81.66 Tg-DM Sorghum residue production in 2013 (RPR) = 156.67 Tg-DM Sorghum residue production in 2013 (bentsen) = 110.03 Tg-DM Sorghum residue production in 2013 (fischer) = 186.69 Tg-DM Other cereals residue production in 2013 (RPR) = 61.61 Tg-DM Other cereals residue production in 2013 (bentsen) = 44.05 Tg-DM Other cereals residue production in 2013 (fischer) = 96.53 Tg-DM Wheat residue production in 2014 (RPR) = 788.79 Tg-DM Wheat residue production in 2014 (bentsen) = 934.58 Tg-DM Wheat residue production in 2014 (fischer) = 968.42 Tg-DM Rice residue production in 2014 (RPR) = 813.84 Tg-DM Rice residue production in 2014 (bentsen) = 1147.14 Tg-DM Rice residue production in 2014 (fischer) = 987.20 Tg-DM Maize residue production in 2014 (RPR) = 1508.54 Tg-DM Maize residue production in 2014 (bentsen) = 1301.18 Tg-DM Maize residue production in 2014 (fischer) = 1209.50 Tg-DM Barley residue production in 2014 (RPR) = 152.44 Tg-DM Barley residue production in 2014 (bentsen) = 150.96 Tg-DM Barley residue production in 2014 (fischer) = 240.93 Tg-DM Millet residue production in 2014 (RPR) = 38.13 Tg-DM Millet residue production in 2014 (bentsen) = 39.39 Tg-DM Millet residue production in 2014 (fischer) = 85.55 Tg-DM Sorghum residue production in 2014 (RPR) = 174.21 Tg-DM Sorghum residue production in 2014 (bentsen) = 119.30 Tg-DM Sorghum residue production in 2014 (fischer) = 198.09 Tg-DM Other cereals residue production in 2014 (RPR) = 59.05 Tg-DM Other cereals residue production in 2014 (bentsen) = 42.36 Tg-DM Other cereals residue production in 2014 (fischer) = 92.49 Tg-DM Wheat grain production in 2015 = 741.83 Tg Wheat residue production in 2015 (RPR) = 801.71 Tg-DM Wheat residue production in 2015 (bentsen) = 948.76 Tg-DM Wheat residue production in 2015 (fischer) = 981.52 Tg-DM Rice grain production in 2015 = 732.87 Tg Rice residue production in 2015 (RPR) = 815.34 Tg-DM Rice residue production in 2015 (bentsen) = 1142.47 Tg-DM Rice residue production in 2015 (fischer) = 976.24 Tg-DM Maize grain production in 2015 = 1053.87 Tg Maize residue production in 2015 (RPR) = 1521.91 Tg-DM Maize residue production in 2015 (bentsen) = 1334.38 Tg-DM Maize residue production in 2015 (fischer) = 1246.72 Tg-DM Barley grain production in 2015 = 148.36 Tg Barley residue production in 2015 (RPR) = 156.14 Tg-DM Barley residue production in 2015 (bentsen) = 151.95 Tg-DM Barley residue production in 2015 (fischer) = 241.02 Tg-DM Millet grain production in 2015 = 28.58 Tg Millet residue production in 2015 (RPR) = 37.72 Tg-DM Millet residue production in 2015 (bentsen) = 38.69 Tg-DM Millet residue production in 2015 (fischer) = 85.23 Tg-DM Sorghum grain production in 2015 = 65.94 Tg Sorghum residue production in 2015 (RPR) = 163.55 Tg-DM Sorghum residue production in 2015 (bentsen) = 113.86 Tg-DM Sorghum residue production in 2015 (fischer) = 186.79 Tg-DM Other cereals grain production in 2015 = 42.86 Tg Other cereals residue production in 2015 (RPR) = 56.57 Tg-DM Other cereals residue production in 2015 (bentsen) = 40.72 Tg-DM Other cereals residue production in 2015 (fischer) = 88.89 Tg-DM ********************* Wheat residue production in 2016 (RPR) = 812.81 Tg-DM Wheat residue production in 2016 (bentsen) = 958.81 Tg-DM Wheat residue production in 2016 (fischer) = 1000.94 Tg-DM Rice residue production in 2016 (RPR) = 821.48 Tg-DM Rice residue production in 2016 (bentsen) = 1151.28 Tg-DM Rice residue production in 2016 (fischer) = 987.00 Tg-DM
Maize residue production in 2016 (RPR) = 1581.36 Tg-DM Maize residue production in 2016 (bentsen) = 1357.63 Tg-DM Maize residue production in 2016 (fischer) = 1232.08 Tg-DM Barley residue production in 2016 (RPR) = 152.93 Tg-DM Barley residue production in 2016 (bentsen) = 150.81 Tg-DM Barley residue production in 2016 (fischer) = 243.95 Tg-DM Millet residue production in 2016 (RPR) = 36.60 Tg-DM Millet residue production in 2016 (bentsen) = 38.78 Tg-DM Millet residue production in 2016 (fischer) = 86.32 Tg-DM Sorghum residue production in 2016 (RPR) = 165.07 Tg-DM Sorghum residue production in 2016 (bentsen) = 111.63 Tg-DM Sorghum residue production in 2016 (fischer) = 186.70 Tg-DM Other cereals residue production in 2016 (RPR) = 57.42 Tg-DM Other cereals residue production in 2016 (bentsen) = 41.03 Tg-DM Other cereals residue production in 2016 (fischer) = 90.42 Tg-DM Wheat residue production in 2017 (RPR) = 840.45 Tg-DM Wheat residue production in 2017 (bentsen) = 970.16 Tg-DM Wheat residue production in 2017 (fischer) = 1012.05 Tg-DM Rice residue production in 2017 (RPR) = 837.51 Tg-DM Rice residue production in 2017 (bentsen) = 1170.12 Tg-DM Rice residue production in 2017 (fischer) = 999.66 Tg-DM Maize residue production in 2017 (RPR) = 1676.31 Tg-DM Maize residue production in 2017 (bentsen) = 1403.87 Tg-DM Maize residue production in 2017 (fischer) = 1299.56 Tg-DM Barley residue production in 2017 (RPR) = 157.43 Tg-DM Barley residue production in 2017 (bentsen) = 151.09 Tg-DM Barley residue production in 2017 (fischer) = 242.49 Tg-DM Millet residue production in 2017 (RPR) = 38.17 Tg-DM Millet residue production in 2017 (bentsen) = 39.05 Tg-DM Millet residue production in 2017 (fischer) = 84.19 Tg-DM Sorghum residue production in 2017 (RPR) = 152.14 Tg-DM Sorghum residue production in 2017 (bentsen) = 102.11 Tg-DM Sorghum residue production in 2017 (fischer) = 172.07 Tg-DM Other cereals residue production in 2017 (RPR) = 59.92 Tg-DM Other cereals residue production in 2017 (bentsen) = 42.50 Tg-DM Other cereals residue production in 2017 (fischer) = 94.33 Tg-DM Wheat residue production in 2018 (RPR) = 795.53 Tg-DM Wheat residue production in 2018 (bentsen) = 939.44 Tg-DM Wheat residue production in 2018 (fischer) = 980.66 Tg-DM Rice residue production in 2018 (RPR) = 848.64 Tg-DM Rice residue production in 2018 (bentsen) = 1178.24 Tg-DM Rice residue production in 2018 (fischer) = 999.28 Tg-DM Maize residue production in 2018 (RPR) = 1638.38 Tg-DM Maize residue production in 2018 (bentsen) = 1386.70 Tg-DM Maize residue production in 2018 (fischer) = 1284.88 Tg-DM Barley residue production in 2018 (RPR) = 149.15 Tg-DM Barley residue production in 2018 (bentsen) = 149.12 Tg-DM Barley residue production in 2018 (fischer) = 242.57 Tg-DM Millet residue production in 2018 (RPR) = 41.54 Tg-DM Millet residue production in 2018 (bentsen) = 42.76 Tg-DM Millet residue production in 2018 (fischer) = 92.87 Tg-DM Sorghum residue production in 2018 (RPR) = 160.77 Tg-DM Sorghum residue production in 2018 (bentsen) = 107.06 Tg-DM Sorghum residue production in 2018 (fischer) = 181.63 Tg-DM Other cereals residue production in 2018 (RPR) = 53.83 Tg-DM Other cereals residue production in 2018 (bentsen) = 40.85 Tg-DM Other cereals residue production in 2018 (fischer) = 87.65 Tg-DM Wheat residue production in 2019 (RPR) = 826.87 Tg-DM Wheat residue production in 2019 (bentsen) = 951.35 Tg-DM Wheat residue production in 2019 (fischer) = 991.14 Tg-DM Rice residue production in 2019 (RPR) = 841.54 Tg-DM Rice residue production in 2019 (bentsen) = 1163.49 Tg-DM Rice residue production in 2019 (fischer) = 985.22 Tg-DM Maize residue production in 2019 (RPR) = 1671.60 Tg-DM Maize residue production in 2019 (bentsen) = 1401.82 Tg-DM Maize residue production in 2019 (fischer) = 1312.25 Tg-DM Barley residue production in 2019 (RPR) = 168.17 Tg-DM Barley residue production in 2019 (bentsen) = 161.41 Tg-DM Barley residue production in 2019 (fischer) = 256.91 Tg-DM Millet residue production in 2019 (RPR) = 37.32 Tg-DM Millet residue production in 2019 (bentsen) = 38.43 Tg-DM Millet residue production in 2019 (fischer) = 83.67 Tg-DM Sorghum residue production in 2019 (RPR) = 148.57 Tg-DM Sorghum residue production in 2019 (bentsen) = 99.98 Tg-DM Sorghum residue production in 2019 (fischer) = 167.47 Tg-DM Other cereals residue production in 2019 (RPR) = 57.87 Tg-DM Other cereals residue production in 2019 (bentsen) = 41.18 Tg-DM Other cereals residue production in 2019 (fischer) = 90.93 Tg-DM Wheat grain production in 2020 = 756.95 Tg Wheat residue production in 2020 (RPR) = 823.47 Tg-DM Wheat residue production in 2020 (bentsen) = 954.03 Tg-DM Wheat residue production in 2020 (fischer) = 995.57 Tg-DM Rice grain production in 2020 = 769.20 Tg Rice residue production in 2020 (RPR) = 859.30 Tg-DM Rice residue production in 2020 (bentsen) = 1185.30 Tg-DM Rice residue production in 2020 (fischer) = 1000.28 Tg-DM Maize grain production in 2020 = 1162.99 Tg Maize residue production in 2020 (RPR) = 1731.94 Tg-DM Maize residue production in 2020 (bentsen) = 1435.16 Tg-DM Maize residue production in 2020 (fischer) = 1337.12 Tg-DM Barley grain production in 2020 = 157.70 Tg Barley residue production in 2020 (RPR) = 166.91 Tg-DM Barley residue production in 2020 (bentsen) = 162.17 Tg-DM Barley residue production in 2020 (fischer) = 262.47 Tg-DM Millet grain production in 2020 = 30.83 Tg Millet residue production in 2020 (RPR) = 40.69 Tg-DM Millet residue production in 2020 (bentsen) = 40.35 Tg-DM Millet residue production in 2020 (fischer) = 85.26 Tg-DM Sorghum grain production in 2020 = 58.92 Tg Sorghum residue production in 2020 (RPR) = 155.49 Tg-DM Sorghum residue production in 2020 (bentsen) = 102.72 Tg-DM Sorghum residue production in 2020 (fischer) = 165.07 Tg-DM Other cereals grain production in 2020 = 48.70 Tg Other cereals residue production in 2020 (RPR) = 64.27 Tg-DM Other cereals residue production in 2020 (bentsen) = 44.10 Tg-DM Other cereals residue production in 2020 (fischer) = 99.78 Tg-DM ********************* Wheat residue production in 2021 (RPR) = 835.11 Tg-DM Wheat residue production in 2021 (bentsen) = 966.30 Tg-DM Wheat residue production in 2021 (fischer) = 1008.09 Tg-DM Rice residue production in 2021 (RPR) = 880.43 Tg-DM Rice residue production in 2021 (bentsen) = 1206.74 Tg-DM Rice residue production in 2021 (fischer) = 1011.54 Tg-DM Maize residue production in 2021 (RPR) = 1793.11 Tg-DM Maize residue production in 2021 (bentsen) = 1480.94 Tg-DM Maize residue production in 2021 (fischer) = 1368.71 Tg-DM Barley residue production in 2021 (RPR) = 153.14 Tg-DM Barley residue production in 2021 (bentsen) = 149.96 Tg-DM Barley residue production in 2021 (fischer) = 240.91 Tg-DM Millet residue production in 2021 (RPR) = 39.72 Tg-DM Millet residue production in 2021 (bentsen) = 39.60 Tg-DM Millet residue production in 2021 (fischer) = 84.47 Tg-DM Sorghum residue production in 2021 (RPR) = 155.71 Tg-DM Sorghum residue production in 2021 (bentsen) = 107.25 Tg-DM Sorghum residue production in 2021 (fischer) = 177.73 Tg-DM Other cereals residue production in 2021 (RPR) = 58.28 Tg-DM Other cereals residue production in 2021 (bentsen) = 42.27 Tg-DM Other cereals residue production in 2021 (fischer) = 92.57 Tg-DM
lat | lon | M49 Code | Wheat country fraction | Wheat ha country fraction | Wheat | Wheat ha | Wheat yield | Wheat_residue_RPR (Mg) | crop_name | Wheat_residue_bentsen (Mg) | Wheat_residue_fischer (Mg) | Year | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -89.75 | -179.75 | 10.0 | NaN | NaN | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
1 | -89.75 | -179.25 | 10.0 | NaN | NaN | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
2 | -89.75 | -178.75 | 10.0 | NaN | NaN | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
3 | -89.75 | -178.25 | 10.0 | NaN | NaN | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
4 | -89.75 | -177.75 | 10.0 | NaN | NaN | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
259195 | 89.75 | 177.75 | NaN | 0.0 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
259196 | 89.75 | 178.25 | NaN | 0.0 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
259197 | 89.75 | 178.75 | NaN | 0.0 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
259198 | 89.75 | 179.25 | NaN | 0.0 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
259199 | 89.75 | 179.75 | NaN | 0.0 | 0.0 | 0.0 | 0.0 | NaN | 0.0 | Wheat | NaN | NaN | 2015 |
259200 rows × 13 columns
#combine crops to get total residue production in each grid cell
residue_prod_dict = {}
col_name_list = []
for method in residue_methods:
col_name_list.append(f'residue production {method} (Mg)')
for year in year_list:
residue_prod_dict[year] = crop_prod_dict[year]['Wheat'][['lon','lat','Year']].copy()
for method in residue_methods:
residue_prod_dict[year][f'residue production {method} (Mg)'] = 0
for crop in crop_list:
residue_prod_dict[year][f'residue production {method} (Mg)'] += crop_prod_dict[year][crop][f'{crop}_residue_{method} (Mg)'].fillna(0)
residue_prod_dict[year]['residue production mean (Mg)'] = residue_prod_dict[year][col_name_list].mean(axis=1)
residue_prod_dict[year]['residue production sd (Mg)'] = residue_prod_dict[year][col_name_list].std(axis=1)
for year in year_list:
print('****************')
print(year)
print('****************')
for method in residue_methods + ['mean']:
print(f'total residue production ({method}) = %.2f Tg' % (residue_prod_dict[year][f'residue production {method} (Mg)'].sum() * 10**-6) )
residue_prod_dict[2015]
**************** 1997 **************** total residue production (RPR) = 2518.96 Tg total residue production (bentsen) = 3046.27 Tg total residue production (fischer) = 3234.10 Tg total residue production (mean) = 2933.11 Tg **************** 1998 **************** total residue production (RPR) = 2507.80 Tg total residue production (bentsen) = 2990.88 Tg total residue production (fischer) = 3151.84 Tg total residue production (mean) = 2883.51 Tg **************** 1999 **************** total residue production (RPR) = 2511.97 Tg total residue production (bentsen) = 3006.64 Tg total residue production (fischer) = 3149.47 Tg total residue production (mean) = 2889.36 Tg **************** 2000 **************** total residue production (RPR) = 2489.38 Tg total residue production (bentsen) = 2978.38 Tg total residue production (fischer) = 3127.52 Tg total residue production (mean) = 2865.09 Tg **************** 2001 **************** total residue production (RPR) = 2549.87 Tg total residue production (bentsen) = 3033.87 Tg total residue production (fischer) = 3201.92 Tg total residue production (mean) = 2928.55 Tg **************** 2002 **************** total residue production (RPR) = 2496.85 Tg total residue production (bentsen) = 2967.33 Tg total residue production (fischer) = 3126.47 Tg total residue production (mean) = 2863.55 Tg **************** 2003 **************** total residue production (RPR) = 2546.95 Tg total residue production (bentsen) = 3005.04 Tg total residue production (fischer) = 3174.81 Tg total residue production (mean) = 2908.93 Tg **************** 2004 **************** total residue production (RPR) = 2762.64 Tg total residue production (bentsen) = 3155.00 Tg total residue production (fischer) = 3290.12 Tg total residue production (mean) = 3069.25 Tg **************** 2005 **************** total residue production (RPR) = 2770.64 Tg total residue production (bentsen) = 3189.92 Tg total residue production (fischer) = 3327.26 Tg total residue production (mean) = 3095.94 Tg **************** 2006 **************** total residue production (RPR) = 2781.86 Tg total residue production (bentsen) = 3203.13 Tg total residue production (fischer) = 3344.90 Tg total residue production (mean) = 3109.96 Tg **************** 2007 **************** total residue production (RPR) = 2878.72 Tg total residue production (bentsen) = 3294.24 Tg total residue production (fischer) = 3419.09 Tg total residue production (mean) = 3197.35 Tg **************** 2008 **************** total residue production (RPR) = 3110.65 Tg total residue production (bentsen) = 3466.10 Tg total residue production (fischer) = 3600.63 Tg total residue production (mean) = 3392.46 Tg **************** 2009 **************** total residue production (RPR) = 3054.39 Tg total residue production (bentsen) = 3411.75 Tg total residue production (fischer) = 3506.90 Tg total residue production (mean) = 3324.35 Tg **************** 2010 **************** total residue production (RPR) = 3071.83 Tg total residue production (bentsen) = 3422.05 Tg total residue production (fischer) = 3509.54 Tg total residue production (mean) = 3334.47 Tg **************** 2011 **************** total residue production (RPR) = 3221.82 Tg total residue production (bentsen) = 3568.77 Tg total residue production (fischer) = 3654.76 Tg total residue production (mean) = 3481.78 Tg **************** 2012 **************** total residue production (RPR) = 3216.42 Tg total residue production (bentsen) = 3585.02 Tg total residue production (fischer) = 3665.02 Tg total residue production (mean) = 3488.82 Tg **************** 2013 **************** total residue production (RPR) = 3446.93 Tg total residue production (bentsen) = 3720.52 Tg total residue production (fischer) = 3793.90 Tg total residue production (mean) = 3653.79 Tg **************** 2014 **************** total residue production (RPR) = 3534.99 Tg total residue production (bentsen) = 3734.92 Tg total residue production (fischer) = 3782.17 Tg total residue production (mean) = 3684.03 Tg **************** 2015 **************** total residue production (RPR) = 3552.94 Tg total residue production (bentsen) = 3770.83 Tg total residue production (fischer) = 3806.41 Tg total residue production (mean) = 3710.06 Tg **************** 2016 **************** total residue production (RPR) = 3627.67 Tg total residue production (bentsen) = 3809.97 Tg total residue production (fischer) = 3827.42 Tg total residue production (mean) = 3755.02 Tg **************** 2017 **************** total residue production (RPR) = 3761.91 Tg total residue production (bentsen) = 3878.89 Tg total residue production (fischer) = 3904.34 Tg total residue production (mean) = 3848.38 Tg **************** 2018 **************** total residue production (RPR) = 3687.85 Tg total residue production (bentsen) = 3844.16 Tg total residue production (fischer) = 3869.54 Tg total residue production (mean) = 3800.52 Tg **************** 2019 **************** total residue production (RPR) = 3751.94 Tg total residue production (bentsen) = 3857.65 Tg total residue production (fischer) = 3887.58 Tg total residue production (mean) = 3832.39 Tg **************** 2020 **************** total residue production (RPR) = 3842.07 Tg total residue production (bentsen) = 3923.83 Tg total residue production (fischer) = 3945.55 Tg total residue production (mean) = 3903.82 Tg **************** 2021 **************** total residue production (RPR) = 3915.50 Tg total residue production (bentsen) = 3993.06 Tg total residue production (fischer) = 3984.00 Tg total residue production (mean) = 3964.19 Tg
lon | lat | Year | residue production RPR (Mg) | residue production bentsen (Mg) | residue production fischer (Mg) | residue production mean (Mg) | residue production sd (Mg) | |
---|---|---|---|---|---|---|---|---|
0 | -179.75 | -89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
1 | -179.25 | -89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
2 | -178.75 | -89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
3 | -178.25 | -89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
4 | -177.75 | -89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
259195 | 177.75 | 89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259196 | 178.25 | 89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259197 | 178.75 | 89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259198 | 179.25 | 89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259199 | 179.75 | 89.75 | 2015 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
259200 rows × 8 columns
#plot residue production
var = 'residue production mean (Mg)'
for year in [2000,2015]:
res_prod_ds = residue_prod_dict[year][["lat", "lon",var]].set_index(["lat", "lon"]).to_xarray()
res_prod_ds = res_prod_ds.reindex(lat=list(reversed(res_prod_ds.lat)))
res_prod_ds = res_prod_ds.where(res_prod_ds>0)
print(f'{year}: {var} = %.2f' % (res_prod_ds[var].sum()*10**-6) )
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,5000,20000,50000,100000,200000,500000,10**6,3*10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
#fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.EckertIV()})
ax.outline_patch.set_edgecolor('white')
im = res_prod_ds[var].plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'{var} for {year}',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01,fraction=0.0235)
cbar.ax.tick_params(labelsize=28)
plt.show()
2000: residue production mean (Mg) = 2865.42
2015: residue production mean (Mg) = 3710.97
#plot residue production timeseries
res_dict = {}
for method in residue_methods + ['mean']:
res_dict[method] = []
for year in year_list:
for method in residue_methods + ['mean']:
res = residue_prod_dict[year][f'residue production {method} (Mg)'].sum() * 10**-6
res_dict[method].append(res)
colour_list = ['red','blue','green','black']
markersize = 5
linewidth = 3
fig, ax = plt.subplots(figsize=(10,6))
for i, method in enumerate(residue_methods + ['mean']):
ax.plot(year_list,res_dict[method],color=colour_list[i],marker='o',markersize=markersize)
ax.plot(year_list,res_dict[method],color=colour_list[i],linewidth=linewidth,label=method)
ax.set_title('Global residue production',fontsize=20)
plt.tick_params(labelsize=20)
plt.xlabel('year',fontsize=20)
plt.ylabel('Residue production (Tg)',fontsize=20)
plt.legend(loc="lower left",fontsize=14)
plt.ylim(0,4200)
plt.show()
#residue production dataset
crop_residue_prod_ds = pd.concat(list(residue_prod_dict.values())).set_index(["lat", "lon",'Year']).to_xarray()
crop_residue_prod_ds = crop_residue_prod_ds.where(crop_residue_prod_ds>0)
crop_residue_prod_ds
array([-89.75, -89.25, -88.75, ..., 88.75, 89.25, 89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
#export
comp = dict(zlib=True, complevel=9)
encoding = {var: comp for var in crop_residue_prod_ds.data_vars}
crop_residue_prod_ds.to_netcdf(data_out_folder + 'crop_residue_prod.nc',encoding=encoding)
Combine production system, animal number and FAO production data
animal_list = ['cattle','sheep','goat']
commodity_list = ['meat','milk']
#import FAO data for meat and milk production
FAO_anim_prod_df = pd.read_csv(FAO_meat_milk_loc,encoding='latin1')
print(pd.unique(FAO_anim_prod_df['Unit']))
FAO_anim_prod_df = FAO_anim_prod_df[['Area Code (M49)','Area','Item Code (CPC)','Item','Year','Value']]
FAO_anim_prod_df = FAO_anim_prod_df.rename(columns={"Value": "production (Mg)"})
#remove double counting of China
FAO_anim_prod_df = FAO_anim_prod_df[FAO_anim_prod_df['Area Code (M49)'] != 156] #China, mainland
FAO_anim_prod_df = FAO_anim_prod_df[FAO_anim_prod_df['Area Code (M49)'] != 446] #Macao
FAO_anim_prod_df = FAO_anim_prod_df[FAO_anim_prod_df['Area Code (M49)'] != 158] #Taiwan
FAO_anim_prod_df = FAO_anim_prod_df[FAO_anim_prod_df['Area Code (M49)'] != 344] #Hong Kong
#combine Sudan
FAO_anim_prod_df['Area Code (M49)'] = FAO_anim_prod_df['Area Code (M49)'].replace(728, 729)
FAO_anim_prod_df['Area Code (M49)'] = FAO_anim_prod_df['Area Code (M49)'].replace(736, 729)
FAO_anim_prod_df['Area'] = FAO_anim_prod_df['Area'].replace('South Sudan', 'Sudan')
FAO_anim_prod_df['Area'] = FAO_anim_prod_df['Area'].replace('Sudan (former)', 'Sudan')
FAO_anim_prod_df = FAO_anim_prod_df.groupby(['Area Code (M49)','Area','Item Code (CPC)','Item','Year']).sum().reset_index()
FAO_anim_prod_df = FAO_anim_prod_df.rename(columns={'Area Code (M49)':'M49 Code'})
FAO_anim_prod_df = FAO_anim_prod_df.merge(regions_df[['M49 Code','Herrero_group']],how='left',on=['M49 Code'])
item_dict = {21512 : ['cattle', 'meat'],
21151 : ['cattle', 'meat'],
21111.01 : ['cattle', 'meat'],
2211 : ['cattle', 'milk'],
21156 : ['goat', 'meat'],
21515 : ['goat', 'meat'],
21116 : ['goat', 'meat'],
2292 : ['goat', 'milk'],
21155 : ['sheep', 'meat'],
21115 : ['sheep', 'meat'],
21514 : ['sheep', 'meat'],
2291 : ['sheep', 'milk']}
FAO_anim_prod_df['animal'] = FAO_anim_prod_df['Item Code (CPC)']
FAO_anim_prod_df['animal'] = FAO_anim_prod_df['animal'].map({k: item_dict[k][0] for k in item_dict})
FAO_anim_prod_df['commodity'] = FAO_anim_prod_df['Item Code (CPC)']
FAO_anim_prod_df['commodity'] = FAO_anim_prod_df['commodity'].map({k: item_dict[k][1] for k in item_dict})
FAO_anim_prod_df = FAO_anim_prod_df[['M49 Code','Area','Herrero_group','animal','commodity','Year','production (Mg)']].groupby(['M49 Code','Area','Herrero_group','Year','animal','commodity']).sum().reset_index()
protein_prod = []
for index, row in FAO_anim_prod_df.iterrows():
protein_prod.append(protein_dict[row['animal']][row['commodity']] * row['production (Mg)'])
FAO_anim_prod_df['protein (Mg)'] = protein_prod
FAO_anim_prod_df
FAO_anim_prod_df.loc[(FAO_anim_prod_df['Area']=='Sudan')]
['tonnes']
M49 Code | Area | Herrero_group | Year | animal | commodity | production (Mg) | protein (Mg) | |
---|---|---|---|---|---|---|---|---|
20511 | 729 | Sudan | MNA | 1995 | cattle | meat | 267750.00 | 36949.50000 |
20512 | 729 | Sudan | MNA | 1995 | cattle | milk | 2760000.00 | 91080.00000 |
20513 | 729 | Sudan | MNA | 1995 | goat | meat | 137299.00 | 18809.96300 |
20514 | 729 | Sudan | MNA | 1995 | goat | milk | 1239000.00 | 40887.00000 |
20515 | 729 | Sudan | MNA | 1995 | sheep | meat | 167585.00 | 22959.14500 |
20516 | 729 | Sudan | MNA | 1995 | sheep | milk | 388000.00 | 12804.00000 |
20517 | 729 | Sudan | MNA | 1996 | cattle | meat | 271405.00 | 37453.89000 |
20518 | 729 | Sudan | MNA | 1996 | cattle | milk | 2880000.00 | 95040.00000 |
20519 | 729 | Sudan | MNA | 1996 | goat | meat | 140415.00 | 19236.85500 |
20520 | 729 | Sudan | MNA | 1996 | goat | milk | 1064000.00 | 35112.00000 |
20521 | 729 | Sudan | MNA | 1996 | sheep | meat | 174791.00 | 23946.36700 |
20522 | 729 | Sudan | MNA | 1996 | sheep | milk | 410000.00 | 13530.00000 |
20523 | 729 | Sudan | MNA | 1997 | cattle | meat | 296000.00 | 40848.00000 |
20524 | 729 | Sudan | MNA | 1997 | cattle | milk | 2928000.00 | 96624.00000 |
20525 | 729 | Sudan | MNA | 1997 | goat | meat | 152031.00 | 20828.24700 |
20526 | 729 | Sudan | MNA | 1997 | goat | milk | 1026000.00 | 33858.00000 |
20527 | 729 | Sudan | MNA | 1997 | sheep | meat | 208750.00 | 28598.75000 |
20528 | 729 | Sudan | MNA | 1997 | sheep | milk | 415000.00 | 13695.00000 |
20529 | 729 | Sudan | MNA | 1998 | cattle | meat | 313000.00 | 43194.00000 |
20530 | 729 | Sudan | MNA | 1998 | cattle | milk | 3000000.00 | 99000.00000 |
20531 | 729 | Sudan | MNA | 1998 | goat | meat | 156600.00 | 21454.20000 |
20532 | 729 | Sudan | MNA | 1998 | goat | milk | 1151000.00 | 37983.00000 |
20533 | 729 | Sudan | MNA | 1998 | sheep | meat | 272093.00 | 37276.74100 |
20534 | 729 | Sudan | MNA | 1998 | sheep | milk | 436000.00 | 14388.00000 |
20535 | 729 | Sudan | MNA | 1999 | cattle | meat | 326200.00 | 45015.60000 |
20536 | 729 | Sudan | MNA | 1999 | cattle | milk | 3500000.00 | 115500.00000 |
20537 | 729 | Sudan | MNA | 1999 | goat | meat | 152080.00 | 20834.96000 |
20538 | 729 | Sudan | MNA | 1999 | goat | milk | 1197000.00 | 39501.00000 |
20539 | 729 | Sudan | MNA | 1999 | sheep | meat | 323100.00 | 44264.70000 |
20540 | 729 | Sudan | MNA | 1999 | sheep | milk | 461000.00 | 15213.00000 |
20541 | 729 | Sudan | MNA | 2000 | cattle | meat | 348000.00 | 48024.00000 |
20542 | 729 | Sudan | MNA | 2000 | cattle | milk | 4000000.00 | 132000.00000 |
20543 | 729 | Sudan | MNA | 2000 | goat | meat | 158960.00 | 21777.52000 |
20544 | 729 | Sudan | MNA | 2000 | goat | milk | 1245000.00 | 41085.00000 |
20545 | 729 | Sudan | MNA | 2000 | sheep | meat | 342400.00 | 46908.80000 |
20546 | 729 | Sudan | MNA | 2000 | sheep | milk | 462000.00 | 15246.00000 |
20547 | 729 | Sudan | MNA | 2001 | cattle | meat | 373600.00 | 51556.80000 |
20548 | 729 | Sudan | MNA | 2001 | cattle | milk | 4500000.00 | 148500.00000 |
20549 | 729 | Sudan | MNA | 2001 | goat | meat | 170880.00 | 23410.56000 |
20550 | 729 | Sudan | MNA | 2001 | goat | milk | 1250000.00 | 41250.00000 |
20551 | 729 | Sudan | MNA | 2001 | sheep | meat | 353700.00 | 48456.90000 |
20552 | 729 | Sudan | MNA | 2001 | sheep | milk | 463000.00 | 15279.00000 |
20553 | 729 | Sudan | MNA | 2002 | cattle | meat | 378600.00 | 52246.80000 |
20554 | 729 | Sudan | MNA | 2002 | cattle | milk | 5000000.00 | 165000.00000 |
20555 | 729 | Sudan | MNA | 2002 | goat | meat | 183720.00 | 25169.64000 |
20556 | 729 | Sudan | MNA | 2002 | goat | milk | 1295000.00 | 42735.00000 |
20557 | 729 | Sudan | MNA | 2002 | sheep | meat | 362800.00 | 49703.60000 |
20558 | 729 | Sudan | MNA | 2002 | sheep | milk | 464000.00 | 15312.00000 |
20559 | 729 | Sudan | MNA | 2003 | cattle | meat | 396000.00 | 54648.00000 |
20560 | 729 | Sudan | MNA | 2003 | cattle | milk | 5494000.00 | 181302.00000 |
20561 | 729 | Sudan | MNA | 2003 | goat | meat | 185520.00 | 25416.24000 |
20562 | 729 | Sudan | MNA | 2003 | goat | milk | 1384000.00 | 45672.00000 |
20563 | 729 | Sudan | MNA | 2003 | sheep | meat | 368623.00 | 50501.35100 |
20564 | 729 | Sudan | MNA | 2003 | sheep | milk | 464000.00 | 15312.00000 |
20565 | 729 | Sudan | MNA | 2004 | cattle | meat | 396000.00 | 54648.00000 |
20566 | 729 | Sudan | MNA | 2004 | cattle | milk | 5384000.00 | 177672.00000 |
20567 | 729 | Sudan | MNA | 2004 | goat | meat | 187016.00 | 25621.19200 |
20568 | 729 | Sudan | MNA | 2004 | goat | milk | 1500000.00 | 49500.00000 |
20569 | 729 | Sudan | MNA | 2004 | sheep | meat | 372522.00 | 51035.51400 |
20570 | 729 | Sudan | MNA | 2004 | sheep | milk | 475000.00 | 15675.00000 |
20571 | 729 | Sudan | MNA | 2005 | cattle | meat | 407000.00 | 56166.00000 |
20572 | 729 | Sudan | MNA | 2005 | cattle | milk | 5480000.00 | 180840.00000 |
20573 | 729 | Sudan | MNA | 2005 | goat | meat | 235656.00 | 32284.87200 |
20574 | 729 | Sudan | MNA | 2005 | goat | milk | 1519000.00 | 50127.00000 |
20575 | 729 | Sudan | MNA | 2005 | sheep | meat | 374508.00 | 51307.59600 |
20576 | 729 | Sudan | MNA | 2005 | sheep | milk | 487000.00 | 16071.00000 |
20577 | 729 | Sudan | MNA | 2006 | cattle | meat | 408000.00 | 56304.00000 |
20578 | 729 | Sudan | MNA | 2006 | cattle | milk | 5274000.00 | 174042.00000 |
20579 | 729 | Sudan | MNA | 2006 | goat | meat | 201571.00 | 27615.22700 |
20580 | 729 | Sudan | MNA | 2006 | goat | milk | 1437000.00 | 47421.00000 |
20581 | 729 | Sudan | MNA | 2006 | sheep | meat | 412075.00 | 56454.27500 |
20582 | 729 | Sudan | MNA | 2006 | sheep | milk | 492000.00 | 16236.00000 |
20583 | 729 | Sudan | MNA | 2007 | cattle | meat | 396000.00 | 54648.00000 |
20584 | 729 | Sudan | MNA | 2007 | cattle | milk | 5292000.00 | 174636.00000 |
20585 | 729 | Sudan | MNA | 2007 | goat | meat | 204400.00 | 28002.80000 |
20586 | 729 | Sudan | MNA | 2007 | goat | milk | 1456000.00 | 48048.00000 |
20587 | 729 | Sudan | MNA | 2007 | sheep | meat | 415295.00 | 56895.41500 |
20588 | 729 | Sudan | MNA | 2007 | sheep | milk | 498000.00 | 16434.00000 |
20589 | 729 | Sudan | MNA | 2008 | cattle | meat | 396000.00 | 54648.00000 |
20590 | 729 | Sudan | MNA | 2008 | cattle | milk | 5329000.00 | 175857.00000 |
20591 | 729 | Sudan | MNA | 2008 | goat | meat | 207760.00 | 28463.12000 |
20592 | 729 | Sudan | MNA | 2008 | goat | milk | 1474000.00 | 48642.00000 |
20593 | 729 | Sudan | MNA | 2008 | sheep | meat | 450299.00 | 61690.96300 |
20594 | 729 | Sudan | MNA | 2008 | sheep | milk | 503000.00 | 16599.00000 |
20595 | 729 | Sudan | MNA | 2009 | cattle | meat | 397200.00 | 54813.60000 |
20596 | 729 | Sudan | MNA | 2009 | cattle | milk | 5347000.00 | 176451.00000 |
20597 | 729 | Sudan | MNA | 2009 | goat | meat | 211400.00 | 28961.80000 |
20598 | 729 | Sudan | MNA | 2009 | goat | milk | 1493000.00 | 49269.00000 |
20599 | 729 | Sudan | MNA | 2009 | sheep | meat | 424515.00 | 58158.55500 |
20600 | 729 | Sudan | MNA | 2009 | sheep | milk | 508000.00 | 16764.00000 |
20601 | 729 | Sudan | MNA | 2010 | cattle | meat | 399400.00 | 55117.20000 |
20602 | 729 | Sudan | MNA | 2010 | cattle | milk | 5373000.00 | 177309.00000 |
20603 | 729 | Sudan | MNA | 2010 | goat | meat | 214200.00 | 29345.40000 |
20604 | 729 | Sudan | MNA | 2010 | goat | milk | 1512000.00 | 49896.00000 |
20605 | 729 | Sudan | MNA | 2010 | sheep | meat | 438358.00 | 60055.04600 |
20606 | 729 | Sudan | MNA | 2010 | sheep | milk | 527000.00 | 17391.00000 |
20607 | 729 | Sudan | MNA | 2011 | cattle | meat | 401800.00 | 55448.40000 |
20608 | 729 | Sudan | MNA | 2011 | cattle | milk | 5400000.00 | 178200.00000 |
20609 | 729 | Sudan | MNA | 2011 | goat | meat | 217701.00 | 29825.03700 |
20610 | 729 | Sudan | MNA | 2011 | goat | milk | 1522000.00 | 50226.00000 |
20611 | 729 | Sudan | MNA | 2011 | sheep | meat | 445713.00 | 61062.68100 |
20612 | 729 | Sudan | MNA | 2011 | sheep | milk | 390000.00 | 12870.00000 |
20613 | 729 | Sudan | MNA | 2012 | cattle | meat | 509821.65 | 70355.38770 |
20614 | 729 | Sudan | MNA | 2012 | cattle | milk | 5373000.00 | 177309.00000 |
20615 | 729 | Sudan | MNA | 2012 | goat | meat | 164746.03 | 22570.20611 |
20616 | 729 | Sudan | MNA | 2012 | goat | milk | 1538000.00 | 50754.00000 |
20617 | 729 | Sudan | MNA | 2012 | sheep | meat | 338022.78 | 46309.12086 |
20618 | 729 | Sudan | MNA | 2012 | sheep | milk | 534000.00 | 17622.00000 |
20619 | 729 | Sudan | MNA | 2013 | cattle | meat | 513867.49 | 70913.71362 |
20620 | 729 | Sudan | MNA | 2013 | cattle | milk | 5393000.00 | 177969.00000 |
20621 | 729 | Sudan | MNA | 2013 | goat | meat | 167643.41 | 22967.14717 |
20622 | 729 | Sudan | MNA | 2013 | goat | milk | 1560000.00 | 51480.00000 |
20623 | 729 | Sudan | MNA | 2013 | sheep | meat | 338876.78 | 46426.11886 |
20624 | 729 | Sudan | MNA | 2013 | sheep | milk | 543000.00 | 17919.00000 |
20625 | 729 | Sudan | MNA | 2014 | cattle | meat | 526558.25 | 72665.03850 |
20626 | 729 | Sudan | MNA | 2014 | cattle | milk | 5423000.00 | 178959.00000 |
20627 | 729 | Sudan | MNA | 2014 | goat | meat | 166750.85 | 22844.86645 |
20628 | 729 | Sudan | MNA | 2014 | goat | milk | 1576000.00 | 52008.00000 |
20629 | 729 | Sudan | MNA | 2014 | sheep | meat | 341685.13 | 46810.86281 |
20630 | 729 | Sudan | MNA | 2014 | sheep | milk | 552000.00 | 18216.00000 |
20631 | 729 | Sudan | MNA | 2015 | cattle | meat | 532075.13 | 73426.36794 |
20632 | 729 | Sudan | MNA | 2015 | cattle | milk | 5474000.00 | 180642.00000 |
20633 | 729 | Sudan | MNA | 2015 | goat | meat | 168229.37 | 23047.42369 |
20634 | 729 | Sudan | MNA | 2015 | goat | milk | 1590000.00 | 52470.00000 |
20635 | 729 | Sudan | MNA | 2015 | sheep | meat | 342408.53 | 46909.96861 |
20636 | 729 | Sudan | MNA | 2015 | sheep | milk | 551599.94 | 18202.79802 |
20637 | 729 | Sudan | MNA | 2016 | cattle | meat | 547678.22 | 75579.59436 |
20638 | 729 | Sudan | MNA | 2016 | cattle | milk | 5518000.00 | 182094.00000 |
20639 | 729 | Sudan | MNA | 2016 | goat | meat | 172197.20 | 23591.01640 |
20640 | 729 | Sudan | MNA | 2016 | goat | milk | 1603000.00 | 52899.00000 |
20641 | 729 | Sudan | MNA | 2016 | sheep | meat | 351939.71 | 48215.74027 |
20642 | 729 | Sudan | MNA | 2016 | sheep | milk | 556256.70 | 18356.47110 |
20643 | 729 | Sudan | MNA | 2017 | cattle | meat | 582320.56 | 80360.23728 |
20644 | 729 | Sudan | MNA | 2017 | cattle | milk | 5559000.00 | 183447.00000 |
20645 | 729 | Sudan | MNA | 2017 | goat | meat | 181295.96 | 24837.54652 |
20646 | 729 | Sudan | MNA | 2017 | goat | milk | 1611000.00 | 53163.00000 |
20647 | 729 | Sudan | MNA | 2017 | sheep | meat | 353550.86 | 48436.46782 |
20648 | 729 | Sudan | MNA | 2017 | sheep | milk | 552233.10 | 18223.69230 |
20649 | 729 | Sudan | MNA | 2018 | cattle | meat | 613179.55 | 84618.77790 |
20650 | 729 | Sudan | MNA | 2018 | cattle | milk | 5334085.00 | 176024.80500 |
20651 | 729 | Sudan | MNA | 2018 | goat | meat | 186115.07 | 25497.76459 |
20652 | 729 | Sudan | MNA | 2018 | goat | milk | 1680173.77 | 55445.73441 |
20653 | 729 | Sudan | MNA | 2018 | sheep | meat | 355381.74 | 48687.29838 |
20654 | 729 | Sudan | MNA | 2018 | sheep | milk | 548485.70 | 18100.02810 |
20655 | 729 | Sudan | MNA | 2019 | cattle | meat | 630140.31 | 86959.36278 |
20656 | 729 | Sudan | MNA | 2019 | cattle | milk | 5404460.00 | 178347.18000 |
20657 | 729 | Sudan | MNA | 2019 | goat | meat | 187914.38 | 25744.27006 |
20658 | 729 | Sudan | MNA | 2019 | goat | milk | 1625111.11 | 53628.66663 |
20659 | 729 | Sudan | MNA | 2019 | sheep | meat | 359352.03 | 49231.22811 |
20660 | 729 | Sudan | MNA | 2019 | sheep | milk | 551294.80 | 18192.72840 |
20661 | 729 | Sudan | MNA | 2020 | cattle | meat | 621639.50 | 85786.25100 |
20662 | 729 | Sudan | MNA | 2020 | cattle | milk | 5463879.41 | 180308.02053 |
20663 | 729 | Sudan | MNA | 2020 | goat | meat | 181716.31 | 24895.13447 |
20664 | 729 | Sudan | MNA | 2020 | goat | milk | 1632190.72 | 53862.29376 |
20665 | 729 | Sudan | MNA | 2020 | sheep | meat | 352368.38 | 48274.46806 |
20666 | 729 | Sudan | MNA | 2020 | sheep | milk | 553693.09 | 18271.87197 |
20667 | 729 | Sudan | MNA | 2021 | cattle | meat | 615819.36 | 84983.07168 |
20668 | 729 | Sudan | MNA | 2021 | cattle | milk | 6061333.92 | 200024.01936 |
20669 | 729 | Sudan | MNA | 2021 | goat | meat | 177076.54 | 24259.48598 |
20670 | 729 | Sudan | MNA | 2021 | goat | milk | 1626628.15 | 53678.72895 |
20671 | 729 | Sudan | MNA | 2021 | sheep | meat | 358524.55 | 49117.86335 |
20672 | 729 | Sudan | MNA | 2021 | sheep | milk | 543985.96 | 17951.53668 |
#calculate for each grid cell the fraction of the country's total animal number
anim_frac_df = country_grid_df.copy()
#anim_frac_df['M49 Code'] = anim_frac_df['ISO3 Code']
#anim_frac_df['M49 Code'] = anim_frac_df['M49 Code'].map(ISO3_M49_dict)
for animal in animal_list:
animal_no_df = anim_no_ds_dict[animal].to_dataframe(f'no. {animal}').reset_index()
anim_frac_df = anim_frac_df.merge(animal_no_df,on=['lon','lat'])
anim_frac_df['M49 Code'] = anim_frac_df['M49 Code'].fillna(-1)
#animals per country
animal_no_country_df = anim_frac_df.groupby('M49 Code').sum().reset_index()
animal_no_country_df = animal_no_country_df[['M49 Code',f'no. {animal}']]
#animal_no_country_dict
animal_no_country_dict = dict(zip(animal_no_country_df['M49 Code'], animal_no_country_df[f'no. {animal}']))
animal_no_country_dict[-1] = 0
def func(m49,anim_no):
return anim_no/(animal_no_country_dict[m49]+10**(-10))
#determine animal fraction in each grid cell
anim_frac_df[f'{animal} fraction'] = list(map(func, anim_frac_df['M49 Code'], anim_frac_df[f'no. {animal}']))
anim_frac_df = anim_frac_df.drop([f'no. {animal}'], axis=1)
"""animal_frac_list = []
for index, row in anim_frac_df.iterrows():
m49_code = row['M49 Code']
if isNaN(m49_code):
animal_frac_list.append(0)
else:
tot = animal_no_country_df.loc[animal_no_country_df['M49 Code']==m49_code][f'no. {animal}'].values[0]
#print(row['no. cattle'])
animal_no = row[f'no. {animal}']
if np.isnan(animal_no):
animal_no = 0
animal_frac_list.append(animal_no/tot)
anim_frac_df[f'{animal} fraction'] = animal_frac_list"""
#add production system information
livestock_sys_df = livestock_sys_ds2.to_dataframe('production system').reset_index()
livestock_sys_df['production system'] = livestock_sys_df['production system'].map(conversion_dict2_inv)
anim_frac_df = pd.merge(anim_frac_df,livestock_sys_df,on=['lat','lon'])
anim_frac_df
anim_frac_df.loc[anim_frac_df['ISO3 Code']=='SDN']
lon | lat | ISO3 Code | M49 Code | cattle fraction | sheep fraction | goat fraction | production system | |
---|---|---|---|---|---|---|---|---|
98330 | 25.25 | 21.75 | SDN | 729.0 | 0.000041 | 0.000139 | 0.000124 | LGA |
98331 | 25.75 | 21.75 | SDN | 729.0 | 0.000039 | 0.000139 | 0.000033 | LGA |
98332 | 26.25 | 21.75 | SDN | 729.0 | 0.000035 | 0.000139 | 0.000032 | LGA |
98333 | 26.75 | 21.75 | SDN | 729.0 | 0.000036 | 0.000139 | 0.000032 | LGA |
98334 | 27.25 | 21.75 | SDN | 729.0 | 0.000045 | 0.000139 | 0.000027 | LGA |
... | ... | ... | ... | ... | ... | ... | ... | ... |
123547 | 33.75 | 4.25 | SDN | 729.0 | 0.002336 | 0.001633 | 0.002765 | LGA |
124261 | 30.75 | 3.75 | SDN | 729.0 | 0.002722 | 0.000448 | 0.001314 | MH |
124262 | 31.25 | 3.75 | SDN | 729.0 | 0.004175 | 0.001607 | 0.005603 | MH |
124263 | 31.75 | 3.75 | SDN | 729.0 | 0.002852 | 0.002113 | 0.006196 | MH |
124264 | 32.25 | 3.75 | SDN | 729.0 | 0.000809 | 0.001567 | 0.003283 | LGH |
833 rows × 8 columns
#import data linking animal-type, commodity-type, region and production system to the percentage of crop residues in the diet
residue_perc_dict = {}
for author in FCR_res_list:
residue_perc_dict[author] = pd.read_csv(crop_res_perc_stem + f'{author}.csv')
#residue_perc_df.loc[residue_perc_df['Herrero_group']=='SAS']
#import data linking animal-type, commodity-type, region and production system to the feed conversion ratio
feed_conv_ratio_dict = {}
for author in FCR_res_list:
feed_conv_ratio_dict[author] = pd.read_csv(FCR_stem + f'{author}.csv')
#feed_conv_ratio_dict['herrero'].loc[feed_conv_ratio_dict['herrero']['Herrero_group']=='SAS']
# for each animal type, commodity and year calculate protein production in each grid cell
# convert protein production into residue usage
residue_feed_dict = {}
for year in year_list:
dum_dict = {}
for animal in animal_list:
dum_dict2 = {}
for commodity in commodity_list:
protein_grid_df = pd.merge(anim_frac_df,FAO_anim_prod_df.loc[(FAO_anim_prod_df['Year']==year) & (FAO_anim_prod_df['animal']==animal) & (FAO_anim_prod_df['commodity']==commodity)],on=['M49 Code'],how='left')
protein_grid_df['protein prod (Mg)'] = protein_grid_df[f'{animal} fraction'] * protein_grid_df['protein (Mg)']
protein_grid_df['Year'] = year
protein_grid_df = protein_grid_df.drop(columns=['cattle fraction','goat fraction','sheep fraction','production (Mg)','protein (Mg)'])
for author in FCR_res_list:
protein_grid_df = protein_grid_df.merge(feed_conv_ratio_dict[author],how='left',on=['animal','commodity','production system','Herrero_group'])
protein_grid_df = protein_grid_df.merge(residue_perc_dict[author],how='left',on=['animal','commodity','production system','Herrero_group'])
protein_grid_df = protein_grid_df.rename(columns={'FCR (kg-protein/kg-feed-DW)' : f'FCR (kg-protein/kg-feed-DW) {author}','residue feed (%)' : f'residue feed (%) {author}'})
protein_grid_df[f'residue feed usage (Mg) {author}'] = (protein_grid_df['protein prod (Mg)'] / protein_grid_df[f'FCR (kg-protein/kg-feed-DW) {author}']) * protein_grid_df[f'residue feed (%) {author}']/100
dum_dict2[commodity] = protein_grid_df
#print(animal,commodity)
#print(dum_dict2[2015].shape)
#print('protein production = %.0f' % (dum_dict2[2015]['protein prod (Mg)'].sum()))
dum_dict[animal] = dum_dict2
residue_feed_dict[year] = dum_dict
print(residue_feed_dict[2015]['cattle']['meat'].shape)
residue_feed_dict[2015]['cattle']['meat']
(259200, 20)
lon | lat | ISO3 Code | M49 Code | production system | Area | Herrero_group | Year | animal | commodity | protein prod (Mg) | FCR (kg-protein/kg-feed-DW) herrero | residue feed (%) herrero | residue feed usage (Mg) herrero | FCR (kg-protein/kg-feed-DW) mekonnen | residue feed (%) mekonnen | residue feed usage (Mg) mekonnen | FCR (kg-protein/kg-feed-DW) mottet | residue feed (%) mottet | residue feed usage (Mg) mottet | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | -179.75 | 89.75 | NaN | -1.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
1 | -179.25 | 89.75 | NaN | -1.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
2 | -178.75 | 89.75 | NaN | -1.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
3 | -178.25 | 89.75 | NaN | -1.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
4 | -177.75 | 89.75 | NaN | -1.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
259195 | 177.75 | -89.75 | ATA | 10.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
259196 | 178.25 | -89.75 | ATA | 10.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
259197 | 178.75 | -89.75 | ATA | 10.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
259198 | 179.25 | -89.75 | ATA | 10.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
259199 | 179.75 | -89.75 | ATA | 10.0 | NaN | NaN | NaN | 2015 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
259200 rows × 20 columns
#combine animal and commodity types to get total residue usage for feed in each grid cell
residue_feed_dict2 = {}
for year in year_list:
residue_feed_dict2[year] = residue_feed_dict[year]['cattle']['meat'][['lon','lat','M49 Code','production system','Herrero_group','Year']].copy()
for author in FCR_res_list:
residue_feed_dict2[year][f'residue feed usage (Mg) {author}'] = 0
for animal in animal_list:
for commodity in commodity_list:
residue_feed_dict2[year][f'residue feed usage (Mg) {author}'] += residue_feed_dict[year][animal][commodity][f'residue feed usage (Mg) {author}'].fillna(0)
residue_feed_dict2[2014]
residue_feed_dict2[2015]['residue feed usage (Mg) mekonnen'].sum()
#residue_feed_ds = residue_feed_dict2.values()[]
805966373.5274622
#print out crop residue usage for feed by region
year = 2015
region_list = pd.unique(regions_df['Herrero_group'])
print(region_list)
for region in region_list:
for author in FCR_res_list:
#res = 0
#for animal in animal_list:
# for commodity in commodity_list:
# x = residue_feed_dict[year][animal][commodity]
# res += x.loc[x['Herrero_group']==region][f'residue feed usage (Mg) {author}'].sum()
#print(f'crop residue use as feed in {region} ({author}) = %.1f Tg' % (res*10**-6))
res2 = residue_feed_dict2[year].loc[residue_feed_dict2[year]['Herrero_group']==region][f'residue feed usage (Mg) {author}'].sum()
print(f'{author} crop residue use as feed in {region} = %.1f Tg' % (res2*10**-6))
['SAS' 'EUR' 'MNA' 'SSA' 'LAM' 'CIS' 'OCE' 'NAM' 'SEA' 'EAS'] herrero crop residue use as feed in SAS = 581.3 Tg mekonnen crop residue use as feed in SAS = 326.7 Tg mottet crop residue use as feed in SAS = 502.4 Tg herrero crop residue use as feed in EUR = 0.0 Tg mekonnen crop residue use as feed in EUR = 0.0 Tg mottet crop residue use as feed in EUR = 16.5 Tg herrero crop residue use as feed in MNA = 24.6 Tg mekonnen crop residue use as feed in MNA = 31.5 Tg mottet crop residue use as feed in MNA = 129.4 Tg herrero crop residue use as feed in SSA = 328.9 Tg mekonnen crop residue use as feed in SSA = 111.6 Tg mottet crop residue use as feed in SSA = 76.7 Tg herrero crop residue use as feed in LAM = 75.7 Tg mekonnen crop residue use as feed in LAM = 70.3 Tg mottet crop residue use as feed in LAM = 85.0 Tg herrero crop residue use as feed in CIS = 23.0 Tg mekonnen crop residue use as feed in CIS = 48.9 Tg mottet crop residue use as feed in CIS = 14.1 Tg herrero crop residue use as feed in OCE = 0.3 Tg mekonnen crop residue use as feed in OCE = 0.3 Tg mottet crop residue use as feed in OCE = 0.3 Tg herrero crop residue use as feed in NAM = 11.1 Tg mekonnen crop residue use as feed in NAM = 21.7 Tg mottet crop residue use as feed in NAM = 0.0 Tg herrero crop residue use as feed in SEA = 68.5 Tg mekonnen crop residue use as feed in SEA = 109.5 Tg mottet crop residue use as feed in SEA = 41.2 Tg herrero crop residue use as feed in EAS = 107.3 Tg mekonnen crop residue use as feed in EAS = 85.0 Tg mottet crop residue use as feed in EAS = 213.4 Tg
#plot residue usage as feed
author = 'herrero'
for year in [2000,2015]:
res_feed_ds = residue_feed_dict2[year][["lat", "lon",f'residue feed usage (Mg) {author}']].set_index(["lat", "lon"]).to_xarray()
res_feed_ds = res_feed_ds.reindex(lat=list(reversed(res_feed_ds.lat)))
res_feed_ds = res_feed_ds.where(res_feed_ds>0)
print(f'{year}: residues used as feed = %.2f' % (res_feed_ds[f'residue feed usage (Mg) {author}'].sum()*10**-6) )
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,5000,20000,50000,100000,200000,500000,10**6,3*10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = res_feed_ds[f'residue feed usage (Mg) {author}'].plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'Residue feed usage (Mg) for {year}',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
2000: residues used as feed = 708.89
2015: residues used as feed = 1222.38
#construct dataset
var_list = []
for author in FCR_res_list:
var_list.append(f'residue feed usage (Mg) {author}')
crop_residue_feed_ds = pd.concat(list(residue_feed_dict2.values())).set_index(["lat", "lon",'Year'])[var_list].to_xarray()
crop_residue_feed_ds = crop_residue_feed_ds.where(crop_residue_feed_ds>0)
for author in FCR_res_list:
print(f'2015, {author}: residues used as feed = %.2f Tg' % (crop_residue_feed_ds.sel(Year=2015)[f'residue feed usage (Mg) {author}'].sum()*10**-6) )
crop_residue_feed_ds
2015, herrero: residues used as feed = 1222.38 Tg 2015, mekonnen: residues used as feed = 805.97 Tg 2015, mottet: residues used as feed = 1082.17 Tg
array([-89.75, -89.25, -88.75, ..., 88.75, 89.25, 89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
#plot
res_dict = {}
for method in FCR_res_list:
res_dict[method] = []
for year in year_list:
for method in FCR_res_list:
res = crop_residue_feed_ds[f'residue feed usage (Mg) {method}'].sel(Year=year).sum().values * 10**-6
res_dict[method].append(res)
colour_list = ['red','blue','green','black']
markersize = 5
linewidth = 3
fig, ax = plt.subplots(figsize=(10,6))
for i, method in enumerate(FCR_res_list):
ax.plot(year_list,res_dict[method],color=colour_list[i],marker='o',markersize=markersize)
ax.plot(year_list,res_dict[method],color=colour_list[i],linewidth=linewidth,label=method)
ax.set_title('Global feed usage',fontsize=20)
plt.tick_params(labelsize=20)
plt.xlabel('year',fontsize=20)
plt.ylabel('Feed usage (Tg)',fontsize=20)
plt.legend(loc="lower left",fontsize=14)
plt.ylim(0,1500)
plt.show()
#straw used as bedding in kg/day from Scarlat 2010 (numbers are for Europe)
straw_bedding_req_dict = {'cattle' : 1.5 * 0.25,
'sheep' : 0.1,
'goat' : 0.1,
'horse' : 1.5 + 420/(365*0.9), #include horse fodder at 420 kg fresh matter per horse per year
'pig' : 0.5/8}
#staw usage for bedding in Mg/year
bedding_ds_dict = {}
for animal in animal_list2:
bedding_ds_dict[animal] = anim_no_ds_dict[animal] * straw_bedding_req_dict[animal] * 365 * 10**-3
print(f'{animal}: straw for bedding = %.2f Tg' % (bedding_ds_dict[animal].sum()*10**-6) )
bedding_ds_dict
bedding_dA = bedding_ds_dict['cattle'].fillna(0)
for animal in animal_list2:
if animal != 'cattle':
bedding_dA += bedding_ds_dict[animal].fillna(0)
print(f'Total straw for bedding = %.2f Tg' % (bedding_dA.sum()*10**-6) )
bedding_dA = bedding_dA.where(bedding_dA>0)
bedding_dA
bedding_list = []
for year in year_list:
bedding_list.append(bedding_dA)
bedding_ds = xr.concat(bedding_list, pd.Index(year_list, name='Year'))
bedding_ds = bedding_ds.to_dataset(name='bedding (Mg)')
bedding_ds
cattle: straw for bedding = 199.46 Tg goat: straw for bedding = 34.94 Tg sheep: straw for bedding = 42.07 Tg horse: straw for bedding = 62.87 Tg pig: straw for bedding = 22.26 Tg Total straw for bedding = 361.60 Tg
array([ 89.75, 89.25, 88.75, ..., -88.75, -89.25, -89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,2000,5000,20000,50000,100000,200000,500000,1*10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = bedding_ds['bedding (Mg)'].sel(Year=2015).plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'Residue for bedding (Mg)',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
#add together feed and bedding
crop_residue_animal_ds = crop_residue_feed_ds.copy().fillna(0)
for var in crop_residue_animal_ds.keys():
crop_residue_animal_ds[var] += bedding_ds.reindex(lat=list(reversed(bedding_ds.lat)))['bedding (Mg)'].fillna(0)
#plot timeseries
res_dict = {}
for method in FCR_res_list:
res_dict[method] = []
for year in year_list:
for method in FCR_res_list:
res = crop_residue_animal_ds[f'residue feed usage (Mg) {method}'].sel(Year=year).sum().values * 10**-6
res_dict[method].append(res)
colour_list = ['red','blue','green','black']
markersize = 5
linewidth = 3
fig, ax = plt.subplots(figsize=(10,6))
for i, method in enumerate(FCR_res_list):
ax.plot(year_list,res_dict[method],color=colour_list[i],marker='o',markersize=markersize)
ax.plot(year_list,res_dict[method],color=colour_list[i],linewidth=linewidth,label=method)
ax.set_title('Global animal residue usage',fontsize=20)
plt.tick_params(labelsize=20)
plt.xlabel('year',fontsize=20)
plt.ylabel('Animal residue usage (Tg)',fontsize=20)
plt.legend(loc="lower left",fontsize=14)
plt.ylim(0,2000)
plt.show()
#export
comp = dict(zlib=True, complevel=9)
encoding = {var: comp for var in crop_residue_animal_ds.data_vars}
crop_residue_animal_ds.fillna(0).where(crop_residue_prod_ds['residue production mean (Mg)'] > 0).to_netcdf(data_out_folder + 'crop_residue_animal_usage.nc',encoding=encoding)
#pd.read_hdf('/Users/smerald-a/ldndc/resources/fire/GFED4.1s_2015.hdf5','emission')
#fire_ds = xr.open_dataset('/Users/smerald-a/ldndc/resources/fire/GFED4.1s_2015.hdf5')
dA_list = []
for year in year_list:
if year >=2017:
beta_label = '_beta'
else:
beta_label = ''
filename = GFED4s_stem + f"{year}{beta_label}.hdf5"
f = h5py.File(filename, 'r')
key1 = list(f.keys())
#print(key1)
lat_arr = np.array(f['lat'])
lat_list = lat_arr[:,0]
lon_arr = np.array(f['lon'])
lon_list = lon_arr[0,:]
month_list = list(f['emissions'].keys())
#print(month_list)
area_arr = np.array(f['ancill']['grid_cell_area'])
DM_year_arr = np.zeros(area_arr.shape)
#print(DM_year_arr)
for month in month_list:
DM_month_arr = np.array(f['emissions'][month]['DM'])
#print(DM_month_arr)
partition_arr = np.array(f['emissions'][month]['partitioning']['DM_AGRI'])
#print(partition_arr)
#multiply DM burned (kg/m2) by agricultural fraction and grid cell area (m2)
DM_ag_arr = DM_month_arr * partition_arr * area_arr
DM_year_arr += DM_ag_arr
#print(f'{year}: agricultural dry matter burned = %.2f Tg' % (DM_year_arr.sum()*10**-9) )
dA = xr.DataArray(DM_year_arr * 10**-3,
coords={'lat': lat_list,'lon': lon_list},
dims=["lat", "lon"])
dA2 = regridder_sum(dA,1/4,2)
dA_list.append(dA2)
print(f'{year}: agricultural dry matter burned = %.2f Tg' % (dA2.sum()*10**-6) )
GFED4s_ds = xr.concat(dA_list, pd.Index(year_list, name='Year'))
GFED4s_ds = GFED4s_ds.to_dataset(name='GFED4s burnt residues (Mg)')
GFED4s_ds
1997: agricultural dry matter burned = 334.97 Tg 1998: agricultural dry matter burned = 377.98 Tg 1999: agricultural dry matter burned = 270.56 Tg 2000: agricultural dry matter burned = 274.94 Tg 2001: agricultural dry matter burned = 289.57 Tg 2002: agricultural dry matter burned = 274.21 Tg 2003: agricultural dry matter burned = 251.14 Tg 2004: agricultural dry matter burned = 280.37 Tg 2005: agricultural dry matter burned = 322.80 Tg 2006: agricultural dry matter burned = 325.70 Tg 2007: agricultural dry matter burned = 278.74 Tg 2008: agricultural dry matter burned = 338.63 Tg 2009: agricultural dry matter burned = 274.07 Tg 2010: agricultural dry matter burned = 263.44 Tg 2011: agricultural dry matter burned = 237.01 Tg 2012: agricultural dry matter burned = 234.39 Tg 2013: agricultural dry matter burned = 212.80 Tg 2014: agricultural dry matter burned = 270.26 Tg 2015: agricultural dry matter burned = 282.26 Tg 2016: agricultural dry matter burned = 232.53 Tg 2017: agricultural dry matter burned = 242.56 Tg 2018: agricultural dry matter burned = 210.61 Tg 2019: agricultural dry matter burned = 237.79 Tg 2020: agricultural dry matter burned = 237.27 Tg 2021: agricultural dry matter burned = 215.19 Tg
array([ 89.75, 89.25, 88.75, ..., -88.75, -89.25, -89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
for year in [1998,2015,2021]:
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,5000,10000,20000,50000,100000,200000,500000,4*10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = GFED4s_ds['GFED4s burnt residues (Mg)'].sel(Year=year).where(dA2>0).plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'Residues burnt (Mg) in {year}',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
FINN_ds = xr.open_dataset('/Users/smerald-a/ldndc/resources/fire/FINN/FINN_crop_burning.nc')
FINN_ds = FINN_ds.rename({'burnt biomass (Mg)' : 'FINN burnt residues (Mg)'})
FINN_ds = xr.concat([GFED4s_ds.sel(Year=slice(1997,2001)).rename({'GFED4s burnt residues (Mg)' : 'FINN burnt residues (Mg)'}),FINN_ds],dim='Year')
FINN_ds
array([-89.75, -89.25, -88.75, ..., 88.75, 89.25, 89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], ..., [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], [[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]])
burnt_res_ds = xr.merge([GFED4s_ds,FINN_ds])
burnt_res_ds
#export
comp = dict(zlib=True, complevel=9)
encoding = {var: comp for var in burnt_res_ds.data_vars}
burnt_res_ds.fillna(0).where(crop_residue_prod_ds['residue production mean (Mg)'] > 0).to_netcdf(data_out_folder + 'crop_residue_burnt.nc',encoding=encoding)
GDP_df = pd.read_csv(GDP_loc,encoding='latin1')
GDP_df = GDP_df.rename(columns={'Area Code (M49)' : 'M49 Code', 'Value' : 'GDP (2015$)'})
GDP_df = GDP_df.merge(country_codes_df[['M49 Code','Area Code']],on='M49 Code')
GDP_df = GDP_df[['M49 Code','Area','Year','GDP (2015$)']]
GDP_df
low_income_GDP_thres = 1046 # 2015$
high_income_GDP_thres = 12735 # 2015$ #value in 2015 from world bank? IMF?
low_income_fuel_frac = 0.3 #from Sinton00, which estimates that china in 1995-7 used about 40% of straw for domestic fuel (at this time it was a poor country)
high_income_fuel_frac = 0.1 #from borowski20 estimate for Germany for industrial and special crop usage
res_fuel_frac_list = []
for index, row in GDP_df.iterrows():
year = row['Year']
GDP = row['GDP (2015$)']
if GDP < low_income_GDP_thres:
res_fuel_frac = low_income_fuel_frac
elif GDP > low_income_GDP_thres and GDP < high_income_GDP_thres:
res_fuel_frac = low_income_fuel_frac - (GDP - low_income_GDP_thres)/(high_income_GDP_thres - low_income_GDP_thres) * (low_income_fuel_frac - high_income_fuel_frac)
else:
res_fuel_frac = high_income_fuel_frac
res_fuel_frac_list.append( res_fuel_frac )
GDP_df['res fuel frac'] = np.array(res_fuel_frac_list)
#GDP_df.loc[GDP_df['Area'] == 'Poland']
GDP_df
M49 Code | Area | Year | GDP (2015$) | res fuel frac | |
---|---|---|---|---|---|
0 | 4 | Afghanistan | 1970 | 937.0 | 0.300000 |
1 | 4 | Afghanistan | 1971 | 910.0 | 0.300000 |
2 | 4 | Afghanistan | 1972 | 772.0 | 0.300000 |
3 | 4 | Afghanistan | 1973 | 736.0 | 0.300000 |
4 | 4 | Afghanistan | 1974 | 754.0 | 0.300000 |
... | ... | ... | ... | ... | ... |
10142 | 716 | Zimbabwe | 2016 | 1434.0 | 0.293361 |
10143 | 716 | Zimbabwe | 2017 | 1479.0 | 0.292591 |
10144 | 716 | Zimbabwe | 2018 | 1529.0 | 0.291736 |
10145 | 716 | Zimbabwe | 2019 | 1382.0 | 0.294251 |
10146 | 716 | Zimbabwe | 2020 | 1373.0 | 0.294405 |
10147 rows × 5 columns
#dom_fuel_df_dict = {}
ds_list = []
for year in year_list:
dA_list = []
for method in residue_methods + ['mean']:
if year == 2021:
year2 = 2020
else:
year2 = year
dom_fuel_df = residue_prod_dict[year].copy()
dom_fuel_df = dom_fuel_df.merge(country_grid_df,how='left',on=['lon','lat'])
#dom_fuel_df['M49 Code'] = dom_fuel_df['M49 Code'].fillna(-1)
factor_dict = {}
for m49 in pd.unique(GDP_df['M49 Code']):
x = (GDP_df.loc[(GDP_df['M49 Code']==m49) & (GDP_df['Year']==year2), 'res fuel frac'] ).values
try:
factor_dict[m49] = x[0]
except:
pass
factor_dict[-1] = 0
def func(prod,m49):
try:
return prod * factor_dict[m49]
except:
return 0
dom_fuel_df[f'other usage {method} (Mg)'] = list(map(func, dom_fuel_df[f'residue production {method} (Mg)'], dom_fuel_df['M49 Code'].fillna(-1)))
dA = dom_fuel_df[['lon','lat',f'other usage {method} (Mg)']].set_index(["lat", "lon"]).to_xarray()
dA_list.append(dA)
#dom_fuel_df_dict[year] = {method : dom_fuel_df[['lon','lat','Year',f'domestic fuel {method} (Mg)']]}
#print(f'{year}: max domestic fuel residue usage = %.2f Tg' % (dom_fuel_df[f'domestic fuel {method} (Mg)'].sum() * 10**-6) )
ds_list.append(xr.merge(dA_list))
other_ds = xr.concat(ds_list, pd.Index(year_list, name='Year'))
other_ds
#dom_fuel_df_dict[2015]['mean']
array([-89.75, -89.25, -88.75, ..., 88.75, 89.25, 89.75])
array([-179.75, -179.25, -178.75, ..., 178.75, 179.25, 179.75])
array([1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
array([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], ..., [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]]])
array([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], ..., [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]]])
array([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], ..., [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]]])
array([[[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], ..., [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], [[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]]])
#dom_fuel_ds = pd.concat(list(dom_fuel_df_dict.values())).set_index(["lat", "lon",'Year']).to_xarray()
#dom_fuel_ds = dom_fuel_ds.where(dom_fuel_ds>0)
#dom_fuel_ds
var = 'other usage mean (Mg)'
colours = ['darkblue','royalblue','skyblue','lemonchiffon','gold','orange','red','crimson']
boundaries = [0,2000,5000,20000,50000,100000,200000,500000,1*10**6]
cmap = matplotlib.colors.ListedColormap(colours)
norm = matplotlib.colors.BoundaryNorm(boundaries=boundaries, ncolors=len(cmap.colors) )
fig, ax = plt.subplots(1, 1, figsize=(20,10),subplot_kw={'projection': ccrs.PlateCarree()})
ax.outline_patch.set_edgecolor('white')
im = other_ds[var].where(other_ds[var]>0).sel(Year=2015).plot.imshow(ax=ax, transform=ccrs.PlateCarree(),cmap=cmap,norm=norm,add_colorbar=False)
ax.coastlines()
ax.set_title(f'Residue for domestic fuel, special crops and industry (Mg)',fontsize=36)
cbar = ax.figure.colorbar(
matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap),
ax=ax, pad=0.01)
cbar.ax.tick_params(labelsize=28)
plt.show()
#export
comp = dict(zlib=True, complevel=9)
encoding = {var: comp for var in other_ds.data_vars}
other_ds.fillna(0).where(crop_residue_prod_ds['residue production mean (Mg)'] > 0).to_netcdf(data_out_folder + 'other_usage.nc',encoding=encoding)
#feed conversion ratios
region_list = ['CIS','EUR','OCE','NAM','LAM','EAS','SEA','SAS','MNA','SSA']
prod_sys = ['LGA','LGH','LGT','MA','MH','MT','Urban','Other']
def df_creator(filename,animal,commodity):
df = pd.read_csv(data_folder + filename, header=None, names=['no.','FCR (kg-protein/kg-feed-DW)'])
if animal == 'cattle' and commodity == 'meat':
df['FCR (kg-protein/kg-feed-DW)'] = 1/df['FCR (kg-protein/kg-feed-DW)']
df['production system'] = prod_sys * len(region_list[1:])
df['Herrero_group'] = [item for sublist in [[k]*len(prod_sys) for k in region_list[1:]] for item in sublist]
df = df.drop(columns='no.')
df['animal'] = animal
df['commodity'] = commodity
df = df[['animal','commodity','Herrero_group','production system','FCR (kg-protein/kg-feed-DW)']]
x = df.loc[df['Herrero_group']=='EUR'].copy()
x['Herrero_group'] = 'CIS'
df = pd.concat([x,df])
return df.reset_index(drop=True)
cattle_meat = df_creator('cattle_meat.csv','cattle','meat')
cattle_milk = df_creator('cattle_milk.csv','cattle','milk')
goat_meat = df_creator('goat_meat.csv','goat','meat')
goat_milk = df_creator('goat_milk.csv','goat','milk')
sheep_meat = goat_meat.copy()
sheep_milk = goat_milk.copy()
sheep_meat['animal'] = 'sheep'
sheep_milk['animal'] = 'sheep'
FCR_df = pd.concat([cattle_meat,cattle_milk,goat_meat,goat_milk,sheep_meat,sheep_milk])
#FCR_df.to_csv(data_folder + 'feed_conversion_ratio.csv',index=False)
FCR_df
animal | commodity | Herrero_group | production system | FCR (kg-protein/kg-feed-DW) | |
---|---|---|---|---|---|
0 | cattle | meat | CIS | LGA | 0.004362 |
1 | cattle | meat | CIS | LGH | 0.003721 |
2 | cattle | meat | CIS | LGT | 0.004518 |
3 | cattle | meat | CIS | MA | 0.007906 |
4 | cattle | meat | CIS | MH | 0.010542 |
... | ... | ... | ... | ... | ... |
75 | sheep | milk | SSA | MA | 0.002466 |
76 | sheep | milk | SSA | MH | 0.004364 |
77 | sheep | milk | SSA | MT | 0.005312 |
78 | sheep | milk | SSA | Urban | 0.004458 |
79 | sheep | milk | SSA | Other | 0.004126 |
480 rows × 5 columns
region_list = ['CIS','EUR','OCE','NAM','LAM','EAS','SEA','SAS','MNA','SSA']
prod_sys = ['LGA','LGH','LGT','MA','MH','MT','Urban','Other']
res_frac_dict = {}
for animal in animal_list:
res_frac_dict[animal] = {}
for commodity in commodity_list:
res_frac_dict[animal][commodity] = {}
for region in region_list:
res_frac_dict[animal][commodity][region] = {}
res_frac_dict['cattle']['meat']['CIS'] = [0,0,0,35,33,29,0,0]
res_frac_dict['cattle']['meat']['EAS'] = [0,0,0,44,47,16,0,0]
res_frac_dict['cattle']['meat']['EUR'] = [0,0,0,0,0,0,0,0]
res_frac_dict['cattle']['meat']['LAM'] = [0,0,0,50,0,0,0,0]
res_frac_dict['cattle']['meat']['MNA'] = [0,0,0,0,0,0,0,0]
res_frac_dict['cattle']['meat']['NAM'] = [0,0,0,31,31,20,0,0]
res_frac_dict['cattle']['meat']['OCE'] = [0,0,0,0,1,1,0,0]
res_frac_dict['cattle']['meat']['SAS'] = [0,0,0,39,40,29,21,21]
res_frac_dict['cattle']['meat']['SEA'] = [0,0,0,44,71,72,0,0]
res_frac_dict['cattle']['meat']['SSA'] = [4,0,0,35,47,29,0,0]
res_frac_dict['cattle']['milk']['CIS'] = [0,0,0,36,31,30,0,0]
res_frac_dict['cattle']['milk']['EAS'] = [0,0,0,87,67,30,0,0]
res_frac_dict['cattle']['milk']['EUR'] = [0,0,0,0,0,0,0,0]
res_frac_dict['cattle']['milk']['LAM'] = [0,0,0,21,25,12,0,0]
res_frac_dict['cattle']['milk']['MNA'] = [0,0,0,35,19,7,0,0]
res_frac_dict['cattle']['milk']['NAM'] = [0,0,0,0,0,0,0,0]
res_frac_dict['cattle']['milk']['OCE'] = [0,0,0,0,0,0,0,0]
res_frac_dict['cattle']['milk']['SAS'] = [0,0,0,35,32,28,56,56]
res_frac_dict['cattle']['milk']['SEA'] = [0,0,0,41,57,67,0,0]
res_frac_dict['cattle']['milk']['SSA'] = [4,0,11,33,27,29,6,5]
res_frac_dict['goat']['meat']['CIS'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['meat']['EAS'] = [0,0,0,12,18,0,0,0]
res_frac_dict['goat']['meat']['EUR'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['meat']['LAM'] = [0,0,0,25,20,0,0,0]
res_frac_dict['goat']['meat']['MNA'] = [0,0,0,27,27,17,0,0]
res_frac_dict['goat']['meat']['NAM'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['meat']['OCE'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['meat']['SAS'] = [0,0,0,13,26,12,12,12]
res_frac_dict['goat']['meat']['SEA'] = [0,0,0,25,38,40,0,0]
res_frac_dict['goat']['meat']['SSA'] = [3,0,0,31,23,20,0,0]
res_frac_dict['goat']['milk']['CIS'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['milk']['EAS'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['milk']['EUR'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['milk']['LAM'] = [0,0,0,22,5,0,0,0]
res_frac_dict['goat']['milk']['MNA'] = [0,0,0,28,25,24,0,0]
res_frac_dict['goat']['milk']['NAM'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['milk']['OCE'] = [0,0,0,0,0,0,0,0]
res_frac_dict['goat']['milk']['SAS'] = [0,0,0,0,4,22,0,0]
res_frac_dict['goat']['milk']['SEA'] = [0,0,0,0,0,14,0,0]
res_frac_dict['goat']['milk']['SSA'] = [0,0,0,19,2,0,0,0]
res_frac_dict['sheep'] = res_frac_dict['goat']
col_animal = []
col_commodity = []
col_region = []
col_prod_sys = []
col_res_perc = []
for animal, val1 in res_frac_dict.items():
for commodity, val2 in val1.items():
for region, residue_perc_list in val2.items():
for i, residue_perc in enumerate(residue_perc_list):
col_animal.append(animal)
col_commodity.append(commodity)
col_region.append(region)
col_prod_sys.append(prod_sys[i])
col_res_perc.append(residue_perc)
crop_res_perc_df = pd.DataFrame(
{'animal': col_animal,
'commodity': col_commodity,
'Herrero_group': col_region,
'production system': col_prod_sys,
'residue feed (%)': col_res_perc
})
#crop_res_perc_df.to_csv(data_folder + 'crop_residue_perc_herrero.csv',index=False)
crop_res_perc_df
animal | commodity | Herrero_group | production system | residue feed (%) | |
---|---|---|---|---|---|
0 | cattle | meat | CIS | LGA | 0 |
1 | cattle | meat | CIS | LGH | 0 |
2 | cattle | meat | CIS | LGT | 0 |
3 | cattle | meat | CIS | MA | 35 |
4 | cattle | meat | CIS | MH | 33 |
... | ... | ... | ... | ... | ... |
475 | goat | milk | SSA | MA | 19 |
476 | goat | milk | SSA | MH | 2 |
477 | goat | milk | SSA | MT | 0 |
478 | goat | milk | SSA | Urban | 0 |
479 | goat | milk | SSA | Other | 0 |
480 rows × 5 columns
region_list = ['CIS','EUR','OCE','NAM','LAM','EAS','SEA','SAS','MNA','SSA']
prod_sys_list = ['grazing','mixed','industrial']
commodity_list = ['meat','milk']
#from Herrero13
protein_dict = {'cattle' : {'meat' : 0.138, 'milk' : 0.033},
'goat' : {'meat' : 0.137, 'milk' : 0.033},
'sheep' : {'meat' : 0.137, 'milk' : 0.033}}
FCE_dict = {}
for animal in animal_list:
FCE_dict[animal] = {}
for commodity in commodity_list:
FCE_dict[animal][commodity] = {}
for prod_sys in prod_sys_list:
FCE_dict[animal][commodity][prod_sys] = {}
for region in region_list:
FCE_dict[animal][commodity][prod_sys][region] = {}
#Appendix I
#kg DM feed per kg output (meat or milk)
FCE_dict['cattle']['meat']['grazing']['LAM'] = 76
FCE_dict['cattle']['meat']['grazing']['EAS'] = 90
FCE_dict['cattle']['meat']['grazing']['CIS'] = 48
FCE_dict['cattle']['meat']['grazing']['NAM'] = 40
FCE_dict['cattle']['meat']['grazing']['OCE'] = 46
FCE_dict['cattle']['meat']['grazing']['SAS'] = 280
FCE_dict['cattle']['meat']['grazing']['SEA'] = 163
FCE_dict['cattle']['meat']['grazing']['SSA'] = 110
FCE_dict['cattle']['meat']['grazing']['MNA'] = 97
FCE_dict['cattle']['meat']['grazing']['EUR'] = 59
FCE_dict['cattle']['meat']['mixed']['LAM'] = 63
FCE_dict['cattle']['meat']['mixed']['EAS'] = 61
FCE_dict['cattle']['meat']['mixed']['CIS'] = 31
FCE_dict['cattle']['meat']['mixed']['NAM'] = 24
FCE_dict['cattle']['meat']['mixed']['OCE'] = 36
FCE_dict['cattle']['meat']['mixed']['SAS'] = 121
FCE_dict['cattle']['meat']['mixed']['SEA'] = 90
FCE_dict['cattle']['meat']['mixed']['SSA'] = 56
FCE_dict['cattle']['meat']['mixed']['MNA'] = 41
FCE_dict['cattle']['meat']['mixed']['EUR'] = 53
FCE_dict['cattle']['meat']['industrial']['LAM'] = 21
FCE_dict['cattle']['meat']['industrial']['EAS'] = 35
FCE_dict['cattle']['meat']['industrial']['CIS'] = 9
FCE_dict['cattle']['meat']['industrial']['NAM'] = 4
FCE_dict['cattle']['meat']['industrial']['OCE'] = 11
FCE_dict['cattle']['meat']['industrial']['SAS'] = 33
FCE_dict['cattle']['meat']['industrial']['SEA'] = 25
FCE_dict['cattle']['meat']['industrial']['SSA'] = 14
FCE_dict['cattle']['meat']['industrial']['MNA'] = 13
FCE_dict['cattle']['meat']['industrial']['EUR'] =16
FCE_dict['cattle']['milk']['grazing']['LAM'] = 3.8
FCE_dict['cattle']['milk']['grazing']['EAS'] = 4.8
FCE_dict['cattle']['milk']['grazing']['CIS'] = 2.6
FCE_dict['cattle']['milk']['grazing']['NAM'] = 2.3
FCE_dict['cattle']['milk']['grazing']['OCE'] = 1.8
FCE_dict['cattle']['milk']['grazing']['SAS'] = 6.5
FCE_dict['cattle']['milk']['grazing']['SEA'] = 7.4
FCE_dict['cattle']['milk']['grazing']['SSA'] = 4.1
FCE_dict['cattle']['milk']['grazing']['MNA'] = 3.3
FCE_dict['cattle']['milk']['grazing']['EUR'] = 3.3
FCE_dict['cattle']['milk']['mixed']['LAM'] = 2.6
FCE_dict['cattle']['milk']['mixed']['EAS'] = 1.8
FCE_dict['cattle']['milk']['mixed']['CIS'] = 2
FCE_dict['cattle']['milk']['mixed']['NAM'] = 1
FCE_dict['cattle']['milk']['mixed']['OCE'] = 1.3
FCE_dict['cattle']['milk']['mixed']['SAS'] = 1.9
FCE_dict['cattle']['milk']['mixed']['SEA'] = 3.5
FCE_dict['cattle']['milk']['mixed']['SSA'] = 3.2
FCE_dict['cattle']['milk']['mixed']['MNA'] = 1.9
FCE_dict['cattle']['milk']['mixed']['EUR'] = 1.2
FCE_dict['cattle']['milk']['industrial']['LAM'] = 1
FCE_dict['cattle']['milk']['industrial']['EAS'] = 0.9
FCE_dict['cattle']['milk']['industrial']['CIS'] = 1.3
FCE_dict['cattle']['milk']['industrial']['NAM'] = 0.5
FCE_dict['cattle']['milk']['industrial']['OCE'] = 0.7
FCE_dict['cattle']['milk']['industrial']['SAS'] = 1
FCE_dict['cattle']['milk']['industrial']['SEA'] = 1
FCE_dict['cattle']['milk']['industrial']['SSA'] = 1
FCE_dict['cattle']['milk']['industrial']['MNA'] = 1
FCE_dict['cattle']['milk']['industrial']['EUR'] = 0.6
FCE_dict['sheep']['meat']['grazing']['LAM'] = 114
FCE_dict['sheep']['meat']['grazing']['EAS'] = 49
FCE_dict['sheep']['meat']['grazing']['CIS'] = 96
FCE_dict['sheep']['meat']['grazing']['NAM'] = 33
FCE_dict['sheep']['meat']['grazing']['OCE'] = 40
FCE_dict['sheep']['meat']['grazing']['SAS'] = 54
FCE_dict['sheep']['meat']['grazing']['SEA'] = 36
FCE_dict['sheep']['meat']['grazing']['SSA'] = 44
FCE_dict['sheep']['meat']['grazing']['MNA'] = 33
FCE_dict['sheep']['meat']['grazing']['EUR'] = 33
FCE_dict['sheep']['meat']['mixed']['LAM'] = 74
FCE_dict['sheep']['meat']['mixed']['EAS'] = 21
FCE_dict['sheep']['meat']['mixed']['CIS'] = 47
FCE_dict['sheep']['meat']['mixed']['NAM'] = 27
FCE_dict['sheep']['meat']['mixed']['OCE'] = 27
FCE_dict['sheep']['meat']['mixed']['SAS'] = 20
FCE_dict['sheep']['meat']['mixed']['SEA'] = 21
FCE_dict['sheep']['meat']['mixed']['SSA'] = 27
FCE_dict['sheep']['meat']['mixed']['MNA'] = 17
FCE_dict['sheep']['meat']['mixed']['EUR'] = 33
FCE_dict['sheep']['meat']['industrial']['LAM'] = 30
FCE_dict['sheep']['meat']['industrial']['EAS'] = 14
FCE_dict['sheep']['meat']['industrial']['CIS'] = 23
FCE_dict['sheep']['meat']['industrial']['NAM'] = 10
FCE_dict['sheep']['meat']['industrial']['OCE'] = 10
FCE_dict['sheep']['meat']['industrial']['SAS'] = 11
FCE_dict['sheep']['meat']['industrial']['SEA'] = 8
FCE_dict['sheep']['meat']['industrial']['SSA'] = 10
FCE_dict['sheep']['meat']['industrial']['MNA'] = 7
FCE_dict['sheep']['meat']['industrial']['EUR'] = 10
FCE_dict['sheep']['milk'] = FCE_dict['sheep']['meat']
FCE_dict['goat'] = FCE_dict['sheep']
prod_sys = ['LGA','LGH','LGT','MA','MH','MT','Urban','Other']
prod_sys_conversion_dict = {'LGA' : 'grazing',
'LGH' : 'grazing',
'LGT' : 'grazing',
'MA' : 'mixed',
'MH' : 'mixed',
'MT' : 'mixed',
'Urban' : 'industrial',
'Other' : 'industrial'}
col_animal = []
col_commodity = []
col_region = []
col_prod_sys = []
col_FCR = []
for animal in animal_list:
for commodity in commodity_list:
for ps in prod_sys_conversion_dict.keys():
prod_sys = prod_sys_conversion_dict[ps]
for region in region_list:
col_animal.append(animal)
col_commodity.append(commodity)
col_region.append(region)
col_prod_sys.append(ps)
FCE = FCE_dict[animal][commodity][prod_sys][region]
FCR = protein_dict[animal][commodity] / FCE
col_FCR.append(FCR)
FCR_df = pd.DataFrame(
{'animal': col_animal,
'commodity': col_commodity,
'Herrero_group': col_region,
'production system': col_prod_sys,
'FCR (kg-protein/kg-feed-DW)': col_FCR
})
#FCR_df.to_csv(data_folder + 'FCR_mekonnen.csv',index=False)
FCR_df
animal | commodity | Herrero_group | production system | FCR (kg-protein/kg-feed-DW) | |
---|---|---|---|---|---|
0 | cattle | meat | CIS | LGA | 0.002875 |
1 | cattle | meat | EUR | LGA | 0.002339 |
2 | cattle | meat | OCE | LGA | 0.003000 |
3 | cattle | meat | NAM | LGA | 0.003450 |
4 | cattle | meat | LAM | LGA | 0.001816 |
... | ... | ... | ... | ... | ... |
475 | goat | milk | EAS | Other | 0.002357 |
476 | goat | milk | SEA | Other | 0.004125 |
477 | goat | milk | SAS | Other | 0.003000 |
478 | goat | milk | MNA | Other | 0.004714 |
479 | goat | milk | SSA | Other | 0.003300 |
480 rows × 5 columns
region_list = ['CIS','EUR','OCE','NAM','LAM','EAS','SEA','SAS','MNA','SSA']
region_list2 = ['OECD','non-OECD']
prod_sys_list = ['grazing','mixed','industrial']
FCE_dict = {}
for animal in animal_list:
FCE_dict[animal] = {}
for commodity in commodity_list:
FCE_dict[animal][commodity] = {}
for prod_sys in prod_sys_list:
FCE_dict[animal][commodity][prod_sys] = {}
for region in region_list2:
FCE_dict[animal][commodity][prod_sys][region] = {}
FCE_dict['cattle']['meat']['grazing']['OECD'] = 67
FCE_dict['cattle']['meat']['mixed']['OECD'] = 53
FCE_dict['cattle']['meat']['industrial']['OECD'] = 62
FCE_dict['cattle']['meat']['grazing']['non-OECD'] = 195
FCE_dict['cattle']['meat']['mixed']['non-OECD'] = 171
FCE_dict['cattle']['meat']['industrial']['non-OECD'] = 99
FCE_dict['cattle']['milk'] = FCE_dict['cattle']['meat']
FCE_dict['sheep']['meat']['grazing']['OECD'] = 132
FCE_dict['sheep']['meat']['mixed']['OECD'] = 111
FCE_dict['sheep']['meat']['industrial']['OECD'] = 111
FCE_dict['sheep']['meat']['grazing']['non-OECD'] = 221
FCE_dict['sheep']['meat']['mixed']['non-OECD'] = 190
FCE_dict['sheep']['meat']['industrial']['non-OECD'] = 190
FCE_dict['sheep']['milk'] = FCE_dict['sheep']['meat']
FCE_dict['goat'] = FCE_dict['sheep']
prod_sys = ['LGA','LGH','LGT','MA','MH','MT','Urban','Other']
prod_sys_conversion_dict = {'LGA' : 'grazing',
'LGH' : 'grazing',
'LGT' : 'grazing',
'MA' : 'mixed',
'MH' : 'mixed',
'MT' : 'mixed',
'Urban' : 'industrial',
'Other' : 'industrial'}
region_conversion_dict = {'CIS' : 'non-OECD',
'EUR' : 'OECD',
'OCE' : 'OECD',
'NAM' : 'OECD',
'LAM' : 'non-OECD',
'EAS' : 'non-OECD',
'SEA' : 'non-OECD',
'SAS' : 'non-OECD',
'MNA' : 'non-OECD',
'SSA' : 'non-OECD'}
col_animal = []
col_commodity = []
col_region = []
col_prod_sys = []
col_FCR = []
for animal in animal_list:
for commodity in commodity_list:
for ps in prod_sys_conversion_dict.keys():
prod_sys = prod_sys_conversion_dict[ps]
for region in region_list:
col_animal.append(animal)
col_commodity.append(commodity)
col_region.append(region)
col_prod_sys.append(ps)
FCE = FCE_dict[animal][commodity][prod_sys][region_conversion_dict[region]]
FCR = 1 / FCE
col_FCR.append(FCR)
FCR_df = pd.DataFrame(
{'animal': col_animal,
'commodity': col_commodity,
'Herrero_group': col_region,
'production system': col_prod_sys,
'FCR (kg-protein/kg-feed-DW)': col_FCR
})
#FCR_df.to_csv(data_folder + 'FCR_mottet.csv',index=False)
FCR_df
animal | commodity | Herrero_group | production system | FCR (kg-protein/kg-feed-DW) | |
---|---|---|---|---|---|
0 | cattle | meat | CIS | LGA | 0.005128 |
1 | cattle | meat | EUR | LGA | 0.014925 |
2 | cattle | meat | OCE | LGA | 0.014925 |
3 | cattle | meat | NAM | LGA | 0.014925 |
4 | cattle | meat | LAM | LGA | 0.005128 |
... | ... | ... | ... | ... | ... |
475 | goat | milk | EAS | Other | 0.005263 |
476 | goat | milk | SEA | Other | 0.005263 |
477 | goat | milk | SAS | Other | 0.005263 |
478 | goat | milk | MNA | Other | 0.005263 |
479 | goat | milk | SSA | Other | 0.005263 |
480 rows × 5 columns
region_list = ['CIS','EUR','OCE','NAM','LAM','EAS','SEA','SAS','MNA','SSA']
prod_sys_list = ['LGA','LGH','LGT','MA','MH','MT','Urban','Other']
res_frac_dict = {}
for animal in animal_list:
res_frac_dict[animal] = {}
for commodity in commodity_list:
res_frac_dict[animal][commodity] = {}
for region in region_list:
res_frac_dict[animal][commodity][region] = {}
res_frac_dict['cattle']['meat']['NAM'] = 0
res_frac_dict['cattle']['meat']['CIS'] = 2.1
res_frac_dict['cattle']['meat']['EUR'] = 3.8
res_frac_dict['cattle']['meat']['MNA'] = 24.2
res_frac_dict['cattle']['meat']['EAS'] = 46.2
res_frac_dict['cattle']['meat']['SEA'] = 46.2
res_frac_dict['cattle']['meat']['OCE'] = 0
res_frac_dict['cattle']['meat']['SAS'] = 68
res_frac_dict['cattle']['meat']['LAM'] = 10.2
res_frac_dict['cattle']['meat']['SSA'] = 19.4
res_frac_dict['cattle']['milk']['NAM'] = 0
res_frac_dict['cattle']['milk']['CIS'] = 1.8
res_frac_dict['cattle']['milk']['EUR'] = 2.5
res_frac_dict['cattle']['milk']['MNA'] = 31.7
res_frac_dict['cattle']['milk']['EAS'] = 38.4
res_frac_dict['cattle']['milk']['SEA'] = 38.4
res_frac_dict['cattle']['milk']['OCE'] = 0
res_frac_dict['cattle']['milk']['SAS'] = 60.1
res_frac_dict['cattle']['milk']['LAM'] = 8.7
res_frac_dict['cattle']['milk']['SSA'] = 17
res_frac_dict['sheep']['meat']['NAM'] = 0
res_frac_dict['sheep']['meat']['CIS'] = 13.7
res_frac_dict['sheep']['meat']['EUR'] = 13
res_frac_dict['sheep']['meat']['MNA'] = 37.4
res_frac_dict['sheep']['meat']['EAS'] = 39.2
res_frac_dict['sheep']['meat']['SEA'] = 39.2
res_frac_dict['sheep']['meat']['OCE'] = 1.2
res_frac_dict['sheep']['meat']['SAS'] = 55.9
res_frac_dict['sheep']['meat']['LAM'] = 9.9
res_frac_dict['sheep']['meat']['SSA'] = 27.9
res_frac_dict['sheep']['milk']['NAM'] = 0
res_frac_dict['sheep']['milk']['CIS'] = 11.5
res_frac_dict['sheep']['milk']['EUR'] = 16.4
res_frac_dict['sheep']['milk']['MNA'] = 38.4
res_frac_dict['sheep']['milk']['EAS'] = 26.9
res_frac_dict['sheep']['milk']['SEA'] = 26.9
res_frac_dict['sheep']['milk']['OCE'] = 1.1
res_frac_dict['sheep']['milk']['SAS'] = 53.9
res_frac_dict['sheep']['milk']['LAM'] = 8.7
res_frac_dict['sheep']['milk']['SSA'] = 31.1
res_frac_dict['goat'] = res_frac_dict['sheep']
col_animal = []
col_commodity = []
col_region = []
col_prod_sys = []
col_res_perc = []
for animal in animal_list:
for commodity in commodity_list:
for region in region_list:
for prod_sys in prod_sys_list:
col_animal.append(animal)
col_commodity.append(commodity)
col_region.append(region)
col_prod_sys.append(prod_sys)
col_res_perc.append(res_frac_dict[animal][commodity][region])
crop_res_perc_df = pd.DataFrame(
{'animal': col_animal,
'commodity': col_commodity,
'Herrero_group': col_region,
'production system': col_prod_sys,
'residue feed (%)': col_res_perc
})
crop_res_perc_df.to_csv(data_folder + 'crop_residue_perc_mottet.csv',index=False)
crop_res_perc_df
animal | commodity | Herrero_group | production system | residue feed (%) | |
---|---|---|---|---|---|
0 | cattle | meat | CIS | LGA | 2.1 |
1 | cattle | meat | CIS | LGH | 2.1 |
2 | cattle | meat | CIS | LGT | 2.1 |
3 | cattle | meat | CIS | MA | 2.1 |
4 | cattle | meat | CIS | MH | 2.1 |
... | ... | ... | ... | ... | ... |
475 | goat | milk | SSA | MA | 31.1 |
476 | goat | milk | SSA | MH | 31.1 |
477 | goat | milk | SSA | MT | 31.1 |
478 | goat | milk | SSA | Urban | 31.1 |
479 | goat | milk | SSA | Other | 31.1 |
480 rows × 5 columns