Skip to content

Commit

Permalink
wip: incorporating AP's fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aleaf committed Sep 23, 2024
1 parent 1d02f71 commit ee0a7e5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions mfsetup/sourcedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1381,9 +1381,16 @@ def setup_array(model, package, var, data=None,
# special handling of some variables
# (for lakes)
simulate_high_k_lakes = model.cfg['high_k_lakes']['simulate_high_k_lakes']
if var == 'botm' and simulate_high_k_lakes:
# only execute this code if building the model (not loading)
if not model._load:
apply_lake_bathymetry_to_model_top = False
if var == 'botm':
if 'lak' in model.cfg['model']['packages'] and not model._load and\
np.sum(model.lake_bathymetry) != 0:
# only execute this code if building the model (not loading)
# and if lake bathymetry was supplied
# (bathymetry is loaded from the configuration file input
# when the model.lake_bathymetry property is called for the first time;
# see MFsetupMixin._set_lake_bathymetry)
apply_lake_bathymetry_to_model_top = True
bathy = model.lake_bathymetry

# save a copy of original top elevations
Expand Down Expand Up @@ -1417,7 +1424,6 @@ def setup_array(model, package, var, data=None,
shutil.copy(model.cfg['intermediate_data']['top'][0],
original_top_file)
top = model.load_array(original_top_file)
lake_botm_elevations = top[bathy != 0] - bathy[bathy != 0]
if model.version == 'mf6':
# reset the model top to the lake bottom
top[bathy != 0] -= bathy[bathy != 0]
Expand Down Expand Up @@ -1605,9 +1611,9 @@ def setup_array(model, package, var, data=None,

# write the top array again, because top was filled
# with botm array above
# NOTE: that tends to corrupt the top array,
# NOTE: that tends to corrupt the top array,
# is that only applicable to simulate_high_k_lakes ?)
if var == 'botm' and simulate_high_k_lakes:
if var == 'botm' and apply_lake_bathymetry_to_model_top:
top_filepath = model.setup_external_filepaths(package, 'top',
model.cfg[package]['top_filename_fmt'])[0]
save_array(top_filepath, top,
Expand Down

0 comments on commit ee0a7e5

Please sign in to comment.