Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWY: add results suffix to a few files #1525

Merged
merged 7 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

Unreleased Changes
------------------
* Annual Water Yield
* Added the results_suffix to a few intermediate files where it was
missing. https://github.com/natcap/invest/issues/1517
* Urban Nature Access
* Fixed a ``NameError`` that occurred when running the model using
search radii defined per population group with an exponential search
Expand Down
134 changes: 67 additions & 67 deletions src/natcap/invest/annual_water_yield.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,61 +376,61 @@
}
}
}
}
}
},
"intermediate": {
"type": "directory",
"contents": {
"clipped_lulc.tif": {
"about": "Aligned and clipped copy of LULC input.",
"bands": {1: {"type": "integer"}}
},
"intermediate": {
"type": "directory",
"contents": {
"clipped_lulc.tif": {
"about": "Aligned and clipped copy of LULC input.",
"bands": {1: {"type": "integer"}}
},
"depth_to_root_rest_layer.tif": {
"about": (
"Aligned and clipped copy of root restricting "
"layer depth input."),
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"eto.tif": {
"about": "Aligned and clipped copy of ET0 input.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"kc_raster.tif": {
"about": "Map of KC values.",
"bands": {
1: {"type": "number", "units": u.none}
}
},
"pawc.tif": {
"about": "Aligned and clipped copy of PAWC input.",
"bands": {1: {"type": "ratio"}},
},
"pet.tif": {
"about": "Map of potential evapotranspiration.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"precip.tif": {
"about": "Aligned and clipped copy of precipitation input.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"root_depth.tif": {
"about": "Map of root depth.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"veg.tif": {
"about": "Map of vegetated state.",
"bands": {1: {"type": "integer"}},
}
"depth_to_root_rest_layer.tif": {
"about": (
"Aligned and clipped copy of root restricting "
"layer depth input."),
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"eto.tif": {
"about": "Aligned and clipped copy of ET0 input.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"kc_raster.tif": {
"about": "Map of KC values.",
"bands": {
1: {"type": "number", "units": u.none}
}
},
"pawc.tif": {
"about": "Aligned and clipped copy of PAWC input.",
"bands": {1: {"type": "ratio"}},
},
"pet.tif": {
"about": "Map of potential evapotranspiration.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"precip.tif": {
"about": "Aligned and clipped copy of precipitation input.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"root_depth.tif": {
"about": "Map of root depth.",
"bands": {
1: {"type": "number", "units": u.millimeter}
}
},
"veg.tif": {
"about": "Map of vegetated state.",
"bands": {1: {"type": "integer"}},
}
}
},
Expand Down Expand Up @@ -576,8 +576,12 @@ def execute(args):
wyield_path = os.path.join(
per_pixel_output_dir, f'wyield{file_suffix}.tif')
aet_path = os.path.join(per_pixel_output_dir, f'aet{file_suffix}.tif')

demand_path = os.path.join(intermediate_dir, f'demand{file_suffix}.tif')
veg_raster_path = os.path.join(intermediate_dir, f'veg{file_suffix}.tif')
root_raster_path = os.path.join(
intermediate_dir, f'root_depth{file_suffix}.tif')
kc_raster_path = os.path.join(
intermediate_dir, f'kc_raster{file_suffix}.tif')

watersheds_path = args['watersheds_path']
watershed_results_vector_path = os.path.join(
Expand Down Expand Up @@ -694,39 +698,35 @@ def execute(args):
'table_name': 'Biophysical'}
# Create Kc raster from table values to use in future calculations
LOGGER.info("Reclassifying temp_Kc raster")
tmp_Kc_raster_path = os.path.join(intermediate_dir, 'kc_raster.tif')
create_Kc_raster_task = graph.add_task(
func=utils.reclassify_raster,
args=((clipped_lulc_path, 1), Kc_dict, tmp_Kc_raster_path,
args=((clipped_lulc_path, 1), Kc_dict, kc_raster_path,
gdal.GDT_Float32, nodata_dict['out_nodata'],
reclass_error_details),
target_path_list=[tmp_Kc_raster_path],
target_path_list=[kc_raster_path],
dependent_task_list=[align_raster_stack_task],
task_name='create_Kc_raster')

# Create root raster from table values to use in future calculations
LOGGER.info("Reclassifying tmp_root raster")
tmp_root_raster_path = os.path.join(
intermediate_dir, 'root_depth.tif')
create_root_raster_task = graph.add_task(
func=utils.reclassify_raster,
args=((clipped_lulc_path, 1), root_dict, tmp_root_raster_path,
args=((clipped_lulc_path, 1), root_dict, root_raster_path,
gdal.GDT_Float32, nodata_dict['out_nodata'],
reclass_error_details),
target_path_list=[tmp_root_raster_path],
target_path_list=[root_raster_path],
dependent_task_list=[align_raster_stack_task],
task_name='create_root_raster')

# Create veg raster from table values to use in future calculations
# of determining which AET equation to use
LOGGER.info("Reclassifying tmp_veg raster")
tmp_veg_raster_path = os.path.join(intermediate_dir, 'veg.tif')
create_veg_raster_task = graph.add_task(
func=utils.reclassify_raster,
args=((clipped_lulc_path, 1), vegetated_dict, tmp_veg_raster_path,
args=((clipped_lulc_path, 1), vegetated_dict, veg_raster_path,
gdal.GDT_Float32, nodata_dict['out_nodata'],
reclass_error_details),
target_path_list=[tmp_veg_raster_path],
target_path_list=[veg_raster_path],
dependent_task_list=[align_raster_stack_task],
task_name='create_veg_raster')

Expand All @@ -737,7 +737,7 @@ def execute(args):
func=pygeoprocessing.raster_map,
kwargs=dict(
op=numpy.multiply, # PET = ET0 * KC
rasters=[eto_path, tmp_Kc_raster_path],
rasters=[eto_path, kc_raster_path],
target_path=tmp_pet_path,
target_nodata=nodata_dict['out_nodata']),
target_path_list=[tmp_pet_path],
Expand All @@ -747,8 +747,8 @@ def execute(args):

# List of rasters to pass into the vectorized fractp operation
raster_list = [
tmp_Kc_raster_path, eto_path, precip_path, tmp_root_raster_path,
depth_to_root_rest_layer_path, pawc_path, tmp_veg_raster_path]
kc_raster_path, eto_path, precip_path, root_raster_path,
depth_to_root_rest_layer_path, pawc_path, veg_raster_path]

LOGGER.debug('Performing fractp operation')
calculate_fractp_task = graph.add_task(
Expand Down
4 changes: 2 additions & 2 deletions src/natcap/invest/carbon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
LOGGER = logging.getLogger(__name__)

CARBON_OUTPUTS = {
f"c_{scenario}_{pool}.tif": {
f"c_{pool}_{scenario}.tif": {
"about": (
f"Raster of {pool_name} carbon values in the {scenario_name} "
"scenario, mapped from the Carbon Pools table to the LULC."),
Expand Down Expand Up @@ -252,7 +252,7 @@
}},
"created_if": "lulc_redd_path"
},
"intermediate": {
"intermediate_outputs": {
"type": "directory",
"contents": {
**CARBON_OUTPUTS
Expand Down
Loading