Example #1
0
def test_wave_inputQuantity():
    wrong_type_mesage = "Wave inputs must be astropy Quantities"
    with pytest.raises(TypeError) as excinfo:
        va.Wavelength(10, 23)
        assert excinfo.value.message == wrong_type_mesage
    with pytest.raises(TypeError) as excinfo:
        va.Wavelength(10 * u.AA, 23)
        assert excinfo.value.message == wrong_type_mesage
Example #2
0
def product_search(base, time_range, date_time_start):
    if 'EIT' in base:
        wavelen = int(base[3:6])
        product_results = Fido.search(
            avso.Time(time_range, date_time_start), avso.Source('SOHO'),
            avso.Instrument('EIT'), avso.Provider('SDAC'),
            avso.Wavelength(wavelen * avso.u.Angstrom,
                            wavelen * avso.u.Angstrom))

    elif 'MDI' in base:
        product_results = Fido.search(avso.Time(time_range, date_time_start),
                                      avso.Source('SOHO'),
                                      avso.Instrument('MDI'),
                                      avso.Provider('SDAC'),
                                      avso.Physobs('LOS_MAGNETIC_FIELD'))

    elif 'LASCO' in base:
        detector = base.split('_')[1]
        product_results = Fido.search(avso.Time(time_range, date_time_start),
                                      avso.Provider('SDAC'),
                                      avso.Source('SOHO'),
                                      avso.Instrument('LASCO'),
                                      avso.Detector(detector))

    return product_results
Example #3
0
def test_wave_toangstrom():
    # TODO: this test should test that inputs are in any of spectral units
    # more than just converted to Angstroms.
    frequency = [(1, 1 * u.Hz), (1e3, 1 * u.kHz), (1e6, 1 * u.MHz),
                 (1e9, 1 * u.GHz)]

    energy = [(1, 1 * u.eV), (1e3, 1 * u.keV), (1e6, 1 * u.MeV)]

    for factor, unit in energy:
        w = va.Wavelength((62 / factor) * unit, (62 / factor) * unit)
        assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199

    w = va.Wavelength(62 * u.eV, 62 * u.eV)
    assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199
    w = va.Wavelength(62e-3 * u.keV, 62e-3 * u.keV)
    assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199

    for factor, unit in frequency:
        w = va.Wavelength((1.506e16 / factor) * unit,
                          (1.506e16 / factor) * unit)
        assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199

    w = va.Wavelength(1.506e16 * u.Hz, 1.506e16 * u.Hz)
    assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199
    w = va.Wavelength(1.506e7 * u.GHz, 1.506e7 * u.GHz)
    assert int(w.min.to(u.AA, u.equivalencies.spectral()).value) == 199

    with pytest.raises(u.UnitsError) as excinfo:
        va.Wavelength(10 * u.g, 23 * u.g)
    assert (
        'This unit is not convertable to any of [Unit("Angstrom"), Unit("kHz"), '
        'Unit("keV")]' in str(excinfo.value))
Example #4
0
def test_wave_xor():
    one = va.Wavelength(0 * u.AA, 1000 * u.AA)
    a = one ^ va.Wavelength(200 * u.AA, 400 * u.AA)

    assert a == attr.AttrOr([va.Wavelength(0 * u.AA, 200 * u.AA),
                             va.Wavelength(400 * u.AA, 1000 * u.AA)])

    a ^= va.Wavelength(600 * u.AA, 800 * u.AA)

    assert a == attr.AttrOr(
        [va.Wavelength(0 * u.AA, 200 * u.AA), va.Wavelength(400 * u.AA, 600 * u.AA),
         va.Wavelength(800 * u.AA, 1000 * u.AA)])
Example #5
0
def test_path(client, tmpdir):
    """
    Test that '{file}' is automatically appended to the end of a custom path if
    it is not specified.
    """
    qr = client.search(va.Time('2011-06-07 06:33', '2011-06-07 06:33:08'),
                       va.Instrument('aia'), va.Wavelength(171 * u.AA))
    tmp_dir = tmpdir / "{file}"
    files = client.fetch(qr, path=tmp_dir)

    assert len(files) == 1

    # The construction of a VSO filename is bonkers complex, so there is no
    # practical way to determine what it should be in this test, so we just
    # put it here.
    assert "aia_lev1_171a_2011_06_07t06_33_02_77z_image_lev1.fits" in files[0]
Example #6
0
def test_tables_all_types():
    # Data retriver response objects
    drclient = Fido.search(a.Time('2012/3/4', '2012/3/6'),
                           a.Instrument('lyra') | a.Instrument('rhessi'))
    drtables = drclient.tables
    assert isinstance(drtables, list)
    assert isinstance(drtables[0], Table)

    # VSO response objects
    vsoclient = Fido.search(va.Time('2011-06-07 06:33', '2011-06-07 06:33:08'),
                            va.Instrument('aia'), va.Wavelength(171 * u.AA))
    vsotables = vsoclient.tables
    assert isinstance(vsotables, list)
    assert isinstance(vsotables[0], Table)

    # JSOC response objects
    jsocclient = Fido.search(
        a.Time('2014-01-01T00:00:00', '2014-01-01T01:00:00'),
        a.jsoc.Series('hmi.v_45s'), a.jsoc.Notify('*****@*****.**'))
    jsoctables = jsocclient.tables

    assert isinstance(jsoctables, list)
    assert isinstance(jsoctables[0], Table)