【问题标题】:NetCDF combining time variable units for different daysNetCDF 组合不同日期的时间变量单位
【发布时间】:2018-07-07 06:35:59
【问题描述】:

我目前正在处理价值 20 年的飞行的气溶胶数据。我希望能够定义一段时间来显示数据。但是,所有数据自一天开始以来都以秒为单位。可以在这里看到:

 <class 'netCDF4._netCDF4.Variable'>
float64 UTC_time(UTC_time)
    standard_name: time
    long_name: UTC time
    units: seconds since 1996-07-30 00:00:00
    calendar: standard
unlimited dimensions:
current shape = (1006,)
filling off

<class 'netCDF4._netCDF4.Variable'>
float64 UTC_time(UTC_time)
    standard_name: time
    long_name: UTC time
    units: seconds since 1996-07-30 00:00:00
    calendar: standard
unlimited dimensions:
current shape = (9864,)
filling off

是否可以为所有这些数据设置开始时间,以便我可以参考整个数据集,例如只获取 2015 年 7 月的所有数据。

非常感谢您提供任何可能的帮助。

【问题讨论】:

    标签: python python-3.x netcdf geo netcdf4


    【解决方案1】:

    您可以使用 netCDF num2date 将时间单位从 1996 年 7 月 30 日 00:00:00 以来的秒数转换为日历日期。

    import netCDF4
    
    ncfile = netCDF4.Dataset('file.nc', 'r')
    time = ncfile.variables['time'] #don't cast to numpy array yet
    time_convert = netCDF4.num2date(time[:], time.units, time.calendar)
    

    【讨论】:

    • 不客气。如果有帮助,请考虑检查此答案是否已解决。
    猜你喜欢
    • 1970-01-01
    • 2018-02-10
    • 2020-06-26
    • 2019-10-28
    • 2013-12-25
    • 2019-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多