WeatherData: Weather Data Object

WeatherDataR Documentation

Weather Data Object

Description

Data structure containing weather data for a given site for several years.

Details

All fields representing weather variables are vectors of length 365 times N, where N is the number of years for which weather data is stored. In other words, every variable has one value for each of the 365 of each of the N years.

Weather inputs

The weather input file should be organized as space separated columns with a year column and at least the following parameters as headers (further columns are ignored):

  • DOY day of year in given year

  • Ta average temperature of given day (Celsius).

  • precip precipitation in millimeter per day.

  • PAR photosynthetically active radiation in MJ/m^2^. Can be calculated from average sunlight irradiance SRad in J/s/m^2^ as: PAR = SRad * 0.47 * 24 * 60 * 60 / 1e6

  • ET0 evapotranspiration in mm.

These parameters are stored in this object in the respective PARAM_vec fields.

Snow model

The precipitation and temperature inputs are used in order to estimate the snow cover for each day by use of a snow model. The employed model is as formulated by Kokkonen et al. 2006 and makes use of parameters from Rango and Martinec, 1995.

Public fields

weather_file

Name of provided weather data file.

years

numeric Integer representation of the contained years.

vec_size

Length of the PARAM_vec vectors, which is equal to number of contained years times 365.

year_vec

Vector of length vec_size, holding the year for the respective index.

W

A list generated by get_weather_for_year() which contains weather data only for a given year. The keys in the list are:

  • aCO2 (atmospheric CO2 concentration in ppm)

  • year

  • DOY

  • Ta

  • Ta_sm (smoothed daily average temperature)

  • PAR

  • PP

  • PET

  • liquidP

  • melt

  • snow

  • ndays (number of days in this year)

Methods

Public methods


Method new()

Create a new WeatherData object.

Usage
WeatherData$new(weather_file = NULL, years = NULL)
Arguments
weather_file

string Path to file containing the weather data to be read.

years

numeric Vector of years for which the weather is to be extracted.


Method read_weather()

Read weather data from supplied weather_file.

Usage
WeatherData$read_weather(weather_file, years = NULL)
Arguments
weather_file

Path to or name of file containing weather data.

years

Years for which the weather is to be extracted. Default (NULL) is to read in all found years.


Method ensure_file_integrity()

Check if supplied input file is formatted correctly.

Check if required column names are present and fix NA entries.

Usage
WeatherData$ensure_file_integrity(weather)
Arguments
weather

data.table of the read input file with header = TRUE.


Method calculate_day_length()

Calculate the expected length of day based on a site's geographical latitude.

Usage
WeatherData$calculate_day_length(latitude)
Arguments
latitude

numeric; geographical latitude in degrees.


Method get_weather_for_year()

Extract state variables to the weather data for given year and return them as a list.

Usage
WeatherData$get_weather_for_year(year)
Arguments
year

integer Year for which to extract weather data.

Returns

W List containing the keys aCO2, year, DOY, Ta, Ta_sm, PAR, PP, PET, liquidP, melt, snow, ndays.


Method clone()

The objects of this class are cloneable with this method.

Usage
WeatherData$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

References

\insertRef

rango1995RevisitingDegreeDayMethodgrowR

\insertRef

kokkonen2006ConstructionDegreedaySnowgrowR

See Also

WeatherData⁠$read_weather()⁠


growR documentation built on May 29, 2024, 9:12 a.m.