Beispiel #1
0
def run_msis(dates, lons, lats, alts, f107s, f107as, aps, options):
    """Call MSIS looping over all possible inputs.

    Parameters
    ----------
    dates : list of dates
        Date and time to calculate the output at.
    lons : list of floats
        Longitudes to calculate the output at.
    lats : list of floats
        Latitudes to calculate the output at.
    alts : list of floats
        Altitudes to calculate the output at.
    f107s : list of floats
        F107 value for the given date(s).
    f107as : list of floats
        F107 running 100-day average for the given date(s).
    aps : list of floats
        Ap for the given date(s).
    options : list of floats (length 25)
        A list of options (switches) to the model
    """
    # 11 == 10 densities + 1 temperature
    # Output density: He, O, N2, O2, Ar, Total (gm/cm3), H, N, Anomalous O
    # Output temp: exospheric, specific altitude

    _, input_data = msis.create_input(dates, lons, lats, alts, f107s, f107as,
                                      aps)

    output = msis.run(dates, lons, lats, alts, f107s, f107as, aps, options)

    # Force to float, JSON serializer in future calls does not work
    # with float32 output
    # Return the altitutdes, latitudes, longitudes with the data
    return (input_data[:, 2:5], output.reshape(-1, 11).astype(np.float))
Beispiel #2
0
def test_create_input_multi_date(input_data, expected_input):
    date, lon, lat, alt, f107, f107a, ap = input_data
    # Repeat 5 dates
    input_data = ([date] * 5, lon, lat, alt, [f107] * 5, [f107a] * 5, ap * 5)
    shape, data = msis.create_input(*input_data)
    assert shape == (5, 1, 1, 1)
    assert data.shape == (5, 14)
    assert_array_equal(data, [expected_input] * 5)
Beispiel #3
0
def test_create_input_datetime(input_data, expected_input):
    # Test with datetime, not just np.datetime64s
    # .item() gets the datetime object from the np.datetime64 object
    input_data = (input_data[0].item(), ) + input_data[1:]
    shape, data = msis.create_input(*input_data)
    assert shape == (1, )
    assert data.shape == (1, 14)
    assert_array_equal(data[0, :], expected_input)
Beispiel #4
0
def test_create_input_multi_lon_lat(input_data, expected_input):
    date, lon, lat, alt, f107, f107a, ap = input_data
    # Repeat 5 dates
    input_data = (date, [lon] * 5, [lat] * 5, alt, f107, f107a, ap)
    shape, data = msis.create_input(*input_data)
    assert shape == (1, 5, 5, 1)
    assert data.shape == (5 * 5, 14)
    assert_array_equal(data, [expected_input] * 5 * 5)
Beispiel #5
0
def test_create_input_f107__date_mismatch(input_data):
    # Make sure we raise when f107 and dates are different shapes
    # Repeat 5 dates, but not f107
    input_data = ([input_data[0]] * 5, ) + input_data[1:]
    with pytest.raises(ValueError, match='The length of dates'):
        msis.create_input(*input_data)
Beispiel #6
0
def test_create_input_single_point(input_data, expected_input):
    shape, data = msis.create_input(*input_data)
    assert shape == (1, )
    assert data.shape == (1, 14)
    assert_array_equal(data[0, :], expected_input)