Learn R Programming

oce (version 1.0-1)

read.met: Read a met File

Description

Reads a comma-separated value file in the format used by the Environment Canada [1]. The agency does not publish a format for these files, so this function was based on a study of a few sample files, and it may fail for other files, if Environment Canada changes the format.

Usage

read.met(file, type = NULL, skip, tz = getOption("oceTz"),
  debug = getOption("oceDebug"))

Arguments

file

a connection or a character string giving the name of the file to load.

type

if NULL, then the first line is studied, in order to determine the file type. If type="msc", then a file as formatted by Environment Canada is assumed.

skip

optional number of lines of header that occur before the actual data. If this is not supplied, read.met scans the file until it finds a line starting with "Date/Time", and considers all lines above that to be header.

tz

timezone assumed for time data

debug

a flag that turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more.

Value

An object of class "met", of which the data slot contains vectors time, temperature, pressure, u, and v. The velocity components have units m/s and are the components of the vector of wind direction. In other words, the oceanographic convention on velocity is employed, not the meteorological one; the weather forecaster's "North wind" has positive v and zero u. In addition to these things, data also contains wind (in km/h), taken straight from the data file.

References

1. Environment Canada website for Historical Climate Data http://climate.weather.gc.ca/index_e.html

See Also

Other things related to met data: [[,met-method, [[<-,met-method, as.met, download.met, met-class, met, plot,met-method, subset,met-method, summary,met-method

Examples

Run this code
# NOT RUN {
library(oce)
# Recreate data(met) and plot u(t) and v(t)
metFile <- download.met(id=6358, year=2003, month=9, destdir=".")
met <- read.met(metFile)
met <- oceSetData(met, "time", met[["time"]]+4*3600,
                 note="add 4h to local time to get UTC time")
plot(met, which=3:4)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab