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

0 Members and 1 Guest are viewing this topic.

Offline lightmaster

  • MB-HWS Template Dev
  • Forecaster
  • *****
  • Posts: 324
    • Baxley,GA Weather
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: 840
  • #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
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline lightmaster

  • MB-HWS Template Dev
  • Forecaster
  • *****
  • Posts: 324
    • Baxley,GA Weather
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: 840
  • #conligwx
    • conligwx.org
Thanks, though Mine works exactly the way I want the units to show anyway.
Regards Simon
Davis Vantage Pro2 Plus (6162UK) • Daytime FARS • WeatherLink Live • AirLink • PurpleAir PA-II-SD • CumulusMX •


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9279
  • 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, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline weather34

  • Forecaster
  • *****
  • Posts: 1068
    • https://weather34.com/homeweatherstation
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 »

Offline lightmaster

  • MB-HWS Template Dev
  • Forecaster
  • *****
  • Posts: 324
    • Baxley,GA Weather
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.

 

anything