# Raw radiance integer to temperature in degrees Celcius
#' ReVuePro: Rad_Temp
#'
#' A function to convert raw radiance values from radiometric JPGs - captured with a FLIR Vue Pro - to temperature, in degrees Celcius.
#' @param x A string of radiance values in kilowats/metre squared (kW/m2), to be converted to temperature in degrees Celcius.
#' @param Planck_R1 A callibration constant, specific per FLIR camera. This can be determined using 'exiftool.exe', produced by Phil Harvey. Default is 17096.453125.
#' @param Planck_R2 A callibration constant, specific per FLIR camera. This can be determined using 'exiftool.exe', produced by Phil Harvey. Default is 0.04351538.
#' @param Planck_B A callibration constant, specific per FLIR camera. This can be determined using 'exiftool.exe', produced by Phil Harvey. Default is 1428.0.
#' @param Planck_F A callibration constant, specific per FLIR camera. This can be determined using 'exiftool.exe', produced by Phil Harvey. Default is 1.0.
#' @param Planck_O A callibration constant, specific per FLIR camera. This can be determined using 'exiftool.exe', produced by Phil Harvey. Default is -55.0.
#' @param emissivity The relative energy that is emitted (or radiated) from the surface of the object in the image, compared to that emitted from a blackbody in equivalent conditions. This value must lay between 0 and 1. Default is 0.98.
#' @param obj_distance The distance between the thermal imaging camera and object to be measured within the image. This value is expressed in metres. Default is 1.0 metres.
#' @param amb_temp Ambient/atmospheric temperature at the time of image capture, in degrees Celcius.
#' @param ref_temp The temperature reflected from the object in question - again, in degrees Celcius. Default is to assume that the reflected temperature is equal to ambient temperature.
#' @param window_temp The temperature of window though which the thermal image was take, in degrees Calcius. Default is to assume that window temperature is equal to ambient temperature.
#' @param wind_transmittance The relative amount of light transmitted though a window between the thermal imaging camera and object in question. This value must lay between 0 and 1, with a default value of 1.
#' @param humidity Relative, atmospheric humidity at the time if image character. This value is expressed as a percentage, and therefore should lay between 0 and 100.
#' @keywords VuePro, Thermal
#' @examples
#' ## Reading in binary version of FLIR JPG, and decrypt
#' setwd("C:/MyRawJPGs")
#' RmFlirTag("ABird.jpg", "C:/MyProcessedJPGs")
#'
#' ## Determining length of radiance data, within binary JPG.
#' # Image dimensions = 336 x 256
#' Imagelength = (336*256)*2
#'
#' ## Extracting binary pertaining to radiance data, and converting
#' Image = Tagless[2723:(2722+Imagelength)]
#' TempString = Rad_Temp(Image, Planck_R1 = 17096.453125, Planck_R2 = 0.04351538, Planck_B = 1428.0, Planck_F = 1,
#' Planck_O = -55.0, emissivity = 0.98, obj_distance = 1.0, amb_temp = 23.0, humidity = 30).
#' @export
Rad_Temp<-function(x, Planck_R1 = 17096.453125, Planck_R2 = 0.04351538, Planck_B = 1428.0, Planck_F = 1,
Planck_O = -55.0, emissivity = 0.98, obj_distance = 1.0, amb_temp, ref_temp = amb_temp,
window_temp = amb_temp, wind_transmittance = 1, humidity) {
# Atmospheric constants
ATA1 = 0.006569
ATA2 = 0.012620
ATB1 = -0.002276
ATB2 = -0.006670
ATX = 1.900000
# Setup for temperature conversion
emisswind = 1 - wind_transmittance
reflwind = 0
water = (humidity/100)*exp(1.5587+0.06939*(amb_temp)-0.00027816*(amb_temp)^2+0.00000068455*(amb_temp)^3)
tau1 = ATX*exp(-sqrt(obj_distance/2)*(ATA1+ATB1*sqrt(water)))+(1-ATX)*exp(-sqrt(obj_distance/2)*(ATA2+ATB2*sqrt(water)))
tau2 = ATX*exp(-sqrt(obj_distance/2)*(ATA1+ATB1*sqrt(water)))+(1-ATX)*exp(-sqrt(obj_distance/2)*(ATA2+ATB2*sqrt(water)))
rawrefl1= Planck_R1/(Planck_R2*(exp(Planck_B/(ref_temp+273.15))-Planck_F))-Planck_O
rawrefl1attn = (1-emissivity)/emissivity*rawrefl1
rawatm1 = Planck_R1/(Planck_R2*(exp(Planck_B/(amb_temp+273.15))-Planck_F))-Planck_O
rawatm1attn = (1-tau1)/emissivity/tau1*rawatm1
rawwind = Planck_R1/(Planck_R2*(exp(Planck_B/(window_temp+273.15))-Planck_F))-Planck_O
rawwindattn = emisswind/emissivity/tau1/wind_transmittance*rawwind
rawrefl2 = Planck_R1/(Planck_R2*(exp(Planck_B/(ref_temp+273.15))-Planck_F))-Planck_O
rawrefl2attn = reflwind/emissivity/tau1/wind_transmittance*rawrefl2
rawatm2 = Planck_R1/(Planck_R2*(exp(Planck_B/(amb_temp+273.15))-Planck_F))-Planck_O
rawatm2attn = (1-tau2)/emissivity/tau1/wind_transmittance/tau2*rawatm2
rawsubtract = (rawatm1attn + rawatm2attn + rawwindattn + rawrefl1attn + rawrefl2attn)
rawdivisor = emissivity*tau1*wind_transmittance*tau2
# Temp calculation
Temp_Vals<-c()
for(i in 1:length(x)){
Temp_Vals[i]=(Planck_B/log(Planck_R1/(Planck_R2*(x[i]/rawdivisor - rawsubtract + Planck_O)) + Planck_F)-273.15)
}
return(Temp_Vals)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.