Skip to content

Conversation

@dcamron
Copy link
Member

@dcamron dcamron commented Apr 7, 2023

From recent discussions and #2092 (comment), a quick update to use weighted_continuous_average in bunkers_storm_motion for the layer wind averages instead of np.mean. Opening this up to any discussion before updating any test values (and making sure a small change works back to Minimum.)

Checklist

@dcamron dcamron added Type: Maintenance Updates and clean ups (but not wrong) Area: Calc Pertains to calculations labels Apr 7, 2023
@dcamron dcamron added this to the April 2023 milestone Apr 7, 2023
@dcamron dcamron requested a review from a team as a code owner April 7, 2023 22:56
@dcamron dcamron requested review from dopplershift and removed request for a team April 7, 2023 22:56
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this. I'm curious how bad the test value changes are...I would hope they're not significant.

@dcamron
Copy link
Member Author

dcamron commented Apr 10, 2023

I'm happy with this. I'm curious how bad the test value changes are...I would hope they're not significant.

Max absolute difference: 0.37513416
Max relative difference: 0.11791906
 x: array([ 2.062733  ,  0.96246913, 11.22554254, 12.83861839,  6.64413777,
        6.90054376])
 y: array([ 2.18346161,  0.86094706, 11.6006767 , 12.53639395,  6.89206916,
        6.69867051])

@dopplershift
Copy link
Member

Probably a little bigger than I'd like (percentage-wise) but not really scary.

@dopplershift
Copy link
Member

@dcamron Do you want to fix up the tests to get this in the release?

@dcamron
Copy link
Member Author

dcamron commented Apr 28, 2023

If there's no other community input and we feel good about these changes, I'm glad to.

@dcamron dcamron requested a review from dopplershift May 3, 2023 16:31
@dopplershift dopplershift merged commit 64608b0 into Unidata:main May 3, 2023
@yfNJU
Copy link

yfNJU commented Aug 18, 2025

Hello @dopplershift @dcamron! After reviewing #2092 and #2144 , I think using mean_pressure_weighted for bunkers storm motion calculation might be better. Because the get_layer function in weighted_continuous_average only return pressure profile to pres_prof, which is used in calculating [trapezoid(var_prof, x=pres_prof) / (pres_prof[-1] - pres_prof[0]) for var_prof in others]
Considering that even for isobaric layer data, the mass of air blocks between pressure layers is not consistent, using mean_pressure_weighted might be a better method for calculating the average wind speed of the entire layer. In the function corfidi_storm_motion for calculating MCS storm motions using the Corfidi method, the mean_pressure_weighted function is used to calculate the average wind.

@dopplershift
Copy link
Member

dopplershift commented Aug 18, 2025

@yfNJU Hi! I would point you to #1361, where we intentionally changed bunkers_storm_motion to use a non-pressure-weighted mean for the wind, as that's what is explicitly specified in the Bunkers (2000) paper. In fact, they arrived at the non-pressure weighted average as it empirically yielded the best mean absolute error (MAE).

EDIT: If you have an updated peer-reviewed publication indicating broad acceptance that using a pressure-weighted mean yields an improved technique, I'd love to see it and would be interested then in updating MetPy's implementation to reflect the latest science.

@yfNJU
Copy link

yfNJU commented Aug 19, 2025

@yfNJU Hi! I would point you to #1361, where we intentionally changed bunkers_storm_motion to use a non-pressure-weighted mean for the wind, as that's what is explicitly specified in the Bunkers (2000) paper. In fact, they arrived at the non-pressure weighted average as it empirically yielded the best mean absolute error (MAE).

EDIT: If you have an updated peer-reviewed publication indicating broad acceptance that using a pressure-weighted mean yields an improved technique, I'd love to see it and would be interested then in updating MetPy's implementation to reflect the latest science.

Thank you very much for you reply! I reviewed #1361 and confirmed that the method mentioned therein aligns with Eq. (1) in Bunker [(2014)]. Additionally, I agree with #2092's consideration that Eq. (1) in Bunker (2014) appears to assume even sampling of levels in a vertical profile, whereas #2092's approach of using the average value between adjacent layers multiplied by the pressure difference as a weighting factor is more convincing.

Additionally, I recommend adding Bunker (2014). to the references of bunkers_storm_motion. This paper explicitly defines the non-pressure-weighted formulation. It is also worth noting that it introduces the "effective layer" method for wind averaging, which utilizes pressure-weighted vertical integration and has already been applied in the SHARPpy algorithm (See def bunkers_storm_motion in line 2407). Maybe we can consider developing a effective_layer_bunkers_storm_motion function. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Calc Pertains to calculations Type: Maintenance Updates and clean ups (but not wrong)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add non-weighted pressure-based mean function

3 participants