Giter Site home page Giter Site logo

biogas's Issues

Multiple elements in when argument, summBg()

The current (old) approach is within the heart of the function, complicated, and would not work for e.g., a combination of pdwhen and a numeric. Nor would new rate.crit.met column work with more than one when element. Should rewrite as recursive call as with other additions at top.

Implement gasDens

This function replaces hard-wired N2 gas density. At least mass2vol() needs to be updated.

stdVol() warning in cumBg() and cumBgMan()

cum.prodl.man <- cumBgMan(strawPressure, comp = strawComp, temp = 31,
data.struct = 'long',
id.name = "bottle", time.name = "time",
dat.name = "pres", comp.name = "xCH4",
temp.init = 21.55, pres.resid = "pres.resid", pres.init = 0.0,
headspace = strawSetup, vol.hs.name = "headspace",
pres.amb = 101.3, absolute = FALSE,
extrap = TRUE, addt0 = TRUE,
unit.pres = "kPa")

Biogas composition is interpolated.
Pressure measurements are GAUGE If this is incorrect, change 'absolute' argu
ment to TRUE.
Using a standard pressure of 101.325 kPa and standard temperature of 0 C for
standardizing volume.
Warning message:
In stdVol(dat[, vol.hs.name], temp = dat[, "temp.prev"], pres = dat$pres.res
id.prev, :
pres ranges from 101.3 kPa to 203.4356 kPa. Is this really correct?

Check calcBgGD() arguments

For example, there is no check that m.pre.name or m.post.name are actually columns in data frame -> useless errors!

summBg() when = 'end' problem

Why did I ever user 'vol.name' to sort here?

else if (length(when) == 1 && tolower(when) == "end") {
    summ1 <- data.frame(id = ids, time = NA, vol = NA)
    names(summ1) <- c(id.name, time.name, vol.name)
    vol <- vol[order(vol[, id.name], vol[, vol.name]), ]
    for (i in ids) {
        dc <- vol[vol[, id.name] == i, ]
        summ1[summ1[, id.name] == i, c(time.name, vol.name)] <- dc[nrow(

dc),
c(time.name, vol.name)]
}
}

Means time returned may not be latest time.

Time mismatch for pd duration in summBg()

If final time is selected by e.g. when = "1p3d" but not all bottles have the same final time, function will tag a bottle as pdnotyet (rate criterion not met). Can we interpolate first in the function so we have the same times for all bottles?

calcBgVol() problem with fixed xCH4/comp

dat <- calcBgVol(dat, comp = 0.65, comp.name = 'xCH4', temp = 'temp.c', pres = 'pres.hPa', data.struct = 'long',
                 id.name = 'channel', time.name = 'time.d', vol.name = 't.vol', unit.pres = 'hPa')

will not work (gives useless error) without comp.name. Although DataPrep function has default for comp.name, call in calcBg will send in NULL and so there is no place to put xCH4/comp in the returned data frame. So DataPrep has to check for null with comp exists and use a default name xCH4.

summBg() show.when problems

Error when there is no subtraction of inoculum contribution with show.when = TRUE.

IMP <- summBg(cbg, setup = ds, id.name = 'id', time.name = 'time.d',

  •            descrip.name = 'substrate', norm.name = 'm.inoc.vs', 
    
  •            show.more = TRUE, when = 'end')
    

Response variable (volume) is cbg$cvCH4.
Inoculum contribution not subtracted.
Response normalized by setup$m.inoc.vs.
Error in [.data.frame(summ2, , s2cols) : undefined columns selected

Description of optional output, summBg()

From Alexandre B.: When we set show.more to TRUE , we get extra columns, such as "rsd.inoc" "fv.inoc" "se1" "se2" "se3" (if show.obs = F) and "vol.mi.rsd" "cvCH4.tot" "cvCH4.inoc" "fv.inoc" "se.inoc" "cvCH4.se" (if show.obs = T). What do they mean? I could not find anything about them.

Molar volume check for gdComp()

Can use recursive call after check of molar volume to get a more precise result, if only to exactly match mass2vol(). Should be able to do by adding molar volume of biogas as gdComp() argument.

VDI 2016 method for BMP duration

New rate.crit argument in summBg() works but is not complete. Needs to be able to identify cases where net yield drops (rates are negative). Not clear how this should be handled with respect to maximum 1% gross time based on VDI report.

planBMP unit error

There seems to be an error in mass output. See example below.

planBMP(15.6, 850, isr = 2, m.tot = 250)
Parameter Unit Value


Inoc. VS conc. g/g 15.6
Substrate VS conc. g/g 850
Mix. VS conc. g/g 23.2
ISR (VS basis) g/g 2
Inoc. mass g 248
Substrate mass g 2.27
Mixture mass g 250
Sub. VS mass g 1930
Inoc. VS mass g 3860
Mix. VS mass g 5800

Biogas composition interpolation for manometric, cumBg()

When bottles are not vented and residual pressure is the same as initial pressure, missing composition data should be set to earliest following available observation, and not interpolated. Realized this when working with LeAF data.

Issue when calculating Biogas from COD on OBA

I noticed another bug on OBA. In the theoretical biogas tab, if you set COD mass, when you choose ‘More details’ or ‘Reaction’ as output, you get a wrong value, i.e. 0.001 L for 1 g COD, instead of 0.349 L for 1 g COD. Moreover, choosing one of these options does not display the reaction or extra details…

&& problem in R-devel check

Last time I tried, package did not pass CRAN tests on R-devel because of this issue. Best option would be to get rid of all of the && and || operators if possible. I am not sure which ones remain.

Tibbles

The data processing functions should be able to handle tibbles.

Bug in summBg() when show.rates=T and inoc.name not specified

While looking at the other summBg() problem with show.rates = TRUE, I observed an unexpected behavior with regard to rates when inoculum contribution is not subtracted. Starting from the previous example, on latest dev branch:

data(feedSetup)
data(feedVol)

cpw <- calcBgVol(feedVol, comp = 1, temp = 0, pres = 1, data.struct = "wide",
                       time.name = "time.d", vol.name = "1", dry = TRUE, interval = FALSE)

s1.noinoc <- summBg(cpw, feedSetup, id.name = 'id', time.name = 'time.d', descrip.name = 'descrip', norm.name = 'm.sub.vs', show.obs = TRUE, show.rates = TRUE)

The column rrvCH4 is now improperly sorted. Output from plot(s1.noinoc[s1.noinoc$id==4,]$rrvCH4):
bild

Commenting out this line makes the data properly ordered again:

dd <- dd[order(dd[, time.name]), ]

It seems to me that this line may be superfluous, as the dataframe is also sorted before returning (e.g., lines 501, 660, 694-704), but maybe I am missing an edge case here?

NULL in checkArgClassValue()

Encountered this issue in GD functions. Should be "NULL" not NULL, it seems. Must be present in other functions.

Add VDI empirical chemical formulas

The VDI 4630 doc has these values:

image

Seem strange for carbohydrate and protein.
If we can find them, we might add the empirical formulas to std.forms.

summBg() help file

v. 1.23.3:

If show.more = TRUE additional columns are returned: summ2 <- summ2[ , c(descrip.name, time.name,’mean’, ’se’, ’sd’, ’n’, ’rsd.inoc’, ’fv.inoc’, ’se1’, ’se2’, ’se3’)]

Oops.

calcBgGD comp.sub check

> mv <- calcBgGD(mv, temp.vol = 20, temp.grav = 30, pres.vol = 1, pres.grav = 1.
5,
+                id.name = 'id', time.name = 'time.d',
+                vol.name = 'vol', m.pre.name = 'm.init', m.post.name = 'm.final
', comp.sub = 0)
Error: Expect class "logical, character" for argument comp.sub but got "numeric"
.

Check the check. Should be numeric.

Update vignette

biogas_quick_start.Rnw still uses cumBg(). Should be changed to calcBgVol() etc.

Add to planBMP()

Would be useful to have estimates of daily biogas production and headspace pressure for planning. Would need kinetic constant input and bottle headspace.

Stange mass2vol() values at low pressure

Following code gives some negative or very large volumes for pressure close to 1 kPa:

plot(mass2vol(0.1, xCH4 = 0.65, temp = 35, pres = c(1:200)/2, unit.pres = "kPa"))

Is this correct result? And why? May not be a problem with code but would be good to clarify.

Create leak() function

Function needed for calculating leakage from mass measurements.

Something like:

leakBg(
dat,
time.name,
m.pre.name,
m.post.name,
...
)

Output should include:
Interval
Leak mass
Total mass
Venting mass
Cumulative
Leak mass
Total mass
Venting mass

New release

The CRAN and master versions of biogas are almost 2 years old. Let's try to sort out the remaining important open issues and merge with master, create a release on GitHub, and submit a new version to CRAN.

summBg() 'when' argument bugs (with/without 'show.rates' = TRUE)

From Alex B. (see message below)

library(biogas)
data(vol2)
data(comp2)
data(setup2)

cbg <- cumBg(vol2, comp = comp2, temp = 20, pres = 1,
id.name = "bottle", time.name = "days",
dat.name = "meas.vol", comp.name = "CH4.conc",
extrap = TRUE)

s1 <- summBg(vol = cbg, setup = setup2, id.name = "bottle",
time.name = "days", descrip.name = "description",
inoc.name = "Inoculum", inoc.m.name = "inoc.mass",
norm.name = "sub.vs", show.obs = TRUE, show.rates = TRUE)

s2 <- summBg(vol = cbg, setup = setup2, id.name = "bottle",
time.name = "days", descrip.name = "description",
inoc.name = "Inoculum", inoc.m.name = "inoc.mass",
norm.name = "sub.vs", show.obs = TRUE, when = "meas", show.rates = FALSE)

Problems:

  1. Gives warning on ignoring 'when' for s1 (even though no when is given.
  2. s1 seems to normalize CH4 volume but s2 does not.
  3. Observation in output differ between s1 and s2.

Package check problems

These are from R CMD check --as-cran with a76aaff

Nothing too difficult, just needs some time.

* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
  Component 14: 'is.NA' value mismatch: 6 in current 1 in target
  ── Failure (test_LowLevelFunctions.R:126:3): mass2vol non vectorised result is correct ──
  mass2vol(...) not equal to `stdVCH4`.
  1/1 mismatches
  [1] 1673 - 1676 == -2.56
  ── Failure (test_LowLevelFunctions.R:131:5): planBMP works ─────────────────────
  planBMP(...) not equal to c(...).
  3/10 mismatches (average diff: 2)
  [8]  0.001 - 1 == -0.999
  [9]  0.002 - 2 == -1.998
  [10] 0.003 - 3 == -2.997
  
  [ FAIL 3 | WARN 2 | SKIP 0 | PASS 35 ]
  Error: Test failures
  Execution halted
* checking for code/documentation mismatches ... WARNING
Codoc mismatches from documentation object 'mass2vol':
mass2vol
  Code: function(mass, xCH4, xCO2 = 1 - xCH4 - xN2, xN2 = 0, temp,
                 pres, temp.std = getOption("temp.std",
                 as.numeric(NA)), pres.std = getOption("pres.std",
                 as.numeric(NA)), unit.temp = getOption("unit.temp",
                 "C"), unit.pres = getOption("unit.pres", "atm"), value
                 = "CH4", headspace = NULL, headcomp = "N2", temp.init
                 = NULL, std.message = TRUE)
  Docs: function(mass, xCH4, temp, pres, temp.std =
                 getOption("temp.std", as.numeric(NA)), pres.std =
                 getOption("pres.std", as.numeric(NA)), unit.temp =
                 getOption("unit.temp", "C"), unit.pres =
                 getOption("unit.pres", "atm"), value = "CH4",
                 headspace = NULL, headcomp = "N2", temp.init = NULL,
                 std.message = TRUE)
  Argument names in code not in docs:
    xCO2 xN2
  Mismatches in argument names (first 3):
    Position: 3 Code: xCO2 Docs: temp
    Position: 4 Code: xN2 Docs: pres
    Position: 5 Code: temp Docs: temp.std

Codoc mismatches from documentation object 'planBMP':
planBMP
  Code: function(vs.inoc, vs.sub, isr = NA, m.inoc = NA, m.sub = NA,
                 m.tot = m.inoc + m.sub, m.vs.sub = vs.sub *
                 m.sub/1000, digits = 3, warn = TRUE, nice = TRUE)
  Docs: function(vs.inoc, vs.sub, isr = NA, m.inoc = NA, m.sub = NA,
                 m.tot = NA, m.vs.sub = vs.sub * m.sub, digits = 3,
                 warn = TRUE, nice = TRUE)
  Mismatches in argument default values:
    Name: 'm.tot' Code: m.inoc + m.sub Docs: NA
    Name: 'm.vs.sub' Code: vs.sub * m.sub/1000 Docs: vs.sub * m.sub

Data codoc mismatches from documentation object 'feedSetup':
Variables in data frame 'feedSetup'
  Code: descrip id m.inoc m.sub.vs
  Docs: id m.inoc m.sub.vs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.