def setup_netcdf_root(root,
header,
N):
"""
Add variables, dimensions (all of size *N), and attributes from
*config* to :class:`Dataset` *root* and return *root*.
"""
# add global attributes
root.source = header.Source_of_Data
root.station = header.Station_Name
root.code = header.IAGA_CODE
root.latitude = header.Geodetic_Latitude
root.longitude = header.Geodetic_Longitude
root.elevation = header.Elevation
root.reported = header.Reported
root.sensor_orientation = header.Sensor_Orientation
root.data_interval_type = header.Data_Interval_Type
root.data_type = header.Data_Type
root.creation_time_utc = str(datetime.utcnow())
# add dimensions
time_dim = root.createDimension('time', N)
codes = ['X', 'Y', 'Z', 'F', 'H', 'D']
for code in codes:
dim = root.createDimension(code, N)
# add variables
time = root.createVariable('time', 'f8', ('time',))
time.standard_name = 'time'
time.units = 'seconds since 2000-01-01 12:00:00.0'
time.calendar = 'gregorian'
for code in codes:
var = root.createVariable(code,
'f8',
(code,),
zlib=True)
var.standard_name = NAME_MAP[code]
var.units = UNITS_MAP[code]
return root
评论列表
文章目录