【发布时间】:2015-12-02 07:59:38
【问题描述】:
我正在编写一个 netCDF 文件并尝试从年初开始创建一个以秒为单位的时间变量。我正在为一个温度变量写这个,该变量的值在一年内每 6 小时记录一次(1459 个元素)。如何制作一个写入这两个变量的 netCDF 文件,时间范围从年初开始,每 6 小时步进一次?
if year_desired % 4 == 0:
ntime = 1462
else : ntime = 1458
n_air_temperature = np.reshape(air_temperature_opendap,(ntime,1,1))
# Assign the dimension data to the new NetCDF file.
ntime = int(ntime)
ncfile.createDimension('time',ntime)
ncfile.createDimension('latitude',1)
ncfile.createDimension('longitude',1)
air_temperature = ncfile.createVariable('air_temperature',dtype('float32').char, ('time','latitude','longitude'))
air_temperature[21600::] = n_air_temperature
ncfile.close()
【问题讨论】:
-
@MikeMüller 刚刚在上面发帖
-
@James,我注意到您已经问了 7 个问题,但从未接受过答案。请参阅stackoverflow.com/help/accepted-answer。我了解我对这个问题的回答可能无法解决您的问题(对不起,我不知道 netcdf)。但是您的其他一些问题有很好的答案,您应该考虑接受。
-
@jimhark 你确实解决了我的问题!我很抱歉没有“接受”你的回答,我是新手。感谢您的信息!
-
@James,不用担心。感谢您的接受,我很高兴它有所帮助。如果您愿意,您还有另一个机会帮助其他用户,方法是在您的问题末尾添加一条说明日期操作如何适合 netcdf 代码的注释。 (我自己对此有一种闲散的好奇心。)