Skip to content

Commit

Permalink
dd more centerline shapes to prepro output
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaussion committed Sep 7, 2022
1 parent e12a230 commit d0ace1a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
29 changes: 21 additions & 8 deletions oggm/cli/prepro_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
from oggm import utils, workflow, tasks, GlacierDirectory
from oggm.core import gis
from oggm.exceptions import InvalidParamsError, InvalidDEMError
from oggm.core.dynamic_spinup import (
dynamic_mu_star_run,
dynamic_mu_star_run_fallback,
dynamic_mu_star_run_with_dynamic_spinup,
dynamic_mu_star_run_with_dynamic_spinup_fallback)

# Module logger
from oggm.utils import get_prepro_base_url, file_downloader
Expand Down Expand Up @@ -165,8 +160,8 @@ def run_prepro_levels(rgi_version=None, rgi_reg=None, border=None,
if dynamic_spinup is set, define the starting year for the simulation.
The default is 1979, unless the climate data starts later.
continue_on_error : bool
if True the workflow continues if a task raise an error. For operational
runs it should be set to True. Default is True
if True the workflow continues if a task raises an error. For operational
runs it should be set to True (the default).
"""

# Input check
Expand Down Expand Up @@ -480,9 +475,27 @@ def _time_log():

# And for level 2: shapes
if len(gdirs_cent) > 0:
opath = os.path.join(sum_dir, 'centerlines_{}.shp'.format(rgi_reg))
opath = os.path.join(sum_dir, f'{rgi_reg}_centerlines.shp')
utils.write_centerlines_to_shape(gdirs_cent, to_tar=True,
path=opath)
opath = os.path.join(sum_dir, f'{rgi_reg}_centerlines_smoothed.shp')
utils.write_centerlines_to_shape(gdirs_cent, to_tar=True,
ensure_exterior_match=True,
simplify_line=0.5,
corner_cutting=5,
path=opath)
opath = os.path.join(sum_dir, f'{rgi_reg}_flowlines.shp')
utils.write_centerlines_to_shape(gdirs_cent, to_tar=True,
flowlines_output=True,
path=opath)
opath = os.path.join(sum_dir, f'{rgi_reg}_geom_widths.shp')
utils.write_centerlines_to_shape(gdirs_cent, to_tar=True,
geometrical_widths_output=True,
path=opath)
opath = os.path.join(sum_dir, f'{rgi_reg}_widths.shp')
utils.write_centerlines_to_shape(gdirs_cent, to_tar=True,
corrected_widths_output=True,
path=opath)

# L2 OK - compress all in output directory
log.workflow('L2 done. Writing to tar...')
Expand Down
6 changes: 5 additions & 1 deletion oggm/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,11 @@ def test_full_run(self):
'glacier_statistics_11.csv'))
assert 'main_flowline_length' in df
assert os.path.isfile(os.path.join(odir, 'RGI61', 'b_020', 'L2',
'summary', 'centerlines_11.tar.gz'))
'summary', '11_centerlines.tar.gz'))
assert os.path.isfile(os.path.join(odir, 'RGI61', 'b_020', 'L2',
'summary', '11_centerlines_smoothed.tar.gz'))
assert os.path.isfile(os.path.join(odir, 'RGI61', 'b_020', 'L2',
'summary', '11_widths.tar.gz'))

df = pd.read_csv(os.path.join(odir, 'RGI61', 'b_020', 'L3', 'summary',
'glacier_statistics_11.csv'), index_col=0)
Expand Down
2 changes: 1 addition & 1 deletion oggm/utils/_downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def get_dl_verify_data(section):
"""

verify_key = 'dl_verify_data_' + section
if cfg.DATA.get(verify_key) is not None:
if verify_key in cfg.DATA:
return cfg.DATA[verify_key]

verify_file_path = os.path.join(cfg.CACHE_DIR, 'downloads.sha256.hdf')
Expand Down

0 comments on commit d0ace1a

Please sign in to comment.