all temperature should be in celsius

soil temperature in CF is in K, capful assumes it is in C.

@ankurdesai @mdietze @jam2767 this fixes the gapfilling for soil temperatures..
Couldn’t you at least use named self-documenting constants—e.g. something like (in some global place) define CELSIUS_TO_KELVIN_OFFSET := 273.15 and then use that in your conversions?

From: Rob Kooper <notifications@github.com<mailto:notifications@github.com>>
Reply-To: PecanProject/pecan <reply@reply.github.com<mailto:reply@reply.github.com>>
Date: Thursday, December 18, 2014 at 1:31 PM
To: PecanProject/pecan <pecan@noreply.github.com<mailto:pecan@noreply.github.com>>
Subject: Re: [pecan] all temperature should be in celsius (#294)


In modules/data.atmosphere/R/metgapfill.R<https://github.com/PecanProject/pecan/pull/294#discussion-diff-22065030>:

> @@ -220,7 +221,7 @@ metgapfill <- function(in.path, in.prefix, outfolder, start_date, end_date, over
>      if (length(which(is.na(Lw_f))) > 0) error <- c(error, "surface_downwelling_longwave_flux_in_air")
>      ncvar_put(nc,varid='surface_downwelling_longwave_flux_in_air',vals=Lw_f)
>
> -    if(('Ts1_f' %in% colnames(Extracted))) Ts1_f <- Extracted[,'Ts1_f']
> +    if(('Ts1_f' %in% colnames(Extracted))) Ts1_f <- Extracted[,'Ts1_f'] + 273.15


yes, but that makes the code 2-3 times slower:

require(udunits2)

t <- sample(-400:400, 20000, replace=TRUE)/10

system.time(replicate(expr=t+273.15, n=10000))
system.time(replicate(expr=ud.convert(t, "Celsius", "Kelvin"), n=10000))


—
Reply to this email directly or view it on GitHub<https://github.com/PecanProject/pecan/pull/294/files#r22065030>.