Last active
May 15, 2021 13:54
-
-
Save rajeshpv/bbba48670bd8fa8c6266a5bb5eff1837 to your computer and use it in GitHub Desktop.
PSI Conversions SA-5015 jira has details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcPsi(read, loc) { | |
const readVal = read.v * read.mul; | |
const h = loc.elevation + loc.elevationOffset; | |
return calcPsiDirect(read.m, h, readVal); | |
} | |
function calcPsiDirect(uom, h, readVal){ | |
let newVal = -1; | |
switch (uom) { | |
case "PSIA": | |
newVal = readVal - (PsiPascElev(h) * 0.000145033); | |
break; | |
case "PSI": | |
newVal = readVal; | |
break; | |
case "BARA": | |
newVal = readVal - (PsiPascElev(h) * Math.pow(10, -5)); | |
break; | |
case "BAR": | |
newVal = readVal * 14.5038; | |
break; | |
} //end-switch | |
return newVal; | |
} | |
function PsiPascElev(h) { | |
let beforeExp = (1 - (2.25577 * Math.pow(10, -5) * h)); | |
return Math.pow(beforeExp, 5.25588) * 101325; | |
} | |
let readRec = { | |
"v": 207.6, | |
"inputId": 2, | |
"mul": 1, | |
"m": "PSIA" | |
}; | |
let loc = { | |
"lat": 35.86583, | |
"lng": -78.85754, | |
"elevation": 108, | |
"elevationOffset": -1.2192 | |
}; | |
let psi = calcPsi(readRec, loc); | |
console.log(psi); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment