seas (version 0.4-3)

mscdata: Meteorological Service of Canada sample climate data

Description

Sample climate data from the Meteorological Service of Canada (MSC) climate stations in western Canada.

Usage

data(mscdata)

Arguments

Format

A data.frame with 26358 daily observations on the following 10 variables (metric units of ‘<U+00B0>C’ and ‘mm’ per day):

id:

factor used to distinguish multiple stations within a single data frame

year:

integer year

yday:

integer day of year; 1--365 or 1--366

date:

Date class

t_max:

daily maximum temperature

t_min:

daily minimum temperature

t_mean:

daily mean temperature

precip:

total daily precipitation

rain:

total daily liquid-phase precipitation

snow:

total daily solid-phase precipitation

The climate variables have attributes (attr of units and long.name to identify their units and long names for plotting labels.

There are three climate stations in this data frame from:

ID Station Location Province
1096450 Prince George BC
1108447 Vancouver BC

All data spans from 1975 to 2004 for each station. Missing values are present.

Details

The field id is optional, but very handy when handling multiple stations. Also, the day of year (yday) and year are optional, since these are stored in the date, using dat$date <- as.Date(paste(dat$year,dat$yday),"%Y %j").

The units and long.name attributes stored in the climate variables are optional, but help annotate the graphics.

See Also

mscstn has MSC station ID codes, locations and names; mksub produces subsets of data; read.msc reads MSC archive files, such as A1128551.DLY

Examples

Run this code
# NOT RUN {
data(mscstn)
data(mscdata)
par.orig <- par(no.readonly=TRUE)

# structure in R
str(mscdata)

# first few rows
head(mscdata)

# here are all the station IDs
stnids <- levels(mscdata$id)

# show all data
rng.p <- range(mscdata$precip, na.rm=TRUE)
rng.t <- range(mscdata$t_mean, na.rm=TRUE)
par(mfcol=c(2, 3), mgp=c(2, 1, 0), mar=c(3, 3, 3, 1), bty="l")
for (n in levels(mscdata$id)) {
  dat <- mscdata[mscdata$id == n,]
  plot(t_mean ~ date, dat, "l", col="red", ylim=rng.t)
  abline(h=0)
  plot(precip ~ date, dat, "l", col="blue", ylim=rng.p, main=n)
}
par(par.orig)

# show stations and station names available in this data frame
data.frame(stnids, name=getstnname(stnids))
dat <- mksub(mscdata, id=1108447)
dat$month <- mkseas(dat, "mon")
plot(t_mean ~ date, dat, "l")
plot(t_mean ~ date, dat, subset=(month == "Dec"))
seas.temp.plot(dat)
year.plot(dat)

# plot high-resolution statistics
dly.tmp <- tapply(dat$t_mean, dat$yday,
  quantile, c(5, 25, 50, 75, 95) / 100, na.rm=TRUE)
dly <- data.frame(yday=1:366,
  t(matrix(unlist(dly.tmp), nrow=5)))
names(dly) <- c("yday", "d5", "d25", "median", "d75", "d95")
plot(median ~ yday, dly, "n", ylim=c(-5, 25),
  ylab="mean temperature", xlab="day of year")
polygon(c(1:366, 366:1), c(dly$d5, rev(dly$d95)),
        border=FALSE, col="grey80")
polygon(c(1:366, 366:1), c(dly$d25, rev(dly$d75)),
        border=FALSE, col="grey50")
lines(median ~ yday, dly)
abline(h=0)
# }

Run the code above in your browser using DataLab