This function can do three things related to the Global Summary of the Day ("GSOD") database from the National Climatic Data Centre (NCDC) of the National Oceanic and Atmospheric Administration (NOAA):
1. It can list stations that are close to a specified position (geographic coordinates).
2. It can retrieve weather data for a named weather station (or a vector of multiple stations).
For the name, the chillRcode from the list returned by the
should be used.
3. It can 'clean' downloaded data (for one or multiple stations), so that they can easily be used in chillR
Which of these functions is carried out depends on the action argument.
This function can run independently, but it is also called by the
weather2chillR functions, which some users might find a bit
easier to handle.
1 2 3 4 5 6 7 8 9 10 11 12
accepts 3 types of inputs to decide on the mode of action for the function.
either a vector of geographic coordinates (for the
numeric vector with two elements, specifying the start
and end date of the period of interest. Only required when running in
if the list of weather stations has already been downloaded, the list can be passed to the function through this argument. This can save a bit of time, since it can take a bit of time to download the list, which can have several MB.
if the location is specified by geographic coordinates, this argument determines the number of nearby stations in the list that is returned.
boolean variable indicating if most columns should be
dropped from the file. If set to
boolean variable indicating whether the interval of
interest should end on the present day, rather than extending until the end
of the year specified under
is a boolean parameter to be passed to
is a boolean parameter to be passed to
is a boolean parameter to include the name of the respective weather station in the resulting data frame in case the function is used in the downloading or formatting mode.
The GSOD database is described here: https://www.ncei.noaa.gov/access/metadata/landing-page/bin/iso?id=gov.noaa.ncdc:C00516
'list_stations' mode, several formats are possible for specifying
the location vector, which can consist of either two or three coordinates
(it can include elevation). Possible formats include
c(1, 2, 3),
c(x = 1, y = 2, z = 3),
c(lat = 2, long = 1, elev = 3). If elements of the vector are not
names, they are interpreted as c(Longitude, Latitude, Elevation).
The 'chillRCode' is generated by this function, when it is run with geographic coordinates as location inputs. In the list of nearby stations that is returned then, the chillRCode is provided and can then be used as input for running the function in 'downloading' mode. For downloading the data, use the same call as before but replace the location argument with the chillRCode.
The output depends on the action argument. If it is
the function returns a list of
station_to_choose_from weather stations that
are close to the specified location. This list also contains information
about how far away these stations are (in km), how much the elevation
difference is (if elevation is specified; in m) and how much overlap there
is between the data contained in the database and the time period specified
time_interval. If action is
'download_weather' the output is a list of
two elements: 1.
database="GSOD" 2. the downloaded weather record, extended
to the full duration of the specified time interval. If the
was a vector of stations, the output will be a list of such objects.
If action is a weather
data.frame or a weather record downloaded with
this function (in
'download_weather' mode), the output is the same
data in a format that is easy to use in chillR. If drop_most was set to
TRUE, most columns are dropped. If the
location input was a
list of weather datasets, all elements of the list will be processed.
Many databases have data quality flags, which may sometimes indicate that data aren't reliable. These are not considered by this function!
For many places, the GSOD database is quite patchy, and the length of the record indicated in the summary file isn't always very useful (e.g. there could only be two records for the first and last date). Files are downloaded by year, so if we specify a long interval, this may take a bit of time.
Eike Luedeling and Eduardo Fernandez
The chillR package:
Luedeling E, Kunz A and Blanke M, 2013. Identification of chilling and heat requirements of cherry trees - a statistical approach. International Journal of Biometeorology 57,679-689.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
# List the near weather stations # stat_list <- handle_gsod(action = "list_stations", # location = c(x = -122, y = 38.5), # time_interval = c(2002, 2002)) # the line above takes longer to run than CRAN allows for examples. # The line below therefore # generates an abbreviated stat_list that allows running the code. # stat_list <- data.frame(chillR_code = c("724828_99999", # "724828_93241", # "720576_174"), # STATION.NAME = c("NUT TREE", # "NUT TREE AIRPORT", # "UNIVERSITY AIRPORT"), # Lat = c(38.383, 38.378, 38.533), # Long = c(-121.967, -121.958, -121.783), # BEGIN = c(20010811, 20060101, 20130101), # END = c(20051231, 20160110, 20160109)) # gw <- handle_gsod(action = "download_weather", # location = "724828_93241", # time_interval = c(2010, 2012), # station_list = stat_list, # quiet = TRUE) # weather <- handle_gsod(gw, add.DATE = FALSE)[]$weather # make_chill_plot(tempResponse(stack_hourly_temps(fix_weather(weather)), # Start_JDay = 300, End_JDay = 50), # "Chill_Portions", start_year = 2010, # end_year = 2012, metriclabel = "Chill Portions", # misstolerance = 50)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.