MazamaScience/RAWSmet

new wrcc_load() function

Closed this issue · 0 comments

The whole point of providing support for rawsDataDir is to save already downloaded data for easy reuse. Now it's time to make that reuse easy. A new wrcc_load() function should accept the same arguments as wrcc_createTimeseriesObject() but should first look to see if it has already been saved. This implies that we have a standardized naming scheme for these datasets.

Ideally, a user would just type myStation <- wrcc_load(<nwsID>, meta) and get back the object. The second time they do this it will be lightning fast because they are getting the pre-downloaded, pre-generated object from their local computer.

Let me suggest the following structure for this function:

fw13_load(
  stationID = NULL,
  meta = NULL,
  startdate = strftime(lubridate::now(tzone = "UTC"), "%Y%m0101", tz = "UTC"),
  enddate = strftime(lubridate::now(tzone = "UTC"), "%Y%m%d23", tz = "UTC"),
  baseUrl = "https://wrcc.dri.edu/cgi-bin/wea_list2.pl"
  verbose = TRUE
) {

  # ----- Validate parameters -----

  ...

  dataDir <- getRawsDataDir()

  # ----- Check for local data -----

  year <- lubridate::year(lubridate::now(tone = "UTC"))
  fileName = sprintf("wrcc_%s_%d.rda", nwsID, year)

  # if found, get and return the data

  # ----- Obtain data from WRCC -----

  # rawsObject <- wrcc_createTimeseriesObject()

  # save this to dataDir

  # ----- Return ------

}|