Skip to content

Climate

jschoate edited this page Jul 23, 2024 · 6 revisions

read_clim

The read_clim function will read RHESSys formatted timeseries climate files (i.e. the .tmin, .tmax, .rain, etc... files) into one R object. When a prefix name common to several climate files is supplied, it will read in all climate files that have that same prefix (i.e. w8_daily.rain, w8_daily.tmax, w8_daily.tmin, w8_daily.daytime_rain_duration, etc...). For example, to read in all climate files beginning with the prefix w8_daily into a new R object named W8allClim:

W8allClim = read_clim("w8_daily")    

If the file suffix (extension) is also included, then only that particular time series will be read in, i.e.:

W8rain = read_clim("w8_daily.rain")    
  • You may need to load this library: library(xfun)
    (for the file_ext() function)

  • Works for any daily input

  • prefix supplied will return all matching data

  • including suffix (extension) returns just that time series (e.g. 'site.rain' only return the precipitation time series)

  • function also outputs columns for : date, year, month, day, wateryear (wy), year day (yd), and water year day (wyd)

  • Climate data files do not have to span the same time period - the start and end dates do not have to be the same for rain, temperature, wind, relative_humidity, etc....

  • If the separate climate data files span different time periods, the days that do not have observations in common with other inputs will be filled by NA (i.e. if temperature runs from 1980-2020 but precip runs only from 1990-2020, then precip for 1980-1990 will be filled by NA)

    • if you have uncommon periods of observations and want a file that only contains the time period for which data is available for all types:

    W8clim_common = na.omit(W8allClim)

    • this will return the object W8clim_common that removes rows with NA in any column
Clone this wiki locally