sidfex.plot.speedangle: Plot Speed-vs-Angle Errors for SIDFEx Data

View source: R/sidfex.plot.speedangle.R

sidfex.plot.speedangleR Documentation

Plot Speed-vs-Angle Errors for SIDFEx Data

Description

Generate a so-called speed-angle-plot for SIDFEx forecast data. Speed and angle errors are always based on the integrated displacement of the target (e.g., buoy) from its initial position. If only a (sub-)index of the forecasts is provided, all relevant forecast and observational data are read, remapped to a common time axis, analysed, and subsequently plotted; if intermediate results (that must be consistent with the index) are provided, the corresponding steps are skipped.

Usage

sidfex.plot.speedangle(index=NULL,read.fcst.res=NULL,read.obs.res=NULL,remap.res=NULL,col.by="DaysLeadTime",colbar=sl.colbar.redgreyblue_256,colbar.breaks=NULL,colbar.breaks.log=FALSE,points.type="p",device="pdf",file=paste0("~/sidfex.plot.speedangle.",device),width=NULL,do.init.device=TRUE,do.close.device=TRUE,labels=TRUE,labels.cex=1,bg.lines.lwd=labels.cex,...)

Arguments

index

a data frame specifying the SIDFEx forecasts to be read/analysed/plotted, or NULL (default). In the latter case, read.fcst.res must be provided and a corresponding index is derived from that.

read.fcst.res

a list with SIDFEx forecasts as returned by sidfex.read.fcst, or NULL (default). In the latter case, sidfex.read.fcst is used to read the required forecasts based on index.

read.obs.res

a list with SIDFEx observations as returned by sidfex.read.obs, or NULL (default). In the latter case, sidfex.read.obs is used to read the required observations (based on index or read.fcst.res). Providing this argument can save time. Ignored if remap.res is provided, which saves even more time.

remap.res

a list with remapped SIDFEx observations as returned by sidfex.remaptime.obs2fcst, or NULL (default). In the latter case, sidfex.remaptime.obs2fcst is used to remap observations temporally to times at which the forecasts are valid. Providing this argument can save time.

col.by

a character specifiying by what property data points shall be coloured. Can be either any column of index (except File): File, GroupID, MethodID, TargetID, InitYear, InitDayOfYear, EnsMemNum, SubmitYear, SubmitDayOfYear, ProcessedYear, ProcessedDayOfYear, Delay, nTimeSteps, FirstTimeStepYear, FirstTimeStepDayOfYear, LastTimeStepYear, LastTimeStepDayOfYear, and FcstTime. Or, it can be a column of the forecast data table: Year, DayOfYear, Lat, Lon, and DaysLeadTime. Some of these are interpreted in a categorical way (e.g., GroupID, EnsMemNum, and Year), and some as continuous numerical values (e.g., Delay, Lat, and DaysLeadTime, which is the default).

colbar

a spheRlab colourbar as returned by sl.colbar). If col.by is categorical, colbar must contain at least as many colours as there are categories; if colbar has more colours, the colourbar is thinned out.

colbar.breaks

an optional numeric vector specifying the breaks between colours. Ignored if col.by is categorical.

colbar.breaks.log

a logical value indicating whether breaks for the colourbar shall be placed in logarithmic steps. Default is breaks.log=FALSE. Ignored if col.by is categorical or if breaks is provided.

points.type

a character specifying whether only points ('p'), only lines ('l'), or both ('b') shall be plotted.

device

a character specifying which graphics device to use, or NULL for the default device. Default is device='pdf'.

file

a character specifying the output file (if device!=NULL). Default is file=paste0("~/sidfex.plot.speedangle.",device).

width

a scalar specifying the width of the resulting figure. The height will be equal. If NULL (default), a (hopefully) useful value depending on device is used.

labels

a logical value specifying whether or not labels shall be plotted. Default is TRUE.

labels.cex

a numerical value specifying the amount by which labels shall be magnified relative to the default.

bg.lines.lwd

a numerical value specifying the width of the background lines (marking the 'coordinate system').

...

Further graphical parameters to be forwarded to points (see documentation of points for details).

Value

A list with the elements col.by, colbar, categorical, breaks, and labels, which can be used to plot the corresponding colourbar with sl.plot.colbar.

Author(s)

Helge Goessling

See Also

sidfex.read.fcst, sidfex.read.obs, sidfex.remap.obs2fcst

Examples

# load whole SIDFEx forecast index
index = sidfex.load.index()

# extract subindex with all forecasts that match some filters
subindex = index[ index$TargetID == "300234063991680" &
                  index$GroupID %in% c("metno001","esrl001","ukmo001","eccc001") &
                  index$InitYear == 2018 &
                  index$InitDayOfYear > 210 &
                  index$InitDayOfYear < 215, ]

# Generate a speed-angle-plot for all forecast data corresponding to the subindex, with colours according to the GroupID, as well as the corresponding colourbar
colbar = sidfex.plot.speedangle(subindex,col.by="GroupID",points.type="l",colbar=sl.colbar(cols = c("violet","blue","green","yellow","orange","red"),N=256),device="pdf",file="~/speedangle_example_1.pdf")
sl.plot.colbar(colbar,file.name="~/speedangle_example_1_colbar.pdf")

# Generate another speed-angle-plot for the same data, but with colours according to DaysLeadTime
colbar = sidfex.plot.speedangle(subindex,col.by="DaysLeadTime",points.type="l",colbar=sl.colbar(cols = c("violet","blue","green","yellow","orange","red"),N=256),device="pdf",file="~/speedangle_example_2.pdf")
sl.plot.colbar(colbar,file.name="~/speedangle_example_2_colbar.pdf")

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