Skip to content

Commit a55b156

Browse files
committed
Slight update to reading in forcing from yaml to allow a directory
1 parent 2462526 commit a55b156

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/supy/_load.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,14 @@ def load_SUEWS_Forcing_met_df_yaml(path_forcing):
815815

816816
if isinstance(path_forcing, (str, Path)):
817817
path_forcing = Path(path_forcing).resolve()
818-
df_forcing_met = read_suews(path_forcing)
819-
elif isinstance(path_forcing, list):
818+
if path_forcing.is_dir():
819+
path_forcing = sorted(path_forcing.glob('*'))
820+
else:
821+
df_forcing_met = read_suews(path_forcing)
822+
if isinstance(path_forcing, list):
820823
path_forcing = [Path(p).resolve() for p in path_forcing]
821824
df_forcing_met = pd.concat([read_suews(fn) for fn in path_forcing])
822-
else:
825+
if not isinstance(path_forcing, (str, Path)) and not isinstance(path_forcing, list):
823826
import pdb; pdb.set_trace()
824827
# `drop_duplicates` in case some duplicates mixed
825828
df_forcing_met = df_forcing_met.drop_duplicates()

src/supy/_supy_module.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def load_forcing_grid(
237237
df_forcing_met = load_SUEWS_Forcing_met_df_yaml(path_input)
238238
tstep_met_in = df_forcing_met.index[1] - df_forcing_met.index[0]
239239
tstep_met_in = int(tstep_met_in.total_seconds())
240-
kdownzen = init_config_from_yaml(path=path_init).model.control.kdownzen.value
240+
kdownzen = init_config_from_yaml(path=path_init).model.control.kdownzen
241+
if kdownzen is not None:
242+
kdownzen = kdownzen.value
241243
if kdownzen is None:
242244
df_forcing_met_tstep = resample_forcing_met(
243245
df_forcing_met, tstep_met_in, tstep_mod, lat, lon, alt, timezone

0 commit comments

Comments
 (0)