sidfex.rot.fcst: Rotate (Adjust) SIDFEx Forecasts

sidfex.rot.fcstR Documentation

Rotate (Adjust) SIDFEx Forecasts

Description

Rotate SIDFEx forecasts, typically to correct their initial position or to adjust them based on the most recent observed position.

Usage

sidfex.rot.fcst(obs = NULL, fcst, obsref.DaysLeadTime = 0, obsref.Year = NULL, obsref.DayOfYear = NULL,
lonlat.orig = NULL, lonlat.new = NULL, rot.InitX = FALSE, ensmean.based = FALSE, data.path = NULL)

Arguments

obs

a list with SIDFEx observations as returned by sidfex.read.obs, or NULL (default). Used to determine the rotation parameters based on observed positions only if lonlat.orig and lonlat.new are not provided. If obs=NULL, sidfex.read.obs is used to read the required observations.

fcst

a list with SIDFEx forecasts as returned by sidfex.read.fcst (or a single element from the res.list element of such a list).

obsref.DaysLeadTime

a numeric scalar specifying the time in days relative to the respective forecast initial time to use to adjust the forecast trajectories based on the corresponding observed position. Default is 0. Not used if obsref.Year and obsref.DayOfYear are provided.

obsref.Year

an integer specifying the year of the time to use to adjust the forecast trajectories based on the corresponding observed position. Default is NULL, in which case the rotation parameters are determined based either on obsref.DaysLeadTime or on lonlat.orig and lonlat.new.

obsref.DayOfYear

a numeric scalar specifying the day of year of the time to use to adjust the forecast trajectories based on the corresponding observed position. Used only in combination with obsref.Year.

lonlat.orig

a 2-element (longitude-latitude) vector specifying the original position of a reference point. Used only in combination with lonlat.new, which is the new position of the reference point after the rotation. The latter is performed such that lonlat.orig and lonlat.new are located on the equator of the rotation. Default is NULL, in which case these points are determined based on deviations from observed positions, using either obsref.DaysLeadTime or obsref.Year and obsref.DayOfYear.

lonlat.new

a 2-element (longitude-latitude) vector specifying the new position of a reference point after the rotation. Used only in combination with lonlat.orig.

rot.InitX

a logical value specifying whether also to rotate variables outside the data matrix corresponding to initial locations. Default is TRUE.

ensmean.based

a logical value specifying whether individual ensemble member shall be rotated using the same rotation parameters as for the rotation of the ensemble mean. Default is FALSE, in which case each member is adjusted individually.

data.path

NULL or a character specifying the directory of the forecast (and observational) data. If NULL, it is attempted to source a file named .SIDFEx in the home directory where a character variable data.path.fcst (and data.path.obs) needs to be defined.

Value

a list which is identical with the input fcst, except that the trajectories have been rotated. See the documentation of sidfex.read.fcst for details.

Note

Based on several spheRlab functions.

Author(s)

Helge Goessling

See Also

sidfex.read.fcst, sidfex.read.obs

Examples

# Load the forecast data index
index = sidfex.load.index()

# Show the first rows of the index to see which variables can be used to subselect the index
head(index)

# Select a subset containing one specific forecast ensemble
subind = sidfex.fcst.search.extractFromTable(gid = "ecmwf001" , tid = "300234063991680", iy = 2019, idoy = 1, return.dataframe = TRUE)

# Read the forecasts
fcst = sidfex.read.fcst(subind)

# Remap these seasonal-range forecasts to the first ten days only
fcst.remapped = sidfex.remaptime.fcst(fcst,newtime.DaysLeadTime=0:10)

# Plot latitude against forecast lead time for the individual ensemble members and the ensemble mean
dat = fcst.remapped$res.list[[1]]$data
times = dat$DaysLeadTime
lats = dat[,substr(names(dat),1,3)=="Lat"]
plot(NA,xlim=range(times),ylim=range(lats),xlab="Forecast Lead Time (Days)",ylab="Latitude (Degrees North)")
for (i in 2:ncol(lats)) {lines(times,lats[,i], col="grey")}
lines(times,lats[,1],col="black",lwd=2)

# Load and plot the corresponding observations
obs = sidfex.read.obs(subind)
obs.remapped = sidfex.remaptime.obs2fcst(obs,fcst.remapped)
lines(times,obs.remapped$res.list[[1]]$data$Lat,col="red",lwd=2)

# You see that the initial location of the forecast ensemble is slightly offset from the true initial location (due to some subtle intricacies of the tracing method used in the ecmwf001 forecasts). So let's correct the initial location of the forecast ensemble to match the initial observed position:
fcst.corrected = sidfex.rot.fcst(obs = obs, fcst = fcst.remapped)
dat.corrected = fcst.corrected$res.list[[1]]$data
lats.corrected = dat.corrected[,substr(names(dat.corrected),1,3)=="Lat"]
for (i in 2:ncol(lats.corrected)) {lines(times,lats.corrected[,i], col="cyan")}
lines(times,lats.corrected[,1],col="blue",lwd=2)

# Now let's imagine a real-time scenario where the forecast is already 3 days old (current date is 2019 January 4th, 00:00UTC), but we still want to use the forecast to estimate the future trajectory. We can do so by rotating the forecast (and all ensemble members) based on the current observed position:
fcst.realtime = sidfex.rot.fcst(obs = obs, fcst = fcst.remapped, obsref.Year=2019, obsref.DayOfYear=4)
dat.realtime = fcst.realtime$res.list[[1]]$data
lats.realtime = dat.realtime[,substr(names(dat.realtime),1,3)=="Lat"]
for (i in 2:ncol(lats.realtime)) {lines(times,lats.realtime[,i], col="orange")}
lines(times,lats.realtime[,1],col="brown",lwd=2)

# Let's replot the observations to make it visible again
lines(times,obs.remapped$res.list[[1]]$data$Lat,col="red",lwd=2)


helgegoessling/SIDFEx documentation built on March 15, 2024, 2:26 p.m.