Skip to content

Commit 34bf4f7

Browse files
authored
Merge pull request #1525 from davemfish/bugfix/AWY-1517-model-specs
AWY: add results suffix to a few files
2 parents 886bb2c + 9086b64 commit 34bf4f7

File tree

3 files changed

+72
-69
lines changed

3 files changed

+72
-69
lines changed

HISTORY.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
3939
Unreleased Changes
4040
------------------
41+
* Annual Water Yield
42+
* Added the results_suffix to a few intermediate files where it was
43+
missing. https://github.com/natcap/invest/issues/1517
4144
* Urban Nature Access
4245
* Fixed a ``NameError`` that occurred when running the model using
4346
search radii defined per population group with an exponential search

src/natcap/invest/annual_water_yield.py

Lines changed: 67 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -376,61 +376,61 @@
376376
}
377377
}
378378
}
379+
}
380+
}
381+
},
382+
"intermediate": {
383+
"type": "directory",
384+
"contents": {
385+
"clipped_lulc.tif": {
386+
"about": "Aligned and clipped copy of LULC input.",
387+
"bands": {1: {"type": "integer"}}
379388
},
380-
"intermediate": {
381-
"type": "directory",
382-
"contents": {
383-
"clipped_lulc.tif": {
384-
"about": "Aligned and clipped copy of LULC input.",
385-
"bands": {1: {"type": "integer"}}
386-
},
387-
"depth_to_root_rest_layer.tif": {
388-
"about": (
389-
"Aligned and clipped copy of root restricting "
390-
"layer depth input."),
391-
"bands": {
392-
1: {"type": "number", "units": u.millimeter}
393-
}
394-
},
395-
"eto.tif": {
396-
"about": "Aligned and clipped copy of ET0 input.",
397-
"bands": {
398-
1: {"type": "number", "units": u.millimeter}
399-
}
400-
},
401-
"kc_raster.tif": {
402-
"about": "Map of KC values.",
403-
"bands": {
404-
1: {"type": "number", "units": u.none}
405-
}
406-
},
407-
"pawc.tif": {
408-
"about": "Aligned and clipped copy of PAWC input.",
409-
"bands": {1: {"type": "ratio"}},
410-
},
411-
"pet.tif": {
412-
"about": "Map of potential evapotranspiration.",
413-
"bands": {
414-
1: {"type": "number", "units": u.millimeter}
415-
}
416-
},
417-
"precip.tif": {
418-
"about": "Aligned and clipped copy of precipitation input.",
419-
"bands": {
420-
1: {"type": "number", "units": u.millimeter}
421-
}
422-
},
423-
"root_depth.tif": {
424-
"about": "Map of root depth.",
425-
"bands": {
426-
1: {"type": "number", "units": u.millimeter}
427-
}
428-
},
429-
"veg.tif": {
430-
"about": "Map of vegetated state.",
431-
"bands": {1: {"type": "integer"}},
432-
}
389+
"depth_to_root_rest_layer.tif": {
390+
"about": (
391+
"Aligned and clipped copy of root restricting "
392+
"layer depth input."),
393+
"bands": {
394+
1: {"type": "number", "units": u.millimeter}
395+
}
396+
},
397+
"eto.tif": {
398+
"about": "Aligned and clipped copy of ET0 input.",
399+
"bands": {
400+
1: {"type": "number", "units": u.millimeter}
433401
}
402+
},
403+
"kc_raster.tif": {
404+
"about": "Map of KC values.",
405+
"bands": {
406+
1: {"type": "number", "units": u.none}
407+
}
408+
},
409+
"pawc.tif": {
410+
"about": "Aligned and clipped copy of PAWC input.",
411+
"bands": {1: {"type": "ratio"}},
412+
},
413+
"pet.tif": {
414+
"about": "Map of potential evapotranspiration.",
415+
"bands": {
416+
1: {"type": "number", "units": u.millimeter}
417+
}
418+
},
419+
"precip.tif": {
420+
"about": "Aligned and clipped copy of precipitation input.",
421+
"bands": {
422+
1: {"type": "number", "units": u.millimeter}
423+
}
424+
},
425+
"root_depth.tif": {
426+
"about": "Map of root depth.",
427+
"bands": {
428+
1: {"type": "number", "units": u.millimeter}
429+
}
430+
},
431+
"veg.tif": {
432+
"about": "Map of vegetated state.",
433+
"bands": {1: {"type": "integer"}},
434434
}
435435
}
436436
},
@@ -576,8 +576,12 @@ def execute(args):
576576
wyield_path = os.path.join(
577577
per_pixel_output_dir, f'wyield{file_suffix}.tif')
578578
aet_path = os.path.join(per_pixel_output_dir, f'aet{file_suffix}.tif')
579-
580579
demand_path = os.path.join(intermediate_dir, f'demand{file_suffix}.tif')
580+
veg_raster_path = os.path.join(intermediate_dir, f'veg{file_suffix}.tif')
581+
root_raster_path = os.path.join(
582+
intermediate_dir, f'root_depth{file_suffix}.tif')
583+
kc_raster_path = os.path.join(
584+
intermediate_dir, f'kc_raster{file_suffix}.tif')
581585

582586
watersheds_path = args['watersheds_path']
583587
watershed_results_vector_path = os.path.join(
@@ -694,39 +698,35 @@ def execute(args):
694698
'table_name': 'Biophysical'}
695699
# Create Kc raster from table values to use in future calculations
696700
LOGGER.info("Reclassifying temp_Kc raster")
697-
tmp_Kc_raster_path = os.path.join(intermediate_dir, 'kc_raster.tif')
698701
create_Kc_raster_task = graph.add_task(
699702
func=utils.reclassify_raster,
700-
args=((clipped_lulc_path, 1), Kc_dict, tmp_Kc_raster_path,
703+
args=((clipped_lulc_path, 1), Kc_dict, kc_raster_path,
701704
gdal.GDT_Float32, nodata_dict['out_nodata'],
702705
reclass_error_details),
703-
target_path_list=[tmp_Kc_raster_path],
706+
target_path_list=[kc_raster_path],
704707
dependent_task_list=[align_raster_stack_task],
705708
task_name='create_Kc_raster')
706709

707710
# Create root raster from table values to use in future calculations
708711
LOGGER.info("Reclassifying tmp_root raster")
709-
tmp_root_raster_path = os.path.join(
710-
intermediate_dir, 'root_depth.tif')
711712
create_root_raster_task = graph.add_task(
712713
func=utils.reclassify_raster,
713-
args=((clipped_lulc_path, 1), root_dict, tmp_root_raster_path,
714+
args=((clipped_lulc_path, 1), root_dict, root_raster_path,
714715
gdal.GDT_Float32, nodata_dict['out_nodata'],
715716
reclass_error_details),
716-
target_path_list=[tmp_root_raster_path],
717+
target_path_list=[root_raster_path],
717718
dependent_task_list=[align_raster_stack_task],
718719
task_name='create_root_raster')
719720

720721
# Create veg raster from table values to use in future calculations
721722
# of determining which AET equation to use
722723
LOGGER.info("Reclassifying tmp_veg raster")
723-
tmp_veg_raster_path = os.path.join(intermediate_dir, 'veg.tif')
724724
create_veg_raster_task = graph.add_task(
725725
func=utils.reclassify_raster,
726-
args=((clipped_lulc_path, 1), vegetated_dict, tmp_veg_raster_path,
726+
args=((clipped_lulc_path, 1), vegetated_dict, veg_raster_path,
727727
gdal.GDT_Float32, nodata_dict['out_nodata'],
728728
reclass_error_details),
729-
target_path_list=[tmp_veg_raster_path],
729+
target_path_list=[veg_raster_path],
730730
dependent_task_list=[align_raster_stack_task],
731731
task_name='create_veg_raster')
732732

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

748748
# List of rasters to pass into the vectorized fractp operation
749749
raster_list = [
750-
tmp_Kc_raster_path, eto_path, precip_path, tmp_root_raster_path,
751-
depth_to_root_rest_layer_path, pawc_path, tmp_veg_raster_path]
750+
kc_raster_path, eto_path, precip_path, root_raster_path,
751+
depth_to_root_rest_layer_path, pawc_path, veg_raster_path]
752752

753753
LOGGER.debug('Performing fractp operation')
754754
calculate_fractp_task = graph.add_task(

src/natcap/invest/carbon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
LOGGER = logging.getLogger(__name__)
2222

2323
CARBON_OUTPUTS = {
24-
f"c_{scenario}_{pool}.tif": {
24+
f"c_{pool}_{scenario}.tif": {
2525
"about": (
2626
f"Raster of {pool_name} carbon values in the {scenario_name} "
2727
"scenario, mapped from the Carbon Pools table to the LULC."),
@@ -252,7 +252,7 @@
252252
}},
253253
"created_if": "lulc_redd_path"
254254
},
255-
"intermediate": {
255+
"intermediate_outputs": {
256256
"type": "directory",
257257
"contents": {
258258
**CARBON_OUTPUTS

0 commit comments

Comments
 (0)