Skip to content

Commit

Permalink
allow pathlib paths in write_and_run
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrakenhoff committed Jul 2, 2024
1 parent ee6ed3e commit 295623d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nlmod/sim/sim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime as dt
import logging
import os
import pathlib
from shutil import copyfile

import flopy
Expand Down Expand Up @@ -51,7 +52,10 @@ def write_and_run(sim, ds, write_ds=True, script_path=None, silent=False):
ds.attrs["model_dataset_written_to_disk_on"] = dt.datetime.now().strftime(
"%Y%m%d_%H:%M:%S"
)
ds.to_netcdf(os.path.join(ds.attrs["model_ws"], f"{ds.model_name}.nc"))
if isinstance(ds.attrs["model_ws"], pathlib.PurePath):
ds.to_netcdf(ds.attrs["model_ws"] / f"{ds.model_name}.nc")
else:
ds.to_netcdf(os.path.join(ds.attrs["model_ws"], f"{ds.model_name}.nc"))

logger.info("write modflow files to model workspace")
sim.write_simulation(silent=silent)
Expand Down

0 comments on commit 295623d

Please sign in to comment.