DS.GCM.to.grid: Downscale Global GCM Models to a Regular Grid

Description Usage Arguments Details Value Author(s) Examples

View source: R/DS.GCM.to.grid.R

Description

need a function to downscale data to regular grid

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## 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)

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