Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function salinity($measuredConductivity, $measuredTemperature, $measuredDepth) {
- // PHP version by Ben Ostrowsky
- // Based on Excel formulas by James Douglass
- // http://jimbodouglass.blogspot.com/2010/11/conductivity-to-salinity-conversion-for.html
- // Based on Fofonoff, N.P. and Millard, R.C., Jr. (1983). Algorithms for computation
- // of fundamental properties of seawater. http://hdl.handle.net/1912/2470
- // Added code to compensate for depth.
- $referenceConductivity = 42900.0; // microsiemens per cm^2
- $conductivityRatio = $measuredConductivity / $referenceConductivity;
- $waterDensity = 1.03 * 10^3; // kilograms per m^3 (pure water would be 1.00 * 10^3)
- $gravity = 9.8; // meters per s^2
- $airPressure = 10.0; // decibars
- $computedPressure = ($waterDensity * $gravity * $measuredDepth / 10.0) + $airPressure;
- $littlert = (
- 0.6766097
- + 0.0200564 * $measuredTemperature
- + 0.0001104259 * ($measuredTemperature^2)
- + (-6.9698*10^-7) * ($measuredTemperature^3)
- + ( 1.0031*10^-9) * ($measuredTemperature^4)
- );
- $Rp =
- 1 + (
- (
- $computedPressure * (
- 2.070*10^-5 * ($computedPressure^0)
- + (-6.370*10^-10) * ($computedPressure^1)
- + 3.989*10^-15 * ($computedPressure^2)
- )
- /
- (
- 1
- + (3.426*10^-2) * ($measuredTemperature^1)
- + (4.464*10^-4) * ($measuredTemperature^2)
- + ( 4.215*10^-1 + (-3.107*10^-3) * $measuredTemperature ) * $conductivityRatio
- )
- )
- );
- $bigRt = $conductivityRatio / ($littlert * $Rp);
- $dS =
- (
- ( $measuredTemperature - 15.0) / (1 + 0.0162*( $measuredTemperature - 15.0 ) )
- )
- * (
- 0.0005
- + (-0.0056) * ($bigRt^0.5)
- + (-0.0066) * ($bigRt^1)
- + (-0.0375) * ($bigRt^1.5)
- + ( 0.0636) * ($bigRt^2)
- + (-0.0144) * ($bigRt^2.5)
- );
- $computedSalinity =
- 0.008
- + (-0.1692) * ($bigRt^0.5)
- + 25.3851 * ($bigRt^1)
- + 14.0941 * ($bigRt^1.5)
- + (-7.0261) * ($bigRt^2)
- + 2.7081 * ($bigRt^2.5)
- + $dS;
- return $computedSalinity;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement