Skip to content

Commit 672e7bb

Browse files
committed
fixed a bug in calculation of result statistics
1 parent b945750 commit 672e7bb

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

agile1d/core/inversion.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
import warnings
55
import time
6+
import copy
67

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

476477
def save_past_evolution_to_disk(gdir, data_logger):
477478
# recreate initial flowline
478-
fl_final = data_logger.flowlines[-1]
479+
fl_final = copy.deepcopy(data_logger.flowlines[-1])
479480
# set to initial ice thickness distribution, this already includes a
480481
# potential spinup
481-
fl_final.surface_h = data_logger.sfc_h_start[-1]
482+
fl_final.surface_h = copy.deepcopy(data_logger.sfc_h_start[-1])
482483
# convert flowline to torch flowline
483484
fl_final = MixedBedFlowline(
484485
line=fl_final.line, dx=fl_final.dx, map_dx=fl_final.map_dx,

agile1d/sandbox/calculate_statistics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import pickle
3+
import copy
34
import numpy as np
45
import xarray as xr
56
from oggm import utils, cfg
@@ -112,8 +113,8 @@ def calculate_result_statistics(gdir, data_logger, print_statistic=False):
112113
ds.attrs['controls_stats'] = controls_stats
113114

114115
# how well do we match the past glacier state -----------------------------
115-
fls_start_mdl = data_logger.flowlines[-1]
116-
sfc_h_start = data_logger.sfc_h_start[-1]
116+
fls_start_mdl = copy.deepcopy(data_logger.flowlines[-1])
117+
sfc_h_start = copy.deepcopy(data_logger.sfc_h_start[-1])
117118
fls_start_mdl.surface_h = sfc_h_start
118119
fls_start_true = gdir.read_pickle('model_flowlines',
119120
filesuffix='_creation_spinup')[0]
@@ -162,7 +163,7 @@ def get_volume(fl):
162163
ds.attrs['past_evol_stats'] = past_evol_stats
163164

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

0 commit comments

Comments
 (0)