Skip to content

Commit b30e6b0

Browse files
committed
Write hgrid info in output nc file
1 parent 2e5c975 commit b30e6b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bdschism/bdschism/gen_elev2d.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import click
2323
import warnings
2424
import glob
25+
import os
2526

2627
class THWriter(object):
2728
def __init__(self, path, size, starttime):
@@ -65,7 +66,7 @@ def __del__(self):
6566

6667

6768
class NetCDFTHWriter(THWriter):
68-
def __init__(self, fpath_out, nloc, starttime, dt, slr):
69+
def __init__(self, fpath_out, nloc, starttime, dt, slr, hgrid_fpath):
6970
self.outfile = Dataset(fpath_out, "w", format="NETCDF4_CLASSIC")
7071
fout = self.outfile
7172

@@ -101,6 +102,7 @@ def __init__(self, fpath_out, nloc, starttime, dt, slr):
101102
fout.history = "Created " + str(datetime.now())
102103
fout.source = "gen_ elev2D.py"
103104
fout.slr = str(slr)
105+
fout.hgrid = os.path.abspath(hgrid_fpath)
104106

105107
def write_step(self, iter, time, vals):
106108
self.timeseries[iter, :, 0, 0] = vals
@@ -372,7 +374,7 @@ def gen_elev2D(hgrid_fpath, outfile, pt_reyes_fpath, monterey_fpath, start, end,
372374
if fpath_out.endswith("th"):
373375
thwriter = BinaryTHWriter(fpath_out, nnode, None)
374376
elif fpath_out.endswith("nc"):
375-
thwriter = NetCDFTHWriter(fpath_out, nnode, sdate, dt, slr)
377+
thwriter = NetCDFTHWriter(fpath_out, nnode, sdate, dt, slr, hgrid_fpath)
376378
else:
377379
raise ValueError(
378380
"File extension for output not recognized in file: {}".format(fpath_out)

0 commit comments

Comments
 (0)