示例#1
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)
示例#2
0
def test_calculate_temperature_em():
    # Create GOESLightcurve object, then create new one with
    # temperature & EM using with calculate_temperature_em().
    goeslc = lightcurve.GOESLightCurve.create("2014-01-01 00:00",
                                              "2014-01-01 01:00")
    goeslc_new = goes.calculate_temperature_em(goeslc)
    # Test correct exception is raised if a GOESLightCurve object is
    # not inputted.
    with pytest.raises(TypeError):
        goes.calculate_temperature_em([])
    # Find temperature and EM manually with _goes_chianti_tem()
    temp, em = goes._goes_chianti_tem(
        Quantity(goeslc.data.xrsb, unit='W/m**2'),
        Quantity(goeslc.data.xrsa, unit='W/m**2'),
        satellite=int(goeslc.meta["TELESCOP"].split()[1]),
        date="2014-01-01")
    # Check that temperature and EM arrays from _goes_chianti_tem()
    # are same as those in new GOESLightcurve object.
    assert goeslc_new.data.temperature.all() == temp.value.all()
    assert goeslc_new.data.em.all() == em.value.all()
    # Check rest of data frame of new GOESLightCurve object is same
    # as that in original object.
    goeslc_revert = copy.deepcopy(goeslc_new)
    del goeslc_revert.data["temperature"]
    del goeslc_revert.data["em"]
    assert_frame_equal(goeslc_revert.data, goeslc.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)
示例#4
0
def test_calculate_temperature_em():
    # Create XRSTimeSeries object, then create new one with
    # temperature & EM using with calculate_temperature_em().
    goeslc = timeseries.TimeSeries(get_test_filepath("go1520110607.fits"))
    goeslc_new = goes.calculate_temperature_em(goeslc)
    # Test correct exception is raised if a XRSTimeSeries object is
    # not inputted.
    with pytest.raises(TypeError):
        goes.calculate_temperature_em([])
    # Find temperature and EM manually with _goes_chianti_tem()
    temp, em = goes._goes_chianti_tem(
        goeslc.quantity("xrsb"),
        goeslc.quantity("xrsa"),
        satellite=int(goeslc.meta.metas[0]["TELESCOP"].split()[1]),
        date="2014-01-01")
    # Check that temperature and EM arrays from _goes_chianti_tem()
    # are same as those in new XRSTimeSeries object.
    assert goeslc_new.data.temperature.all() == temp.value.all()
    assert goeslc_new.data.em.all() == em.value.all()
    # Check rest of data frame of new XRSTimeSeries object is same
    # as that in original object.
    goeslc_revert = copy.deepcopy(goeslc_new)
    del goeslc_revert.data["temperature"]
    del goeslc_revert.data["em"]
    assert_frame_equal(goeslc_revert.data, goeslc.data)
示例#5
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])
示例#6
0
def test_calculate_temperature_em():
    # Create XRSTimeSeries object, then create new one with
    # temperature & EM using with calculate_temperature_em().
    goeslc = timeseries.TimeSeries(get_test_filepath("go1520110607.fits"))
    goeslc_new = goes.calculate_temperature_em(goeslc)
    # Test correct exception is raised if a XRSTimeSeries object is
    # not inputted.
    with pytest.raises(TypeError):
        goes.calculate_temperature_em([])
    # Find temperature and EM manually with _goes_chianti_tem()
    temp, em = goes._goes_chianti_tem(
        goeslc.quantity("xrsb"),
        goeslc.quantity("xrsa"),
        satellite=int(goeslc.meta.metas[0]["TELESCOP"].split()[1]), date="2014-01-01")
    # Check that temperature and EM arrays from _goes_chianti_tem()
    # are same as those in new XRSTimeSeries object.
    assert goeslc_new.data.temperature.all() == temp.value.all()
    assert goeslc_new.data.em.all() == em.value.all()
    # Check rest of data frame of new XRSTimeSeries object is same
    # as that in original object.
    goeslc_revert = copy.deepcopy(goeslc_new)
    del goeslc_revert.data["temperature"]
    del goeslc_revert.data["em"]
    assert_frame_equal(goeslc_revert.data, goeslc.data)
示例#7
0
def test_calculate_temperature_em():
    # Create GOESLightcurve object, then create new one with
    # temperature & EM using with calculate_temperature_em().
    goeslc = lightcurve.GOESLightCurve.create("2014-01-01 00:00", "2014-01-01 01:00")
    goeslc_new = goes.calculate_temperature_em(goeslc)
    # Test correct exception is raised if a GOESLightCurve object is
    # not inputted.
    with pytest.raises(TypeError):
        goes.calculate_temperature_em([])
    # Find temperature and EM manually with _goes_chianti_tem()
    temp, em = goes._goes_chianti_tem(
        Quantity(goeslc.data.xrsb, unit='W/m**2'),
        Quantity(goeslc.data.xrsa, unit='W/m**2'),
        satellite=int(goeslc.meta["TELESCOP"].split()[1]), date="2014-01-01")
    # Check that temperature and EM arrays from _goes_chianti_tem()
    # are same as those in new GOESLightcurve object.
    assert goeslc_new.data.temperature.all() == temp.value.all()
    assert goeslc_new.data.em.all() == em.value.all()
    # Check rest of data frame of new GOESLightCurve object is same
    # as that in original object.
    goeslc_revert = copy.deepcopy(goeslc_new)
    del goeslc_revert.data["temperature"]
    del goeslc_revert.data["em"]
    assert_frame_equal(goeslc_revert.data, goeslc.data)