Skip to content

Commit

Permalink
included max thickness due to min w0 in bed_h boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-schmitt committed Jul 21, 2023
1 parent 59d3008 commit b945750
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
34 changes: 23 additions & 11 deletions agile1d/core/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def add_setting():

@entity_task(log, writes=['inversion_input'])
def prepare_for_agile_inversion(gdir, inversion_settings=None,
filesuffix='_agile'):
filesuffix='_agile'):
"""TODO
"""
if inversion_settings is None:
Expand All @@ -322,11 +322,18 @@ def get_control_var_bounds(data_logger):
fl = data_logger.flowline_init
ice_mask = data_logger.ice_mask
bed_h_bounds = data_logger.bed_h_bounds
bounds[var_indices] = [(sfc_h - thick * bed_h_bounds[1],
sfc_h - thick * bed_h_bounds[0])
for sfc_h, thick in

h_max_w0 = (fl.widths_m[fl.thick > 0] - data_logger.min_w0_m) / \
fl._lambdas[fl.thick > 0]

bounds[var_indices] = [(sfc_h - min(thick * bed_h_bounds[1],
thick_max),
sfc_h - thick * bed_h_bounds[0]
)
for sfc_h, thick, thick_max in
zip(fl.surface_h[ice_mask],
fl.thick[ice_mask])]
fl.thick[ice_mask],
h_max_w0)]

# Outdated calculation using GlabTop
# upper_limits = get_adaptive_upper_ice_thickness_limit(
Expand All @@ -344,14 +351,19 @@ def get_control_var_bounds(data_logger):
fl = data_logger.flowline_init
ice_mask = data_logger.ice_mask
bed_h_bounds = data_logger.bed_h_bounds
bounds[var_indices] = [((sfc_h - thick * bed_h_bounds[1]) *
width_m,
(sfc_h - thick * bed_h_bounds[0]) *
width_m)
for sfc_h, thick, width_m in

h_max_w0 = (fl.widths_m[fl.thick > 0] - data_logger.min_w0_m) / \
fl._lambdas[fl.thick > 0]

bounds[var_indices] = [((sfc_h - min(thick * bed_h_bounds[1],
thick_max)) * width_m,
(sfc_h - thick * bed_h_bounds[0]) * width_m
)
for sfc_h, thick, width_m, thick_max in
zip(fl.surface_h[ice_mask],
fl.thick[ice_mask],
fl.widths_m[ice_mask])]
fl.widths_m[ice_mask],
h_max_w0)]

# Outdated calculation using GlabTop
# upper_limits = get_adaptive_upper_ice_thickness_limit(
Expand Down
2 changes: 1 addition & 1 deletion agile1d/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def data_logger_init(hef_gdir, control_vars, spinup_option, dynamic_models,
inversion_settings['regularisation_terms'] = {'smoothed_bed': 1.,
'smoothed_flux': 10.}
prepare_for_agile_inversion(hef_gdir, inversion_settings=inversion_settings,
filesuffix='_agile')
filesuffix='_agile')
data_logger = initialise_DataLogger(hef_gdir, inversion_input_filesuffix='_agile')
return data_logger

Expand Down
16 changes: 8 additions & 8 deletions agile1d/tests/test_inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from agile1d.core.first_guess import get_first_guess
from agile1d.core.inversion import (prepare_for_agile_inversion,
get_control_var_bounds,
get_default_inversion_settings,
agile_inversion)
get_control_var_bounds,
get_default_inversion_settings,
agile_inversion)
from agile1d.core.data_logging import initialise_DataLogger
from agile1d.core.cost_function import create_cost_fct, descale_unknown_parameters

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

# add default inversion_input_agile and try again
prepare_for_agile_inversion(hef_gdir, inversion_settings=None,
filesuffix='_agile')
filesuffix='_agile')
data_logger = initialise_DataLogger(
hef_gdir, inversion_input_filesuffix='_agile')

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

prepare_for_agile_inversion(hef_gdir,
inversion_settings=inversion_settings,
filesuffix='_agile')
inversion_settings=inversion_settings,
filesuffix='_agile')

data_logger = agile_inversion(hef_gdir, give_data_logger_back=True,
save_past_evolution=True)
save_past_evolution=True)

# test if data_logger contains data
assert data_logger.minimize_message is not None
Expand Down

0 comments on commit b945750

Please sign in to comment.