示例#1
0
def test_calculate_radiative_loss_rate():
    # Define input variables.
    goeslc_input = timeseries.TimeSeries(get_test_filepath("go1520110607.fits"))
    not_goeslc = []
    goeslc_no_em = goes.calculate_temperature_em(goeslc_input)
    del goeslc_no_em.data["em"]

    # Check correct exceptions are raised to incorrect inputs
    with pytest.raises(TypeError):
        goes_test = goes.calculate_radiative_loss_rate(not_goeslc)

    # Check function gives correct results.
    # Test case 1: GOESLightCurve object with only flux data
    goeslc_test = goes.calculate_radiative_loss_rate(goeslc_input)
    exp_data = np.array([1.78100055e+19, 1.66003113e+19, 1.71993065e+19,
                         1.60171768e+19, 1.71993065e+19])
    np.testing.assert_allclose(goeslc_test.data.rad_loss_rate[:5],
                               exp_data)

    # Test case 2: GOESLightCurve object with flux and temperature
    # data, but no EM data.
    goes_test = goes.calculate_radiative_loss_rate(goeslc_no_em)
    # we test that the column has been added
    assert "rad_loss_rate" in goes_test.columns
    # Compare every 50th value to save on filesize
    return np.array(goes_test.data[::50])
示例#2
0
def test_calculate_radiative_loss_rate():
    # Define input variables.
    goeslc_input = lightcurve.GOESLightCurve.create("2014-01-01 00:00:00",
                                                    "2014-01-01 00:00:10")
    not_goeslc = []
    goeslc_no_em = goes.calculate_temperature_em(goeslc_input)
    del goeslc_no_em.data["em"]

    # Check correct exceptions are raised to incorrect inputs
    with pytest.raises(TypeError):
        goes_test = goes.calculate_radiative_loss_rate(not_goeslc)

    # Check function gives correct results.
    # Test case 1: GOESLightCurve object with only flux data
    goeslc_test = goes.calculate_radiative_loss_rate(goeslc_input)
    goeslc_expected = goes.calculate_temperature_em(goeslc_input)
    goeslc_expected.data["rad_loss_rate"] = \
      np.array([5.44914366e+19, 5.44914366e+19, 5.43465905e+19,
                5.38282295e+19, 5.42019309e+19])
    assert_frame_equal(goeslc_test.data, goeslc_expected.data)

    # Test case 2: GOESLightCurve object with flux and temperature
    # data, but no EM data.
    goes_test = goes.calculate_radiative_loss_rate(goeslc_no_em)
    assert_frame_equal(goeslc_test.data, goeslc_expected.data)
示例#3
0
def test_calculate_radiative_loss_rate():
    # Define input variables.
    goeslc_input = lightcurve.GOESLightCurve.create("2014-01-01 00:00:00",
                                            "2014-01-01 00:00:10")
    not_goeslc = []
    goeslc_no_em = goes.calculate_temperature_em(goeslc_input)
    del goeslc_no_em.data["em"]
    
    # Check correct exceptions are raised to incorrect inputs
    with pytest.raises(TypeError):
        goes_test = goes.calculate_radiative_loss_rate(not_goeslc)

    # Check function gives correct results.
    # Test case 1: GOESLightCurve object with only flux data
    goeslc_test = goes.calculate_radiative_loss_rate(goeslc_input)
    goeslc_expected = goes.calculate_temperature_em(goeslc_input)
    goeslc_expected.data["rad_loss_rate"] = \
      np.array([5.44914366e+19, 5.44914366e+19, 5.43465905e+19,
                5.38282295e+19, 5.42019309e+19])
    assert_frame_equal(goeslc_test.data, goeslc_expected.data)

    # Test case 2: GOESLightCurve object with flux and temperature
    # data, but no EM data.
    goes_test = goes.calculate_radiative_loss_rate(goeslc_no_em)
    assert_frame_equal(goeslc_test.data, goeslc_expected.data)