append.nc {climates}R Documentation

Append Temporally Disjunct NCDF data

Description

define a function to append data of two ncdf files from retrieve.nc or at least have the tim,yy,mm,dd,

Usage

append.nc(nc1, nc2)

Arguments

nc1

~~Describe nc1 here~~

nc2

~~Describe nc2 here~~

Details

we must assume that units, extents, variable, etc. are all the same

Value

...

Note

~~further notes~~

Author(s)

~~who you are~~

References

~put references to the literature/web site here ~

See Also

~~objects to See Also as help, ~~~

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(nc1,nc2) {
	#ensure nc1 & nc2 are from retrieve.nc
	if (all(c('dat','tim','yy','mm','dd', 'lat', 'lon') %in% names(nc1))==FALSE)
  stop('nc1 must have objects named dat, lat, lon, tim, yy, mm and dd as from
  retrieve.nc of clim.pact package')
	if (all(c('dat','tim','yy','mm','dd', 'lat', 'lon') %in% names(nc2))==FALSE)
  stop('nc2 must have objects named dat, lat, lon, tim, yy, mm and dd as from
  retrieve.nc of clim.pact package')
	#do the work
	out = nc1 #copy nc1
	out$dat = array(NA,dim=c(dim(nc1$dat)[1]+dim(nc2$dat)[1],dim(nc1$dat)[2],
  dim(nc1$dat)[3]))#redim dat
	out$dat[1:dim(nc1$dat)[1],,] = nc1$dat #add dat from nc1
	out$dat[(dim(nc1$dat)[1]+1):(dim(nc1$dat)[1]+dim(nc2$dat)[1]),,] = nc2$dat
  #add dat from nc2
	#append the time information
	out$tim = c(nc1$tim,nc2$tim)
	out$yy = c(nc1$yy,nc2$yy)
	out$mm = c(nc1$mm,nc2$mm)
	out$dd = c(nc1$dd,nc2$dd)
	if ('id.t' %in% names(nc1)) out$id.t = c(nc1$id.t,nc2$id.t)
	if ('filename' %in% names(nc1)) out$filename = NA
	if ('attributes' %in% names(nc1)) out$attributes$filename = NA
	#return the data
	return(out)
  }

## End(Not run)

[Package climates version 0.1-1.6 Index]