test_conversion.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. import climate_categories as cc
  2. import pandas as pd
  3. import primap2 as pm2
  4. import xarray as xr
  5. from src.faostat_data_primap.helper.paths import (
  6. downloaded_data_path,
  7. extracted_data_path,
  8. )
  9. from src.faostat_data_primap.read import read_data
  10. def test_conversion_from_FAO_to_IPCC2006_PRIMAP():
  11. # make categorisation A from yaml
  12. categorisation_a = cc.from_python("FAO.py")
  13. # make categorisation B from yaml
  14. categorisation_b = cc.IPCC2006_PRIMAP
  15. # category a not part of climate categories, so we need to add them manually
  16. cats = {
  17. "FAOSTAT": categorisation_a,
  18. "IPCC2006_PRIMAP": categorisation_b,
  19. }
  20. # make conversion from csv
  21. conv = cc.Conversion.from_csv("conversion_FAO_IPPCC2006_PRIMAP.csv", cats=cats)
  22. ds_fao = (
  23. extracted_data_path
  24. / "v2024-11-14/FAOSTAT_Agrifood_system_emissions_v2024-11-14.nc"
  25. )
  26. ds = pm2.open_dataset(ds_fao)
  27. ds_if = ds.pr.to_interchange_format()
  28. da_dict = {}
  29. for var in ds.data_vars:
  30. da_dict[var] = ds[var].pr.convert(
  31. dim="category (FAOSTAT)",
  32. conversion=conv,
  33. # auxiliary_dimensions={"gas" : "source (gas)"},
  34. )
  35. result = xr.Dataset(da_dict)
  36. result_if = result.pr.to_interchange_format()
  37. df_all = pd.concat([ds_if, result_if], axis=0, join="outer", ignore_index=True)
  38. compare = df_all.loc[
  39. (df_all["category (IPCC2006_PRIMAP)"] == "3.A")
  40. | (df_all["category (FAOSTAT)"] == "3")
  41. ]
  42. assert compare
  43. def test_read(tmp_path):
  44. domains_and_releases_to_read = [
  45. # ("farm_gate_agriculture_energy", "2024-11-14"),
  46. # ("farm_gate_emissions_crops", "2024-11-14"),
  47. # ("farm_gate_livestock", "2024-11-14"),
  48. # ("land_use_drained_organic_soils", "2024-11-14"),
  49. # ("land_use_fires", "2024-11-14"),
  50. # ("land_use_forests", "2024-11-14"),
  51. ("pre_post_agricultural_production", "2024-11-14"),
  52. ]
  53. read_data(
  54. domains_and_releases_to_read=domains_and_releases_to_read,
  55. read_path=downloaded_data_path,
  56. save_path=tmp_path,
  57. )
  58. def test_yaml_to_python():
  59. cat = cc.from_yaml("FAO.yaml")
  60. cat.to_python("FAO.py")
  61. def test_python_to_yaml():
  62. from FAO import spec
  63. cat = cc.from_spec(spec)
  64. assert cat
  65. def test_make_dict_comprehension_for_faster_typing(): # noqa: PLR0912 PLR0915
  66. spec = {
  67. "name": "FAO",
  68. "title": (
  69. "Food and Agriculture Organization of the United Nations (FAO) "
  70. "FAOSTAT data set categorisation"
  71. ),
  72. "comment": "Needed to add FAOSTAT data to PRIMAP-hist",
  73. "references": "",
  74. "institution": "FAO",
  75. "hierarchical": True,
  76. "last_update": "2024-12-10",
  77. "version": "2024",
  78. "total_sum": True,
  79. "canonical_top_level_category": "0",
  80. }
  81. categories = {}
  82. # 0. main categories
  83. categories["0"] = {
  84. "title": "Total",
  85. "comment": "All emissions and removals",
  86. "children": [["1", "2", "3", "4", "5", "6", "7"]],
  87. }
  88. children_1 = ["1.A", "1.B"]
  89. children_2 = ["2.A", "2.B", "2.C", "2.D", "2.E"]
  90. children_3 = [f"3.{i}" for i in "ABCDEFGHIJKLMNOPQR"]
  91. # children_4 = ["4.A"]
  92. # children_5 = ["5.A", "5.B"]
  93. # children_6 = ["6.A", "6.B", "6.C"]
  94. # children_7 = [f"3.{i}" for i in "ABCDEFGHIJKLM"]
  95. main_categories = (
  96. # category code, name and comment, gases, children
  97. ("1", "Crops", ["CH4", "N2O"], children_1),
  98. (
  99. "2",
  100. "Energy use in agriculture",
  101. ["CH4", "N2O", "CO2"],
  102. children_2,
  103. ),
  104. ("3", "Livestock", ["CH4", "N2O"], children_3),
  105. # ("4", "Forest", ["CO2"], children_4),
  106. # (
  107. # "5",
  108. # "Drained organic soils",
  109. # ["N2O", "CO2"],
  110. # children_5,
  111. # ),
  112. # ("6", "Fires", ["CH4", "N2O", "CO2"], children_6),
  113. # (
  114. # "7",
  115. # "Pre and post agricultural production",
  116. # ["CH4", "N2O", "CO2"],
  117. # children_7,
  118. # ),
  119. )
  120. for code, name, gases, children in main_categories:
  121. categories[code] = {
  122. "title": name,
  123. "comment": name,
  124. # "alternative_codes": code.replace(".", ""),
  125. "children": [children],
  126. "info": {"gases": gases},
  127. }
  128. # 1. crops
  129. # all crops category
  130. code_all_crops = "1.A"
  131. codes_crops = [f"1.A.{i}" for i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]
  132. categories[code_all_crops] = {
  133. "title": "All crops",
  134. "comment": "All crops",
  135. # "alternative_codes": code_all_crops.replace(".", ""),
  136. "children": [codes_crops],
  137. "info": {"gases": ["CH4", "N2O"]},
  138. }
  139. crops = [
  140. "Wheat",
  141. "Rice",
  142. "Potatoes",
  143. "Millet",
  144. "Barley",
  145. "Maize (corn)",
  146. "Sugar cane",
  147. "Beans, dry",
  148. "Oats",
  149. "Rye",
  150. "Sorghum",
  151. "Soya beans",
  152. ]
  153. crop_burnings = [
  154. True,
  155. True,
  156. False,
  157. False,
  158. False,
  159. True,
  160. True,
  161. False,
  162. False,
  163. False,
  164. False,
  165. False,
  166. ]
  167. rice_cultivations = [
  168. False,
  169. True,
  170. False,
  171. False,
  172. False,
  173. False,
  174. False,
  175. False,
  176. False,
  177. False,
  178. False,
  179. False,
  180. ]
  181. for crop, code, crop_burning, rice_cultivation in zip(
  182. crops, codes_crops, crop_burnings, rice_cultivations
  183. ):
  184. # all crops have at least N2O emissions
  185. gases_main = "N2O"
  186. if crop_burning or rice_cultivation:
  187. gases_main = ["CH4", "N2O"]
  188. # all crops have at least crop residues as child
  189. children_main = [f"{code}.a"]
  190. if crop_burning:
  191. children_main.append(f"{code}.b")
  192. if rice_cultivation:
  193. children_main.append(f"{code}.c")
  194. categories[f"{code}"] = {
  195. "title": f"{crop}",
  196. "comment": f"{crop}",
  197. # "alternative_codes": [f"{code}".replace(".", "")],
  198. "info": {"gases": gases_main},
  199. "children": [children_main],
  200. }
  201. # crop residues (every crop has it)
  202. categories[f"{code}.a.i"] = {
  203. "title": f"{crop} crop residues direct emissions",
  204. "comment": f"{crop} crop residues direct emissions",
  205. # "alternative_codes": [f"{code}.a".replace(".", "")],
  206. "info": {"gases": ["N2O"]},
  207. }
  208. categories[f"{code}.a.ii"] = {
  209. "title": f"{crop} crop residues indirect emissions",
  210. "comment": f"{crop} crop residues indirect emissions",
  211. # "alternative_codes": [f"{code}.a.i".replace(".", "")],
  212. "info": {"gases": ["N2O"]},
  213. }
  214. categories[f"{code}.a"] = {
  215. "title": f"{crop} crop residues",
  216. "comment": f"{crop} crop residues",
  217. # "alternative_codes": [f"{code}.a".replace(".", "")],
  218. "info": {"gases": ["N2O"]},
  219. "children": [[f"{code}.a.ii", f"{code}.a.i"]],
  220. }
  221. if crop_burning:
  222. categories[f"{code}.b"] = {
  223. "title": f"{crop} burning crop residues",
  224. "comment": f"{crop} burning crop residues",
  225. # "alternative_codes": [f"{code}.b".replace(".", "")],
  226. "info": {"gases": ["CH4", "N2O"]},
  227. }
  228. if rice_cultivation:
  229. categories[f"{code}.c"] = {
  230. "title": "Rice cultivation",
  231. "comment": "Rice cultivation",
  232. # "alternative_codes": [f"{code}.c".replace(".", "")],
  233. "info": {"gases": ["CH4"]},
  234. }
  235. # synthetic fertilisers
  236. codes_synthetic_fertilisers = ["1.B", "1.B.1", "1.B.2", "1.B.2.a", "1.B.2.b"]
  237. names = [
  238. "Synthetic fertilisers",
  239. "Direct emissions",
  240. "Indirect emissions",
  241. "Indirect emissions that volatilise",
  242. "Indirect emissions that leach",
  243. ]
  244. children_cats = [["1.B.1", "1.B.2"], None, ["1.B.2.a", "1.B.2.b"], None, None]
  245. for code, name, child_cat in zip(codes_synthetic_fertilisers, names, children_cats):
  246. categories[code] = {
  247. "title": name,
  248. "comment": name,
  249. # "alternative_codes": [code.replace(".", "")],
  250. "info": {"gases": ["N2O"]},
  251. }
  252. if child_cat:
  253. categories[code]["children"] = [child_cat]
  254. # 2. energy use
  255. names = [
  256. "Natural gas",
  257. "Electricity",
  258. "Coal",
  259. "Heat",
  260. "Petroleum",
  261. ]
  262. codes = children_2
  263. for name, code in zip(names, codes):
  264. categories[code] = {
  265. "title": name,
  266. "comment": name,
  267. # "alternative_codes": code.replace(".", ""),
  268. "info": {"gases": ["CH4", "N2O", "CO2"]},
  269. }
  270. # 3 livestock
  271. animals = [
  272. "Asses",
  273. "Camels",
  274. "Cattle, dairy",
  275. "Cattle, non-dairy",
  276. "Chickens, broilers",
  277. "Chickens, layers",
  278. "Goats",
  279. "Horses",
  280. "Mules and hinnies",
  281. "Sheep",
  282. "Llamas",
  283. "Chickens",
  284. "Poultry Birds",
  285. "Buffalo",
  286. "Ducks",
  287. "Swine, breeding",
  288. "Swine, market",
  289. "Turkeys",
  290. ]
  291. codes_animals = [f"3.{i}" for i in "ABCDEFGHIJKLMNOPQR"]
  292. enteric_fermentation = [
  293. "Asses",
  294. "Camels",
  295. "Cattle, dairy",
  296. "Cattle, non-dairy",
  297. "Goats",
  298. "Horses",
  299. "Sheep",
  300. "Mules and hinnies",
  301. "Buffalo",
  302. "Swine, breeding",
  303. "Swine, market",
  304. "Llamas",
  305. ]
  306. for animal, code in zip(animals, codes_animals):
  307. if animal in enteric_fermentation:
  308. gases = ["CH4", "N2O"]
  309. animal_children = [f"{code}.{i}" for i in "1234"]
  310. categories[f"{code}.4"] = {
  311. "title": f"{animal} enteric fermentation",
  312. "comment": f"{animal} enteric fermentation",
  313. # "alternative_codes" : code.replace(".", ""),
  314. "info": {"gases": gases},
  315. }
  316. else:
  317. gases = ["N2O"]
  318. animal_children = [f"{code}.{i}" for i in "123"]
  319. categories[code] = {
  320. "title": animal,
  321. "comment": animal,
  322. # "alternative_codes" : code.replace(".", ""),
  323. "info": {"gases": gases},
  324. "children": [animal_children],
  325. }
  326. # manure management branch
  327. manure_management_children = [f"{code}.1.{i}" for i in "abc"]
  328. categories[f"{code}.1"] = {
  329. "title": f"{animal} manure management",
  330. "comment": f"{animal} manure management",
  331. # "alternative_codes" : code.replace(".", ""),
  332. "info": {"gases": gases},
  333. "children": [manure_management_children],
  334. }
  335. categories[f"{code}.1.a"] = {
  336. "title": f"{animal} decomposition of organic matter",
  337. "comment": f"{animal} decomposition of organic matter",
  338. # "alternative_codes" : code.replace(".", ""),
  339. "info": {"gases": "CH4"},
  340. }
  341. categories[f"{code}.1.b"] = {
  342. "title": f"{animal} manure management (Direct emissions N2O)",
  343. "comment": f"{animal} manure management (Direct emissions N2O)",
  344. # "alternative_codes" : code.replace(".", ""),
  345. "info": {"gases": "N2O"},
  346. }
  347. categories[f"{code}.1.c"] = {
  348. "title": f"{animal} manure management (Indirect emissions N2O)",
  349. "comment": f"{animal} manure management (Indirect emissions N2O)",
  350. # "alternative_codes" : code.replace(".", ""),
  351. "info": {"gases": "N2O"},
  352. }
  353. # manure left on pasture branch
  354. manure_left_on_pasture_children = [f"{code}.2.{i}" for i in "ab"]
  355. categories[f"{code}.2"] = {
  356. "title": f"{animal} manure left on pasture",
  357. "comment": f"{animal} manure left on pasture",
  358. # "alternative_codes" : code.replace(".", ""),
  359. "info": {"gases": "N2O"},
  360. "children": [manure_left_on_pasture_children],
  361. }
  362. categories[f"{code}.2.a"] = {
  363. "title": f"{animal} manure left on pasture (direct emissions N2O)",
  364. "comment": f"{animal} manure left on pasture (direct emissions N2O)",
  365. # "alternative_codes" : code.replace(".", ""),
  366. "info": {"gases": "N2O"},
  367. }
  368. categories[f"{code}.2.b"] = {
  369. "title": f"{animal} manure left on pasture (indirect emissions N2O)",
  370. "comment": f"{animal} manure left on pasture (indirect emissions N2O)",
  371. # "alternative_codes" : code.replace(".", ""),
  372. "info": {"gases": "N2O"},
  373. "children": [[f"{code}.2.b.i", f"{code}.2.b.ii"]],
  374. }
  375. categories[f"{code}.2.b.i"] = {
  376. "title": (
  377. f"{animal} manure left on pasture "
  378. f"(indirect emissions, N2O that leaches)"
  379. ),
  380. "comment": (
  381. f"{animal} manure left on pasture (indirect "
  382. f"emissions, N2O that leaches)"
  383. ),
  384. # "alternative_codes" : code.replace(".", ""),
  385. "info": {"gases": "N2O"},
  386. }
  387. categories[f"{code}.2.b.ii"] = {
  388. "title": (
  389. f"{animal} manure left on pasture "
  390. f"(indirect emissions, N2O that volatilises)"
  391. ),
  392. "comment": (
  393. f"{animal} manure left on pasture (indirect "
  394. f"emissions, N2O that volatilises)"
  395. ),
  396. # "alternative_codes" : code.replace(".", ""),
  397. "info": {"gases": "N2O"},
  398. }
  399. # manure applied branch
  400. manure_applied_children = [f"{code}.3.{i}" for i in "ab"]
  401. categories[f"{code}.3"] = {
  402. "title": f"{animal} manure applied",
  403. "comment": f"{animal} manure applied",
  404. # "alternative_codes" : code.replace(".", ""),
  405. "info": {"gases": "N2O"},
  406. "children": [manure_applied_children],
  407. }
  408. categories[f"{code}.3.a"] = {
  409. "title": f"{animal} manure applied (direct emissions N2O)",
  410. "comment": f"{animal} manure applied (direct emissions N2O)",
  411. # "alternative_codes" : code.replace(".", ""),
  412. "info": {"gases": "N2O"},
  413. }
  414. categories[f"{code}.3.b"] = {
  415. "title": f"{animal} manure applied (indirect emissions N2O)",
  416. "comment": f"{animal} manure applied (indirect emissions N2O)",
  417. # "alternative_codes" : code.replace(".", ""),
  418. "info": {"gases": "N2O"},
  419. "children": [[f"{code}.3.b.i", f"{code}.3.b.ii"]],
  420. }
  421. categories[f"{code}.3.b.i"] = {
  422. "title": (
  423. f"{animal} manure applied " f"(indirect emissions, N2O that leaches)"
  424. ),
  425. "comment": (
  426. f"{animal} manure applied (indirect " f"emissions, N2O that leaches)"
  427. ),
  428. # "alternative_codes" : code.replace(".", ""),
  429. "info": {"gases": "N2O"},
  430. }
  431. categories[f"{code}.3.b.ii"] = {
  432. "title": (
  433. f"{animal} manure applied "
  434. f"(indirect emissions, N2O that volatilises)"
  435. ),
  436. "comment": (
  437. f"{animal} manure applied (indirect "
  438. f"emissions, N2O that volatilises)"
  439. ),
  440. # "alternative_codes" : code.replace(".", ""),
  441. "info": {"gases": "N2O"},
  442. }
  443. # forests
  444. categories["4"] = {
  445. "title": "Carbon stock change in forests",
  446. "comment": "Carbon stock change in forests",
  447. "info": {"gases": "CO2"},
  448. "children": [["4.A", "4.B"]],
  449. }
  450. categories["4.A"] = {
  451. "title": "Forest land",
  452. "comment": "Forest land",
  453. "info": {"gases": "CO2"},
  454. }
  455. categories["4.B"] = {
  456. "title": "Net Forest conversion",
  457. "comment": "Net Forest conversion",
  458. "info": {"gases": "CO2"},
  459. }
  460. # drained organic soils
  461. categories["5"] = {
  462. "title": "Drained organic soils",
  463. "comment": "Drained organic soils",
  464. "info": {"gases": "CO2"},
  465. "children": [["5.A", "5.B"]],
  466. }
  467. categories["5.A"] = {
  468. "title": "Drained grassland",
  469. "comment": "Drained grassland",
  470. "info": {"gases": ["CO2", "N2O"]},
  471. }
  472. categories["5.B"] = {
  473. "title": "Drained cropland",
  474. "comment": "Drained cropland",
  475. "info": {"gases": ["CO2", "N2O"]},
  476. }
  477. # 6 Fires
  478. # Forest fires
  479. forest_fires_children = ["Humid tropical forests", "Other forests"]
  480. forest_fires_children_codes = ["6.A.1", "6.A.2"]
  481. for cat_name, code in zip(forest_fires_children, forest_fires_children_codes):
  482. categories[code] = {
  483. "title": cat_name,
  484. "comment": cat_name,
  485. "info": {"gases": ["CO2", "N2O", "CH4"]},
  486. }
  487. categories["6.A"] = {
  488. "title": "Forest fires",
  489. "comment": "Forest fires",
  490. "info": {"gases": ["CO2", "N2O", "CH4"]},
  491. "children": [forest_fires_children_codes],
  492. }
  493. # Savanna fires
  494. savanna_fires_children = [
  495. "Closed shrubland",
  496. "Grassland",
  497. "Open shrubland",
  498. "Savanna",
  499. "Woody savanna",
  500. ]
  501. savanna_fires_children_codes = ["6.B.1", "6.B.2", "6.B.3", "6.B.4", "6.B.5"]
  502. for cat_name, code in zip(savanna_fires_children, savanna_fires_children_codes):
  503. categories[code] = {
  504. "title": cat_name,
  505. "comment": cat_name,
  506. "info": {"gases": ["CO2", "N2O", "CH4"]},
  507. }
  508. categories["6.B"] = {
  509. "title": "Savanna fires",
  510. "comment": "Savanna fires",
  511. "info": {"gases": ["CO2", "N2O", "CH4"]},
  512. "children": [savanna_fires_children_codes],
  513. }
  514. # fires in organic soils
  515. categories["6.C"] = {
  516. "title": "Fires in organic soils",
  517. "comment": "Fires in organic soils",
  518. "info": {"gases": ["CO2", "N2O", "CH4"]},
  519. }
  520. # 6 fires
  521. categories["6"] = {
  522. "title": "Fires",
  523. "comment": "Fires",
  524. "info": {"gases": ["CO2", "N2O", "CH4"]},
  525. "children": [["6.A", "6.B", "6.C"]],
  526. }
  527. # 7 pre and post production
  528. pre_post_production_categories = [
  529. "Fertilizers Manufacturing",
  530. "Food Transport",
  531. "Food Retail",
  532. "Food Household Consumption",
  533. "Solid Food Waste",
  534. "Domestic Wastewater",
  535. "Industrial Wastewater",
  536. "Incineration",
  537. "Pre- and Post- Production",
  538. "Energy Use (Pre- and Post-Production)",
  539. "Agrifood Systems Waste Disposal",
  540. "Cold Chain F-Gas",
  541. "Pesticides Manufacturing",
  542. "Food Processing",
  543. "Food Packaging",
  544. ]
  545. pre_post_production_categories_codes = ["7." + i for i in "ABCDEFGHIJKLMNO"]
  546. pre_post_production_categories_gases = [
  547. ["CO2", "N2O", "KYOTOGHG (AR5GWP100)"],
  548. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],
  549. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],
  550. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],
  551. ["KYOTOGHG (AR5GWP100)", "CH4"],
  552. ["KYOTOGHG (AR5GWP100)", "CH4", "N2O"],
  553. ["KYOTOGHG (AR5GWP100)", "CH4", "N2O"],
  554. ["CO2", "KYOTOGHG (AR5GWP100)"], # incineration
  555. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],
  556. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"],
  557. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"],
  558. ["FGASES (AR5GWP100)"],
  559. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"],
  560. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)", "FGASES (AR5GWP100)"],
  561. ["CO2", "CH4", "N2O", "KYOTOGHG (AR5GWP100)"],
  562. ]
  563. for cat_name, code, gases in zip(
  564. pre_post_production_categories,
  565. pre_post_production_categories_codes,
  566. pre_post_production_categories_gases,
  567. ):
  568. categories[code] = {
  569. "title": cat_name,
  570. "comment": cat_name,
  571. "info": {"gases": gases},
  572. }
  573. categories["7"] = {
  574. "title": "Pre and post agricultural production",
  575. "comment": "Pre and post agricultural production",
  576. "info": {
  577. "gases": [
  578. "CO2",
  579. "CH4",
  580. "N2O",
  581. "KYOTOGHG (AR5GWP100)",
  582. "FGASES (AR5GWP100)",
  583. ],
  584. },
  585. "children": [pre_post_production_categories_codes],
  586. }
  587. spec["categories"] = categories
  588. fao_cats = cc.HierarchicalCategorization.from_spec(spec.copy())
  589. # run print(fao_cats.show_as_tree())
  590. fao_cats.to_python("FAO.py")
  591. fao_cats.to_yaml("FAO.yaml")
  592. pass