|
@@ -35,7 +35,7 @@ def test_conversion_from_FAO_to_IPCC2006_PRIMAP():
|
|
|
gases = ["CO2", "CH4", "N2O"]
|
|
|
for var in gases:
|
|
|
conv[var] = cc.Conversion.from_csv(
|
|
|
- f"conversion_FAO_IPPCC2006_PRIMAP_{var}.csv", cats=cats
|
|
|
+ f"../../conversion_FAO_IPPCC2006_PRIMAP_{var}.csv", cats=cats
|
|
|
)
|
|
|
|
|
|
|
|
@@ -130,32 +130,27 @@ def test_conversion_from_FAO_to_IPCC2006_PRIMAP():
|
|
|
result_proc = result.pr.add_aggregates_coordinates(agg_info=agg_info)
|
|
|
|
|
|
result_proc_if = result_proc.pr.to_interchange_format()
|
|
|
- assert result_proc_if
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ release_name = "v2024-11-14"
|
|
|
+ output_filename = f"FAOSTAT_Agrifood_system_emissions_{release_name}"
|
|
|
+ output_folder = extracted_data_path / release_name
|
|
|
+
|
|
|
+ if not output_folder.exists():
|
|
|
+ output_folder.mkdir()
|
|
|
+
|
|
|
+ filepath = output_folder / (output_filename + ".csv")
|
|
|
+ print(f"Writing processed primap2 file to {filepath}")
|
|
|
+ pm2.pm2io.write_interchange_format(
|
|
|
+ filepath,
|
|
|
+ result_proc_if,
|
|
|
+ )
|
|
|
+
|
|
|
+ compression = dict(zlib=True, complevel=9)
|
|
|
+ encoding = {var: compression for var in result_proc.data_vars}
|
|
|
+ filepath = output_folder / (output_filename + ".nc")
|
|
|
+ print(f"Writing netcdf file to {filepath}")
|
|
|
+ result_proc.pr.to_netcdf(filepath, encoding=encoding)
|
|
|
|
|
|
|
|
|
def test_read(tmp_path):
|