Unidata / MetPy

MetPy is a collection of tools in Python for reading, visualizing and performing calculations with weather data.
https://unidata.github.io/MetPy/
BSD 3-Clause "New" or "Revised" License
1.26k stars 415 forks source link

Unusual CIN shading on WMW Maniwaki sounding due to Pint errors #1347

Open eliteuser26 opened 4 years ago

eliteuser26 commented 4 years ago

Noticed that the CIN shading for WMW Maniwaki on April 2, 2020 at 12 UTC wasn't correctly displayed as half of it is displayed right of the parcel profile and the rest is shaded right of the measured temperature profile. This is the second time that I see this problem. I was able to reproduce this unusual shading on both Linux and Windows 10. This is a bug which is hard to track as it is infrequent. However after generating the sounding it gave some errors related to the Pint module:

d:\program files\python38\lib\site-packages\pint\quantity.py:1509: RuntimeWarning: invalid value encountered in greater
  return op(self.to_root_units().magnitude, other.to_root_units().magnitude)
d:\program files\python38\lib\site-packages\pint\quantity.py:1509: RuntimeWarning: invalid value encountered in less
  return op(self.to_root_units().magnitude, other.to_root_units().magnitude)

image

eliteuser26 commented 4 years ago

I found the culprit in the sounding data as indicated in the table below. The last row of the sounding contains NaN values. If I use the command below, it breaks the dataframe units. So I have to manually attached the units to the Pandas dataframe. I am not sure if this is supposed to happen with that command.

df = df.dropna(subset=('temperature', 'dewpoint', 'direction', 'speed'), how='any'
               ).reset_index(drop=True)
pressure height temperature dewpoint direction speed u_wind v_wind station station_number time latitude longitude elevation
992.0 189.0 -1.3 -2.5 325.0 1.0 0.573576 -0.819152 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
984.0 252.0 -1.3 -11.3 339.0 5.0 1.791840 -4.667902 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
977.4 305.0 -1.4 -10.0 350.0 8.0 1.389185 -7.878462 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
956.0 477.0 -1.5 -5.7 1.0 13.0 -0.226881 -12.998020 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
939.8 610.0 -1.6 -6.7 10.0 17.0 -2.952019 -16.741732 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
... ... ... ... ... ... ... ... ... ... ... ... ... ...
10.0 30960.0 -48.9 -73.9 275.0 57.0 56.783098 -4.967877 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
9.9 31026.0 -48.9 -73.9 275.0 58.0 57.779292 -5.055033 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
8.0 32410.0 -53.7 -75.7 275.0 73.0 72.722213 -6.362369 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
7.5 32826.0 -51.9 -74.9 275.0 77.0 76.706992 -6.710992 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0
7.4 NaN NaN NaN 275.0 78.0 77.703186 -6.798148 WMW 71722 2020-04-02 12:00:00 46.3 -76.01 189.0