0

While it is not consistent with the Unidata conventions and recommendations, some netcdf files have a time variable with units of the form "years since {some_date}". An Example file was obtained from the KNMI Climate Explorer. With the R package metR version 0.11.0 reading in such a file using ReadNetCDF() yields a reasonable output (as in, a date/time unambiguously in the correct year), at least for multi-decadal length data with reference date near the middle of the year. With metR 0.14.0, nc_ts = ReadNetCDF("sample_yrtime.nc") yields the warning:

In .parse_time(ncfile$dim[[dims[i]]]$vals, ncfile$dim[[dims[i]]]$units,:
time unit has unrecognised units: years. Not parsing.

The time column in the output data.table is essentially an integer index. Is there a way to extract the reference date ({some_date}) or to recover the correct year for each data point using metR >= 0.14? At the moment I'm manually reading the reference date with other software and then doing something like:

library(data.table)
yr0 = 1960
nc_ts[, yr := time + yr0]
climatestudent
  • 459
  • 4
  • 13
  • You seem to be describe a bug in the package, given it was working in an earlier version. You’d be better raising an issue on GitHub https://github.com/eliocamp/metR – Robert Wilson Jul 28 '23 at 06:12
  • Thank you for the suggestion, I get the sense from the source code that it was a deliberate change along the lines of a similar recent change in python `xarray`, but I will check! – climatestudent Jul 30 '23 at 21:19

0 Answers0