anyone experience this before

61 views
Skip to first unread message

Will H

unread,
Nov 5, 2024, 12:04:10 PM11/5/24
to wrfpython-talk
I have a gusts calculation using WRF python, but I get these odd empty spaces where no values are plotting and not interpolating.  Any ideas?


wrf_d02_slp_wind_ter_ft_20241104_2300.pngwrf_d02_SLP_WIND_Gust.gif

Chun-Chih Wang

unread,
Nov 5, 2024, 4:29:42 PM11/5/24
to Will H, wrfpython-talk

Hi Will,

Did you do any vertical interpolation if the gust either in height or pressure?  If so, I have had experiences where if your height or pressure coordinates matches your desired interpolation level, the interpolation will return NaN. In that case, just add or subtract a very small number from your desired level so that none of the vertical coordinates of your data matches the desired level.

David


On Tue., Nov. 5, 2024, 12:04 p.m. Will H <hathew...@gmail.com> wrote:
I have a gusts calculation using WRF python, but I get these odd empty spaces where no values are plotting and not interpolating.  Any ideas?


wrf_d02_slp_wind_ter_ft_20241104_2300.pngwrf_d02_SLP_WIND_Gust.gif

--
You received this message because you are subscribed to the Google Groups "wrfpython-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wrfpython-tal...@ucar.edu.
To view this discussion visit https://groups.google.com/a/ucar.edu/d/msgid/wrfpython-talk/25052d9f-b249-4fee-9615-b2ee29c9ea88n%40ucar.edu.

Will H

unread,
Nov 6, 2024, 11:35:00 AM11/6/24
to wrfpython-talk, chunchih...@gmail.com, wrfpython-talk, Will H
I am reaching out to share and explain recent improvements I have made to the wind gust calculation module in our Python script for processing WRF model outputs. These changes were motivated by a desire to improve accuracy by aligning the method more closely with the principles in the original FORTRAN code and established meteorological practices.

Background and Motivation
The updated method is based on an approach referenced in the original NOAA RUC20 model documentation (Benjamin et al., 2002), as seen in the equation provided in the image you shared. The equation describes how surface gusts can be calculated using the wind speed at 10 meters and at the top of the planetary boundary layer (PBL) with a weighting function that decreases with height. This weighting is capped at 1000 meters, ensuring that the influence of higher altitudes on surface gusts is properly limited.

This methodology aligns with the logic found in the original FORTRAN code, where a height-dependent weighting factor is applied to adjust for wind speed differences at various levels to reflect surface conditions more realistically.

Overview of the Original Python Method
In the initial Python implementation, I used a simplified approach that only interpolated the wind speed at the PBL height and applied a fixed adjustment. Here’s a snippet from the original code:

python
Copy code
# Original wind gust calculation
wspd_pblh = wrf.interplevel(wspd_wdir, height, pblh)  # Interpolate wind speed at PBL height
g_pblh = np.where(pblh <= 1000, pblh, 1000)  # Cap PBL height at 1000m
G = (wspd_wdir10[0] + (wspd_pblh[0] - wspd_wdir10[0]) * (1 - (g_pblh / 2000))) * 3.6  # Calculate gusts in km/h
This approach simply blended the wind speed at 10 meters and at the PBL height with a basic linear weighting, which did not capture the full range of vertical wind influences on gust potential.

Enhanced Method: Iterative Weighting Across Vertical Levels
In the revised script, I implemented an iterative approach inspired by the original FORTRAN code and NOAA RUC20 model formula. This method examines wind speeds across all vertical levels, applying a dynamic weight that decreases with height, as specified in the formula:

WG​=v10​+(vPBL​−v10​)(1−2000mhPBL​​)

In the Python code, I translate this into an iterative process that adjusts for each level, capping the influence above 1000 meters and ensuring consistency with the methodology described in the RUC20 documentation. Here’s the updated code snippet:

python
Copy code
# Revised wind gust calculation
max_gust_speed = np.zeros_like(wspd_wdir10)  # Initialize array for maximum gust speeds

# Iterate over each vertical level
for k in range(u.shape[0]):
    wind_speed_k = np.sqrt(u[k]**2 + v[k]**2)  # Wind speed at level k
    height_k = height[k]

    # Apply dynamic weighting based on height, with cap above 1000m
    weight_k = np.where(height_k <= 1000, 1 - height_k / 2000, 0.5)
    adjusted_speed_k = wspd_wdir10 + (wind_speed_k - wspd_wdir10) * weight_k

    # Track the maximum adjusted gust speed
    max_gust_speed = np.maximum(max_gust_speed, adjusted_speed_k)

# Smooth and convert gusts to mph
gusts = gaussian_filter(max_gust_speed * 2.23694, sigma=1)  # Convert m/s to mph
Key Benefits of the Revised Method
Increased Vertical Detail: By iterating over each level, the new method incorporates detailed information about how winds vary vertically. This approach is more aligned with the FORTRAN method, which also took height variation into account.

Improved Weighting Consistency: The dynamic weighting function, capped at 1000 meters, mirrors the original RUC20 model approach, where the influence of higher altitude winds is realistically diminished. This improves the accuracy of surface gust estimates by reflecting how the PBL modulates wind speed.

Enhanced Forecast Reliability: These changes make the script a more robust tool for predicting wind gusts. By aligning with the scientifically validated methodology in the NOAA RUC20 model and the original FORTRAN code, the revised method offers more reliable and realistic outputs.

This new approach significantly improves the representation of atmospheric dynamics in our gust estimates, making the script more valuable for both research and practical applications.



wrf_d02_SLP_WIND_Gust.gif wrf_d02_slp_wind_ter_m_20241106_0000.png    wrf_d02_SLP_WIND_Gust.gif

Will H

unread,
Nov 6, 2024, 6:24:38 PM11/6/24
to wrfpython-talk, Will H, chunchih...@gmail.com, wrfpython-talk
So, this Python code is inspired by two main approaches: Brasseur’s method and the NOAA RUC20 model. Both of these are commonly used for estimating wind gusts near the ground, but they each bring something unique to the table.

Starting with Surface Wind:
First off, we grab the wind speed at 10 meters above the ground (wspd_wdir10). This is our base wind speed at the surface, which is the foundation for predicting gusts. The RUC20 model from NOAA actually does this too, using the 10-meter wind as a starting point since it represents what’s happening right at ground level.

Looking at Wind Speeds Higher Up:
Then, look at wind speeds at different heights within the boundary layer. Brasseur’s method is all about this – it assumes that gusts can be influenced by winds from any level within the PBL (planetary boundary layer) as long as there’s enough turbulence to bring those higher winds down to the surface. So, we grab the winds from each level, which gives us a range of speeds that could potentially contribute to gusts near the ground.

Applying a Height-Based Weight:
Now, this is where the NOAA RUC20 model is utilized. We apply a weight that decreases with height. Up to 1 km, the weight gradually drops from 1.0 to 0.5, and for anything higher, it stays at 0.5. The idea is that winds higher up have less influence on surface gusts, but they’re still somewhat relevant. This weight factor is straight out of the RUC20 model, which scales down the effect of higher-level winds on surface gusts.

Adjusting and Finding the Max Gust:
For each level, we adjust the surface wind by adding the weighted difference between that level’s wind speed and the 10-meter wind. This gives us an adjusted gust speed for each level. Then, we just keep the maximum gust from all the levels, which, again, lines up with Brasseur’s method – he suggests looking at the strongest possible wind from within the PBL as the potential gust.

Why This Works
This code basically blends NOAA RUC20’s height-based scaling with Brasseur’s idea of pulling from all levels within the PBL. By combining these two methods, we’re able to get a solid estimate of what the maximum gust at the surface might look like, especially during turbulent conditions.


# Calculate the wind speed at each level and find the maximum gust speed
    max_gust_speed = np.zeros_like(wspd_wdir10)  # Assuming wspd_wdir10 is the surface wind speed


    # Iterate over each vertical level
    for k in range(u.shape[0]):
        # Calculate the wind speed at level k

        wind_speed_k = np.sqrt(u[k]**2 + v[k]**2)
        height_k = height[k]

        # Calculate the weight based on height

        weight_k = np.where(height_k <= 1000, 1 - height_k / 2000, 0.5)

        # Adjust the wind speed by the weighted difference from the surface

        adjusted_speed_k = wspd_wdir10 + (wind_speed_k - wspd_wdir10) * weight_k

        # Update the maximum gust speed
        max_gust_speed = np.maximum(max_gust_speed, adjusted_speed_k)

Will H

unread,
Nov 9, 2024, 12:57:48 PM11/9/24
to wrfpython-talk, Will H, chunchih...@gmail.com, wrfpython-talk, Marco Miani, Kevin Goebbert
Okay anyone that can solve this problem?

Here's some data and python code with the graphics.

https://drive.google.com/file/d/1SS9HhZl7EPeDS1mf06BS4hcT4lAxMuO7/view?usp=sharing

Will H

unread,
Nov 9, 2024, 12:59:51 PM11/9/24
to wrfpython-talk, Will H, chunchih...@gmail.com, wrfpython-talk, Marco Miani, Kevin Goebbert, matias...@unc.edu.ar, Leo
while it works over ocean, on CONUS it severely over estimates, so something is a miss.

Will H

unread,
Nov 10, 2024, 9:31:52 AM11/10/24
to wrfpython-talk, Will H, chunchih...@gmail.com, wrfpython-talk, Marco Miani, Kevin Goebbert, matias...@unc.edu.ar
here's the files,  my google drive was full so I had to re-upload them.

https://drive.google.com/file/d/1_5zZxDdfnauBGTZn7Mzp7Lz7nEDQyNmh/view?usp=sharing

Reply all
Reply to author
Forward
0 new messages