diff --git a/analyses/aggregate_results_to_4_km.py b/analyses/aggregate_results_to_4_km.py index 074b807d..a97a4db6 100644 --- a/analyses/aggregate_results_to_4_km.py +++ b/analyses/aggregate_results_to_4_km.py @@ -13,7 +13,7 @@ For sensitivity analysis runs, it only processes outputs which actually have a sensitivity analysis version. The user has to supply a tcd threshold for which forest pixels to include in the results. Defaults to cn.canopy_threshold. For sensitivity analysis, the s3 folder with the aggregations for the standard model must be specified. -sample command: python mp_aggregate_results_to_4_km.py -tcd 30 -t no_shifting_ag -sagg s3://gfw2-data/climate/carbon_model/0_4deg_output_aggregation/biomass_soil/standard/20200901/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200901.tif +sample command: python mp_aggregate_results_to_4_km.py -tcd 30 -t no_shifting_ag -sagg s3://gfw2-data/climate/carbon_model/0_04deg_output_aggregation/biomass_soil/standard/20200901/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200901.tif ''' @@ -71,7 +71,7 @@ def aggregate(tile, thresh, sensit_type, no_upload): #2D array in which the 0.04x0.04 deg aggregated sums will be stored sum_array = np.zeros([250,250], 'float32') - out_raster = "{0}_{1}_0_4deg.tif".format(tile_id, tile_type) + out_raster = "{0}_{1}_0_04deg.tif".format(tile_id, tile_type) uu.check_memory() @@ -185,7 +185,7 @@ def aggregate(tile, thresh, sensit_type, no_upload): # aggregated.close() # Prints information about the tile that was just processed - uu.end_of_fx_summary(start, tile_id, '{}_0_4deg'.format(tile_type), no_upload) + uu.end_of_fx_summary(start, tile_id, '{}_0_04deg'.format(tile_type), no_upload) # Calculates the percent difference between the standard model's net flux output diff --git a/analyses/download_tile_set.py b/analyses/download_tile_set.py index 87d90828..9d174d37 100644 --- a/analyses/download_tile_set.py +++ b/analyses/download_tile_set.py @@ -27,26 +27,26 @@ def download_tile_set(sensit_type, tile_id_list): os.chdir(wd) download_dict = { - # cn.model_extent_dir: [cn.pattern_model_extent], - # cn.age_cat_IPCC_dir: [cn.pattern_age_cat_IPCC], - # cn.annual_gain_AGB_IPCC_defaults_dir: [cn.pattern_annual_gain_AGB_IPCC_defaults], - # cn.annual_gain_BGB_IPCC_defaults_dir: [cn.pattern_annual_gain_BGB_IPCC_defaults], - # cn.stdev_annual_gain_AGB_IPCC_defaults_dir: [cn.pattern_stdev_annual_gain_AGB_IPCC_defaults], - # cn.removal_forest_type_dir: [cn.pattern_removal_forest_type], - # cn.annual_gain_AGC_all_types_dir: [cn.pattern_annual_gain_AGC_all_types], - # cn.annual_gain_BGC_all_types_dir: [cn.pattern_annual_gain_BGC_all_types], - # cn.annual_gain_AGC_BGC_all_types_dir: [cn.pattern_annual_gain_AGC_BGC_all_types], - # cn.stdev_annual_gain_AGC_all_types_dir: [cn.pattern_stdev_annual_gain_AGC_all_types], - # cn.gain_year_count_dir: [cn.pattern_gain_year_count], - # cn.cumul_gain_AGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_all_types], - # cn.cumul_gain_BGCO2_all_types_dir: [cn.pattern_cumul_gain_BGCO2_all_types], - # cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], - # cn.AGC_emis_year_dir: [cn.pattern_AGC_emis_year], - # cn.BGC_emis_year_dir: [cn.pattern_BGC_emis_year], - # cn.deadwood_emis_year_2000_dir: [cn.pattern_deadwood_emis_year_2000], - # cn.litter_emis_year_2000_dir: [cn.pattern_litter_emis_year_2000], - # cn.soil_C_emis_year_2000_dir: [cn.pattern_soil_C_emis_year_2000], - # cn.total_C_emis_year_dir: [cn.pattern_total_C_emis_year], + cn.model_extent_dir: [cn.pattern_model_extent], + cn.age_cat_IPCC_dir: [cn.pattern_age_cat_IPCC], + cn.annual_gain_AGB_IPCC_defaults_dir: [cn.pattern_annual_gain_AGB_IPCC_defaults], + cn.annual_gain_BGB_IPCC_defaults_dir: [cn.pattern_annual_gain_BGB_IPCC_defaults], + cn.stdev_annual_gain_AGB_IPCC_defaults_dir: [cn.pattern_stdev_annual_gain_AGB_IPCC_defaults], + cn.removal_forest_type_dir: [cn.pattern_removal_forest_type], + cn.annual_gain_AGC_all_types_dir: [cn.pattern_annual_gain_AGC_all_types], + cn.annual_gain_BGC_all_types_dir: [cn.pattern_annual_gain_BGC_all_types], + cn.annual_gain_AGC_BGC_all_types_dir: [cn.pattern_annual_gain_AGC_BGC_all_types], + cn.stdev_annual_gain_AGC_all_types_dir: [cn.pattern_stdev_annual_gain_AGC_all_types], + cn.gain_year_count_dir: [cn.pattern_gain_year_count], + cn.cumul_gain_AGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_all_types], + cn.cumul_gain_BGCO2_all_types_dir: [cn.pattern_cumul_gain_BGCO2_all_types], + cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], + cn.AGC_emis_year_dir: [cn.pattern_AGC_emis_year], + cn.BGC_emis_year_dir: [cn.pattern_BGC_emis_year], + cn.deadwood_emis_year_2000_dir: [cn.pattern_deadwood_emis_year_2000], + cn.litter_emis_year_2000_dir: [cn.pattern_litter_emis_year_2000], + cn.soil_C_emis_year_2000_dir: [cn.pattern_soil_C_emis_year_2000], + cn.total_C_emis_year_dir: [cn.pattern_total_C_emis_year], # cn.gross_emis_commod_biomass_soil_dir: [cn.pattern_gross_emis_commod_biomass_soil], # cn.gross_emis_shifting_ag_biomass_soil_dir: [cn.pattern_gross_emis_shifting_ag_biomass_soil], diff --git a/analyses/mp_aggregate_results_to_4_km.py b/analyses/mp_aggregate_results_to_4_km.py index a4bfb3dd..e8713e1b 100644 --- a/analyses/mp_aggregate_results_to_4_km.py +++ b/analyses/mp_aggregate_results_to_4_km.py @@ -13,7 +13,7 @@ For sensitivity analysis runs, it only processes outputs which actually have a sensitivity analysis version. The user has to supply a tcd threshold for which forest pixels to include in the results. Defaults to cn.canopy_threshold. For sensitivity analysis, the s3 folder with the aggregations for the standard model must be specified. -sample command: python mp_aggregate_results_to_4_km.py -tcd 30 -t no_shifting_ag -sagg s3://gfw2-data/climate/carbon_model/0_4deg_output_aggregation/biomass_soil/standard/20200901/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200901.tif +sample command: python mp_aggregate_results_to_4_km.py -tcd 30 -t no_shifting_ag -sagg s3://gfw2-data/climate/carbon_model/0_04deg_output_aggregation/biomass_soil/standard/20200901/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200901.tif ''' @@ -38,9 +38,9 @@ def mp_aggregate_results_to_4_km(sensit_type, thresh, tile_id_list, std_net_flux # Files to download for this script download_dict = { - # cn.annual_gain_AGC_all_types_dir: [cn.pattern_annual_gain_AGC_all_types], - # cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], - # cn.gross_emis_all_gases_all_drivers_biomass_soil_dir: [cn.pattern_gross_emis_all_gases_all_drivers_biomass_soil], + cn.annual_gain_AGC_all_types_dir: [cn.pattern_annual_gain_AGC_all_types], + cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], + cn.gross_emis_all_gases_all_drivers_biomass_soil_dir: [cn.pattern_gross_emis_all_gases_all_drivers_biomass_soil], cn.net_flux_dir: [cn.pattern_net_flux] } @@ -110,7 +110,7 @@ def mp_aggregate_results_to_4_km(sensit_type, thresh, tile_id_list, std_net_flux # from https://stackoverflow.com/questions/12666897/removing-an-item-from-list-matching-a-substring tile_list = [i for i in tile_list if not ('hanson_2013' in i)] tile_list = [i for i in tile_list if not ('rewindow' in i)] - tile_list = [i for i in tile_list if not ('0_4deg' in i)] + tile_list = [i for i in tile_list if not ('0_04deg' in i)] tile_list = [i for i in tile_list if not ('.ovr' in i)] # tile_list = ['00N_070W_cumul_gain_AGCO2_BGCO2_t_ha_all_forest_types_2001_15_biomass_swap.tif'] # test tiles @@ -169,8 +169,8 @@ def mp_aggregate_results_to_4_km(sensit_type, thresh, tile_id_list, std_net_flux # aggregate_results_to_4_km.aggregate(tile, thresh, sensit_type, no_upload) # Makes a vrt of all the output 10x10 tiles (10 km resolution) - out_vrt = "{}_0_4deg.vrt".format(pattern) - os.system('gdalbuildvrt -tr 0.04 0.04 {0} *{1}_0_4deg*.tif'.format(out_vrt, pattern)) + out_vrt = "{}_0_04deg.vrt".format(pattern) + os.system('gdalbuildvrt -tr 0.04 0.04 {0} *{1}_0_04deg*.tif'.format(out_vrt, pattern)) # Creates the output name for the 10km map out_pattern = uu.name_aggregated_output(download_pattern_name, thresh, sensit_type) @@ -221,7 +221,7 @@ def mp_aggregate_results_to_4_km(sensit_type, thresh, tile_id_list, std_net_flux for tile_name in tile_list: tile_id = uu.get_tile_id(tile_name) os.remove('{0}_{1}_rewindow.tif'.format(tile_id, pattern)) - os.remove('{0}_{1}_0_4deg.tif'.format(tile_id, pattern)) + os.remove('{0}_{1}_0_04deg.tif'.format(tile_id, pattern)) # Need to delete rewindowed tiles so they aren't confused with the normal tiles for creation of supplementary outputs rewindow_list = glob.glob('*rewindow*tif') diff --git a/analyses/mp_create_supplementary_outputs.py b/analyses/mp_create_supplementary_outputs.py index b0137ea2..e08892d2 100644 --- a/analyses/mp_create_supplementary_outputs.py +++ b/analyses/mp_create_supplementary_outputs.py @@ -45,7 +45,7 @@ def mp_create_supplementary_outputs(sensit_type, tile_id_list, run_date = None, # Files to download for this script download_dict = { - # cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], + cn.cumul_gain_AGCO2_BGCO2_all_types_dir: [cn.pattern_cumul_gain_AGCO2_BGCO2_all_types], cn.gross_emis_all_gases_all_drivers_biomass_soil_dir: [cn.pattern_gross_emis_all_gases_all_drivers_biomass_soil], cn.net_flux_dir: [cn.pattern_net_flux] } diff --git a/constants_and_names.py b/constants_and_names.py index 307966ec..8b1fda7d 100644 --- a/constants_and_names.py +++ b/constants_and_names.py @@ -542,7 +542,7 @@ ### Emissions from soil only # Date to include in the output directory -emis_run_date_soil_only = '20220316' +emis_run_date_soil_only = '20220318' pattern_gross_emis_commod_soil_only = 'gross_emis_commodity_Mg_CO2e_ha_soil_only_2001_{}'.format(loss_years) gross_emis_commod_soil_only_dir = '{0}gross_emissions/commodities/soil_only/standard/{1}/'.format(s3_base_dir, emis_run_date_soil_only) @@ -618,11 +618,11 @@ ### 4x4 km aggregation tiles for mapping ###### -pattern_aggreg = '0_4deg_modelv{}'.format(version_filename) -pattern_aggreg_sensit_perc_diff = 'net_flux_0_4deg_modelv{}_perc_diff_std'.format(version_filename) -pattern_aggreg_sensit_sign_change = 'net_flux_0_4deg_modelv{}_sign_change_std'.format(version_filename) +pattern_aggreg = '0_04deg_modelv{}'.format(version_filename) +pattern_aggreg_sensit_perc_diff = 'net_flux_0_04deg_modelv{}_perc_diff_std'.format(version_filename) +pattern_aggreg_sensit_sign_change = 'net_flux_0_04deg_modelv{}_sign_change_std'.format(version_filename) -output_aggreg_dir = os.path.join(s3_base_dir, '0_4deg_output_aggregation/biomass_soil/standard/20220316/') +output_aggreg_dir = os.path.join(s3_base_dir, '0_04deg_output_aggregation/biomass_soil/standard/20220316/') diff --git a/readme.md b/readme.md index f3486edb..8fd62c1b 100644 --- a/readme.md +++ b/readme.md @@ -239,7 +239,7 @@ Run three tiles in biomass_swap sensitivity analysis; don't upload intermediates run model_extent stage; don't continue after that stage (no run-through); get carbon pools at time of loss; emissions from biomass and soil; compare aggregated outputs to specified file (although not used in this specific launch because only the first step runs): -`python run_full_model.py -nu -t biomass_swap -s model_extent -r false -d 20229999 -l 00N_000E,00N_110E,40N_90W -ce loss -p biomass_soil -tcd 30 -sagg s3://gfw2-data/climate/carbon_model/0_4deg_output_aggregation/biomass_soil/standard/20200914/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200914.tif -ln "Multi-tile test"` +`python run_full_model.py -nu -t biomass_swap -s model_extent -r false -d 20229999 -l 00N_000E,00N_110E,40N_90W -ce loss -p biomass_soil -tcd 30 -sagg s3://gfw2-data/climate/carbon_model/0_04deg_output_aggregation/biomass_soil/standard/20200914/net_flux_Mt_CO2e_biomass_soil_per_year_tcd30_0_4deg_modelv1_2_0_std_20200914.tif -ln "Multi-tile test"` ##### Running the emissions model diff --git a/removals/annual_gain_rate_IPCC_defaults.py b/removals/annual_gain_rate_IPCC_defaults.py index 32a7cef8..58676f67 100644 --- a/removals/annual_gain_rate_IPCC_defaults.py +++ b/removals/annual_gain_rate_IPCC_defaults.py @@ -19,7 +19,7 @@ def annual_gain_rate(tile_id, sensit_type, gain_table_dict, stdev_table_dict, ou # The key in the dictionary is the forest age category decision tree endpoints. age_dict = {0: 0, 1: 10000, 2: 20000, 3: 30000} - uu.print_log("Processing:", tile_id) + uu.print_log("Creating IPCC default biomass removals rates and standard deviation for {}".format(tile_id)) # Start time start = datetime.datetime.now() @@ -33,20 +33,18 @@ def annual_gain_rate(tile_id, sensit_type, gain_table_dict, stdev_table_dict, ou BGB_IPCC_default_gain_rate = '{0}_{1}.tif'.format(tile_id, output_pattern_list[1]) AGB_IPCC_default_gain_stdev = '{0}_{1}.tif'.format(tile_id, output_pattern_list[2]) - uu.print_log(" Creating IPCC default biomass removals rates and standard deviation for {}".format(tile_id)) - # Opens the input tiles if they exist. kips tile if either input doesn't exist. try: age_cat_src = rasterio.open(age_cat) - uu.print_log(" Age category tile found for {}".format(tile_id)) + uu.print_log(" Age category tile found for {}".format(tile_id)) except: - return uu.print_log(" No age category tile found for {}. Skipping tile.".format(tile_id)) + return uu.print_log(" No age category tile found for {}. Skipping tile.".format(tile_id)) try: cont_eco_src = rasterio.open(cont_eco) - uu.print_log(" Continent-ecozone tile found for {}".format(tile_id)) + uu.print_log(" Continent-ecozone tile found for {}".format(tile_id)) except: - return uu.print_log(" No continent-ecozone tile found for {}. Skipping tile.".format(tile_id)) + return uu.print_log(" No continent-ecozone tile found for {}. Skipping tile.".format(tile_id)) # Grabs metadata about the continent ecozone tile, like its location/projection/cellsize kwargs = cont_eco_src.meta diff --git a/removals/forest_age_category_IPCC.py b/removals/forest_age_category_IPCC.py index df6a36c4..df4a40e0 100644 --- a/removals/forest_age_category_IPCC.py +++ b/removals/forest_age_category_IPCC.py @@ -51,8 +51,6 @@ def forest_age_category(tile_id, gain_table_dict, pattern, sensit_type, no_uploa loss = '{0}_{1}.tif'.format(cn.pattern_loss, tile_id) uu.print_log("Using Hansen loss tile {0} for {1} model run".format(tile_id, sensit_type)) - uu.print_log(" Assigning age categories") - # Opens biomass tile with rasterio.open(model_extent) as model_extent_src: diff --git a/removals/gain_year_count_all_forest_types.py b/removals/gain_year_count_all_forest_types.py index f33c4938..847cbf4d 100644 --- a/removals/gain_year_count_all_forest_types.py +++ b/removals/gain_year_count_all_forest_types.py @@ -36,7 +36,7 @@ def create_gain_year_count_loss_only(tile_id, sensit_type, no_upload): uu.check_memory() if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in loss only pixel gain year count.".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in loss only pixel gain year count.".format(tile_id)) loss_calc = '--calc=(A>0)*(B==0)*(C>0)*(A-1)' loss_outfilename = '{}_growth_years_loss_only.tif'.format(tile_id) loss_outfilearg = '--outfile={}'.format(loss_outfilename) @@ -63,8 +63,9 @@ def create_gain_year_count_gain_only_standard(tile_id, sensit_type, no_upload): uu.check_memory() + # Need to check if loss tile exists because the calc string is depends on the presene/absence of the loss tile if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in gain only pixel gain year count.".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in gain only pixel gain year count.".format(tile_id)) gain_calc = '--calc=(A==0)*(B==1)*(C>0)*({}/2)'.format(cn.gain_years) gain_outfilename = '{}_growth_years_gain_only.tif'.format(tile_id) gain_outfilearg = '--outfile={}'.format(gain_outfilename) @@ -72,7 +73,7 @@ def create_gain_year_count_gain_only_standard(tile_id, sensit_type, no_upload): '--NoDataValue=0', '--overwrite', '--co', 'COMPRESS=DEFLATE', '--type', 'Byte', '--quiet'] uu.log_subprocess_output_full(cmd) else: - uu.print_log("No loss tile found for {}. Not using it for gain only pixel gain year count.".format(tile_id)) + uu.print_log(" No loss tile found for {}. Not using it for gain only pixel gain year count.".format(tile_id)) gain_calc = '--calc=(A==1)*(B>0)*({}/2)'.format(cn.gain_years) gain_outfilename = '{}_growth_years_gain_only.tif'.format(tile_id) gain_outfilearg = '--outfile={}'.format(gain_outfilename) @@ -98,7 +99,7 @@ def create_gain_year_count_gain_only_maxgain(tile_id, sensit_type, no_upload): uu.check_memory() if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in gain only pixel gain year count.".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in gain only pixel gain year count.".format(tile_id)) gain_calc = '--calc=(A==0)*(B==1)*(C>0)*({})'.format(cn.loss_years) gain_outfilename = '{}_growth_years_gain_only.tif'.format(tile_id) gain_outfilearg = '--outfile={}'.format(gain_outfilename) @@ -106,7 +107,7 @@ def create_gain_year_count_gain_only_maxgain(tile_id, sensit_type, no_upload): '--NoDataValue=0', '--overwrite', '--co', 'COMPRESS=DEFLATE', '--type', 'Byte', '--quiet'] uu.log_subprocess_output_full(cmd) else: - uu.print_log("No loss tile found for {}. Not using loss for gain only pixel gain year count.".format(tile_id)) + uu.print_log(" No loss tile found for {}. Not using loss for gain only pixel gain year count.".format(tile_id)) gain_calc = '--calc=(A==1)*(B>0)*({})'.format(cn.loss_years) gain_outfilename = '{}_growth_years_gain_only.tif'.format(tile_id) gain_outfilearg = '--outfile={}'.format(gain_outfilename) @@ -133,7 +134,7 @@ def create_gain_year_count_no_change_standard(tile_id, sensit_type, no_upload): uu.check_memory() if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in no change pixel gain year count.".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in no change pixel gain year count.".format(tile_id)) no_change_calc = '--calc=(A==0)*(B==0)*(C>0)*{}'.format(cn.loss_years) no_change_outfilename = '{}_growth_years_no_change.tif'.format(tile_id) no_change_outfilearg = '--outfile={}'.format(no_change_outfilename) @@ -141,7 +142,7 @@ def create_gain_year_count_no_change_standard(tile_id, sensit_type, no_upload): no_change_outfilearg, '--NoDataValue=0', '--overwrite', '--co', 'COMPRESS=DEFLATE', '--type', 'Byte', '--quiet'] uu.log_subprocess_output_full(cmd) else: - uu.print_log("No loss tile found for {}. Not using it for no change pixel gain year count.".format(tile_id)) + uu.print_log(" No loss tile found for {}. Not using it for no change pixel gain year count.".format(tile_id)) no_change_calc = '--calc=(A==0)*(B>0)*{}'.format(cn.loss_years) no_change_outfilename = '{}_growth_years_no_change.tif'.format(tile_id) no_change_outfilearg = '--outfile={}'.format(no_change_outfilename) @@ -200,7 +201,7 @@ def create_gain_year_count_loss_and_gain_standard(tile_id, sensit_type, no_uploa uu.check_memory() if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in loss and gain pixel gain year count.".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in loss and gain pixel gain year count.".format(tile_id)) loss_and_gain_calc = '--calc=((A>0)*(B==1)*(C>0)*((A-1)+floor(({}+1-A)/2)))'.format(cn.loss_years) loss_and_gain_outfilename = '{}_growth_years_loss_and_gain.tif'.format(tile_id) loss_and_gain_outfilearg = '--outfile={}'.format(loss_and_gain_outfilename) @@ -208,7 +209,7 @@ def create_gain_year_count_loss_and_gain_standard(tile_id, sensit_type, no_uploa loss_and_gain_outfilearg, '--NoDataValue=0', '--overwrite', '--co', 'COMPRESS=DEFLATE', '--type', 'Byte', '--quiet'] uu.log_subprocess_output_full(cmd) else: - uu.print_log("No loss tile found for {}. Skipping loss and gain pixel gain year count.".format(tile_id)) + uu.print_log(" No loss tile found for {}. Skipping loss and gain pixel gain year count.".format(tile_id)) # Prints information about the tile that was just processed @@ -229,7 +230,7 @@ def create_gain_year_count_loss_and_gain_maxgain(tile_id, sensit_type, no_upload uu.check_memory() if os.path.exists(loss): - uu.print_log("Loss tile found for {}. Using it in loss and gain pixel gain year count".format(tile_id)) + uu.print_log(" Loss tile found for {}. Using it in loss and gain pixel gain year count".format(tile_id)) loss_and_gain_calc = '--calc=((A>0)*(B==1)*(C>0)*({}-1))'.format(cn.loss_years) loss_and_gain_outfilename = '{}_growth_years_loss_and_gain.tif'.format(tile_id) loss_and_gain_outfilearg = '--outfile={}'.format(loss_and_gain_outfilename) @@ -237,7 +238,7 @@ def create_gain_year_count_loss_and_gain_maxgain(tile_id, sensit_type, no_upload loss_and_gain_outfilearg, '--NoDataValue=0', '--overwrite', '--co', 'COMPRESS=DEFLATE', '--type', 'Byte', '--quiet'] uu.log_subprocess_output_full(cmd) else: - uu.print_log("No loss tile found for {}. Skipping loss and gain pixel gain year count.".format(tile_id)) + uu.print_log(" No loss tile found for {}. Skipping loss and gain pixel gain year count.".format(tile_id)) # Prints information about the tile that was just processed uu.end_of_fx_summary(start, tile_id, 'growth_years_loss_and_gain', no_upload) @@ -246,7 +247,7 @@ def create_gain_year_count_loss_and_gain_maxgain(tile_id, sensit_type, no_upload # Merges the four gain year count tiles above to create a single gain year count tile def create_gain_year_count_merge(tile_id, pattern, sensit_type, no_upload): - uu.print_log("Merging loss, gain, no change, and loss/gain pixels into single raster for {}".format(tile_id)) + uu.print_log("Merging loss, gain, no change, and loss/gain pixels into single gain year count raster for {}".format(tile_id)) # start time start = datetime.datetime.now() @@ -277,26 +278,26 @@ def create_gain_year_count_merge(tile_id, pattern, sensit_type, no_upload): nodata=0 ) - uu.print_log(" No change tile exists for {} by default".format(tile_id)) + uu.print_log(" No change tile exists for {} by default".format(tile_id)) # Opens the other gain year count tiles. They may not exist for all other tiles. try: loss_only_gain_years_src = rasterio.open(loss_only_gain_years) - uu.print_log(" Loss only tile found for {}".format(tile_id)) + uu.print_log(" Loss only tile found for {}".format(tile_id)) except: - uu.print_log(" No loss only tile found for {}".format(tile_id)) + uu.print_log(" No loss only tile found for {}".format(tile_id)) try: gain_only_gain_years_src = rasterio.open(gain_only_gain_years) - uu.print_log(" Gain only tile found for {}".format(tile_id)) + uu.print_log(" Gain only tile found for {}".format(tile_id)) except: - uu.print_log(" No gain only tile found for {}".format(tile_id)) + uu.print_log(" No gain only tile found for {}".format(tile_id)) try: loss_and_gain_gain_years_src = rasterio.open(loss_and_gain_gain_years) - uu.print_log(" Loss and gain tile found for {}".format(tile_id)) + uu.print_log(" Loss and gain tile found for {}".format(tile_id)) except: - uu.print_log(" No loss and gain tile found for {}".format(tile_id)) + uu.print_log(" No loss and gain tile found for {}".format(tile_id)) # Opens the output tile, giving it the arguments of the input tiles gain_year_count_merged_dst = rasterio.open(gain_year_count_merged, 'w', **kwargs) diff --git a/run_full_model.py b/run_full_model.py index 1398fb24..f10b4099 100644 --- a/run_full_model.py +++ b/run_full_model.py @@ -227,44 +227,43 @@ def main (): cn.soil_C_full_extent_2000_dir, cn.total_C_2000_dir] # Adds the biomass_soil output directories or the soil_only output directories depending on the model run - if 'gross_emissions' in actual_stages: - if emitted_pools == 'biomass_soil': - output_dir_list = output_dir_list + [cn.gross_emis_commod_biomass_soil_dir, - cn.gross_emis_shifting_ag_biomass_soil_dir, - cn.gross_emis_forestry_biomass_soil_dir, - cn.gross_emis_wildfire_biomass_soil_dir, - cn.gross_emis_urban_biomass_soil_dir, - cn.gross_emis_no_driver_biomass_soil_dir, - cn.gross_emis_all_gases_all_drivers_biomass_soil_dir, - cn.gross_emis_co2_only_all_drivers_biomass_soil_dir, - cn.gross_emis_non_co2_all_drivers_biomass_soil_dir, - cn.gross_emis_nodes_biomass_soil_dir] + if emitted_pools == 'biomass_soil': + output_dir_list = output_dir_list + [cn.gross_emis_commod_biomass_soil_dir, + cn.gross_emis_shifting_ag_biomass_soil_dir, + cn.gross_emis_forestry_biomass_soil_dir, + cn.gross_emis_wildfire_biomass_soil_dir, + cn.gross_emis_urban_biomass_soil_dir, + cn.gross_emis_no_driver_biomass_soil_dir, + cn.gross_emis_all_gases_all_drivers_biomass_soil_dir, + cn.gross_emis_co2_only_all_drivers_biomass_soil_dir, + cn.gross_emis_non_co2_all_drivers_biomass_soil_dir, + cn.gross_emis_nodes_biomass_soil_dir] - else: - output_dir_list = output_dir_list + [cn.gross_emis_commod_soil_only_dir, - cn.gross_emis_shifting_ag_soil_only_dir, - cn.gross_emis_forestry_soil_only_dir, - cn.gross_emis_wildfire_soil_only_dir, - cn.gross_emis_urban_soil_only_dir, - cn.gross_emis_no_driver_soil_only_dir, - cn.gross_emis_all_gases_all_drivers_soil_only_dir, - cn.gross_emis_co2_only_all_drivers_soil_only_dir, - cn.gross_emis_non_co2_all_drivers_soil_only_dir, - cn.gross_emis_nodes_soil_only_dir] + else: + output_dir_list = output_dir_list + [cn.gross_emis_commod_soil_only_dir, + cn.gross_emis_shifting_ag_soil_only_dir, + cn.gross_emis_forestry_soil_only_dir, + cn.gross_emis_wildfire_soil_only_dir, + cn.gross_emis_urban_soil_only_dir, + cn.gross_emis_no_driver_soil_only_dir, + cn.gross_emis_all_gases_all_drivers_soil_only_dir, + cn.gross_emis_co2_only_all_drivers_soil_only_dir, + cn.gross_emis_non_co2_all_drivers_soil_only_dir, + cn.gross_emis_nodes_soil_only_dir] output_dir_list = output_dir_list + [cn.net_flux_dir] - if 'create_supplementary_outputs' in actual_stages: - output_dir_list = output_dir_list + \ - [cn.cumul_gain_AGCO2_BGCO2_all_types_per_pixel_full_extent_dir, - cn.cumul_gain_AGCO2_BGCO2_all_types_forest_extent_dir, - cn.cumul_gain_AGCO2_BGCO2_all_types_per_pixel_forest_extent_dir, - cn.gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_full_extent_dir, - cn.gross_emis_all_gases_all_drivers_biomass_soil_forest_extent_dir, - cn.gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_forest_extent_dir, - cn.net_flux_per_pixel_full_extent_dir, - cn.net_flux_forest_extent_dir, - cn.net_flux_per_pixel_forest_extent_dir] + # Supplementary outputs + output_dir_list = output_dir_list + \ + [cn.cumul_gain_AGCO2_BGCO2_all_types_per_pixel_full_extent_dir, + cn.cumul_gain_AGCO2_BGCO2_all_types_forest_extent_dir, + cn.cumul_gain_AGCO2_BGCO2_all_types_per_pixel_forest_extent_dir, + cn.gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_full_extent_dir, + cn.gross_emis_all_gases_all_drivers_biomass_soil_forest_extent_dir, + cn.gross_emis_all_gases_all_drivers_biomass_soil_per_pixel_forest_extent_dir, + cn.net_flux_per_pixel_full_extent_dir, + cn.net_flux_forest_extent_dir, + cn.net_flux_per_pixel_forest_extent_dir] # Creates tiles of annual AGB and BGB removals rate and AGB stdev for mangroves using the standard model