read.nc {climates}R Documentation

Read From a netCDF File

Description

read.nc reads a netCDF file from e.g., PCMDI and picks out vectors that look like longitude, latitude and time. It returns a list containing the data and associated attributes from the netCDF file.

The code here represents some, albeit slight, modification of retrieve.nc of the clim.pact package. As functions of this package require consistent structuring of outputs, we decided to present a modified copy of that function here. Indeed, much of this helpfile comes from retrieve.nc.

Usage

read.nc(filename = file.path("data", "air.mon.mean.nc"), v.nam = "AUTO",
  l.scale = FALSE, greenwich = TRUE, silent = FALSE, x.nam = "lon",
  y.nam = "lat", z.nam = "lev", t.nam = "tim", x.rng = NULL,
  y.rng = NULL, z.rng = NULL, t.rng = NULL, force.chron = TRUE,
  force365.25 = FALSE, regular = TRUE, daysayear = 365.25,
  forceBC = TRUE, use.cdfcont = FALSE, torg = NULL, t.unit = NULL,
  miss2na = TRUE)

Arguments

filename

name of netCDF file.

v.nam

name of variable. "AUTO" -> smart search.

l.scale

'TRUE' uses scaling.factor and add.offset.

greenwich

'TRUE' centres maps on Greenwhich meridian (0 deg E).

x.nam

Name of x-dimension.

y.nam

Name of y-dimension.

z.nam

Name of z-dimension.

t.nam

Name of time-axis.

x.rng

Region to extract.

y.rng

Region to extract.

z.rng

Region to extract.

t.rng

Time interval to extract.Numerical values are used to identify indeces, e.g. as.numeric(1) refers to first field, as.numeric(2) the second field, etc. Character strings, on the other hand, refers to date. E.g. "1-Jan-1990", or "1990" (see datestr2num for various formats).

force.chron

Check for monotonic chronological order (no jumping back and forth in time).

force365.25

TRUE forces a natural 365.25 day year as opposed to a 360-day model year. '-1' forces a 360-day year (commonly used in climate modelling).

regular

TRUE for regular spacing in time (.i.e. no skipping, but one field every month or one field every day).

daysayear

Number of days in the year on average.

forceBC

TRUE for not accepting year 0 (see e.g. Press et al. (1989), Numerical Recepies in Pascal, Cambridge).

use.cdfcont

Flag for Linux versions only: if TRUE use old lines calling 'cdfcont()'

torg

Time origin, such as the 'time\_origin' attribute in netCDF files. e.g. '15-Dec-1949'. A NULL value (default) will try to detect from the file header.

t.unit

Time unit, similar to the 'time\_unit' attribute in netCDF files. e.g. 'day'. A NULL value (default) will try to detect from the file header.

Value

A list of class "nc" and "field.object" with the following data:

dat a 3-D matrix with the data.
lon a vector of longitudes.
lat a vector of latitudes.
tim a vector of times from time.0 (see attributes).
lev a vector of vertical levels (NULL for single level).
v.name variable name.
id.x ID labels for the spatial grid (for mixed fields, see mixFields).
id.t ID labels for the time axis (for combined fields).
yy a vector of years corresponding to tim.
mm a vector of months corresponding to tim.
dd a vector of days corresponding to tim.
n.fld number of fields (for mixed fields, see mixFields).
id.lon ID labels along the longitudes (for mixed fields, see mixFields).
id.lat ID labels along the latitudes (for mixed fields, see mixFields).

.

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

References

Rasmus E. Benestad (2010). clim.pact: Climate analysis and empirical-statistical downscaling (ESD) package for monthly and daily data.. R package version 2.2-41. http://CRAN.R-project.org/package=clim.pact

Examples

## Not run: 
 #need to fill in
 
## End(Not run)

[Package climates version 0.1-1.6 Index]