1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#!/usr/bin/env python
import cmor
import numpy
def main():
missing = -99.
cmor.setup(inpath='Tables',
netcdf_file_action=cmor.CMOR_REPLACE)
cmor.dataset_json("Test/CMOR_input_example.json")
table = 'CMIP6_Amon.json'
cmor.load_table(table)
axes = [{'table_entry': 'time',
'units': 'days since 2000-01-01 00:00:00',
},
{'table_entry': 'latitude',
'units': 'degrees_north',
'coord_vals': [0],
'cell_bounds': [-1, 1]},
{'table_entry': 'longitude',
'units': 'degrees_east',
'coord_vals': [90],
'cell_bounds': [89, 91]},
]
values = numpy.array([missing], numpy.float32)
myma = numpy.ma.masked_values(values, missing)
axis_ids = list()
for axis in axes:
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
varid = cmor.variable('ts', 'K', axis_ids, missing_value=myma.fill_value)
cmor.write(varid, myma, time_vals=[15], time_bnds=[[0, 30]])
cmor.close(varid)
if __name__ == '__main__':
main()
|