DS.GCM.to.grid {climates}R Documentation

Downscale Global GCM Models to a Regular Grid

Description

need a function to downscale data to regular grid

Usage

DS.GCM.to.grid(nc, lon = c(-180, 180), lat = c(-90, 90), cellsize = 0.2,
  type = 2)

Arguments

nc
lon
lat
cellsize
type

Details

nc should be from extend.global.data

Value

Downscale Global GCM Models to a Regular Grid

Author(s)

Jeremy VanDerWal jjvanderwal@gmail.com

Examples

## Not run: 
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(nc,cellsize=0.2,type=2) {
	#ensure nc is from retrieve.nc or similar
	if (all(c('dat','tim','lat', 'lon') %in% names(nc))==FALSE)
  stop('nc must have objects named dat, lat, lon and tim as from
  retrieve.nc of clim.pact package, append.nc or extract.monthly.averages')
	if (!(type %in% 1:3)) stop('type must be 1,2 or 3... see help file')
	#do the work
	lat = seq(-90+0.5*cellsize,90-0.5*cellsize,cellsize)
	lon = seq(-180+05*cellsize,180-0.5*cellsize,cellsize)
	out = array(0,dim=c(length(nc$tim),length(lat),length(lon)))
	for (ii in 1:length(nc$tim)) { out[ii,,] =
  interp2grid(nc$dat[ii,,],lon,lat,nc$lon,nc$lat,type=type) }
	return(list(dat=out,lon=lon,lat=lat,tim=nc$tim))
  }

## End(Not run)

[Package climates version 0.1-1.6 Index]