Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pcmdi_metrics/variability_mode/lib/adjust_timeseries.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import copy

import xarray as xr

from pcmdi_metrics.io import (
Expand Down Expand Up @@ -134,7 +136,7 @@ def get_residual_timeseries(
raise TypeError(
"The first parameter of get_residual_timeseries must be an xarray Dataset"
)
ds_residual = ds_anomaly.copy()
ds_residual = copy.deepcopy(ds_anomaly)
if RmDomainMean:
# Get domain mean
ds_anomaly_region = region_subset(
Expand Down
6 changes: 5 additions & 1 deletion pcmdi_metrics/variability_mode/lib/lib_variability_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ def read_data_in(
data_timeseries = adjust_units(data_timeseries, UnitsAdjust)

# Masking
if var_to_consider == "ts" and LandMask:
if (
(var_in_data.lower() in ["ts", "sst"])
or (var_to_consider.lower() in ["ts", "sst"])
and LandMask
):
# Replace temperature below -1.8 C to -1.8 C (sea ice)
data_timeseries = sea_ice_adjust(data_timeseries)

Expand Down
13 changes: 10 additions & 3 deletions pcmdi_metrics/variability_mode/variability_modes_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,13 @@

# Path to model data as string template
modpath = param.modpath
print("modpath (from param):", modpath)

modpath_lf = param.modpath_lf
if LandMask:
modpath_lf = param.modpath_lf
print("modpath_lf (from param):", modpath_lf)
else:
modpath_lf = None

# Check given model option
models = param.modnames
Expand Down Expand Up @@ -405,7 +410,7 @@

# Set output file name for NetCDF and plot
output_filename_obs = (
f"{mode}_{var}_EOF{eofn_obs}_{season}_obs_{osyear}-{oeyear}"
f"{mode}_{obs_var}_EOF{eofn_obs}_{season}_obs_{osyear}-{oeyear}"
)

if EofScaling:
Expand Down Expand Up @@ -492,6 +497,8 @@
if model not in result_dict["RESULTS"]:
result_dict["RESULTS"][model] = {}

print("modpath:", modpath)

model_path_list = glob.glob(
fill_template(
modpath,
Expand Down Expand Up @@ -560,7 +567,7 @@
"target_model_eofs"
] = eofn_mod

if LandMask:
if LandMask and modpath_lf is not None:
model_lf_path = fill_template(modpath_lf, mip=mip, exp=exp, model=model)
else:
model_lf_path = None
Expand Down
Loading