runwithNMR: Runs microclimate model in hourly timesteps with NicheMapR

View source: R/NicheMapRcode.R

runwithNMRR Documentation

Runs microclimate model in hourly timesteps with NicheMapR

Description

This function is a wrapper function for runNMR() and runmodelS() enabling full microclimate model at any height above or below ground rapidly. NicheMapR is to compute snowdepths, soil moistures and below-ground soil temperatures. The function runmodelS is used to compute below or above canopy air temperatures.

Usage

runwithNMR(
  climdata,
  prec,
  vegp,
  soilp,
  reqhgt,
  lat,
  long,
  altt = 0,
  slope = 0,
  aspect = 0,
  metopen = TRUE,
  windhgt = 2,
  surfwet = 1,
  groundem = 0.95,
  ERR = 1.5,
  cap = 1,
  hori = rep(0, 36),
  maxpool = 1000,
  rainmult = 1,
  SoilMoist_Init = c(0.1, 0.12, 0.15, 0.2, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3),
  animal = FALSE
)

Arguments

climdata

data.frame of climate variables needed to run the run the model. The dataset should follow format of weather()). Times must be in UTC.

prec

vector of hourly or daily precipitation (mm) (see details).

vegp

a list of vegetation parameters as returned by microctools::habitatvars().

soilp

a list of soil parameters as returned by soilinit().

reqhgt

height (m) for which microclimate is needed.

lat

latitude of location (decimal degrees).

long

longitude of location (decimal degrees).

altt

elevation of location (m).

slope

slope of ground surface (decimal degrees).

aspect

aspect of ground surface (decimal degrees, 0 = north).

metopen

optional logical indicating whether the wind measurement used as an input to the model is from a nearby weather station located in open ground (TRUE) or above the canopy for which temperatures are modelled (FALSE - see details)

windhgt

height above ground of wind measurement. If metopen is FALSE, must be above canopy.

surfwet

proportion of leaf surface acting as free water surface.

groundem

thermal emissivity of ground layer.

ERR

Integrator error tolerance for soil temperature calculations.

cap

Is organic cap present on soil surface? (1 = Yes, 0 = No).

hori

Horizon angles (degrees), from 0 degrees azimuth (north) clockwise in 10 degree intervals.

maxpool

Max depth for water pooling on the surface (mm), to account for runoff.

rainmult

Rain multiplier for surface soil moisture (used to induce runon).

SoilMoist_Init

Initial volumetric soil water content at each soil node (m^3/m^3)

Details

This is a wrapper function for runmodelS() and runNMR() that allows fairly rapid calaulation of microclimatic conditions below ground and/or above canopy. It uses the NicheMapR package to calculate soil moisture-dependent soil temperatures, treating the vegetation canopy as a single layer and then calculates air and leaf temperatures,air humidity and radiation using runmodelS. Precipitation values are needed for computation of soil moisture and can either be supplied as a vector of hourly values (must have identical number of values as in climdata) or daily values (climdata must contain climate for entire days). It compares the length of the vector to climdata to determine whether values are daily or hourly. In this function constant soil poperties are are assumed throughout the soil profile. For more flexible implementation, runNMR() and runmodelS() can be run seperately.

Value

a list of two objects:

a data.frame of microclimate variables for height reqhgt as returned by runmodelS()

a list of NicheMapR outputs as returned by runNMR()

See Also

runmodelS(), runNMR()

Examples

require(NicheMapR)
# ====================================================================== #
# ~~~~~~~~~~~~~~~ Run model using inbuilt weather datasets ~~~~~~~~~~~~~ #
# ====================================================================== #
tme<-as.POSIXlt(weather$obs_time,tz="UTC")
vegp <- habitatvars(4, 50.2178, -5.32656, tme, m = 10) # Decidious broadleaf forest
soilp<- soilinit("Loam")
climrun <- runwithNMR(weather,dailyprecip,vegp,soilp,1,50.2178,-5.32656)
# ====================================================================== #
# ~~~~~~~~~~~~~~~ Extract and view data from outputs ~~~~~~~~~~~~~~~~~~~ #
# ====================================================================== #
metout<-climrun$metout
nmrout<-climrun$nmrout
soiltemps<-as.data.frame(nmrout$soil)
head(metout)
head(soiltemps)
head(nmrout$soilmoist)
head(nmrout$sunsnow)
head(nmrout$plant)
# ====================================================================== #
# ~~~~~~~~~~~~~~~ Plot soil and air temperatures ~~~~~~~~~~~~~~~~~~~~~~~ #
# ====================================================================== #
tsoil1<-soiltemps$D2.5cm
tsoil2<-soiltemps$D50cm
tair<-metout$Tloc
tref<-metout$Tref
tleaf<-metout$tleaf
Month<-as.POSIXct(metout$obs_time,tz="UTC")
tmn<-min(tsoil1,tsoil2,tair,tref,tleaf)
tmx<-max(tsoil1,tsoil2,tair,tref,tleaf)
par(mfrow=c(2,1))
# Air
plot(tref~Month,type="l",col=rgb(0,0,0,0.3),ylab="Temperature",ylim=c(tmn,tmx))
par(new=T)
plot(tleaf~Month,type="l",col=rgb(0,1,0,0.3),xlab="",ylab="",ylim=c(tmn,tmx))
par(new=T)
plot(tair~Month,type="l",col=rgb(1,0,0,0.3),xlab="",ylab="",ylim=c(tmn,tmx))
# Soil
plot(tref~Month,type="l",col=rgb(0,0,0,0.5),ylab="Temperature",ylim=c(tmn,tmx))
par(new=T)
plot(tsoil1~Month,type="l",col="red",xlab="",ylab="",ylim=c(tmn,tmx))
par(new=T)
plot(tsoil2~Month,type="l",col="blue",lwd=2,xlab="",ylab="",ylim=c(tmn,tmx))
# ====================================================================== #
# ~~~~~~~~~~~~~~~ Plot data by monthly mean ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# ====================================================================== #
tme<-as.POSIXlt(metout$obs_time,tz="UTC")
tsoil1m<-aggregate(tsoil1,by=list(tme$mon),mean)$x
tsoil2m<-aggregate(tsoil2,by=list(tme$mon),mean)$x
tairm<-aggregate(tair,by=list(tme$mon),mean)$x
trefm<-aggregate(tref,by=list(tme$mon),mean)$x
tleafm<-aggregate(tleaf,by=list(tme$mon),mean)$x
tmn<-min(tsoil1m,tsoil2m,tairm,trefm,tleafm)
tmx<-max(tsoil1m,tsoil2m,tairm,trefm,tleafm)
Month<-c(1:12)
# Air
par(mfrow=c(2,1))
plot(trefm~Month,type="l",lwd=2,col="darkgray",ylab="Temperature",ylim=c(tmn,tmx))
par(new=T)
plot(tleafm~Month,type="l",lwd=2,col="darkgreen",xlab="",ylab="",ylim=c(tmn,tmx))
par(new=T)
plot(tairm~Month,type="l",lwd=2,col="red",xlab="",ylab="",ylim=c(tmn,tmx))
plot(trefm~Month,type="l",lwd=2,col="darkgray",ylab="Temperature",ylim=c(tmn,tmx))
par(new=T)
plot(tsoil1m~Month,type="l",lwd=2,col="red",xlab="",ylab="",ylim=c(tmn,tmx))
par(new=T)
plot(tsoil2m~Month,type="l",lwd=2,col="blue",xlab="",ylab="",ylim=c(tmn,tmx))
# ====================================================================== #

ilyamaclean/microclimc documentation built on July 28, 2023, 1:40 a.m.