|
22 | 22 | import click |
23 | 23 | import warnings |
24 | 24 | import glob |
| 25 | +import os |
25 | 26 |
|
26 | 27 | class THWriter(object): |
27 | 28 | def __init__(self, path, size, starttime): |
@@ -65,7 +66,7 @@ def __del__(self): |
65 | 66 |
|
66 | 67 |
|
67 | 68 | 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): |
69 | 70 | self.outfile = Dataset(fpath_out, "w", format="NETCDF4_CLASSIC") |
70 | 71 | fout = self.outfile |
71 | 72 |
|
@@ -101,6 +102,7 @@ def __init__(self, fpath_out, nloc, starttime, dt, slr): |
101 | 102 | fout.history = "Created " + str(datetime.now()) |
102 | 103 | fout.source = "gen_ elev2D.py" |
103 | 104 | fout.slr = str(slr) |
| 105 | + fout.hgrid = os.path.abspath(hgrid_fpath) |
104 | 106 |
|
105 | 107 | def write_step(self, iter, time, vals): |
106 | 108 | self.timeseries[iter, :, 0, 0] = vals |
@@ -372,7 +374,7 @@ def gen_elev2D(hgrid_fpath, outfile, pt_reyes_fpath, monterey_fpath, start, end, |
372 | 374 | if fpath_out.endswith("th"): |
373 | 375 | thwriter = BinaryTHWriter(fpath_out, nnode, None) |
374 | 376 | 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) |
376 | 378 | else: |
377 | 379 | raise ValueError( |
378 | 380 | "File extension for output not recognized in file: {}".format(fpath_out) |
|
0 commit comments