I am trying to convert annual temperature and rainfall data from the Indian Met Office from .grd to netcdf using CDO in Linux. However when I import the netcdf file into R & inspect the dates, there is no value for Jan 1st for a given year & either a value for the following year or a duplicate date depending on the file (I have the correct total number of dates in each case). I want to ensure that this is a labelling issue & that the ordering is correct, and not a problem with the conversion or underlying data.
Steps to reproduce:
Download the binary max-temperature file for 1951 from http://www.imdpune.gov.in/Clim_Pred_LRF_New/Grided_Data_Download.html#
Create a ctl file (Maxtemp_MaxT_1951.ctl) with the following text, based on their example:
DSET Maxtemp_MaxT_1951.GRD
TITLE 1 degree analyzed grids
UNDEF 99.9
XDEF 31 LINEAR 67.5 1
YDEF 31 LINEAR 7.5 1
ZDEF 1 Linear 1 1
TDEF 365 LINEAR 1JAN1994 1DY
VARS 1
T 0 99 DAILYTEMP
ENDVARS
- Run the following in bash to generate the .nc file
cdo -f nc import_binary Maxtemp_MaxT_1951.ctl Maxtemp_MaxT_1951.nc
- Import the netcdf into R
library(raster)
library(ncdf4)
netcdf_example <- "my_path//Maxtemp_MaxT_1951.nc"
brick_test <- brick(netcdf_example,varname="t")
head(brick_test@z)
The first listed date-time is "1951-01-02 23:56:02" and the last is "1952-01-01 23:56:02"
Per comment below, the issue appears to be on the raster import (dates show up properly when called from CDO). Also in case it's relevant I'm doing the conversion in Linux then syncing the .nc files via Dropbox, then importing using R for Windows.