Skip to content

Commit

Permalink
Merge 5239a96 into 376879f
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-schmitt committed Jan 18, 2022
2 parents 376879f + 5239a96 commit 493e028
Show file tree
Hide file tree
Showing 4 changed files with 618 additions and 131 deletions.
30 changes: 29 additions & 1 deletion oggm/cli/prepro_levels.py
Expand Up @@ -82,7 +82,7 @@ def run_prepro_levels(rgi_version=None, rgi_reg=None, border=None,
add_consensus=False, start_level=None,
start_base_url=None, max_level=5, ref_tstars_base_url='',
logging_level='WORKFLOW', disable_dl_verify=False,
continue_on_error=True):
dynamic_spinup=False, continue_on_error=True):
"""Generate the preprocessed OGGM glacier directories for this OGGM version
Parameters
Expand Down Expand Up @@ -151,6 +151,8 @@ def run_prepro_levels(rgi_version=None, rgi_reg=None, border=None,
a dict of parameters to override.
disable_dl_verify : bool
disable the hash verification of OGGM downloads
dynamic_spinup: str
include a dynamic spinup matching 'area' OR 'volume' at the RGI-date
"""

# Input check
Expand Down Expand Up @@ -178,6 +180,14 @@ def run_prepro_levels(rgi_version=None, rgi_reg=None, border=None,
raise InvalidParamsError('evolution_model should be one of '
"['fl_sia', 'massredis'].")

if dynamic_spinup and dynamic_spinup not in ['area', 'volume']:
raise InvalidParamsError(f"Dynamic spinup option '{dynamic_spinup}' "
"not supported")

if dynamic_spinup and evolution_model == 'massredis':
raise InvalidParamsError("Dynamic spinup is not working/tested"
"with massredis!")

# Time
start = time.time()

Expand Down Expand Up @@ -586,9 +596,21 @@ def _time_log():
evolution_model = FluxBasedModel

# OK - run
if dynamic_spinup:
workflow.execute_entity_task(tasks.run_dynamic_spinup, gdirs,
evolution_model=evolution_model,
minimise_for=dynamic_spinup,
output_filesuffix='_dynamic_spinup',
)

init_model_filesuffix = '_dynamic_spinup'
else:
init_model_filesuffix = None

workflow.execute_entity_task(tasks.run_from_climate_data, gdirs,
min_ys=y0, ye=ye,
evolution_model=evolution_model,
init_model_filesuffix=init_model_filesuffix,
output_filesuffix='_historical')

# Now compile the output
Expand Down Expand Up @@ -722,6 +744,10 @@ def parse_args(args):
'against a hash sum.')
parser.add_argument('--disable-mp', nargs='?', const=True, default=False,
help='if you want to disable multiprocessing.')
parser.add_argument('--dynamic_spinup', type=str, default='',
help="include a dynamic spinup for matching 'area' OR "
"'volume' at the RGI-date")

args = parser.parse_args(args)

# Check input
Expand Down Expand Up @@ -773,6 +799,8 @@ def parse_args(args):
disable_dl_verify=args.disable_dl_verify,
ref_tstars_base_url=args.ref_tstars_base_url,
evolution_model=args.evolution_model,
dynamic_spinup=False if args.dynamic_spinup == '' else
args.dynamic_spinup,
)


Expand Down

0 comments on commit 493e028

Please sign in to comment.