GLEON / rLakeAnalyzer

An R version of Lake Analyzer
43 stars 26 forks source link

issue w/ water.density salinity calculation #98

Open jordansread opened 6 years ago

jordansread commented 6 years ago

It seems the ^2 is missing from the source code?

image

lawinslow commented 6 years ago

Yup, I think its missing.

Sanity check with the OCE package

> 1000 + oce::swSigma0(35,25, pressure=10.1325)
 [1] 1023.342
> rLakeAnalyzer::water.density(25, 35)
[1] 1022.768

If we fix the equation to have the S^2 at the end.

> rLakeAnalyzer::water.density(25, 35)
[1] 1023.343

Digging into OCE, we can find their implementation of this equation. It is written in a way I didn't expect, but if you expand the algebra out, you find that last Salinity term (associated with 4.8314e-4) is squared.

So I think you're right. That last term should be squared.

jordansread commented 6 years ago

Thanks for digging in - seems a simple fix, but an embarrassing error I made in the first place.

lawinslow commented 6 years ago

Don't worry about it.

While I've said this before, this is why these tools should be open source.

@jread-usgs want to review and merge #99 quick?