extract_clim: Produces hourly data for a single location ready for use with...

View source: R/extract_clim.R

extract_climR Documentation

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

Description

'extract_clim' takes an nc file containing hourly ERA5 climate data, and for a given set of coordinates, produces an (optionally) inverse distance weighted mean of each variable, ready for use by default with 'microclima::runauto' and 'NicheMapR::micro_era5()', but also compatible with 'microclimc', 'microclimf', and 'micropoint' (see argument 'format'). Also provides the option to implement a diurnal temperature range correction to air temperatures.

Usage

extract_clim(
  nc,
  long,
  lat,
  start_time,
  end_time,
  d_weight = TRUE,
  dtr_cor = TRUE,
  dtr_cor_fac = 1.285,
  format = "microclima"
)

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'.

dtr_cor

logical value indicating whether to apply a diurnal temperature range correction to air temperature values. Default = 'TRUE'.

dtr_cor_fac

numeric value to be used in the diurnal temperature range correction. Default = 1.285, based on calibration against UK Met Office observations.

format

specifies what microclimate package extracted climate data will

Value

Returns a data frame containing hourly values for a suite of climate variables. The returned climate variables depends on the value of argument 'format'.

If format is "microclima" or "NicheMapR":

'obs_time' | the date-time (timezone specified in col timezone)

'temperature' | (degrees celsius)

'humidity' | specific humidity (kg / kg)

'pressure' | (Pa)

'windspeed' | (m / s)

'winddir' | wind direction, azimuth (degrees from north)

'emissivity' | downward long wave radiation flux divided by the sum of net long-wave radiation flux and downward long wave radiation flux (unitless)

'netlong' | Net longwave radiation (MJ / m2 / hr)

'uplong' | Upward longwave radiation (MJ / m2 / hr)

'downlong' | Downward longwave radiation (MJ / m2 / hr)

'rad_dni' | Direct normal irradiance (MJ / m2 / hr)

'rad_dif' | Diffuse normal irradiance (MJ / m2 / hr)

'szenith' | Solar zenith angle (degrees from a horizontal plane)

'cloudcover' | (percent)

'timezone' | (unitless)

If format is "microclimc":

'obs_time' | POSIXlt object of dates and times

'temp' | temperature (degrees C)

'relhum' | relative humidity (percentage)

'pres' | atmospheric press (kPa)

'swrad' | Total incoming shortwave radiation (W / m^2)

'difrad' | Diffuse radiation (W / m^2)

'skyem' | Sky emissivity (0-1)

'windspeed' | Wind speed (m/s)

'winddir' | Wind direction (decimal degrees)

'precip' | precipitation (mm)

If format is "micropoint" or "microclimf":

'obs_time' | POSIXlt object of dates and times

'temp' | temperature (degrees C)

'relhum' | relative humidity (percentage)

'pres' | atmospheric press (kPa)

'swdown' | Total incoming shortwave radiation (W / m^2)

'difrad' | Diffuse radiation (W / m^2)

'skyem' | Sky emissivity (0-1)

'lwdown' | Total downward longwave radiation (W / m^2)

'windspeed' | Wind speed (m/s)

'winddir' | Wind direction (decimal degrees)

'precip' | precipitation (mm)


everydayduffy/mcera5 documentation built on Feb. 15, 2025, 11:33 p.m.