Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Lightning Probability #207

Open
GlennGoddard opened this issue Jan 11, 2023 · 4 comments
Open

Add Lightning Probability #207

GlennGoddard opened this issue Jan 11, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@GlennGoddard
Copy link
Contributor

New Feature

This is an oversimplification given the data we have to work with but might be useful. This will return a percentage as written:

def calculate_lightning_risk(lightning_strike_distance, lightning_strike_energy, strikes_1hr, strikes_3hr, strikes_today):
    # Constants
    D = lightning_strike_distance # distance of lightning strikes
    E = lightning_strike_energy # energy of the lightning strike
    S1 = strikes_1hr # number of strikes in the last hour
    S3 = strikes_3hr # number of strikes in the last 3 hours
    S = strikes_today # total number of strikes today
    
    # Lightning risk calculation
    risk_factor = D*E + S1 + S3 + S
    lightning_risk = risk_factor/sum([D*E, S1, S3, S])
    return lightning_risk

Additional context

No response

@GlennGoddard GlennGoddard added the enhancement New feature or request label Jan 11, 2023
@GlennGoddard
Copy link
Contributor Author

This is written to provide more weight to more recent strikes since the 1hr strikes are included in the 3 hour, and the 3 hour is included in the total for the day.

@GlennGoddard
Copy link
Contributor Author

GlennGoddard commented Jan 12, 2023

ReDone in JavaScript for testing and provide % probability:

// Probability of Lightning
// for testing in Node-Red (Java-Script) all inputs are Imperial
// function in metric since WeatherFlow2MQTT is best done metric

temperature = (msg.temperature - 32) * (5/9)
relativeHumidity = msg.humidity
solarRadiation = msg.sr
windSpeed = msg.wind_speed * 0.44704
pressure = msg.sea_press * 33.863886666667
strikes_1m = msg.light_1m
strikes_1h = msg.light_1h
strikes_3h = msg.light_3h
strikes_day = msg.light_day
dew_point = (msg.dp - 32)*(5/9)
cloudy = flow.cloudy
partly_cloudy = flow.part_cloud

let prob = 0;

// temperature, dew point, and relative humidity check
if (temperature > 30) {
    if (relativeHumidity > 50 && dew_point > 15) {
        prob += 30;
    } else if (relativeHumidity > 30 && dew_point > 10) {
        prob += 20;
    }
}

// solar radiation check
if (solarRadiation > 600) {
    prob += 25
} else if (solarRadiation > 400) {
    prob += 10;
}

// wind speed check
if (windSpeed < 15) {
    prob += 15
}

// pressure check
if (pressure < 1000) {
    prob += 25
} else if (pressure < 1010) {
    prob += 10;
}

// lightning detector check
if (strikes_1m > 1 || strikes_1h > 20 || strikes_3h > 50 || strikes_day > 120) {
    prob += 25
} else if (strikes_1m > 0 || strikes_1h > 10 || strikes_3h > 20 || strikes_day > 50) {
    prob += 10;
}

// cloud coverage check
if (cloudy || partly_cloudy) {
    prob += 25;
}

msg.light = prob
return msg;

@GlennGoddard
Copy link
Contributor Author

I am looking up lightning data per latitude to maybe include

Most Likely conditions for Lightning:
humidity range 50-70%
temperature range 20-30C / 68-86F
sea level pressure range 1010-1020hPa
local time 2-3pm and 2-3am

Lightning has occurred at -85F / -65C; very rare however

@GlennGoddard GlennGoddard changed the title Add Lightning Strike Risk Add Lightning Probability Jan 18, 2023
@GlennGoddard
Copy link
Contributor Author

I am still experimenting, but everything I have tried so far is not consistent in prediction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant