Hi,

You problem as stated certainly is puzzling since you have one NCDF file but 
'time units are different'.  I don't know what to make of that.

If you had a simpler case where data are dimensioned as [x,y,t] then you can 
convert dates to index use in ncdf4::ncvar_get()

I would start with a look-up-table of the dates in the file.

lut <- seq(from = as.Date("1850-01-01"), to = as.Date(Sys.Date()), by = 'day')

The use base::findInterval() to convert your start/stop dates to indices. 

mine <- as.Date(c("1971-01-01", "1990-03-01"))

startstop <- findInterval(mine, lut)


Is that at all close to what you seek?
Ben





> On Mar 23, 2017, at 6:07 AM, കുഞ്ഞായി kunjaai <dileepkunj...@gmail.com> wrote:
> 
> Dear All,
> 
> I am trying to extract a time series  from a netCDF file.
> 
> I want to extract data for the time period  1971-1  to 1990-12-31 only.
> 
> time axis units is  'days since 1850-1-1'
> 
> For one or two files I can use "count" argument,  but I have more than 100
> such files and its time units are different.
> 
> Is there any easy way to extract the particular time period using ncdf4
> package?
> 
> Thank you in advance.
> 
> -- 
> DILEEPKUMAR. R
> J R F, IIT DELHI
> 
>       [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to