Exemplo n.º 1
0
def test_all_data_single_pressure_iastate():
    """Test Iowa State request for all data at a single pressure level."""
    df = IAStateUpperAir.request_all_data(datetime(1999, 5, 4, 0),
                                          pressure=500)
    idx = df.loc[df.station == 'KDDC'].index[0]

    assert (df['time'][idx] == datetime(1999, 5, 4, 0))
    assert (df['station'][idx] == 'KDDC')

    assert_almost_equal(df['pressure'][idx], 500.0, 2)
    assert_almost_equal(df['height'][idx], 5606.0, 2)
    assert_almost_equal(df['temperature'][idx], -17.2, 2)
    assert_almost_equal(df['dewpoint'][idx], -22.9, 2)
    assert_almost_equal(df['u_wind'][idx], 30.834774, 2)
    assert_almost_equal(df['v_wind'][idx], 35.47135, 2)
    assert_almost_equal(df['speed'][idx], 47.0, 1)
    assert_almost_equal(df['direction'][idx], 221.0, 1)

    assert (df.units['pressure'] == 'hPa')
    assert (df.units['height'] == 'meter')
    assert (df.units['temperature'] == 'degC')
    assert (df.units['dewpoint'] == 'degC')
    assert (df.units['u_wind'] == 'knot')
    assert (df.units['v_wind'] == 'knot')
    assert (df.units['speed'] == 'knot')
    assert (df.units['direction'] == 'degrees')
    assert (df.units['station'] is None)
    assert (df.units['time'] is None)
Exemplo n.º 2
0
def test_iastate():
    """Test that we are properly parsing data from the Iowa State archive."""
    df = IAStateUpperAir.request_data(datetime(1999, 5, 4, 0), 'OUN')

    assert (df['time'][0] == datetime(1999, 5, 4, 0))
    assert (df['station'][0] == 'KOUN')

    assert_almost_equal(df['pressure'][6], 872.7, 2)
    assert_almost_equal(df['height'][6], 1172.0, 2)
    assert_almost_equal(df['temperature'][6], 18.2, 2)
    assert_almost_equal(df['dewpoint'][6], 15.1, 2)
    assert_almost_equal(df['u_wind'][6], 4.631, 2)
    assert_almost_equal(df['v_wind'][6], 37.716, 2)
    assert_almost_equal(df['speed'][6], 38.0, 1)
    assert_almost_equal(df['direction'][6], 187.0, 1)

    assert (df.units['pressure'] == 'hPa')
    assert (df.units['height'] == 'meter')
    assert (df.units['temperature'] == 'degC')
    assert (df.units['dewpoint'] == 'degC')
    assert (df.units['u_wind'] == 'knot')
    assert (df.units['v_wind'] == 'knot')
    assert (df.units['speed'] == 'knot')
    assert (df.units['direction'] == 'degrees')
    assert (df.units['station'] is None)
    assert (df.units['time'] is None)
Exemplo n.º 3
0
def test_high_alt_iastate():
    """Test Iowa State data that starts at pressure less than 925 hPa."""
    df = IAStateUpperAir.request_data(datetime(2010, 12, 9, 12), 'BOI')

    assert (df['time'][0] == datetime(2010, 12, 9, 12))
    assert (df['station'][0] == 'KBOI')

    assert_almost_equal(df['pressure'][0], 919.0, 2)
    assert_almost_equal(df['height'][0], 871.0, 2)
    assert_almost_equal(df['temperature'][0], -0.1, 2)
    assert_almost_equal(df['dewpoint'][0], -0.2, 2)
    assert_almost_equal(df['u_wind'][0], 2.598, 2)
    assert_almost_equal(df['v_wind'][0], 1.500, 2)
    assert_almost_equal(df['speed'][0], 3.0, 1)
    assert_almost_equal(df['direction'][0], 240.0, 1)

    assert (df.units['pressure'] == 'hPa')
    assert (df.units['height'] == 'meter')
    assert (df.units['temperature'] == 'degC')
    assert (df.units['dewpoint'] == 'degC')
    assert (df.units['u_wind'] == 'knot')
    assert (df.units['v_wind'] == 'knot')
    assert (df.units['speed'] == 'knot')
    assert (df.units['direction'] == 'degrees')
    assert (df.units['station'] is None)
    assert (df.units['time'] is None)
Exemplo n.º 4
0
def test_interp():
    """Test the interpolation flag for the IA State retrieval."""
    df = IAStateUpperAir.request_data(datetime(2011, 4, 14, 18),
                                      'OUN',
                                      interp_nans=True)
    assert not df['temperature'].isnull().any()
    assert not df['dewpoint'].isnull().any()
Exemplo n.º 5
0
def test_high_alt_iastate():
    """Test Iowa State data that starts at pressure less than 925 hPa."""
    df = IAStateUpperAir.request_data(datetime(2010, 12, 9, 12), 'BOI')

    assert(df['time'][0] == datetime(2010, 12, 9, 12))
    assert(df['station'][0] == 'KBOI')

    assert_almost_equal(df['pressure'][0], 919.0, 2)
    assert_almost_equal(df['height'][0], 871.0, 2)
    assert_almost_equal(df['temperature'][0], -0.1, 2)
    assert_almost_equal(df['dewpoint'][0], -0.2, 2)
    assert_almost_equal(df['u_wind'][0], 2.598, 2)
    assert_almost_equal(df['v_wind'][0], 1.500, 2)
    assert_almost_equal(df['speed'][0], 3.0, 1)
    assert_almost_equal(df['direction'][0], 240.0, 1)

    assert(df.units['pressure'] == 'hPa')
    assert(df.units['height'] == 'meter')
    assert(df.units['temperature'] == 'degC')
    assert(df.units['dewpoint'] == 'degC')
    assert(df.units['u_wind'] == 'knot')
    assert(df.units['v_wind'] == 'knot')
    assert(df.units['speed'] == 'knot')
    assert(df.units['direction'] == 'degrees')
    assert(df.units['station'] is None)
    assert(df.units['time'] is None)
Exemplo n.º 6
0
def test_all_data_single_pressure_iastate():
    """Test Iowa State request for all data at a single pressure level."""
    df = IAStateUpperAir.request_all_data(datetime(1999, 5, 4, 0), pressure=500)
    idx = df.loc[df.station == 'KDDC'].index[0]

    assert(df['time'][idx] == datetime(1999, 5, 4, 0))
    assert(df['station'][idx] == 'KDDC')

    assert_almost_equal(df['pressure'][idx], 500.0, 2)
    assert_almost_equal(df['height'][idx], 5606.0, 2)
    assert_almost_equal(df['temperature'][idx], -17.2, 2)
    assert_almost_equal(df['dewpoint'][idx], -22.9, 2)
    assert_almost_equal(df['u_wind'][idx], 30.834774, 2)
    assert_almost_equal(df['v_wind'][idx], 35.47135, 2)
    assert_almost_equal(df['speed'][idx], 47.0, 1)
    assert_almost_equal(df['direction'][idx], 221.0, 1)

    assert(df.units['pressure'] == 'hPa')
    assert(df.units['height'] == 'meter')
    assert(df.units['temperature'] == 'degC')
    assert(df.units['dewpoint'] == 'degC')
    assert(df.units['u_wind'] == 'knot')
    assert(df.units['v_wind'] == 'knot')
    assert(df.units['speed'] == 'knot')
    assert(df.units['direction'] == 'degrees')
    assert(df.units['station'] is None)
    assert(df.units['time'] is None)
Exemplo n.º 7
0
def test_iastate():
    """Test that we are properly parsing data from the Iowa State archive."""
    df = IAStateUpperAir.request_data(datetime(1999, 5, 4, 0), 'OUN')

    assert(df['time'][0] == datetime(1999, 5, 4, 0))
    assert(df['station'][0] == 'KOUN')

    assert_almost_equal(df['pressure'][6], 872.7, 2)
    assert_almost_equal(df['height'][6], 1172.0, 2)
    assert_almost_equal(df['temperature'][6], 18.2, 2)
    assert_almost_equal(df['dewpoint'][6], 15.1, 2)
    assert_almost_equal(df['u_wind'][6], 4.631, 2)
    assert_almost_equal(df['v_wind'][6], 37.716, 2)
    assert_almost_equal(df['speed'][6], 38.0, 1)
    assert_almost_equal(df['direction'][6], 187.0, 1)

    assert(df.units['pressure'] == 'hPa')
    assert(df.units['height'] == 'meter')
    assert(df.units['temperature'] == 'degC')
    assert(df.units['dewpoint'] == 'degC')
    assert(df.units['u_wind'] == 'knot')
    assert(df.units['v_wind'] == 'knot')
    assert(df.units['speed'] == 'knot')
    assert(df.units['direction'] == 'degrees')
    assert(df.units['station'] is None)
    assert(df.units['time'] is None)
Exemplo n.º 8
0
def test_all_data_all_levels_iastate():
    """Test Iowa State request for all data at all levels."""
    df = IAStateUpperAir.request_all_data(datetime(1999, 5, 4, 0))
    idx = df.loc[df.station == 'KDDC'].index[12]

    assert(df['time'][idx] == datetime(1999, 5, 4, 0))
    assert(df['station'][idx] == 'KDDC')

    assert_almost_equal(df['pressure'][idx], 700.0, 2)
    assert_almost_equal(df['height'][idx], 2969.0, 2)
    assert_almost_equal(df['temperature'][idx], 5.8, 2)
    assert_almost_equal(df['dewpoint'][idx], -11.7, 2)
    assert_almost_equal(df['u_wind'][idx], 33.234, 2)
    assert_almost_equal(df['v_wind'][idx], 33.234, 2)
    assert_almost_equal(df['speed'][idx], 47.0, 1)
    assert_almost_equal(df['direction'][idx], 225.0, 1)

    assert(df.units['pressure'] == 'hPa')
    assert(df.units['height'] == 'meter')
    assert(df.units['temperature'] == 'degC')
    assert(df.units['dewpoint'] == 'degC')
    assert(df.units['u_wind'] == 'knot')
    assert(df.units['v_wind'] == 'knot')
    assert(df.units['speed'] == 'knot')
    assert(df.units['direction'] == 'degrees')
    assert(df.units['station'] is None)
    assert(df.units['time'] is None)
Exemplo n.º 9
0
def test_all_data_all_levels_iastate():
    """Test Iowa State request for all data at all levels."""
    df = IAStateUpperAir.request_all_data(datetime(1999, 5, 4, 0))
    idx = df.loc[df.station == 'KDDC'].index[12]

    assert (df['time'][idx] == datetime(1999, 5, 4, 0))
    assert (df['station'][idx] == 'KDDC')

    assert_almost_equal(df['pressure'][idx], 700.0, 2)
    assert_almost_equal(df['height'][idx], 2969.0, 2)
    assert_almost_equal(df['temperature'][idx], 5.8, 2)
    assert_almost_equal(df['dewpoint'][idx], -11.7, 2)
    assert_almost_equal(df['u_wind'][idx], 33.234, 2)
    assert_almost_equal(df['v_wind'][idx], 33.234, 2)
    assert_almost_equal(df['speed'][idx], 47.0, 1)
    assert_almost_equal(df['direction'][idx], 225.0, 1)

    assert (df.units['pressure'] == 'hPa')
    assert (df.units['height'] == 'meter')
    assert (df.units['temperature'] == 'degC')
    assert (df.units['dewpoint'] == 'degC')
    assert (df.units['u_wind'] == 'knot')
    assert (df.units['v_wind'] == 'knot')
    assert (df.units['speed'] == 'knot')
    assert (df.units['direction'] == 'degrees')
    assert (df.units['station'] is None)
    assert (df.units['time'] is None)
Exemplo n.º 10
0
def read_upper_air_iastate(date):
    try:
        data = IAStateUpperAir().request_all_data(date)
    except ValueError:
        #print("ERROR: no data available for ",date)
        #print("     Trying previous synoptic time")
        return None
        #date = date - timedelta(hours = 12)
        #data = IAStateUpperAir().request_all_data(date)
    data = add_station_lat_lon(data)

    return data
Exemplo n.º 11
0
def test_no_future_data_iastate():
    """Test Iowa State data when future data are requested."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_data(datetime(2999, 12, 9, 12), 'BOI')
Exemplo n.º 12
0
def test_no_data_iastate():
    """Test Iowa State data when no data are available."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_data(datetime(2010, 12, 9, 1), 'BOI')
Exemplo n.º 13
0
def test_no_future_data_with_pressure_iastate():
    """Test Iowa State data when future data are requested with the pressure argument."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_all_data(datetime(2999, 12, 9, 12),
                                         pressure=850.)
Exemplo n.º 14
0
def test_no_future_data_iastate():
    """Test Iowa State data when future data are requested."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_data(datetime(2999, 12, 9, 12), 'BOI')
Exemplo n.º 15
0
def test_no_data_iastate():
    """Test Iowa State data when no data are available."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_data(datetime(2010, 12, 9, 1), 'BOI')
Exemplo n.º 16
0
def test_no_future_data_with_pressure_iastate():
    """Test Iowa State data when future data are requested with the pressure argument."""
    with pytest.raises(ValueError):
        IAStateUpperAir.request_all_data(datetime(2999, 12, 9, 12), pressure=850.)
Exemplo n.º 17
0
# Set a date and time for upper-air observations (should only be 00 or 12
# UTC for the hour).
#
# Request all data from Iowa State using the Siphon package. The result is
# a pandas DataFrame containing all of the sounding data from all
# available stations.
#

# Set date for desired UPA data
today = datetime.utcnow()

# Go back one day to ensure data availability
date = datetime(today.year, today.month, today.day, 0) - timedelta(days=1)

# Request data using Siphon request for data from Iowa State Archive
data = IAStateUpperAir.request_all_data(date)

######################################################################
# Subset Observational Data
# -------------------------
#
# From the request above will give all levels from all radisonde sites
# available through the service. For plotting a pressure surface map there
# is only need to have the data from that level. Below the data is subset
# and a few parameters set based on the level chosen. Additionally, the
# station information is obtained and latitude and longitude data is added
# to the DataFrame.
#

level = 500
# Import the Iowa state simple web service upper air object
from siphon.simplewebservice.iastate import IAStateUpperAir

# Create the datetime and station variables you'll need
request_time = datetime(2011, 4, 14, 18)
station = 'OUN'

# Make the request for the data
df = IAStateUpperAir.request_data(request_time, station)

# Attach units to the data
sounding = pandas_dataframe_to_unit_arrays(df)