Open michaelstrupler opened 5 months ago
I urge you to come up with a truly minimal example next time.
It caused so much hassle to make gdal work on my unbuntu and to install terra and all the other dependencies of your ChamberProc master branch. You have to invest the work to reduce your example that does require to install all those dependencies.
Similar as we discussed in #6, you can do after you created your dataset, you save it an provide it to download.
saveRDS(df,"inst/genData/issue8_duration.rds")
.
I provide this file with branch durationplot2 of the RespChamberProc package, so that the following MWE can be used:
library(RespChamberProc)
df <- readRDS(url("https://github.com/bgctw/RespChamberProc/raw/d6f28ce0f9fe2e4fec93d1928ff98962c302f792/inst/genData/issue8_duration.rds?raw=TRUE"),"rb")
chamberVol = 0.4*0.4*0.4 # define here chamber volume and surface area
surfaceArea = 0.4*0.4
# reproduces the error
resDur_H2O <- plotDurationUncertainty( df
,colTime = "TIMESTAMP"
,colConc = "H2Oppt"
,colTemp="AirTemp"
,volume = chamberVol
, durations = seq(124,404,by=5)
)
The problem with the example is that with the specified minimum duration (124) there are not enough records to determine the leverage of influencial records at the start (after tLag) or at the end (in function sigmaBootLeverage
) .
It only occurs with H20 fluxes, because the estimated lagtime is larger (hence shorter period until minimum duration).
I updated RespChamberProc in branch durationplot
to deliver a better error message, and adapted the default argument of durations. Please, test it with installing RespChamberProc from this branch, e.g. using
devtools::install_github("bgctw/RespChamberProc", ref="durationplot2")
With using the default (adapted in durationplot2) it avoids the error:
# using default durations
resDur_H2O <- plotDurationUncertainty( df
,colTime = "TIMESTAMP"
,colConc = "H2Oppt"
,colTemp="AirTemp"
,volume = chamberVol
,nDur = 5
)
# the first duration is the minimum with enough records to inspect
# as inferred by the default
resDur_H2O$statAll[[1]]$duration
Thanks a lot.
I am trying to adapt the function plotDurationUncertainty() for use with multiple chunks and to use the Coefficient of Variance (CV = sd/mean) instead of the sd as criterium to define the optimal measurement time window.
If I run this adapted function with the sample data provided here:
https://github.com/michaelstrupler/ChamberProc/blob/master/inst/genData/issue8_duration.rds
nest()
:
! Can't supply .by
when .data
is a grouped data frame.Backtrace: ▆
it seems that the error occurs because the data.frame in the function "calcClosedChamberFluxForChunkSpecs" is nested. However, this nesting seems to be necessary for that function.
Please find the MWE (with the function included in the R-File) here: https://github.com/michaelstrupler/ChamberProc/blob/master/inst/Issue8_duration.R
Thanks for your help!
I found the solution, forgot to add "ungroup()" at the end of dsChunk creation....all ok now :)
If I use the function "plotDurationUncertainty()" for another gas than the standard (which is CO2), I get the follwoing error (below), which I don't understand, because the "by" argument in the sequence is positive and between min and max. Please find a MWE attached.
MWE_plotDurationUncertainty.R.zip