ai2es / utorview

WoFS UNet Tornado Guidance Viewer
Creative Commons Zero v1.0 Universal
2 stars 2 forks source link

Accumulated probabilities #11

Open djgagne opened 9 months ago

djgagne commented 9 months ago

There was a feature request from SPC to have probabilities that look as close to Monte Flora's ML wofs model as possible. One way to do this is accumulating the 5 minute tornado probabilities over a 30 minute window with the following formula.

prob_30min = 1 - np.prod(1-prob_5_min)

It is the probability of at least one 5 min period in that 30 minute period having a tornado.

It is possible to do this in JavaScript with our sparse arrays while keeping them sparse. If there are multiple nonzero values across time at a given point, then you just multiply their 1-prob values together and assume the 0 values would then be 1, resulting in identity for those values.

The first forecast time would be F30min, which is consistent with the cbwofs website.

djgagne commented 9 months ago

Here is some pseudocode of what I want to happen. The logic may not be entirely correct but this is the rough idea of what should work:

probs_5min = sparse array of probabilities
accumulated = {index: [], probs: []}
time = 30
for f in range(time - 30, time, 5):
    for i in probs_5min[index]:
       if i in accumulated[index]:
          accumulated[index] *=  1- probs_5min[values][i]
       else:
          accumulated[index] =  1 - probs_5min[values][i]
accumulated = 1 - accumulated