Skip to content

Commit

Permalink
Develop (#56)
Browse files Browse the repository at this point in the history
* Readme Update:
Changed typo in Purpose and Scope section from NH4 to CH4.

* Update from previous Curtis driver to 1km drivers:
-Updates drivers path and pattern in constants_and_names.py and constants.h
-Added hard commodites flu value and new drivers class output paths to constants.h
-Added new drivers classes (hard commodites and other natural disturbances) to preprocessing steps in calc_gross_emissions_generic.cpp (lines 1 - 530).
-TODO: Update equations in calc_gross_emissions_generic.cpp from line 530 on.
-Changed permanant agriculture (formerly commodity driven deforestation) flu vlaues in flu_val.cpp with updated values from IPCC 2019 Refinement for boreal/ temperate and tropical forests.
-TODO: Decide what flu value to use for (climate_zone == 9) // Montane
-TODO: Update equations.cpp file with information for new drivers.

* Commit:
- Changed drivers path and patterns and Flu values back to 10km drivers inputs for testing purposes
- Deleted calc_gross_emissions_no_shifting_ag.cpp and calc_gross_emissions_convert_to_grassland.cpp since they are outdated and no longer being used for sensitivity analysis
- Updated dataset, gdal, etc names in calc_gross_emissions_generic.cpp from int values to descriptive names (e.g. INGDAL1 >> INGDAL_AGC)
- Added empty objects for CH4only and N2O only output but they have not been added to the decision tree/ calculation yet

* Commit:
- Changed python files for gross emission calculations
- Successfully ran 1 tile locally using 10km drivers with new c++ code for biomass_soil. Processing time was slightly longer than v1.3.2 (6:42 vs 8:50) so pushing these changes so that I can test biomass_soil for 00N_000E on a spot machine.
- TODOs: QC output then update soil_only c++ code and run with soil_only version

* Commit:
- Ran previous commit in EC2 instance and calc_gross_emissions_generic.cpp couldn't compile so I realized that the previous local run was from the old calc_gross_emissions_generic.exe
- Fixed bugs so that new calc_gross_emissions_generic.cpp can compile
- Successfully ran 1 tile with -sp then 3 tiles with mp locally using 10km drivers with new c++ code for biomass_soil. Processing time was approx 4 minutes faster than old code (5:05 vs 8:50).
- TODOs: QC output then update soil_only c++ code and run with soil_only version

* Commit:
- Successfully ran calc_gross_emissions_soil_only.cpp for 00N_110E with -sp using 10km drivers

* Commit:
- Changing emis_run_date_biomass_soil in constants_and_names.py to '20248888' for full ec2 run

* Commit:
- In constants_and_names.py, updated version to 1.4.0, changed drivers to 1km drivers and deleted driver-specific emissions output
- In constants.h, changed drivers to 1km drivers and deleted driver-specific emissions output
- In flu_val.cpp, updated flu values for 1km drivers. Note: Currently using averages for "montane" climate zone, but in the future we will reclassify "montane" as "dry" or "moist/wet" and use those values instead of using averages.
- In calc_gross_emissions_generic.cpp and calc_gross_emissions_soil_only.cpp, updated decision tree for permanent agriculture, shifting cultivation, forest management, wildfire, and settlements & infrastructure. Updated non-co2, fire emissions equation for forest management and wildfire to include litter and deadwood.
TODO: Still need to update decision tree and node codes for  hard commodities, other natural disturbances, and no driver. Also need to update equation.cpp.

* Commit:
- Updated calc_gross_emissions_generic.cpp, calc_gross_emissions_soil_only.cpp, and node codes with updated decision tree for hard commodities, other natural disturbances, and no driver. Added commented out code w/ TODOs to split non co2 emissions into CH4 only and N2O only.
- Updated constants_and_names.py with dir and pattern for soil_only CH4_only and N2O_only outputs to use after splitting non co2 emissions.
- Updated equations.cpp with new drivers classes. Changed combustion factor for other natural disturbances/ no drivers to boreal = 0.34 and temperate = 0.45. Added commented out code w/ TODOs to split non co2 emissions into CH4 only and N2O only. Q: How many sig figs to use for peat_drain_annual_CH4_only and peat_drain_annual_N2O_only
- Added commented out code w/ TODOs to split non co2 emissions into CH4 only and N2O only in  mp_calculate_gross_emissions.py.

* Commit:
- Fixed type issue (non_soil_bgc_c[x] to non_soil_bgc_c). calc_gross_emissions_generic.cpp compiles correctly now. calc_gross_emissions_soil_only.cpp also compiles

* Commit:
- Updated run_full_model.py to run test tiles with master script on spot machine from emissions stage onwards using new drivers

* Commit:
- Updated run_full_model.py to run test tiles with master script on spot machine from emissions stage onwards using new drivers

* Commit:
- Deleted 10km drivers path/pattern and driver-specific outputs for soil_only mode in constants_and_names.py.
- Added a comment in calc_gross_emissions_generic.cpp, calc_gross_emissions_soil_only.cpp, and equations.cpp where peatburn_CH4_only is intitialized that there are no N2O emissions from burning peat. That way, we don't wonder in the future why N2O emissions has one less term than CH4 emissions (i.e. no peatburn_N2O_only)
- Added note about making unassigned driver the same as other natural disturbances in calc_gross_emissions_generic.cpp and calc_gross_emissions_soil_only.cpp
- Added link to the carbon_budget_flowchart.pptx at the top of the constants.h, equations.cpp, and flu_val.cpp since all three files use inputs from those slides.
- Added note to constants.h and flu_val.cpp that the function in flu_val.cpp is specifically for the permanent agriculture driver
- Updated peat_drain_annual_non_CO2 to 2 significant figures in equations.cpp
Both the calc_gross_emissions_generic.cpp and calc_gross_emissions_soil_only.cpp compile without any errors

* Commit:
- Updated all relevant files to split the non-co2 emissions into CH4-only and N2O-only emissions output. Both the calc_gross_emissions_generic.cpp and the calc_gross_emissions_soil_only.cpp files compile correctly.

* Commit:
- Updated emis_run_date in constants_and_names.py to run updated output with 1km drivers and seperate output for CH4 and N2O

* Commit:
- Updated flux output dates in constants_and_names.py to run updated output with 1km drivers and seperate output for CH4 and N2O (forgot to include in last commit)

* Commit:
- During the full tile run, got the following error when trying to download the 1km tiles:"An error occurred (AccessDenied) when calling the GetObject operation: Access Denied". Troubleshooted in a small ec2 instance and realized that the --no-sign-request flag in the s3_folder_download utility was causing the issue. Added an additional if statement in the s3_folder_download utility without the --no-sign-request flag so that driver tiles can be downloaded.
- soil_only CH4 and N2O rasters were not being uploaded to s3 even though they were created during the mode run. Realized that the upload tile step was looking for tiles with "gross_emis_ch4_only_all_drivers_Mg_CO2e_ha_soil_only_2001_23 pattern" but the tiles being created by the C++ code had pattern "gross_emis_CH4_only_all_drivers_Mg_CO2e_ha_soil_only_2001_23 pattern" (ie capitalized GHG). Changed pattern_gross_emis_ch4_only_all_drivers_soil_only and pattern_gross_emis_n2o_only_all_drivers_soil_only in constants_and_names.py from lower cased ch4 and n2o to capitalized CH4 and N2O.

* Commit:
- Changed drivers path and pattern in constants_and_names.py and constants.h from 20241004 to 20241121

* Update readme.md

---------

Co-authored-by: dagibbs22 <[email protected]>
  • Loading branch information
melrose-wri and dagibbs22 authored Dec 19, 2024
1 parent e720247 commit f8348b8
Show file tree
Hide file tree
Showing 16 changed files with 2,326 additions and 3,803 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ model_output/

flux_model_log*txt

/analyses/ESSD_figures/ipcc_flux_bar_chart.py

docker-compose.yaml
89 changes: 31 additions & 58 deletions constants_and_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
######## ########

# Model version
version = '1.3.2'
version = '1.4.0'
version_filename = version.replace('.', '_')


Expand Down Expand Up @@ -332,10 +332,11 @@
plant_pre_2000_processed_dir = os.path.join(s3_base_dir, 'other_emissions_inputs/IDN_MYS_plantation_pre_2000/processed/20200724/')

# Drivers of tree cover loss
drivers_raw_dir = os.path.join(s3_base_dir, 'other_emissions_inputs/tree_cover_loss_drivers/raw/')
pattern_drivers_raw = 'Goode_FinalClassification_2023_wgs84_v20240402.tif'
pattern_drivers = 'tree_cover_loss_driver_processed'
drivers_processed_dir = os.path.join(s3_base_dir, 'other_emissions_inputs/tree_cover_loss_drivers/processed/drivers_2023/20240402/')

drivers_raw_dir = 's3://gfw2-data/drivers_of_loss/1_km/raw/20241121/'
pattern_drivers_raw = 'drivers_of_TCL_1_km_20241121.tif'
pattern_drivers = 'drivers_of_TCL_1_km_20241121'
drivers_processed_dir = 's3://gfw2-data/drivers_of_loss/1_km/processed/20241121/'

# Tree cover loss from fires
TCLF_raw_dir = 's3://gfw2-data/forest_change/hansen_2023_fire/'
Expand Down Expand Up @@ -646,66 +647,32 @@
### Emissions from biomass and soil (all carbon emitted_pools)

# Date to include in the output directory
emis_run_date_biomass_soil = '20240402'

# pattern_gross_emis_commod_biomass_soil = f'gross_emis_commodity_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
pattern_gross_emis_commod_biomass_soil = f'gross_emis_commodity_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_commod_biomass_soil_dir = f'{s3_base_dir}gross_emissions/commodities/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_forestry_biomass_soil = f'gross_emis_forestry_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_forestry_biomass_soil_dir = f'{s3_base_dir}gross_emissions/forestry/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_shifting_ag_biomass_soil = f'gross_emis_shifting_ag_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_shifting_ag_biomass_soil_dir = f'{s3_base_dir}gross_emissions/shifting_ag/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_urban_biomass_soil = f'gross_emis_urbanization_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_urban_biomass_soil_dir = f'{s3_base_dir}gross_emissions/urbanization/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_wildfire_biomass_soil = f'gross_emis_wildfire_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_wildfire_biomass_soil_dir = f'{s3_base_dir}gross_emissions/wildfire/biomass_soil/standard/{emis_run_date_biomass_soil}/'
emis_run_date_biomass_soil = '20241122'
pattern_gross_emis_all_gases_all_drivers_biomass_soil = f'gross_emis_all_gases_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/all_gases/biomass_soil/standard/full_extent/per_hectare/{emis_run_date_biomass_soil}/'

pattern_gross_emis_no_driver_biomass_soil = f'gross_emis_no_driver_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_no_driver_biomass_soil_dir = f'{s3_base_dir}gross_emissions/no_driver/biomass_soil/standard/{emis_run_date_biomass_soil}/'
pattern_gross_emis_all_gases_all_drivers_biomass_soil_forest_extent = f'gross_emis_all_gases_all_drivers_Mg_CO2e_ha_biomass_soil_forest_extent_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_forest_extent_dir = f'{s3_base_dir}gross_emissions/all_drivers/all_gases/biomass_soil/standard/forest_extent/per_hectare/{emis_run_date_biomass_soil}/'

pattern_gross_emis_co2_only_all_drivers_biomass_soil = f'gross_emis_CO2_only_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_co2_only_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/CO2_only/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_non_co2_all_drivers_biomass_soil = f'gross_emis_non_CO2_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_non_co2_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/non_CO2/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_all_gases_all_drivers_biomass_soil = f'gross_emis_all_gases_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/all_gases/biomass_soil/standard/full_extent/per_hectare/{emis_run_date_biomass_soil}/'
pattern_gross_emis_ch4_only_all_drivers_biomass_soil = f'gross_emis_CH4_only_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_ch4_only_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/CH4_only/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_all_gases_all_drivers_biomass_soil_forest_extent = f'gross_emis_all_gases_all_drivers_Mg_CO2e_ha_biomass_soil_forest_extent_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_forest_extent_dir = f'{s3_base_dir}gross_emissions/all_drivers/all_gases/biomass_soil/standard/forest_extent/per_hectare/{emis_run_date_biomass_soil}/'
pattern_gross_emis_n2o_only_all_drivers_biomass_soil = f'gross_emis_N2O_only_all_drivers_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
gross_emis_n2o_only_all_drivers_biomass_soil_dir = f'{s3_base_dir}gross_emissions/all_drivers/N2O_only/biomass_soil/standard/{emis_run_date_biomass_soil}/'

pattern_gross_emis_nodes_biomass_soil = f'gross_emis_decision_tree_nodes_biomass_soil_2001_{loss_years}'
gross_emis_nodes_biomass_soil_dir = f'{s3_base_dir}gross_emissions/decision_tree_nodes/biomass_soil/standard/{emis_run_date_biomass_soil}/'

### Emissions from soil only

# Date to include in the output directory
emis_run_date_soil_only = '20240402'


pattern_gross_emis_commod_soil_only = f'gross_emis_commodity_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_commod_soil_only_dir = f'{s3_base_dir}gross_emissions/commodities/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_forestry_soil_only = f'gross_emis_forestry_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_forestry_soil_only_dir = f'{s3_base_dir}gross_emissions/forestry/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_shifting_ag_soil_only = f'gross_emis_shifting_ag_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_shifting_ag_soil_only_dir = f'{s3_base_dir}gross_emissions/shifting_ag/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_urban_soil_only = f'gross_emis_urbanization_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_urban_soil_only_dir = f'{s3_base_dir}gross_emissions/urbanization/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_wildfire_soil_only = f'gross_emis_wildfire_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_wildfire_soil_only_dir = f'{s3_base_dir}gross_emissions/wildfire/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_no_driver_soil_only = f'gross_emis_no_driver_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_no_driver_soil_only_dir = f'{s3_base_dir}gross_emissions/no_driver/soil_only/standard/{emis_run_date_soil_only}/'

emis_run_date_soil_only = '20241122'
pattern_gross_emis_all_gases_all_drivers_soil_only = f'gross_emis_all_gases_all_drivers_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_all_gases_all_drivers_soil_only_dir = f'{s3_base_dir}gross_emissions/all_drivers/all_gases/soil_only/standard/{emis_run_date_soil_only}/'

Expand All @@ -715,6 +682,12 @@
pattern_gross_emis_non_co2_all_drivers_soil_only = f'gross_emis_non_CO2_all_drivers_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_non_co2_all_drivers_soil_only_dir = f'{s3_base_dir}gross_emissions/all_drivers/non_CO2/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_ch4_only_all_drivers_soil_only = f'gross_emis_CH4_only_all_drivers_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_ch4_only_all_drivers_soil_only_dir = f'{s3_base_dir}gross_emissions/all_drivers/CH4_only/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_n2o_only_all_drivers_soil_only = f'gross_emis_N2O_only_all_drivers_Mg_CO2e_ha_soil_only_2001_{loss_years}'
gross_emis_n2o_only_all_drivers_soil_only_dir = f'{s3_base_dir}gross_emissions/all_drivers/N2O_only/soil_only/standard/{emis_run_date_soil_only}/'

pattern_gross_emis_nodes_soil_only = f'gross_emis_decision_tree_nodes_soil_only_2001_{loss_years}'
gross_emis_nodes_soil_only_dir = f'{s3_base_dir}gross_emissions/decision_tree_nodes/soil_only/standard/{emis_run_date_soil_only}/'

Expand All @@ -724,39 +697,39 @@

# Net emissions for all forest types and all carbon emitted_pools in all pixels
pattern_net_flux = f'net_flux_Mg_CO2e_ha_biomass_soil_2001_{loss_years}'
net_flux_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/full_extent/per_hectare/20240402/')
net_flux_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/full_extent/per_hectare/20241122/')

# Net emissions for all forest types and all carbon emitted_pools in forest extent
pattern_net_flux_forest_extent = f'net_flux_Mg_CO2e_ha_biomass_soil_forest_extent_2001_{loss_years}'
net_flux_forest_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/forest_extent/per_hectare/20240402/')
net_flux_forest_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/forest_extent/per_hectare/20241122/')


### Per pixel model outputs
######

# Gross removals per pixel in all pixels
pattern_cumul_gain_AGCO2_BGCO2_all_types_per_pixel_full_extent = f'gross_removals_AGCO2_BGCO2_Mg_pixel_all_forest_types_full_extent_2001_{loss_years}'
cumul_gain_AGCO2_BGCO2_all_types_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'gross_removals_AGCO2_BGCO2_all_forest_types/standard/full_extent/per_pixel/20240308/')
cumul_gain_AGCO2_BGCO2_all_types_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'gross_removals_AGCO2_BGCO2_all_forest_types/standard/full_extent/per_pixel/20241122/')

# Gross removals per pixel in forest extent
pattern_cumul_gain_AGCO2_BGCO2_all_types_per_pixel_forest_extent = f'gross_removals_AGCO2_BGCO2_Mg_pixel_all_forest_types_forest_extent_2001_{loss_years}'
cumul_gain_AGCO2_BGCO2_all_types_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'gross_removals_AGCO2_BGCO2_all_forest_types/standard/forest_extent/per_pixel/20240308/')
cumul_gain_AGCO2_BGCO2_all_types_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'gross_removals_AGCO2_BGCO2_all_forest_types/standard/forest_extent/per_pixel/20241122/')

# Gross emissions per pixel in all pixels
pattern_gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_full_extent = f'gross_emis_all_gases_all_drivers_Mg_CO2e_pixel_biomass_soil_full_extent_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'gross_emissions/all_drivers/all_gases/biomass_soil/standard/full_extent/per_pixel/20240402/')
gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'gross_emissions/all_drivers/all_gases/biomass_soil/standard/full_extent/per_pixel/20241122/')

# Gross emissions per pixel in forest extent
pattern_gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_forest_extent = f'gross_emis_all_gases_all_drivers_Mg_CO2e_pixel_biomass_soil_forest_extent_2001_{loss_years}'
gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'gross_emissions/all_drivers/all_gases/biomass_soil/standard/forest_extent/per_pixel/20240402/')
gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'gross_emissions/all_drivers/all_gases/biomass_soil/standard/forest_extent/per_pixel/20241122/')

# Net flux per pixel in all pixels
pattern_net_flux_per_pixel_full_extent = f'net_flux_Mg_CO2e_pixel_biomass_soil_full_extent_2001_{loss_years}'
net_flux_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/full_extent/per_pixel/20240402/')
net_flux_per_pixel_full_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/full_extent/per_pixel/20241122/')

# Net flux per pixel in forest extent
pattern_net_flux_per_pixel_forest_extent = f'net_flux_Mg_CO2e_pixel_biomass_soil_forest_extent_2001_{loss_years}'
net_flux_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/forest_extent/per_pixel/20240402/')
net_flux_per_pixel_forest_extent_dir = os.path.join(s3_base_dir, 'net_flux_all_forest_types_all_drivers/biomass_soil/standard/forest_extent/per_pixel/20241122/')


### 4x4 km aggregation tiles for mapping
Expand All @@ -766,7 +739,7 @@
pattern_aggreg_sensit_perc_diff = f'net_flux_0_04deg_modelv{version_filename}_perc_diff_std'
pattern_aggreg_sensit_sign_change = f'net_flux_0_04deg_modelv{version_filename}_sign_change_std'

output_aggreg_dir = os.path.join(s3_base_dir, '0_04deg_output_aggregation/biomass_soil/standard/20240402/')
output_aggreg_dir = os.path.join(s3_base_dir, '0_04deg_output_aggregation/biomass_soil/standard/20241122/')



Expand Down
Empty file.
17 changes: 9 additions & 8 deletions emissions/calculate_gross_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ def calc_emissions(tile_id, emitted_pools, folder):
:param emitted_pools: Whether emissions from soil only is calculated, or emissions from biomass and soil.
Options are: soil_only or biomass_soil.
:param folder:
:return: 10 tiles: 6 tiles with emissions for each driver; CO2 emissions from all drivers;
non-CO2 emissions from all drivers; all gases (CO2 and non-CO2 from all drivers);
emissions decision tree nodes (used for QC).
:return: 6 tiles -
1. all gases (CO2, CH4 and N2O from all drivers);
2. CO2 emissions from all drivers;
3. non-CO2 emissions from all drivers (CH4 and N2O from all drivers);
4. CH4 emissions from all drivers;
5. N2O emissions from all drivers;
6. emissions decision tree nodes (used for QC).
Units: Mg CO2e/ha over entire model period.
"""

Expand All @@ -27,14 +31,11 @@ def calc_emissions(tile_id, emitted_pools, folder):
uu.check_memory()

# Runs the correct c++ script given the emitted_pools (biomass+soil or soil_only) and model type selected.
# soil_only, no_shiftin_ag, and convert_to_grassland have special gross emissions C++ scripts.
# soil_only has special gross emissions C++ scripts.
# The other sensitivity analyses and the standard model all use the same gross emissions C++ script.
if (emitted_pools == 'soil_only') & (cn.SENSIT_TYPE == 'std'):
cmd = [f'{cn.c_emis_compile_dst}/calc_gross_emissions_soil_only.exe', tile_id, cn.SENSIT_TYPE, folder]

elif (emitted_pools == 'biomass_soil') & (cn.SENSIT_TYPE in ['convert_to_grassland', 'no_shifting_ag']):
cmd = [f'{cn.c_emis_compile_dst}/calc_gross_emissions_{cn.SENSIT_TYPE}.exe', tile_id, cn.SENSIT_TYPE, folder]

# This C++ script has an extra argument that names the input carbon emitted_pools and output emissions correctly
elif (emitted_pools == 'biomass_soil') & (cn.SENSIT_TYPE not in ['no_shifting_ag', 'convert_to_grassland']):
cmd = [f'{cn.c_emis_compile_dst}/calc_gross_emissions_generic.exe', tile_id, cn.SENSIT_TYPE, folder]
Expand All @@ -46,7 +47,7 @@ def calc_emissions(tile_id, emitted_pools, folder):


# Identifies which pattern to use for counting tile completion
pattern = cn.pattern_gross_emis_commod_biomass_soil
pattern = cn.pattern_gross_emis_co2_only_all_drivers_biomass_soil
if (emitted_pools == 'biomass_soil') & (cn.SENSIT_TYPE == 'std'):
pattern = pattern

Expand Down
Loading

0 comments on commit f8348b8

Please sign in to comment.