Learn R Programming

TrenchR: an R package for transparent environmental and ecological biophysics

Author: TrEnCh project, Buckley Lab, Department of Biology, University of Washington

Package website

Description

The TrenchR package aids in Translating Environmental Change into organismal responses. The package facilitates microclimate modeling to translate weather station data into the environmental conditions experienced by organisms and biophysical modeling to predict organismal body temperatures given the environmental conditions. The package aims to introduce and enable microclimate and biophysical modeling to improve ecological and evolutionary forecasting and includes tutorials and well as a series of educational modules introducing microclimate and biophysical modeling. The package focuses on transparent and modular functions but also includes some biophysical models for particular organisms. The package complements and integrates with the NicheMapR package, which contains more complex functions that are generally not intended for modular use.

Installation

You can install the TrenchR package from CRAN:

install.packages("TrenchR")  

The latest version of the package can be installed from the github repository:

install.packages("devtools")   
devtools::install_github("trenchproject/TrenchR")

Using the package

The package encompasses simple functions that can be combined to estimate environmental conditions and their impacts on organisms. Many of the functions are adapted from biophysical ecology texts including the following:

  • Gates DM. 1980. Biophysical Ecology.
  • Campbell GS and Norman JM. 2000. An introduction to environmental biophysics.

Package Vignettes

We introduce functions in categorically grouped tutorials. A good place to start is the Allometry and conversions tutorial, which provides tools for preparing data such as estimating additional dimensions of organisms from measured dimensions.

vignette("AllometryAndConversionsTutorial.Rmd", package = "TrenchR")

The Estimating microclimates tutorial provides resources for estimating the environmental conditions experienced by organisms. This includes estimating solar radiation and its components, diurnal variation in temperature and radiation, temperature and wind speed profiles, and soil temperatures and profiles.

vignette("MicroclimateTutorial", package = "TrenchR")

Finally, the core biophysical modeling functions are described in a tutorial on Using energy balances to estimate body temperatures. Components of an energy budget can be estimated using individual functions and then operative environmental temperatures, Te, can be solved for using either a generic energy balance or taxa specific biophysical models.

vignette("TeTutorial", package = "TrenchR")

Future Directions

We welcome code contributions, fixes, and comments. Code (scripts and functions) will be accepted in any programming language and thorough commenting will be appreciated. We would also appreciate your including a header that describes the intent, input, and output of your scripts and functions.

Citation

If you use this package, We would appreciate a citation. You can see an up to date citation information with citation("TrenchR"). You can cite either the package or the accompanying journal article.

Developer notes

Please see the Contributor Notes and Code of Conduct.

We use Rdpack to facilitate package documentation with BibTeX citations. See the documentation workflow document for more details about building package manual components.

Copy Link

Version

Install

install.packages('TrenchR')

Monthly Downloads

185

Version

1.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Lauren Buckley

Last Published

September 13th, 2023

Functions in TrenchR (1.1.1)

Prandtl_number

Prandtl Number
Qnet_Gates

Net Energy Exchange Between an Animal and the Environment
Qradiation_absorbed

Absorbed Solar and Thermal Radiation
TPC_beta

Beta Function Thermal Performance Curve
Qmetabolism_from_mass

Metabolism as a Function of Mass
Qemitted_thermal_radiation

Emitted Thermal Radiation
Qmetabolism_from_mass_temp

Metabolism as a Function of Mass and Body Temperature
Reynolds_number

Reynolds Number
TPC

Gaussian-Quadratic Function Thermal Performance Curve
Qthermal_radiation_absorbed

Absorbed Thermal Radiation
Qevaporation

Heat Loss Associated with Evaporative Water Loss
Tb_butterfly

Operative Environmental Temperature of a Butterfly
Tb_limpet

Operative Environmental Temperature of a Limpet
Tb_grasshopper

Operative Environmental Temperature of a Grasshopper
Tb_Gates2

Operative Environmental Temperature of an Ectotherm Based on a Variant of Gates (1980)
T_sky

Effective radiant temperature of sky (K)
Tb_Gates

Operative Environmental Temperature of an Ectotherm Based on Gates (1980)
Tb_lizard_Fei

Operative Temperature of a Lizard Using Fei et al. (2012)
Tb_limpetBH

Operative Environmental Temperature of a Limpet Based on a Model by Helmuth
Tb_lizard

Operative Environmental Temperature of a Lizard
Tb_CampbellNorman

Operative Environmental Temperature of an Ectotherm based on Campbell and Norman (1988)
Tb_snail

Operative Environmental Temperature of a Marine Snail
actual_vapor_pressure

Actual Vapor Pressure from Dewpoint Temperature
VAPPRS

Saturation Vapor Pressure
Tb_mussel

Operative Environmental Temperature of a Mussel
Tsoil

Approximate Soil Temperature
WETAIR

Properties of Wet Air
TrenchR-package

TrenchR: Tools for Microclimate and Biophysical Ecology
air_temp_profile

Air Temperature Profile using MICRO Routine
Tbed_mussel

Operative Environmental Temperature of a Mussel Bed
Tb_salamander_humid

Humid Operative Environmental Temperature of a Salamander
day_of_year

Calendar Day from Date
air_temp_profile_neutral

Air Temperature at a Specified Height Under Neutral Conditions
air_temp_profile_segment

Air Temperature at a Specified Height
boundary_layer_resistance

Boundary Layer Resistance
airpressure_from_elev

Air Pressure from Elevation
daylength

Day Length
dec_angle

Solar Declination in Radians
constants

General Use Constants
azimuth_angle

Azimuth Angle
angle conversions

Convert Angles Between Radians and Degrees
diurnal_temp_variation_sinesqrt

Hourly Temperature Variation using Sine and Square Root Functions
external_resistance_to_water_vapor_transfer

External Resistance to Water Vapor Transfer
diurnal_temp_variation_sineexp

Hourly Temperature Variation assuming Sine and Exponential Components
diurnal_radiation_variation

Hourly Solar Radiation
degree_days

Degree Days
heat_transfer_coefficient

Estimate the Heat Transfer Coefficient Empirically
direct_solar_radiation

Direct Solar Radiation
heat_transfer_coefficient_approximation

Estimate the Heat Transfer Coefficient Using a Spherical Approximation
free_or_forced_convection

Determine if Convection is Free or Forced
diurnal_temp_variation_sine

Hourly Temperature Variation assuming a Sine Interpolation
proportion_diffuse_solar_radiation

Ratio of Diffuse to Direct Solar Radiation
proportion_silhouette_area

Organism Silhouette Area
proportion_silhouette_area_shapes

Organism Silhouette Area using Shape Approximations
saturation_vapor_pressure

Saturation Vapor Pressure
saturation_water_vapor_pressure

Saturation Water Vapor Pressure
monthly_solar_radiation

Average Monthly Solar Radiation
heat_transfer_coefficient_simple

Estimate the Heat Transfer Coefficient using Simple Relationships
soil_conductivity

Soil Thermal Conductivity
mass_from_length

Organism Mass from Length
partition_solar_radiation

Diffuse Fraction for Partitioning Solar Radiation
soil_temperature

Calculate Soil Temperature using ODEs
surface_area_from_length

Organism Surface Area from Length
soil_temperature_function

Core Function for Calculating Soil Temperature
surface_area_from_mass

Organism Surface Area from Mass
solar_radiation

Estimate the Three Components of Solar Radiation (Direct, Diffuse and Reflected)
soil_temperature_integrand

Solve Equation for Soil Temperature
solar_noon

Time of Solar Noon
soil_specific_heat

Soil Specific Heat
soil_temperature_equation

Core Function Called to Solve Equation for Soil Temperature
surface_area_from_volume

Organism Surface Area from Volume
volume_from_length

Organism Volume from Length
temperature conversions

Convert Among Temperature Scales
wind_speed_profile_neutral

Wind Speed at a Specific Height Under Neutral Conditions
zenith_angle

Zenith Angle
surface_roughness

Surface Roughness from Empirical Measurements
wind_speed_profile_segment

Wind Speed at a Specified Height
Qconvection

Organismal Convection
DRYAIR

Properties of Dry Air
Nusselt_number

Nusselt Number
Qconduction_animal

Conductance Assuming Animal Thermal Conductivity is Rate Limiting
Nusselt_from_Reynolds

Nusselt Number from the Reynolds Number
Nusselt_from_Grashof

Nusselt Number from the Grashof Number
Grashof_number_Gates

Grashof Number as in Gates (1980)
Qconduction_substrate

Conductance Assuming Substrate Thermal Conductivity is Rate Limiting
Grashof_number

Grashof Number