Skip to content

Commit

Permalink
Add label as suffix if output requested in print_gridded_dataset_univ…
Browse files Browse the repository at this point in the history
…ar_statistics_over_zones()
  • Loading branch information
NikosAlexandris committed Mar 21, 2021
1 parent 1dcd888 commit 99d8b4a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lib/python/temporal/univar_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ def print_gridded_dataset_univar_statistics_over_zones(
for category
in categories_and_labels
]

for category, label in categories_and_labels:

gscript.message(_(f'Zone {category} \'{label}\''))
# mask category
try:
gscript.message(_(f'Zone {category} \'{label}\''))
gscript.run_command(
'r.mask',
quiet=True,
Expand All @@ -192,16 +193,21 @@ def print_gridded_dataset_univar_statistics_over_zones(
except CalledModuleError:
gscript.fatal(_('%s failed') % 'r.mask')

if output:
label = label.replace(' ', '_')
label = label.replace('/', '_')
zonal_output = output + '_' + label

# get statistics
print_gridded_dataset_univar_statistics(
"strds",
input,
output,
where,
extended,
no_header,
fs,
rast_region,
input=input,
output=zonal_output,
where=where,
extended=extended,
no_header=no_header,
fs=fs,
rast_region=rast_region,
)

gscript.message('\n')
Expand Down Expand Up @@ -352,4 +358,4 @@ def print_vector_dataset_univar_statistics(input, output, twhere, layer, type, c
dbif.close()

if output is not None:
out_file.close()
out_file.close()

0 comments on commit 99d8b4a

Please sign in to comment.