sealvl.py (860B)
1 #!/usr/bin/env python 2 import sys 3 import numpy as np 4 import netCDF4 as nc4 5 6 input = np.loadtxt(sys.stdin) 7 8 f = nc4.Dataset("sealvl.nc", "w", format="NETCDF4") 9 #f.Conventions = "CF-1.3" 10 f.createDimension("time", input[:, 0].size) 11 f.createDimension("nbnds", 2) 12 13 time = f.createVariable("time", "f4", ("time",)) 14 time.long_name = "Time" 15 time.standard_name = "time" 16 time.units = "years since 1-1-1" 17 time.calendar = "365_day" 18 time.bounds = "time_bnds" 19 20 time_bnds = f.createVariable("time_bnds", "f4", ("time", "nbnds")) 21 time_bnds.units = time.units 22 time_bnds.calendar = time.calendar 23 24 delta_SL = f.createVariable("delta_SL", "f4", ("time",)) 25 delta_SL.long_name = "Sea Level (variation from present)" 26 delta_SL.standard_name = "global_average_sea_level_change" 27 delta_SL.units = "meters" 28 29 time[:] = input[:, 0] 30 delta_SL[:] = input[:, 1] 31 time_bnds[:] = time[:] 32 33 f.close()