commit a667852e299cec83941bdecfbda11373b96a3fa9
parent b005ee30787a7ad679644bbe0e864dbbf52356a6
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Fri, 26 Nov 2021 12:58:17 +0100
sealvl.py: add time bounds as per cf conventions
Diffstat:
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/sealvl.py b/sealvl.py
@@ -6,20 +6,28 @@ import netCDF4 as nc4
input = np.loadtxt(sys.stdin)
f = nc4.Dataset("sealvl.nc", "w", format="NETCDF4")
-
+#f.Conventions = "CF-1.3"
f.createDimension("time", input[:, 0].size)
+f.createDimension("nbnds", 2)
+
time = f.createVariable("time", "f4", ("time",))
time.long_name = "Time"
time.standard_name = "time"
time.units = "years since 1-1-1"
time.calendar = "365_day"
+time.bounds = "time_bnds"
+
+time_bnds = f.createVariable("time_bnds", "f4", ("time", "nbnds"))
+time_bnds.units = time.units
+time_bnds.calendar = time.calendar
-delta_SL = f.createVariable("delta_SL", "f4", "time")
+delta_SL = f.createVariable("delta_SL", "f4", ("time",))
delta_SL.long_name = "Sea Level (variation from present)"
delta_SL.standard_name = "global_average_sea_level_change"
delta_SL.units = "meters"
time[:] = input[:, 0]
delta_SL[:] = input[:, 1]
+time_bnds[:] = time[:]
f.close()
\ No newline at end of file