extract_precip: Produces daily or hourly precipitation data for a single...

View source: R/extract_precip.R

extract_precipR Documentation

Produces daily or hourly precipitation data for a single location ready for use with 'microclima::runauto'.

Description

'extract_precip' takes an nc file containing hourly ERA5 climate data, and for a given set of coordinates, produces an (optionally) inverse distance weighted mean of precipitation (at daily or hourly resolution) ready for use with 'microclima::runauto'.

Usage

extract_precip(
  nc,
  long,
  lat,
  start_time,
  end_time,
  d_weight = TRUE,
  convert_daily = TRUE
)

Arguments

nc

character vector containing the path to the nc file. Use the 'build_era5_request' and 'request_era5' functions to acquire an nc file with the correct set of variables. Data within nc file must span the period defined by start_time and end_time.

long

longitude of the location for which data are required (decimal degrees, -ve west of Greenwich Meridian).

lat

latitude of the location for which data are required (decimal degrees, -ve south of the equator).

start_time

a POSIXlt or POSIXct object indicating the first day or hour for which data are required. Encouraged to specify desired timezone as UTC (ERA5 data are in UTC by default), but any timezone is accepted.

end_time

a POSIXlt or POSIXct object indicating the last day or hour for which data are required. Encouraged to specify desired timezone as UTC (ERA5 data are in UTC by default), but any timezone is accepted.

d_weight

logical value indicating whether to apply inverse distance weighting using the 4 closest neighbouring points to the location defined by 'long' and 'lat'. Default = 'TRUE'.

convert_daily

a flag indicating whether the user desires to convert the precipitation vector from hourly to daily averages (TRUE) or remain as hourly values (FALSE). Only daily precipitation will be accepted by 'microclima::runauto'.

Value

a numeric vector of daily or hourly precipitation (mm).


dklinges9/mcera5 documentation built on March 1, 2024, 11:40 p.m.