コード例 #1
0
ファイル: test_fido.py プロジェクト: yashrsharma44/sunpy
def offline_query(draw, instrument=offline_instruments()):
    """
    Strategy for any valid offline query
    """
    query = draw(instrument)
    # If we have AttrAnd then we don't have GOES
    if isinstance(query, a.Instrument) and query.value == 'goes':
        query &= draw(goes_time())
    else:
        query = attr.and_(query, draw(time_attr()))
    return query
コード例 #2
0
ファイル: test_fido.py プロジェクト: Cadair/sunpy
def offline_query(draw, instrument=offline_instruments()):
    """
    Strategy for any valid offline query
    """
    query = draw(instrument)
    # If we have AttrAnd then we don't have GOES
    if isinstance(query, a.Instrument) and query.value == 'goes':
        query &= draw(goes_time())
    else:
        query = attr.and_(query, draw(time_attr()))
    return query
コード例 #3
0
ファイル: test_fido.py プロジェクト: DEVANSH99/sunpy
def online_query(draw, instrument=online_instruments(), time=time_attr()):
    query = draw(instrument)
    # If we have AttrAnd then we don't have RHESSI
    if isinstance(query, a.Instrument) and query.value == 'rhessi':
        # Build a time attr which does not span a month.
        year = draw(st.integers(min_value=2003, max_value=2017))
        month = draw(st.integers(min_value=1, max_value=12))
        days = draw(st.integers(min_value=1, max_value=28))
        query = query & a.Time("{}-{}-01".format(year, month, days),
                               "{}-{}-{}".format(year, month, days))
    return query
コード例 #4
0
ファイル: test_fido.py プロジェクト: bwgref/sunpy
def online_query(draw, instrument=online_instruments(), time=time_attr()):
    query = draw(instrument)
    # If we have AttrAnd then we don't have RHESSI
    if isinstance(query, a.Instrument) and query.value == 'rhessi':
        # Build a time attr which does not span a month.
        year = draw(st.integers(min_value=2003, max_value=2017))
        month = draw(st.integers(min_value=1, max_value=12))
        days = draw(st.integers(min_value=1, max_value=28))
        query = query & a.Time("{}-{}-01".format(year, month, days),
                               "{}-{}-{}".format(year, month, days))
    return query
コード例 #5
0
ファイル: test_eve.py プロジェクト: Hypnus1803/sunpy
@pytest.mark.online
@pytest.mark.parametrize(
    'query',
    [(a.Time('2012/10/4', '2012/10/6') & a.Instrument('eve') & a.Level(0))])
def test_fido(query):
    qr = Fido.search(query)
    client = qr.get_response(0).client
    assert isinstance(qr, UnifiedResponse)
    assert isinstance(client, eve.EVEClient)
    response = Fido.fetch(qr)
    assert len(response) == qr._numfile


@pytest.mark.online
@given(time_attr(time=datetimes(timezones=[], max_year=datetime.datetime.utcnow().year, min_year=2010)))
@settings(max_examples=2, timeout=240)
def test_levels(time):
    """
    Test the correct handling of level 0 / 1.
    The default should be level 1 from VSO, level 0 comes from EVEClient.
    """
    eve_a = a.Instrument('EVE')
    qr = Fido.search(time, eve_a)
    client = qr.get_response(0).client
    assert isinstance(client, VSOClient)

    qr = Fido.search(time, eve_a, a.Level(0))
    client = qr.get_response(0).client
    assert isinstance(client, eve.EVEClient)
コード例 #6
0
ファイル: test_goes_suvi.py プロジェクト: thilak007/sunpy
import astropy.units as u

import sunpy.net.dataretriever.sources.goes as goes
from sunpy.net import Fido
from sunpy.net import attrs as a
from sunpy.net.dataretriever.client import QueryResponse
from sunpy.net.tests.strategies import time_attr
from sunpy.time import TimeRange, parse_time


@pytest.fixture
def suvi_client():
    return goes.SUVIClient()


@given(time_attr())
def test_can_handle_query(suvi_client, time):
    ans1 = suvi_client._can_handle_query(time, a.Instrument.suvi)
    assert ans1 is True
    ans2 = suvi_client._can_handle_query(time, a.Instrument.suvi,
                                         a.Wavelength(131 * u.Angstrom))
    assert ans2 is True
    ans3 = suvi_client._can_handle_query(time, a.Instrument.suvi,
                                         a.Wavelength(131 * u.Angstrom),
                                         a.Level.two)
    assert ans3 is True
    ans4 = suvi_client._can_handle_query(time)
    assert ans4 is False
    ans5 = suvi_client._can_handle_query(time, a.Instrument.aia)
    assert ans5 is False
    ans6 = suvi_client._can_handle_query(time, a.Instrument.suvi,
コード例 #7
0
ファイル: test_fermi_gbm.py プロジェクト: Cadair/sunpy
                          'current/glg_cspec_n5_110607_v00.pha',
                          'https://heasarc.gsfc.nasa.gov/FTP/fermi/data/gbm/daily/2011/06/09/'
                          'current/glg_cspec_n5_110609_v00.pha'),
                          (TimeRange('2016/09/09', '2016/09/11'),
                          'https://heasarc.gsfc.nasa.gov/FTP/fermi/data/gbm/daily/2016/09/09/'
                          'current/glg_cspec_n5_160909_v00.pha',
                          'https://heasarc.gsfc.nasa.gov/FTP/fermi/data/gbm/daily/'
                          '2016/09/11/current/glg_cspec_n5_160911_v00.pha')])
def test_get_url_for_time_range(timerange, url_start, url_end):
    urls = LCClient._get_url_for_timerange(timerange, detector='n5', resolution='cspec')
    assert isinstance(urls, list)
    assert urls[0] == url_start
    assert urls[-1] == url_end


@given(time_attr())
def test_can_handle_query(time):
    ans1 = LCClient._can_handle_query(time, a.Instrument('gbm'))
    assert ans1 is True
    ans2 = LCClient._can_handle_query(time, a.Instrument('gbm'),
                                      a.Detector('n5'))
    assert ans2 is True
    ans3 = LCClient._can_handle_query(time, a.Instrument('gbm'),
                                      a.Detector('n5'), a.Resolution('ctime'))
    assert ans3 is True
    ans4 = LCClient._can_handle_query(time)
    assert ans4 is False


@pytest.mark.remote_data
@pytest.mark.parametrize("time,instrument", [
コード例 #8
0
    'query',
    [(a.Time('2012/10/4', '2012/10/6') & a.Instrument('eve') & a.Level(0))])
def test_fido(query):
    qr = Fido.search(query)
    client = qr.get_response(0).client
    assert isinstance(qr, UnifiedResponse)
    assert isinstance(client, eve.EVEClient)
    response = Fido.fetch(qr)
    assert len(response) == qr._numfile


@pytest.mark.remote_data
@given(
    time_attr(time=Times(
        max_value=datetime.datetime(datetime.datetime.utcnow().year, 1, 1, 0,
                                    0),
        min_value=datetime.datetime(2010, 1, 1, 0, 0),
    )))
@settings(max_examples=2, timeout=240)
def test_levels(time):
    """
    Test the correct handling of level 0 / 1.
    The default should be level 1 from VSO, level 0 comes from EVEClient.
    """
    eve_a = a.Instrument('EVE')
    qr = Fido.search(time, eve_a)
    client = qr.get_response(0).client
    assert isinstance(client, VSOClient)

    qr = Fido.search(time, eve_a, a.Level(0))
    client = qr.get_response(0).client
コード例 #9
0
                 time=Times(max_value=datetime.datetime(
                     datetime.datetime.utcnow().year, 1, 1, 0, 0),
                            min_value=datetime.datetime(1981, 1, 1, 0, 0)),
                 delta=TimeDelta()):
    t1 = draw(time)
    t2 = t1 + draw(delta)

    assume(t2 < Time.now())

    return a.dkist.EmbargoEndTime(t1, t2)


for attr_type in DKISTDatasetClient.register_values():
    st.register_type_strategy(attr_type, _generate_from_register_values)

st.register_type_strategy(a.Time, time_attr())
st.register_type_strategy(a.Wavelength, _unit_range)
st.register_type_strategy(a.dkist.SpectralSampling, _unit_range)
st.register_type_strategy(a.dkist.TemporalSampling, _unit_range)
st.register_type_strategy(a.dkist.SpatialSampling, _unit_range)
st.register_type_strategy(a.dkist.BrowseMovie, _browse_movie())
st.register_type_strategy(a.dkist.FriedParameter, _unit_range)
st.register_type_strategy(a.dkist.PolarimetricAccuracy, _unit_range)
st.register_type_strategy(a.dkist.ExposureTime, _unit_range)
st.register_type_strategy(a.dkist.EmbargoEndTime, _embargo_end())


@settings(suppress_health_check=[HealthCheck.too_slow])
@st.composite
def query_and(draw,
              stattrs=st.lists(st.sampled_from(_supported_attr_types()),
コード例 #10
0
ファイル: test_eve.py プロジェクト: DanRyanIrish/sunpy
@pytest.mark.remote_data
@pytest.mark.parametrize(
    'query',
    [(a.Time('2012/10/4', '2012/10/6') & a.Instrument('eve') & a.Level(0))])
def test_fido(query):
    qr = Fido.search(query)
    client = qr.get_response(0).client
    assert isinstance(qr, UnifiedResponse)
    assert isinstance(client, eve.EVEClient)
    response = Fido.fetch(qr)
    assert len(response) == qr._numfile


@pytest.mark.remote_data
@given(time_attr(time=datetimes(
    max_value=datetime.datetime(datetime.datetime.utcnow().year, 1, 1, 0, 0),
    min_value=datetime.datetime(2010, 1, 1, 0, 0),
)))
@settings(max_examples=2, timeout=240)
def test_levels(time):
    """
    Test the correct handling of level 0 / 1.
    The default should be level 1 from VSO, level 0 comes from EVEClient.
    """
    eve_a = a.Instrument('EVE')
    qr = Fido.search(time, eve_a)
    client = qr.get_response(0).client
    assert isinstance(client, VSOClient)

    qr = Fido.search(time, eve_a, a.Level(0))
    client = qr.get_response(0).client
    assert isinstance(client, eve.EVEClient)
コード例 #11
0
@pytest.mark.remote_data
@pytest.mark.parametrize(
    'query',
    [(a.Time('2012/10/4', '2012/10/6') & a.Instrument('eve') & a.Level(0))])
def test_fido(query):
    qr = Fido.search(query)
    client = qr.get_response(0).client
    assert isinstance(qr, UnifiedResponse)
    assert isinstance(client, eve.EVEClient)
    response = Fido.fetch(qr)
    assert len(response) == qr._numfile


@pytest.mark.remote_data
@given(
    time_attr(time=datetimes(
        timezones=[], max_year=datetime.datetime.utcnow().year, min_year=2010))
)
@settings(max_examples=2, timeout=240)
def test_levels(time):
    """
    Test the correct handling of level 0 / 1.
    The default should be level 1 from VSO, level 0 comes from EVEClient.
    """
    eve_a = a.Instrument('EVE')
    qr = Fido.search(time, eve_a)
    client = qr.get_response(0).client
    assert isinstance(client, VSOClient)

    qr = Fido.search(time, eve_a, a.Level(0))
    client = qr.get_response(0).client
    assert isinstance(client, eve.EVEClient)