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
2 changes: 1 addition & 1 deletion SalishSeaTools/envs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ MarkupSafe==3.0.3
matplotlib==3.10.8
matplotlib-inline==0.2.1
mdurl==0.1.2
mistune==3.2.1
mistune==3.3.0
more-itertools==10.8.0
munkres==1.1.4
mypy_extensions==1.1.0
Expand Down
23 changes: 11 additions & 12 deletions SalishSeaTools/salishsea_tools/evaltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import pandas as pd
import pytz
import xarray as xr
import cftime #Added for noleap exeption.
import cftime # Added for noleap exeption.

from salishsea_tools import geo_tools, places

Expand Down Expand Up @@ -232,7 +232,7 @@ def matchData(
)
for file_type in file_types
}

# Call a function to match model field values to the observation data using the specified method
data = _match_model_to_data(
method,
Expand All @@ -247,7 +247,7 @@ def matchData(
model_file_hours_res,
n_spatial_dims,
pre_indexed=pre_indexed,
nam_fmt = mod_nam_fmt
nam_fmt=mod_nam_fmt,
)
data.reset_index(drop=True, inplace=True)
return data
Expand Down Expand Up @@ -473,7 +473,7 @@ def _match_model_to_data(
model_file_hours_res,
n_spatial_dims,
pre_indexed=False,
nam_fmt = "nowcast"
nam_fmt="nowcast",
):
"""
Match model field values to the provided observational data using the specified method.
Expand Down Expand Up @@ -1012,12 +1012,11 @@ def _getTimeInd_bin(idt, ifid, torig, hpf=None):
if "time_centered_bounds" in ifid.variables.keys():
tlist = ifid.variables["time_centered_bounds"][:, :]
tc = ifid["time_counter"]
target_num = cftime.date2num(idt, units=tc.units, calendar=tc.calendar) #This way noleap runs also work
ih = [
iii
for iii, hhh in enumerate(tlist)
if hhh[1] > target_num][0]

target_num = cftime.date2num(
idt, units=tc.units, calendar=tc.calendar
) # This way noleap runs also work
ih = [iii for iii, hhh in enumerate(tlist) if hhh[1] > target_num][0]

else: # hacky fix because time_centered_bounds missing from post-processed daily files
nt = len(ifid.variables["time_counter"][:])
if "hours" in ifid.variables["time_counter"].units:
Expand Down Expand Up @@ -1237,7 +1236,7 @@ def index_model_files_flex(
t_0 = list()
t_n = list()
for ifl in paths:
if nam_fmt in ["nowcast","SHEM"]:
if nam_fmt in ["nowcast", "SHEM"]:
dates = re.findall(r"\d{8}", re.search(r"\d{8}_\d{8}", ifl)[0])
elif nam_fmt == "long":
dates = re.findall(r"\d{8}", re.search(r"\d{8}-\d{8}", ifl)[0])
Expand Down Expand Up @@ -3315,7 +3314,7 @@ def getChlNRatio(
"nmlfile must contain full namelist path or basedir and nam_fmt must be defined"
)
if basedir:
if nam_fmt in ["nowcast","SHEM"]:
if nam_fmt in ["nowcast", "SHEM"]:
nmlfile = os.path.join(basedir, idt.strftime("%d%b%y").lower(), nmlfile)
elif nam_fmt == "long":
nmlfile = os.path.join(basedir, nmlfile)
Expand Down