R/tglob_sphere.r

Defines functions tglob_sphere

Documented in tglob_sphere

#' tglob_sphere
#'
#' Calculate the globe temperature in degC. 
#' The code is based on the work James C. Liljegren Decision and Information Sciences Division Argonne National Laboratory.
#' 
#'
#' @param t numeric        Air temperature in degC.
#' @param rh numeric       Relative humidity in percentage.
#' @param wind numeric     Mean Wind speed in meter per second.
#' @param solar  numeric   Global solar radiation in Watt on mq.
#' @param zenith numeric   Zenith angle in decimal degrees.
#' @param pair numeric     Air pressure in millibar or hPa. Default 1010 hPa.
#' @param alb_sfc numeric  Mean albedo of surroundings. Default is 0.4.
#' @param fdir numeric     Ratio of directed solar respect to the diffuse.Default is 0.8.
#' @param diam numeric     Diameter in meter of globometer. Default is 0.05. 
#' @param maxair numeric   Upper bound of search range referred to air temperature in degC. Default is 10
#' @param minair numeric   Lower bound of search range referred to air temperature in degC. Default is 10
#' @param prec numeric      Precision of outcomes.Default is 0.01  
#' @return globe temperature in degC
#' 
#' @author Istituto per la Bioeconomia CNR Firenze Italy  Alfonso Crisci \email{alfonso.crisci@@ibe.cnr.it}
#' @references Liljegren J, Carhart R, Lawday P, Tschopp S, Sharp R,2008, "Modeling Wet Bulb Globe Temperature using Standard Meteorological Measurements" Journal of Occupational and Environmental Hygiene 5, 645-655. 
#' @keywords   Globometric temperature.
#' 
#' @export
#'
#'


tglob_sphere=function(t,rh,wind,solar,zenith=0,pair=1010,alb_sfc=0.4,fdir=0.8,diam=0.05,maxair=10,minair=2,prec=0.01) {
                       
                         ct$assign("t", as.array(t))
                         ct$assign("rh", as.array(rh))
                         ct$assign("speed", as.array(wind))
                         ct$assign("solar", as.array(solar))
                         ct$assign("pair", as.array(pair))
                         ct$assign("fdir", as.array(fdir))
                         ct$assign("zenith", as.array(zenith))
                         ct$assign("diam", as.array(diam))
                         ct$assign("alb_sfc", as.array(alb_sfc))
                         ct$assign("maxair", as.array(maxair))
                         ct$assign("minair", as.array(minair))
                         ct$assign("prec", as.array(prec))
                         ct$eval("var res=[]; for(var i=0, len=t.length; i < len; i++){ res[i]=tglob_sphere(t[i],rh[i],speed[i],solar[i],zenith[i],pair[0],alb_sfc[0],fdir[0],diam[0],maxair[0],minair[0],prec[0])};")
                         res=ct$get("res")
                         return(ifelse(res==9999,NA,res))
}
alfcrisci/rBiometeo documentation built on Feb. 1, 2024, 4:47 p.m.