pacificclimate / ncdf4.helpers

Routines to make using NetCDF files in R cleaner and easier.
5 stars 1 forks source link

An error occurred while using the nc.get.time.series function to get the UTC date. #10

Open PanfengZhang opened 6 months ago

PanfengZhang commented 6 months ago

An error occurred while using the nc.get.time.series function to get the UTC date.

The example of .nc data is from NCEP (https://psl.noaa.gov/thredds/fileServer/Datasets/ncep.reanalysis/Monthlies/surface/slp.mon.ltm.1991-2020.nc)

library(ncdf4)
library(ncdf4.helpers)

diri = "C:/Rmet/data/slp.mon.ltm.1991-2020.nc"
fin <- nc_open(diri)

nc.get.time.series(fin)
##  [1] "0000-12-30" "0001-01-30" "0001-02-27" "0001-03-30" "0001-04-29"
##  [6] "0001-05-30" "0001-06-29" "0001-07-30" "0001-08-30" "0001-09-29"
## [11] "0001-10-30" "0001-11-29"

ncatt_get(fin, "time")$interpreted_actual_range
## [1] "0001/01/01 00:00:00 - 0001/12/01 00:00:00"

According to the metadata information of the data, it is known that the data started in January, not December.