GLEON / LakeMetabolizer

Collection of Lake Metabolism Functions
16 stars 10 forks source link

metab.bookkeep #117

Closed hdugan closed 8 years ago

hdugan commented 8 years ago

Hi all, I'm making a teaching example using Lake Metabolizer, and I keep getting weird answers with the metab.bookkeep function. Basically, NEP is too high.

The guts of the function are:

#gas flux out is negative
#normalized to z.mix, del_concentration/timestep (e.g., mg/L/10min)
gas.flux <- (do.sat - do.obs) * (k.gas/freq) / z.mix 

#remove the component of delta.do that is due to gas flux
delta.do.metab <- delta.do + gas.flux[1:(length(gas.flux)-1)]

Are we sure that it shouldn't be: delta.do.metab <- delta.do - gas.flux[1:(length(gas.flux)-1)] If into the lake is positive gas flux, then metabolism between timesteps should be the difference in DO minus the flux into the lake. Have I just royally confused myself?

jzwart commented 8 years ago

Good catch Hilary. You're right gas flux should be subtracted from delta DO. Looks like gas flux is implemented correctly for the other models (Bayes, mle, kalman, ols), we should make note to change the metab figure for the MS once we eventually get proofs back.

pchanson commented 8 years ago

Hilary,

Caveat - I may easily be misinterpreting the implementation that's in metab.bookkeep function, so it would be important to have multiple eyes on this. Short answer is that I think you are correct.

dO/dt = GPP - R + Fatm; assuming a positive flux is into the system

GPP - R = NEP

dO2/dt = NEP + Fatm

NEP = dO2/dt - Fatm

If the system is undersaturated, part of the increase of DO will be due to an influx of DO (I.e., +Fatm), and we want to subtract that from DO/dt, otherwise NEP would be over-estimated. If the system is supersaturated, then DO would not change as much as it should due to a loss of DO as efflux (I.e., -Fatm). We would want to add that back into the system by subtracting a negative flux. So, given the above equation, it's important that a supersaturated system have a negative Fatm. According to the equations below, gas.flux will be negative if the system is supersaturated. This is good. According to the equations below, delta.do.metab has (+) gas.flux as written, when according to my equations above, it should be (-). I agree with you that the equation has the wrong sign for Fatm. Again, this assumes I understand the implementation.

Paul


Paul Hanson Distinguished Research Professor UW Center for Limnology

From: hdugan notifications@github.com<mailto:notifications@github.com> Reply-To: GLEON/LakeMetabolizer reply@reply.github.com<mailto:reply@reply.github.com> Date: Wednesday, June 22, 2016 at 12:39 PM To: GLEON/LakeMetabolizer LakeMetabolizer@noreply.github.com<mailto:LakeMetabolizer@noreply.github.com> Subject: [GLEON/LakeMetabolizer] metab.bookkeep (#117)

Hi all, I'm making a teaching example using Lake Metabolizer, and I keep getting weird answers with the metab.bookkeep function. Basically, NEP is too high.

The guts of the function are:

gas flux out is negative

normalized to z.mix, del_concentration/timestep (e.g., mg/L/10min)

gas.flux <- (do.sat - do.obs) * (k.gas/freq) / z.mix

remove the component of delta.do that is due to gas flux

delta.do.metab <- delta.do + gas.flux[1:(length(gas.flux)-1)]

Are we sure that it shouldn't be: delta.do.metab <- delta.do - gas.flux[1:(length(gas.flux)-1)] If into the lake is positive gas flux, then metabolism between timesteps should be the difference in DO minus the flux into the lake. Have I just royally confused myself?

You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/GLEON/LakeMetabolizer/issues/117, or mute the threadhttps://github.com/notifications/unsubscribe/AAY8fV9yzgHYOTpEWOyYTkwt1iYoxXDeks5qOXNugaJpZM4I8CTc.

hdugan commented 8 years ago

"When we get proofs back". Good one Jake.

Also, thank you for double checking my sanity.

lawinslow commented 8 years ago

@hdugan v1.5.0 update will be on CRAN in time for GLEON! https://cran.r-project.org/web/packages/LakeMetabolizer/index.html

rBatt commented 8 years ago

@jzwart Ah, just now saw this, so it looks like people have already inspected this result. Maybe ignore my comments on the commit.

jzwart commented 8 years ago

@rBatt it's good to get more eyes on this.

rBatt commented 8 years ago

There's at least 1 paper I saw published recently that used this BK code.

My Blue Lake paper (https://github.com/rBatt/DarkenedLake) used the Kalman filter (I'm pretty sure).

It's really easy to figure this out once you dig into it. Like Paul said, it's pretty clear which sign the flux should have if the lake is under- (or super-) saturated. Once you know the sign convention we use for K (I always forget this), then you can really just look at the equations and figure out what it should be doing.

On Thu, Jun 23, 2016 at 2:10 PM, Jake Zwart notifications@github.com wrote:

@rBatt https://github.com/rBatt it's good to get more eyes on this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GLEON/LakeMetabolizer/issues/117#issuecomment-228134641, or mute the thread https://github.com/notifications/unsubscribe/AFXrf8UzIEDLe9XexUgxJM8Hi9ejNgtAks5qOswNgaJpZM4I8CTc .

Ryan D. Batt Aquatic Ecologist Postdoctoral Researcher, Rutgers University Website: http://limnology.wisc.edu/personnel/batt/