Skip to content

Commit

Permalink
fixed a bug in calculation of result statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
pat-schmitt committed Aug 22, 2023
1 parent b945750 commit 672e7bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions agile1d/core/inversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import warnings
import time
import copy

# External libs
from agile1d.core.dynamics import run_model_and_get_model_values
Expand Down Expand Up @@ -475,10 +476,10 @@ def get_adaptive_upper_ice_thickness_limit(fl, additional_ice_thickness=100,

def save_past_evolution_to_disk(gdir, data_logger):
# recreate initial flowline
fl_final = data_logger.flowlines[-1]
fl_final = copy.deepcopy(data_logger.flowlines[-1])
# set to initial ice thickness distribution, this already includes a
# potential spinup
fl_final.surface_h = data_logger.sfc_h_start[-1]
fl_final.surface_h = copy.deepcopy(data_logger.sfc_h_start[-1])
# convert flowline to torch flowline
fl_final = MixedBedFlowline(
line=fl_final.line, dx=fl_final.dx, map_dx=fl_final.map_dx,
Expand Down
7 changes: 4 additions & 3 deletions agile1d/sandbox/calculate_statistics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pickle
import copy
import numpy as np
import xarray as xr
from oggm import utils, cfg
Expand Down Expand Up @@ -112,8 +113,8 @@ def calculate_result_statistics(gdir, data_logger, print_statistic=False):
ds.attrs['controls_stats'] = controls_stats

# how well do we match the past glacier state -----------------------------
fls_start_mdl = data_logger.flowlines[-1]
sfc_h_start = data_logger.sfc_h_start[-1]
fls_start_mdl = copy.deepcopy(data_logger.flowlines[-1])
sfc_h_start = copy.deepcopy(data_logger.sfc_h_start[-1])
fls_start_mdl.surface_h = sfc_h_start
fls_start_true = gdir.read_pickle('model_flowlines',
filesuffix='_creation_spinup')[0]
Expand Down Expand Up @@ -162,7 +163,7 @@ def get_volume(fl):
ds.attrs['past_evol_stats'] = past_evol_stats

# how well do we match today's glacier state ------------------------------
fls_end_mdl = data_logger.flowlines[-1]
fls_end_mdl = copy.deepcopy(data_logger.flowlines[-1])
fls_end_true = gdir.read_pickle('model_flowlines',
filesuffix='_agile_true_end')[0]

Expand Down

0 comments on commit 672e7bb

Please sign in to comment.