getTemporalIntersection: Temporal intersection

View source: R/subsetGrid.R

getTemporalIntersectionR Documentation

Temporal intersection

Description

Takes two input grids and crops the overlapping part along time dimension

Usage

getTemporalIntersection(obs, prd, which.return = c("obs", "prd"))

Arguments

obs

First grid (typically observations, but not necessarily)

prd

Second grid (typically predictors in downscaling applications, but not necessarily)

which.return

Which subset grid should be returned, obs or prd?

Value

The grid indicated in which.return, encompassing the overlapping time period with the other one.

Author(s)

J Bedia

See Also

checkDim, checkSeason, getYearsAsINDEX, getSeason, for other time dimension helpers

Other subsetting: intersectGrid(), intersectGrid.spatial(), intersectGrid.time(), limitArea(), subsetCluster(), subsetDimension(), subsetGrid(), subsetMembers(), subsetRuntime(), subsetSeason(), subsetSpatial(), subsetStation(), subsetVar(), subsetYears()

Examples


require(climate4R.datasets)
data("NCEP_Iberia_psl")
range(getRefDates(NCEP_Iberia_psl))
data("EOBS_Iberia_tas")
range(getRefDates(EOBS_Iberia_tas))
# Assume NCEP's sea-level pressure is the predictor, 
# and EOBS observations are the predictand,
# encompassing both datasets different temporal periods:
predictor <- subsetGrid(NCEP_Iberia_psl, years = 1987:2001, season = 1)
getSeason(predictor) # January
range(getYearsAsINDEX(predictor)) # period 1987-2001 
predictand <- EOBS_Iberia_tas
getSeason(predictand) # December-January-February (winter)
range(getYearsAsINDEX(predictand)) # period 1983-2002
# We often want to ensure that their time dimension matches perfectly before downscaling:
try(checkDim(predictor, predictand, dimensions = "time"))
# getTemporalIntersection is the solution:
predictand.adj <- getTemporalIntersection(obs = predictand, prd = predictor, which.return = "obs")
getSeason(predictand.adj) # January 
range(getYearsAsINDEX(predictand.adj)) # 1987-2001 
# In the same vein, it is often required to do the same on the predictor 
predictor.adj <- getTemporalIntersection(obs = predictand, prd = predictor, which.return = "prd")
checkDim(predictor.adj, predictand.adj, dimensions = "time") # perfect


SantanderMetGroup/transformeR documentation built on Nov. 25, 2024, 1:25 p.m.