mscdata             package:seas             R Documentation(latin1)

_M_e_t_e_o_r_o_l_o_g_i_c_a_l _S_e_r_v_i_c_e _o_f _C_a_n_a_d_a _s_a_m_p_l_e _c_l_i_m_a_t_e _d_a_t_a

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     data(mscdata)

_F_o_r_m_a_t:

     A 'data.frame' with 26358 daily observations on the following 10
     variables (metric units of 'degrees C' and 'mm' _per day_):

     '_i_d': 'factor' used to distinguish multiple stations within a
          single data frame

     '_y_e_a_r': 'integer' year

     '_y_d_a_y': 'integer' day of year; 1-365 or 1-366

     '_d_a_t_e': 'Date' class

     '_t__m_a_x': daily maximum temperature

     '_t__m_i_n': daily minimum temperature

     '_t__m_e_a_n': daily mean temperature

     '_p_r_e_c_i_p': total daily precipitation

     '_r_a_i_n': total daily liquid-phase precipitation

     '_s_n_o_w': 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
       2100630  Haines Junction     YT

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

_D_e_t_a_i_l_s:

     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.

_A_u_t_h_o_r(_s):

     M.W. Toews

_S_o_u_r_c_e:

     Data provided by the Meteorological Service of Canada, with
     permission. This data may only be reproduced for personal use; any
     other reproduction is permitted only with the written consent of
     Environment Canada.

     <URL: http://www.msc.ec.gc.ca/> 
     <URL: http://climate.weatheroffice.ec.gc.ca/contacts/>

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     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")
     plot.seas.temp(dat)
     plot.year(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)

