CF_date_range: NetCDF-CF Date Intersection

Description Usage Arguments Details Value Author(s) Examples

View source: R/CF_date_range.R

Description

This function takes units and values to describe a NetCDF time coordinate variable and a start/end year. It returns.

Usage

1
CF_date_range(time_units, time_dim, start, end)

Arguments

time_units

A time units string from a netCDF time coordinate variable.

time_dim

The values of a netCDF time coordinate variable.

start

A four digit year to get the starting index for.

end

A four digit year to get the ending index for.

Details

This function is only meant to work for full calendar years.

Value

A named list containing the following variables

  1. 't_ind1'Index position for the first value in the start year.

  2. 't_ind2'Index position for the last value of the end year.

  3. 'time'Values of the time coordinate variable for the requested period.

  4. 'origin'The calendar origin for use as the 'origin' input to chron.

Author(s)

David Blodgett dblodgett@usgs.gov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
\dontrun{
Using ncdf4 and remote data:

library("ncdf4")
start<-1950
end<-1951
OPeNDAP_URI<-"http://cida.usgs.gov/thredds/dodsC/prism"
ncdf4_handle <- nc_open(OPeNDAP_URI)
time_units<-strsplit(ncdf4_handle$dim$time$units, " ")[[1]]
time_dim<-ncdf4_handle$dim$time$vals
CF_date_range(time_units, time_dim, start, end)

Using sample data:

data(CF_date_range_example, package='climates')
CF_date_range(time_units, time_dim, start, end)
}

## End(Not run)

jjvanderwal/climates documentation built on May 19, 2019, 11:41 a.m.