Skip to content

Commit da82c30

Browse files
EliEli
authored andcommitted
Add creation date attribute and write incrementally
1 parent 303af5c commit da82c30

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

schimpy/nudging.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -289,21 +289,22 @@ def concatenate_nudge(
289289
),
290290
)
291291

292-
# Global Attributes -- Metadata
293-
rootgrp_T.history = "Created " + str(datetime.datetime.now())
294-
rootgrp_T.start_date = str(self.start_date)
295-
rootgrp_T.rnday = str(self.rnday)
296-
rootgrp_T.hgrid = os.path.abspath(self.hgrid_fn)
297-
298292
# in schism indices are 1 based
299293
id_map_T[:] = np.array(imap_merged) + 1
300294
itime_id_T[:] = self.time_seconds
301295

302-
# current var dimension [time, map_node, nlevel]
303-
ivar_T[:, :, :, :] = values_merged[:, :, :, np.newaxis]
296+
# Convert once to float32, C-contiguous
297+
values_merged = np.asarray(values_merged, dtype="f4", order="C")
298+
ntime = values_merged.shape[0]
299+
300+
# Write one time slice at a time
301+
for it in range(ntime):
302+
ivar_T[it, :, :, 0] = values_merged[it, :, :]
303+
304304
rootgrp_T.close()
305305
print("%s file created" % nudging_fn)
306306

307+
307308
if v == "temperature":
308309
nudge_gr3_fn = "TEM_nudge_%s.gr3" % suffix
309310
elif v == "salinity":

0 commit comments

Comments
 (0)