read.temperatures.Rd
The temperature data should be a netCDF file of annual grid values. The data is assumed to have its dimensions of time, lat, lon, where lon is the most rapidly varying index, and time is the least.
read.temperatures( filename, len = NULL, tag = basename(filename), varname = "tas", latvar = "lat", lonvar = "lon", timevar = "time" )
filename | Name of the input netCDF file |
---|---|
len | Maximum length of the time series to read. If the data read is longer, it will be trimmed. (Default: read entire time series, regardless of length.) |
tag | A string identifying the name of the scenario. If omitted, the tag will default to the filename. |
varname | Name of the variable to read from the netcdf file. Irrespective of the name in the netcdf file, it will be called 'tas' in the return data. |
latvar | Name of the latitude dimension variable in the input file. |
lonvar | Name of the longitude dimension variable in the input file. |
timevar | Name of the time dimension variable in the input file. |
A griddata
list (see details).
The output will be a list with six fields:
Matrix of temperature data.
Vector operator for global mean temperature.
Vector of latitude values. These are only replicated
once, so their length is nlat, not ngrid. You have to use rep(lat,
nlon)
to get latitudes for each grid cell.
Vector of longitude values. These are only replicated
once, so their lingth is nlon, not ngrid. Getting longitudes for each grid
cell is tricksy. Try as.vector(matrix(rep(lon, nlat), nrow=nlat,
byrow=TRUE))
. Fortunately, you don't need them very often.
Vector of time values, given as years since the base year of the dataset.
A list of datasets that were concatenated to get this structure. The names of the list are the tags given to the dataset, and the values are a vector of start-row, end-row pairs.
The data at each time is represented as a flattened vector of grid cells. The flattening is performed by transposing to lat, lon ordering, so that lat will be the most rapidly varying index (because R uses Fortran-style indexing). Then the spatial dimensions are discarded, resulting in a 1D vector. The time dimension is kept, resulting in a matrix with years in rows and grid cells in columns. The dimensions of the matrix will be Nyear x Ngrid, where Nyear is the number of years in the data set, and Ngrid is the number of grid cells.
The tgop
vector is a vector whose dot product with a flattened grid is
the area-weighted global mean for the grid. It is stored as a column vector,
so tas %*% tgop
is the time series of global mean temperatures.
The lat and lon dimension variables from the input file are also stored in the structure. These are primarily useful for writing out generated grids as netCDF files. The time dimension variable is converted to integer years, starting at 0.
Conventionally, we refer to the output list as griddata
. Notably, any
other function with a griddata
argument is expecting one of these
structures.