<p>I have taken an upper air sounding from UoW Database and currently calculating the Brunt-Vaisala frequency (the 'squared' one, at the moment) using MetPy across several stations for some basic synoptic purposes.</p>
<p>The minimal <em>(at some point)</em> and reproducible code runs like this</p>
<pre><code>    import metpy.calc as mpcalc
    import matplotlib.pyplot as plt
    import numpy as np
    from datetime import datetime
    from metpy.units import units, pandas_dataframe_to_unit_arrays
    from siphon.simplewebservice.wyoming import WyomingUpperAir
    
    stations = ['RPLI', 'RPUB', '98433', 'RPMP', 'RPVP', 'RPMD'] #6 stations
    station_data = {}
    date = datetime(2016, 8, 14, 0)
    
    for station in stations:
        print(f'Getting {station}')
        df = pandas_dataframe_to_unit_arrays(WyomingUpperAir.request_data(date, station))
        df['theta'] = mpcalc.potential_temperature(df['pressure'], df['temperature'])
        df['bv_squared'] = mpcalc.brunt_vaisala_frequency_squared(df['height'], df['theta'])
        station_data[station] = df
    
    mean_bv = []
    for station in stations:
        df = station_data[station]
        keep_idx = (df['height'] &gt;= 1000 * units.m) &amp; (df['height'] &lt;= 5 * units.km)
        mean_bv.append(np.mean(df['bv_squared'][keep_idx]).m)
    
    plt.title(&quot;Atmospheric Stability&quot;)
    plt.plot(mean_bv)
    plt.show()
</code></pre>
<p>which produces a simple plot like this</p>
<p><a href="https://i.sstatic.net/LTreT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/LTreT.png" alt="enter image description here" /></a></p>
<p>I would like to ask on how to smooth out those 'lines'/data, like by applying interpolation? I'm a bit novice, thus I look forward to your help and responses.</p>

CC BY-SA 4.0
2022-08-31T17:42:25.030Z
I can understand why some people might think this question is not about Earth Science & want to close it. I'm interpreting this question as "how would a earth scientist, presumably a meteorologist, analyze the data & produce a smooth curve". I'm voting to keep it open.
Fred
CC BY-SA 4.0
2022-09-01T00:33:14.033Z
Thanks! That's a bit unfortunate to hear that some/few people want to close the thread. I was literally looking for help and landed here since it's meteorology-related.
CGHA
<meteorology><python>
Applying spline interpolation for Brunt-Vaisala frequency
CGHA
# Applying spline interpolation for Brunt-Vaisala frequency

(Asked by: username_0 on 2022-08-31)

I have taken an upper air sounding from UoW Database and currently calculating the Brunt-Vaisala frequency (the 'squared' one, at the moment) using MetPy across several stations for some basic synoptic purposes.

The minimal *(at some point)* and reproducible code runs like this

```
    import metpy.calc as mpcalc
    import matplotlib.pyplot as plt
    import numpy as np
    from datetime import datetime
    from metpy.units import units, pandas_dataframe_to_unit_arrays
    from siphon.simplewebservice.wyoming import WyomingUpperAir
    
    stations = ['RPLI', 'RPUB', '98433', 'RPMP', 'RPVP', 'RPMD'] #6 stations
    station_data = {}
    date = datetime(2016, 8, 14, 0)
    
    for station in stations:
        print(f'Getting {station}')
        df = pandas_dataframe_to_unit_arrays(WyomingUpperAir.request_data(date, station))
        df['theta'] = mpcalc.potential_temperature(df['pressure'], df['temperature'])
        df['bv_squared'] = mpcalc.brunt_vaisala_frequency_squared(df['height'], df['theta'])
        station_data[station] = df
    
    mean_bv = []
    for station in stations:
        df = station_data[station]
        keep_idx = (df['height'] >= 1000 * units.m) & (df['height'] <= 5 * units.km)
        mean_bv.append(np.mean(df['bv_squared'][keep_idx]).m)
    
    plt.title("Atmospheric Stability")
    plt.plot(mean_bv)
    plt.show()

```

which produces a simple plot like this

[![enter image description here](https://i.sstatic.net/LTreT.png)](https://i.sstatic.net/LTreT.png)

I would like to ask on how to smooth out those 'lines'/data, like by applying interpolation? I'm a bit novice, thus I look forward to your help and responses.

**Tags:** meteorology, python

> **Comments:**
> **username_1**: I can understand why some people might think this question is not about Earth Science & want to close it. I'm interpreting this question as "how would a earth scientist, presumably a meteorologist, analyze the data & produce a smooth curve". I'm voting to keep it open.  
> **username_0**: Thanks! That's a bit unfortunate to hear that some/few people want to close the thread. I was literally looking for help and landed here since it's meteorology-related.  

---

## 0 answers

