Skip to content

Commit b945750

Browse files
committed
included max thickness due to min w0 in bed_h boundaries
1 parent 59d3008 commit b945750

File tree

3 files changed

+32
-20
lines changed

3 files changed

+32
-20
lines changed

agile1d/core/inversion.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def add_setting():
302302

303303
@entity_task(log, writes=['inversion_input'])
304304
def prepare_for_agile_inversion(gdir, inversion_settings=None,
305-
filesuffix='_agile'):
305+
filesuffix='_agile'):
306306
"""TODO
307307
"""
308308
if inversion_settings is None:
@@ -322,11 +322,18 @@ def get_control_var_bounds(data_logger):
322322
fl = data_logger.flowline_init
323323
ice_mask = data_logger.ice_mask
324324
bed_h_bounds = data_logger.bed_h_bounds
325-
bounds[var_indices] = [(sfc_h - thick * bed_h_bounds[1],
326-
sfc_h - thick * bed_h_bounds[0])
327-
for sfc_h, thick in
325+
326+
h_max_w0 = (fl.widths_m[fl.thick > 0] - data_logger.min_w0_m) / \
327+
fl._lambdas[fl.thick > 0]
328+
329+
bounds[var_indices] = [(sfc_h - min(thick * bed_h_bounds[1],
330+
thick_max),
331+
sfc_h - thick * bed_h_bounds[0]
332+
)
333+
for sfc_h, thick, thick_max in
328334
zip(fl.surface_h[ice_mask],
329-
fl.thick[ice_mask])]
335+
fl.thick[ice_mask],
336+
h_max_w0)]
330337

331338
# Outdated calculation using GlabTop
332339
# upper_limits = get_adaptive_upper_ice_thickness_limit(
@@ -344,14 +351,19 @@ def get_control_var_bounds(data_logger):
344351
fl = data_logger.flowline_init
345352
ice_mask = data_logger.ice_mask
346353
bed_h_bounds = data_logger.bed_h_bounds
347-
bounds[var_indices] = [((sfc_h - thick * bed_h_bounds[1]) *
348-
width_m,
349-
(sfc_h - thick * bed_h_bounds[0]) *
350-
width_m)
351-
for sfc_h, thick, width_m in
354+
355+
h_max_w0 = (fl.widths_m[fl.thick > 0] - data_logger.min_w0_m) / \
356+
fl._lambdas[fl.thick > 0]
357+
358+
bounds[var_indices] = [((sfc_h - min(thick * bed_h_bounds[1],
359+
thick_max)) * width_m,
360+
(sfc_h - thick * bed_h_bounds[0]) * width_m
361+
)
362+
for sfc_h, thick, width_m, thick_max in
352363
zip(fl.surface_h[ice_mask],
353364
fl.thick[ice_mask],
354-
fl.widths_m[ice_mask])]
365+
fl.widths_m[ice_mask],
366+
h_max_w0)]
355367

356368
# Outdated calculation using GlabTop
357369
# upper_limits = get_adaptive_upper_ice_thickness_limit(

agile1d/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def data_logger_init(hef_gdir, control_vars, spinup_option, dynamic_models,
150150
inversion_settings['regularisation_terms'] = {'smoothed_bed': 1.,
151151
'smoothed_flux': 10.}
152152
prepare_for_agile_inversion(hef_gdir, inversion_settings=inversion_settings,
153-
filesuffix='_agile')
153+
filesuffix='_agile')
154154
data_logger = initialise_DataLogger(hef_gdir, inversion_input_filesuffix='_agile')
155155
return data_logger
156156

agile1d/tests/test_inversion.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from agile1d.core.first_guess import get_first_guess
88
from agile1d.core.inversion import (prepare_for_agile_inversion,
9-
get_control_var_bounds,
10-
get_default_inversion_settings,
11-
agile_inversion)
9+
get_control_var_bounds,
10+
get_default_inversion_settings,
11+
agile_inversion)
1212
from agile1d.core.data_logging import initialise_DataLogger
1313
from agile1d.core.cost_function import create_cost_fct, descale_unknown_parameters
1414

@@ -27,7 +27,7 @@ def test_default_initialisation(self, hef_gdir):
2727

2828
# add default inversion_input_agile and try again
2929
prepare_for_agile_inversion(hef_gdir, inversion_settings=None,
30-
filesuffix='_agile')
30+
filesuffix='_agile')
3131
data_logger = initialise_DataLogger(
3232
hef_gdir, inversion_input_filesuffix='_agile')
3333

@@ -103,7 +103,7 @@ def test_get_control_var_bounds(self, data_logger):
103103
ids=[#'flux_based',
104104
'implicit'])
105105
def test_agile_inversion(self, hef_gdir, control_vars, spinup_options,
106-
dynamic_model, all_supported_control_vars):
106+
dynamic_model, all_supported_control_vars):
107107
# Final integration test that the inversion runs with no errors, also
108108
# test the saving of the final past evolution
109109
inversion_settings = get_default_inversion_settings(get_doc=False)
@@ -131,11 +131,11 @@ def test_agile_inversion(self, hef_gdir, control_vars, spinup_options,
131131
inversion_settings['observations'][measure_key]['2000-2019'] = -1.
132132

133133
prepare_for_agile_inversion(hef_gdir,
134-
inversion_settings=inversion_settings,
135-
filesuffix='_agile')
134+
inversion_settings=inversion_settings,
135+
filesuffix='_agile')
136136

137137
data_logger = agile_inversion(hef_gdir, give_data_logger_back=True,
138-
save_past_evolution=True)
138+
save_past_evolution=True)
139139

140140
# test if data_logger contains data
141141
assert data_logger.minimize_message is not None

0 commit comments

Comments
 (0)