Пример #1
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') & a.Physobs("summary_lightcurve")))
    drtables = drclient.tables
    assert isinstance(drtables, list)
    assert isinstance(drtables[0], Table)

    # VSO response objects
    vsoclient = Fido.search(a.Time('2011-06-07 06:33', '2011-06-07 06:33:08'),
                            a.Instrument('aia'), a.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)
Пример #2
0
def test_both_physobs():
    params = walker.create(a.Physobs("intensity"))
    assert len(params) == 1
    assert params[0]["hasAllStokes"] is False

    params = walker.create(a.Physobs("stokes_parameters"))
    assert len(params) == 1
    assert params[0]["hasAllStokes"] is True

    params = walker.create(a.Physobs("spectral_axis"))
    assert len(params) == 1
    assert params[0]["hasSpectralAxis"] is True

    params = walker.create(a.Physobs("temporal_axis"))
    assert len(params) == 1
    assert params[0]["hasTemporalAxis"] is True
Пример #3
0
def test_vso_fetch_hmi(tmpdir):
    start_time = "2017-01-25"
    end_time = "2017-01-25T23:59:59"
    results = Fido.search(a.Time(start_time, end_time),
                          a.Instrument('HMI') & a.Physobs("LOS_magnetic_field"),
                          a.Sample(1 * u.minute))

    files = Fido.fetch(results[0, 0], path=tmpdir)
    assert len(files) == 1
Пример #4
0
def fido_search_result():
    # A search query with responses from all instruments
    # No JSOC query
    return Fido.search(
        net_attrs.Time("2012/1/1", "2012/1/2"),
        net_attrs.Instrument('lyra') & net_attrs.Level.two | net_attrs.Instrument('eve') |
        net_attrs.Instrument('XRS') | net_attrs.Instrument('noaa-indices') |
        net_attrs.Instrument('noaa-predict') |
        (net_attrs.Instrument('norh') & net_attrs.Wavelength(17*units.GHz)) |
        (net_attrs.Instrument('rhessi') & net_attrs.Physobs("summary_lightcurve"))
    )
Пример #5
0
def test_tables_multiple_response():
    results = Fido.search(a.Time('2012/3/4', '2012/3/6'),
                           a.Instrument('lyra') | (a.Instrument('rhessi') & a.Physobs("summary_lightcurve")))
    tables = results.tables
    assert isinstance(tables, list)
    assert all(isinstance(t, Table) for t in tables)
    assert len(tables) == 2

    columns = ['Start Time', 'End Time', 'Source', 'Instrument', 'Wavelength']
    assert columns == tables[0].colnames and columns == tables[1].colnames

    assert all(entry == 'lyra' for entry in tables[0]['Instrument'])
    assert all(entry == 'rhessi' for entry in tables[1]['Instrument'])
Пример #6
0
@settings(suppress_health_check=[
    HealthCheck.too_slow, HealthCheck.function_scoped_fixture
])
@given(dst.query_and())
def test_can_handle_query(client, query):
    # Can handle query never gets passed an AttrOr
    # It also never passes an AttrAnd, just the components of it
    if isinstance(query, attr.AttrAnd):
        assert client._can_handle_query(*query.attrs)
    else:
        assert client._can_handle_query(query)


@pytest.mark.parametrize("query", (
    a.Instrument("bob"),
    a.Physobs("who's got the button"),
    a.Level(2),
    (a.Instrument("VBI"), a.Level(0)),
    (a.Instrument("VBI"), a.Detector("test")),
    tuple(),
))
def test_cant_handle_query(client, query):
    """Some examples of invalid queries."""
    assert not client._can_handle_query(query)


@no_vso
@settings(suppress_health_check=[
    HealthCheck.too_slow, HealthCheck.function_scoped_fixture
],
          deadline=None)
Пример #7
0
def test_attr_reg():
    assert a.Instrument.rhessi == a.Instrument('RHESSI')
    assert a.Physobs.summary_lightcurve == a.Physobs("summary_lightcurve")
Пример #8
0
from sunpy.net import attrs as a

######################################################################
# In this example we are going to make a lot of side by side figures, so
# let's change the default figure size.

plt.rcParams['figure.figsize'] = (16, 8)

######################################################################
# We are going to download one AIA and one HMI magnetogram image.

time = (a.Sample(24 * u.hour)
        & a.Time('2010-08-19', '2010-08-19T00:10:00', '2010-08-19')
        & a.vso.Extent(0, 0, 0, 0, "FULLDISK"))
aia = a.Instrument('AIA') & a.Wavelength(17 * u.nm, 18 * u.nm)
hmi = a.Instrument('HMI') & a.Physobs("LOS_magnetic_field")

res = Fido.search(time, aia | hmi)

files = Fido.fetch(res[:, 0])

######################################################################
# We create a map for each image and resample each one just to
# reduce the computation time.

map_aia, map_hmi = [
    m.resample((1024, 1024) * u.pix) for m in sunpy.map.Map(sorted(files))
]
# Why do we have to do this?
map_hmi.plot_settings['cmap'] = "hmimag"
map_hmi.plot_settings['norm'] = plt.Normalize(-2000, 2000)
Пример #9
0
     'https://gong2.nso.edu/oQR/zqs/200609/mrzqs060919/mrzqs060919t1754c2048_320.fits.gz'
     )
])
def test_get_url_for_time_range(GSClient, timerange, url_start, url_end):
    qresponse = GSClient.search(timerange)
    urls = [i['url'] for i in qresponse]
    assert isinstance(urls, list)
    assert urls[0] == url_start
    assert urls[-1] == url_end


@pytest.mark.parametrize(
    "query, result",
    [((a.Time('2020/1/1', '2020/1/2'), a.Instrument('gong')), True),
     ((a.Time('2020/1/1', '2020/1/2'), a.Instrument('goes')), False),
     ((a.Time('2020/1/1', '2020/1/2'), a.Instrument('gong'), a.Physobs('LOS_MAGNETIC_FIELD'),
       a.ExtentType('synoptic')), True),
     ((a.Time('2020/1/1', '2020/1/2'), a.Instrument('gong'),
       a.ExtentType('synoptic')), True),
     ((a.Time('2020/1/1', '2020/1/2'), a.Instrument('gong'),
       a.ExtentType('FULL_DISK')), False)])
def test_can_handle_query(query, result):
    assert gong.GONGClient._can_handle_query(*query) == result


@pytest.mark.remote_data
@pytest.mark.parametrize("time,instrument", [
    (Time('2013/8/27', '2013/8/27'), Instrument('gong')),
    (Time('2020/4/23 17:00', '2020/4/23 21:00'), Instrument('gong')),
])
def test_get(GSClient, time, instrument):
Пример #10
0
        client.search(core_attrs.Time('2019/12/30', '2019/12/31'),
                      core_attrs.Instrument('ovsa'))


@pytest.mark.remote_data
def test_incorrect_content_disposition(client):
    results = client.search(
        core_attrs.Time('2011/1/1 01:00', '2011/1/1 01:02'),
        core_attrs.Instrument('mdi'))
    files = client.fetch(results[0:1])

    assert len(files) == 1
    assert files[0].endswith("mdi_vw_v_9466622_9466622.tar")
    assert "Content" not in files[0]


@pytest.mark.parametrize("query, handle", [
    ((a.Time("2011/01/01", "2011/01/02"), ), True),
    ((a.Physobs("LOS_magnetic_field"), ), False),
    ((
        a.Time("2011/01/01", "2011/01/02"),
        a.vso.Provider("SDAC"),
    ), True),
    ((
        a.jsoc.Series("wibble"),
        a.Physobs("LOS_magnetic_field"),
    ), False),
])
def test_can_handle_query(query, handle):
    assert VSOClient._can_handle_query(*query) is handle