示例#1
0
def test_most_unstable_parcel():
    """Tests calculating the most unstable parcel."""
    levels = np.array([1000., 959., 867.9]) * units.mbar
    temperatures = np.array([18.2, 22.2, 17.4]) * units.celsius
    dewpoints = np.array([19., 19., 14.3]) * units.celsius
    ret = most_unstable_parcel(levels, temperatures, dewpoints, depth=100 * units.hPa)
    assert_almost_equal(ret[0], 959.0 * units.hPa, 6)
    assert_almost_equal(ret[1], 22.2 * units.degC, 6)
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
示例#2
0
def test_most_unstable_parcel():
    """Test calculating the most unstable parcel."""
    levels = np.array([1000., 959., 867.9]) * units.mbar
    temperatures = np.array([18.2, 22.2, 17.4]) * units.celsius
    dewpoints = np.array([19., 19., 14.3]) * units.celsius
    ret = most_unstable_parcel(levels, temperatures, dewpoints, depth=100 * units.hPa)
    assert_almost_equal(ret[0], 959.0 * units.hPa, 6)
    assert_almost_equal(ret[1], 22.2 * units.degC, 6)
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
示例#3
0
                              label='LCF')

                    # Calculate EL height and plot as blue dot
                    EL_pressure, EL_temperature = mpcalc.el(p, T, Td, prof_0)
                    skew.plot(EL_pressure,
                              EL_temperature,
                              'bo',
                              markersize=8,
                              fillstyle='none',
                              label='EL')

                    # Calculate most_unstable_parcel
                    mup_pressure, mup_temperature, mup_dewTemperature, mup_index = mpcalc.most_unstable_parcel(
                        p,
                        T,
                        Td,
                        heights=prof_0,
                        bottom=1050 * units.hPa,
                        depth=650 * units.hPa)
                    skew.plot(p[mup_index - 1:mup_index + 1],
                              T[mup_index - 1:mup_index + 1],
                              'b',
                              label='the most unstable level')
                    #skew.plot(p[mup_index-1:mup_index+1], 'b', label='the most unstable parcel')

                    # An example of a slanted line at constant T -- in this case the 0
                    # isotherm
                    skew.ax.axvline(0,
                                    color='brown',
                                    linestyle='-',
                                    linewidth=1,
                              markersize=8,
                              fillstyle='none',
                              label='LCF')

                    # Calculate EL height and plot as blue dot
                    EL_pressure, EL_temperature = mpcalc.el(p, T, Td, prof_0)
                    skew.plot(EL_pressure,
                              EL_temperature,
                              'bo',
                              markersize=8,
                              fillstyle='none',
                              label='EL')

                    # Calculate most unstable parcel
                    mup_pressure, mup_temperature, mup_dewTemperature, mup_index \
                        = mpcalc.most_unstable_parcel(p, T, Td, heights=prof_0, bottom=1050 * units.hPa)
                    skew.plot(p[mup_index - 1:mup_index + 1],
                              T[mup_index - 1:mup_index + 1],
                              'b',
                              label='the most unstable level')

                    # Calculate precipitable water
                    precipitable_water = mpcalc.precipitable_water(Td, p)

                    # An example of a slanted line at constant T -- in this case the 0
                    # isotherm
                    skew.ax.axvline(0,
                                    color='brown',
                                    linestyle='-',
                                    linewidth=1,
                                    label='isothermal')