Local/offline/self-hosted weather forecast?

I do largely find the aviation formula is the one I rely on the most. The reasoning is mostly that the aviation formula is the most portable, the built in formula for Weather Display is not published anywhere, so I have no idea what input data it is using to make it’s calculations, which makes it harder to trust. Additionally there are 2 snow calculations inside Weather Display, showing that the author of the software is just as unsure as the rest of us. The Aviation formula meanwhile, is actually used by pilots - and while it is more of a rough guide (at ground level) - it’s clearly more accurate too.

Did you ever consider low pressure as a condition for snow?
If you did consider it, why not use it?
If you didn’t, then disregard.

I’m just trying to help eliminate some false chances. I was thinking since clouds ‘typically’ aren’t around with high pressure there probably won’t be snow even if all other conditions are available. Just thinking outloud here.

It’s not something I have considered no, I am not sure any of the formulas consider it either. Mostly because it’s difficult to pick a number than you consider to be low pressure. I don’t think there is a figure that works globally, it would very much be highly local per area - especially since snow can arrive on strong winds from a lower pressure area in to a higher pressure area. It’s not uncommon for example in the UK to see snow falling out of a crystal clear sky.

1 Like

@mobile.andrew.jones Ok, next question…
Did you consider a low end temperature for snow?
I don’t live in a (what I would consider) an extreme cold climate but it looks like snow is very unlikely at temperatures of -20C or below due to the lack of ability for the air to hold much moisture.

I have a modified Beteliuice Zambretti forecast running right now in Node-Red with info fed from my Tempest weather station. I need to figure out how to get the 3 hour pressure trends and the caveats for when it is considered stable (stable when no rise or fall of 1.6" or more in the last 3 hours). I currently am using a ‘real time’ trend which seems to work anyway but I get some ‘bouncing’ of the results.

@zacs I think I can get Zambretti into @briis WeatherFlow2MQTT soon. I can do it right now for all Northern hemisphere locations. I need to work with @briis to get Lat/Long into WF2MQTT (probably from the docker command as a variable) (or the most complicated option of pulling it from the HA API utilizing an API key). I only need Latitude for Zambretti but I need Longitude for Solar Radiation estimation which in turn used for cloud determination. I also need the month for determining the season (Winter/Summer) but that should not be an issue. For now I am ok with the trend issue but it can be modified later when a better method is worked out. I will also just output the Zambretti nomenclature as it is calculated and work on a ‘countdown’ array later; I think it is better to get it out there to get feedback on.

I am using the All time stored Max and Min for pressure for the pressure range used by Zambretti instead of having a user input a range…I think this is the best way to do this and will just get more accurate over time. I have combined ‘most’ of my string of separate functions into one, it is still in JavaScript (due to Node-Red) but I should have it in python soon. Note-to-self: Please try to remember that JS uses radians for trig functions and python uses degrees (this keeps biting me over and over).

Again, no - it is not something I have considered. It is another one of those variables that is not global. For example the phrase “it’s too cold for snow” only applies to certain parts of the world, and OK granted that probably applies to most of the places where people want to be able to self host an offline snow predictor, but there could some gotchas. The figure of -20C only works when we go on the basis that the cold air will not rise and form clouds. However warmer upper air can come from elsewhere and snow can still fall. The only figure that we can say for absolutely certain is “too cold for snow” is -40C/F at this temperature meteorologists say the atmosphere is too stable for snow.

1 Like

We can certainly do that. How we get the data depends on if this will run as an Add-On or an independant Docker container, but it it possible…

My two cents is absolutely to keep lat/long (or a single coord) as its own env var. I love the independence that has thus far guided the project.

@briis can you remind me if a trail of historical data is stored in SQL of some sort in weatherflow2mqtt? That would at least allow @GlennHA to write a SELECT MAX,MIN style query over the last X months for barometric pressure (instead of all time max/min).

@mobile.andrew.jones Do you concur with the below?

My take so far on Snow Possible:

var temperature = msg.temperature
var freezing_level = msg.freezing_level
var cloud_base = msg.cloud_base
var dew_point = msg.dew_point
var wet_bulb = msg.wet_bulb
var snow_line = cloud_base - 500 // 500 ft, 150 m
var station_height = 325 // in feet for now

// Convert from F to C
// 2.1C = 35.78F, 1C = 33.8F, 4.1C = 39.38F, -40F = -40C
temperature = (temperature - 32) / 1.8
dew_point = (dew_point - 32) / 1.8
wet_bulb = (wet_bulb - 32) / 1.8

if ((temperature <= 2.1) && (snow_line <= station_height) && (dew_point <= 1) && (wet_blub <= 2.1) && (freezing_line <= cloud_base) && (temperature >= -40)) {
    msg.snow = 'true'
} else {
    msg.snow = 'false'
}

return msg

Snow Probability:

var temperature = msg.temperature
var dew_point = msg.dew_point
var snow_possible = msg.snow
var A = dew_point + temperature
var snow_prob

// Convert A from F to C
A = (A - 32) / 1.8

if (snow_possible == 'true') {
    snow_prob = 80 - 10 * A
} else {
    snow_prob = 0
}

msg.snow_probability = snow_prob
return msg

I have also come across this, but have not implemented yet:
Wet Bulb Zero Level (in feet)
. >3000 Always Rain, Snow Highly Unlikely
. 2000-3000 Mostly Rain, Snow Unlikely, Low Risk of Sleet
. 1000-2000 Snow More Likely than Rain or Sleet
. <1000 Mostly Snow, Light Precipitation and Low Lying Ground may still see Sleet or Rain

I almost concur.
However, as far as I am aware, cloud base is the height above the observation location, not height above sea level, so the station elevation is not required. Additionally the snow line does not need to be at or below the station elevation because snow can and will still fall if the snow line is say 200ft above the station location.

Knowing how high above the station location the snow line is, and doing some experiments with ground wet bulb versus height above station location, may allow the possibility of making a rough approximation as to the type of snow that is likely to fall, be it sleet, big fluffy flakes, dry powder etc, but it really would be rough, because events further up in the atmosphere can throw a spanner in the works, eg it is not uncommon to have snow falling from a very high snow line, melting as it passes through a layer of warmer air, and then freezing again as it passes through colder air - and ending up being either dry powdery snow or ice pellets.

My Cloud Base is above sea level so I do need to adjust.
I went off your post #19 above, I may have misinterpreted what you meant then:

What did you mean by snow height is 0ft?

When the snow height is 0ft, it obviously means conditions are very good for snow, but the snow line doesn’t have to be 0ft, if it is 100ft say, snow can still fall, provided that the surface temperature is cold enough that it doesn’t melt and turn to rain before it reaches the ground.

Also please note in your calculation - you have wet_blub instead of wet_bulb - just in case that was a copy and paste :wink:

I say then, leave it as it is, apart from wet_blub and see if it works. It’s really down to a choice of is it better for it to predict snow, and no snow falls, or is it better for it to predict no snow, and snow falling is then unexpected?

Thanks for noticing the ‘wet_blub’; not sure why that didn’t throw an undefined variable.
I should be ok then shifting the Snow Line from -500ft off of Freezing Line to 750ft??
I’ve seen ranges anywhere from 200 to 1000 feet off of freezing for the snow line. 500 and 750 seem to be the most common that I have come across.

Edit Looks like I need to change snow line to go off of Freezing Line, I accidentally went off of cloud base.

Hopefully this is going to become relevant for me soon, because when they become available in the UK, I intend to get a Weather Flow Tempest station.

Snapshot of current conditions:

Current Conditions @ 10:14:40 pm
Current Temp: 11.9°C  -0.5°C/hr
Current Dew Point: 10.5°C  -0.3°C/hr
Current Wet Bulb: 11.2°C
Current Humidity: 91%       (Absolute Humidity: 63.7795g/m³)
Current Cloud Height: 586.3ft / 178.7m

As I suspected - if the wet bulb and the current temperature are close together -

This gives us something to work with for fog prediction :slight_smile:

Although while much attention has been paid to the snow forecast formulas my site uses - no-one seems to have discovered (and it’s so long ago that I wrote it that I had also forgotten) - we do actually have an experimental fog forecast algorithm on the website:

As of writing -

Ouput: [+10] - Night-time
Ouput: [+20] - Windspeed is calm or low
Ouput: $fog = 30
Ouput: [+20] - Humidity is over 90% and is rising / steady...
Ouput: $fog = 50
Ouput: [+20] - Diff between temp and dewpoint is less than 2'C and over 1'C
Ouput: $fog = 70
Ouput: ($fog = $fog / 75 * 100) = 93.3333333333


Ouput: Based on current conditions and trends - the likeliness of fog in the next few hours is 73 - 93%

I’d say the estimate is correct.

Just turned off my computer, I will compare yours to mine tomorrow. I’ll post what I have here. I have not had Fog since I setup my test environment.

Can you post the algorithm?

Here is my JavaScript for Fog:

var temperature = msg.temperature
var cloud_base = msg.cloud_base
var dew_point = msg.dew_point
var station_height = 325 // in feet for now
var humidity = msg.humidity
var wind_speed = msg.wind_speed
var wet_bulb = msg.wet_bulb
var fog

// Convert from F to C
temperature = (temperature - 32) / 1.8
dew_point = (dew_point - 32) / 1.8
wet_bulb = (wet_bulb - 32) / 1.8

// Convert Wind Speed to Metric
wind_speed = wind_speed * 0.44704

// 2.5C = 4.5F
// 5 knots = 5.7 mph = 2.57 m/s
// 10 knots = 11.5 mph = 5.14 m/s
// -40C = -40F
if (((temperature - dew_point) <= 2.5) && (humidity >= 95) && (temperature >= -40) && (wind_speed >= 2.57) && (wind_speed <= 5.14)) {
    fog = 'true'
} else if (cloud_base <= station_height){
    fog = 'true'
} else {
    fog = 'false'
}

msg.fog = fog
return msg

I am always open to more options.

$fog = 0;
if ($daytime == 1) {
$fog = $fog - 15;
} else { 
// fog is more common at night
  $fog = $fog + 10; 
}
if ($averageWind < 5) { //mph
// fog is more likely when it is calm
  $fog = $fog + 20;
} elseif ($averageWind < 10) { //mph
// it's more windy, fog is slightly less likely
  $fog = $fog + 5;
} else {
// it's unlikely fog will form above 10mph
  $fog = $fog - 20;
}

if ($humidity > 75 && $humidity < 91) { //high humidity
  if ($humidityChangeLastHour > 0 || $humidityChangeLastHour == 0) { // humidity rising or steady
    $fog = $fog + 10;
  } else {
    // humidity is decreasing
    $fog = $fog - 5;
  }
} elseif ($humidity > 90) { // high humidity
  if ($humidityChangeLastHour > 0 || $humidityChangeLastHour == 0) { // humidity rising or steady
    $fog = $fog + 10;
  } else {
    // humidity is decreasing
    $fog = $fog - 1;
  }
} else {
  // humidity is still quite low
  $fog = $fog - 20;
}

$diff = $TempNow - $Dew;

if (($diff < 5.1) and ($diff > 3.9)) { 
  $fog = $fog + 5;
//Diff between temp and dewpoint is less than 5'C and over 4'C");
}
elseif (($diff < 4.1) and ($diff > 2.5)) {
  $fog = $fog + 10;
//Diff between temp and dewpoint is less than 4'C and over 2.5'C");
}
elseif (($diff < 2.6) and ($diff > 1.9)) {
  $fog = $fog + 15;
//Diff between temp and dewpoint is less than 3'C and over 2'C");
}
elseif (($diff < 2.1) and ($diff > 0.9)) {
  $fog = $fog + 20;
//Diff between temp and dewpoint is less than 2'C and over 1'C");
}
elseif ($diff < 1) {
  $fog = $fog + 25;
//Diff between temp and dewpoint is less than 1'C");
} else {
  $fog = $fog - 20;
}

// 75 is the maximum possible score
if ($fog > 0) { $fog = ($fog /75) * 100; } else { $fog = 0; }

This is the basis of the experimental formula based on observations since 2006…

1 Like

The way I see it is that the max value is actually 65 not 75 so 86.6% is the highest probability for fog.
Which may be the best way to go, so it will never say 100% chance of fog.

I just want to make sure I am not missing something. I am interpreting the ‘if’ under the >90% as indented under the elseif, which is the only thing that makes sense to me.

I am modifying what I understand to be the intent for testing. I don’t have a convenient way to track changes in humidity so i am simplifying that section by removing the nested if’s and going with +5 for between 75 and 91% humidity and +10 for >90%. I know this is an oversimplification but it should not be too bad.

Can you check to see if you have the absolute humidity equation again?
I use an oversimplification and I think it estimates low.

Daytime check - max score = 10
Average wind - max score = 20
Humidity check - max score = 10
Difference between temperature and Dew point - max score = 25

Max score 65. Yup

The indented if’s are to check if the humidity is high but the trend is falling - because that reduces the possibility of fog - or if fog is already present indicates that it will dissipate. We do have a way to track the trend, if it’s not provided by weatherflow, then we can simply add a trend sensor in home assistant to track the humidity sensor.

It would however be preferable for weatherflow to provide the value of certain sensors - 1 hour ago, 3 hours ago, 12 hours ago and 24 hours ago. It’s always handy to be able to compare a now value to 24 hours ago, and for barometric trend, knowing the value 3 hours ago, 12 hours ago and 24 hours ago - let’s us understand how quickly the pressure is falling, whether it is a continuous fall, or if there has been some recovery. This is extremely useful information because basic storm predictions can be made. I work on the basis of a 12mb drop in 24 hours is enough to trigger a potential storm warning, but for example a 6mb drop in 3 hours can be a very early storm warning even though it does not drop 12mb over 24 hours.