read.dly: Read GHCN DLY daily weather file into a data frame

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/read.dly.R

Description

Imports daily data files from the Global Historical Climatology Network (GHCN), replaces nodata values with NA, and converts precipitation to mm and temperature to C.

Usage

1
read.dly(filename)

Arguments

filename

Filename or URL of a GHCN DLY file.

Details

All GHCN DLY files should have these five elements: PRCP (precipitation, originally tenths of a mm but mm in the function output); SNOW (snowfall, mm); SNWD (snow depth, mm), TMAX (maximum temperature, originally tenths of degree C but C in the function output), and TMIN (minimum temperature, originally tenths of degree C but C in the function output).

Depending on the station, there may be many other recorded variables. Each variable is accompanied by a series of quality flags, which are preserved from the original file.

Data are in a complex fixed-width format. Please see the GHCN readme for details.

Value

Returns a data frame with date as three columns, YEAR, MONTH, DAY, and each data value present in the original file along with its quality flags. Please see the GHCN readme for details.

Note that units for temperature and precipitation have been converted from the GHCN values.

These columns will always be present in the output:

YEAR

Year.

MONTH

Month number.

DAY

Day of month.

PRCP

Precipitation (mm).

TMAX

Maximum temperature (C).

TMIN

Minimum temperature (C).

Author(s)

Sarah Goslee

References

GHCN data comprises both current and historical weather station data world-wide.

See Also

wth.param, weather

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# ten years of daily weather data, 2000-2009, for State College, PA
weather <- read.dly(system.file("extdata", "USC00368449.dly", package = "VFS"))

# could also use: 
# weather <- read.dly("ftp://ftp.ncdc.noaa.gov/pub/data/ghcn/daily/all/USC00368449.dly")
# weather <- subset(weather, YEAR >= 2000 & YEAR <= 2009)

# daily precipitation
summary(weather$PRCP.VALUE)

# monthly average maximum temperature
aggregate(TMAX.VALUE ~ MONTH, FUN = mean, data = weather)

# generate simulation values
weather.params <- wth.param(weather)

VFS documentation built on May 2, 2019, 8:58 a.m.