Closed coelner closed 7 years ago
It returns altitude so I am not sure why you are suggesting the change in name.
Maybe I understand that completely wrong, but the Altitude at SeaLevel is 0. But we need a function to get a SeaLevel correlated Pressure. So far I read the code, you calculate this. ( https://de.wikipedia.org/wiki/Barometrische_H%C3%B6henformel#Internationale_H.C3.B6henformel ) (You need a SeaLevelAltitude while converting between different geodetic reference systems)
Hi, Tyler, it seems you have caught yourself in the trap of misleading name. The function sealevelAlitude really calculates the sea-level pressure which we know from meteorological reports. To the formula itself:
I recommend the comparison with http://drkfs.net/correctiontosealevel.htm.
Alright all, good data. I should have required more documentation on the pull request. Let me try to clean this up.
Hello, A lot of the time spent to compare calculation methods with official data of weather stations. Generally it is difficult to find complete set of data – usually the Pstation is omitted. I found complete data from Austria and Czech Republic only. https://www.zamg.ac.at/cms/de/wetter/wetterwerte-analysen http://portal.chmi.cz/aktualni-situace/aktualni-stav-pocasi/ceska-republika/stanice/profesionalni-stanice/mapy/teplota-a-vlhkost/stanice
Regarding differences A vs. CZ: Each country uses a bit different algorithm. The table is usable to check different calculation formulas and compare with official data. Secondary it is usable to calibrate pressure sensors. Note: Excel document is created in European language. If you need decimal “.” instead of “,” in numbers then you have to change the character…
Regards jirkaptr Atmospheric calculations test.xlsx
I believe some renaming is in order. The readme claims that altitude is returned, but the source paints a more confusing picture:
/// Convert current pressure to sea-level pressure, returns
/// Altitude (in meters), temperature in Celsius
/// return the equivalent pressure at sea level.
It says that it is converting pressures, then says it returns altitude in meters (and temperature), and then says it returns pressure at sea level. A simple test shows that it returns values that as much more in the range of pressure in Pa
than altitude in m
. It seems much more correct to say it accepts pressure (in Pa), Altitude (in meters) and Temperature (in Celsius), and returns pressure (in Pa). The returns
on the first line of the comment seems erroneous and if left out, the comment as written makes far more sense (name of the method notwithstanding)
For example, a current reading from my BMP280 has a pressure of 101425 Pa, and the sealevel calculation returns 102105 Pa. Note that this is using a known-good altitude, and not the altitude as derived from the Altitude()
method, which returns a significantly different value, but is computed with a default sealevel altitude of 101325 Pa as defined in the header
Given that this method seems to return a value in Pa, and that sealevel altitude should be pretty relatively constant, one might wonder what use this method has? For me, it seems to be for calibration of the Altitude()
. When using the 101325 sealevel pressure, my altitude is about 70m from reality, so instead, using my known-good altitude, and obtaining the 102105 Pa pressure from the method, it seems I can use this value in place of the default sea-level pressure in Altitude()
to get calibrated altitudes.
Here is the original pull request: #22
Looks like it was originally written to calculate equivalent sea level pressure in mb. When I refactored the code my analysis showed it was unit independent code. So, using Pa would not impact the calculation.
@guruathwal can you shed some light on the situation.
I'd have to give it a more careful read, but that sounds correct. There winds up being a ratio of sealevel pressure to atmospheric pressure, and since the conversions between various units of pressure are linear, you should be able to pass in pressure in any unit, and get the adjusted pressure back out in the same unit.
It will just be pressure that it converted though, the temperature/altitude are fixed and used to determine the sealevel pressure.
Alright, a change is in order:
equivalentSeaLevelPressure
.Completed: #49
Hi.. there should not be any confusion.. You input your current altitude in "Meters", Current Pressure in "mb" and current temperature in "celcius" The function will return equivalent Sea Level Pressure in "mb"
rename sealevelAltitude to seaLevelPressure. It is a little bit misleading.