Author Topic: [Weather34] Error in barometer when using nonstandard combinations of units  (Read 231 times)

0 Members and 1 Guest are viewing this topic.

Offline lightmaster

  • Member
  • *
  • Posts: 33
    • KGABAXLE9 website
If you set the units to English/imperial, and set your default barometer units to mb instead of inHG, the barometer chart freaks out and shows the numbers for mb, but the scale of the chart is still set for inHG and the conversions shown are crazy, like 34,000 hPa :shock:. Dug through the .php files and found that in the barometer.php file, it looks like it determines which units to use based mostly, but not completely, on what your default temperature is set to, not what the barometer unit is set to. If you replace all occurrences of
Code: [Select]
$weather["temp_units"]=='C' with
Code: [Select]
$weather["barometer_units"]=='mb' OR $weather["barometer_units"]=="hPa" and all occurrences of
Code: [Select]
$weather["temp_units"]=='F' with
Code: [Select]
$weather["barometer_units"]=='inHg' it lets you pick whichever barometer units you want to use regardless of what the other units are set to.

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 361
  • #conligwx
    • conligwx.org
If you replace all occurrences of
Code: [Select]
$weather["temp_units"]=='C' with
Code: [Select]
$weather["barometer_units"]=='mb' OR $weather["barometer_units"]=="hPa" and all occurrences of
Code: [Select]
$weather["temp_units"]=='F' with
Code: [Select]
$weather["barometer_units"]=='inHg' it lets you pick whichever barometer units you want to use regardless of what the other units are set to.
Replace C or F with Pressure units?

Sent from my ONEPLUS A6003 using Tapatalk

Offline lightmaster

  • Member
  • *
  • Posts: 33
    • KGABAXLE9 website
Replace the entire check for temp_units = C with a check for barometer_units = mb OR hPa: “$weather["temp_units"]=='C'” is replaced with “$weather["barometer_units"]=='mb' OR $weather["barometer_units"]=="hPa"”.

Then do the same replacing the checks for temp_units = F with a check for barometer_units = inHg: “$weather["temp_units"]=='F'” is replaced by “$weather["temp_units"]=='F'”.


Originally, it checked for if Celcius was used, and if so it would assume you were using mb/hPa, or if Fahrenheitn was used, it would assume you used inHg instead. At the same time, it would pull the number from the database as the barometer units you specified in the setup, so it could mix up the units and have some crazy conversions, and used the wrong scale on the graph. With this change, instead of using temperature to assume the barometer units you want to use, it simply checks which units you set it to use instead.

Offline ConligWX

  • Forecaster
  • *****
  • Posts: 361
  • #conligwx
    • conligwx.org
Thanks, though Mine works exactly the way I want the units to show anyway.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6992
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
lightmaster, thanks very much for the fix.

I've merged it into the Cumulus-HWS master at https://github.com/ktrue/CU-HWS

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline weather34

  • its just my hobby
  • Forecaster
  • *****
  • Posts: 735
    • Sinanoba Istanbul Home Weather Station
If you set the units to English/imperial, and set your default barometer units to mb instead of inHG, the barometer chart freaks out and shows the numbers for mb, but the scale of the chart is still set for inHG and the conversions shown are crazy, like 34,000 hPa :shock:. Dug through the .php files and found that in the barometer.php file, it looks like it determines which units to use based mostly, but not completely, on what your default temperature is set to, not what the barometer unit is set to. If you replace all occurrences of
Code: [Select]
$weather["temp_units"]=='C' with
Code: [Select]
$weather["barometer_units"]=='mb' OR $weather["barometer_units"]=="hPa" and all occurrences of
Code: [Select]
$weather["temp_units"]=='F' with
Code: [Select]
$weather["barometer_units"]=='inHg' it lets you pick whichever barometer units you want to use regardless of what the other units are set to.

good morning thanks for taking the time to look into this one. conversions never been my favourite task so I have implemented Ken Trues version from the cumulus
port of the template as it is based on current meteobridge version. Not sure when this will be fully released in the meteobridge version as waiting for new data to be added to API .so many thanks to you and Ken for the solutions ...as always more eyes the better...brian

« Last Edit: January 26, 2019, 11:12:01 PM by weather34 »
Rise up this morning, smiled with the rising sun
Three little birds, by my weather station
Singing sweet songs, of melodies pure and sure
Saying, "This is my message to you"
Singing: "Don't worry about a thing, oh-oh"
'Cause every little thing is gonna be alright….

https://weather34.com/homeweatherstation/

Offline lightmaster

  • Member
  • *
  • Posts: 33
    • KGABAXLE9 website
Not a problem.  :grin:

I had meant to post about it a little while back but forgot, and I noticed the messed up chart again while working on updating the template.