• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python net.Fido类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sunpy.net.Fido的典型用法代码示例。如果您正苦于以下问题:Python Fido类的具体用法?Python Fido怎么用?Python Fido使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Fido类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_fido

def test_fido(mock_fetch):
    qr = Fido.search(a.Time("2012/10/4", "2012/10/6"),
                     a.Instrument('noaa-indices'))
    assert isinstance(qr, UnifiedResponse)

    response = Fido.fetch(qr)
    assert len(response) == qr._numfile
开发者ID:drewleonard42,项目名称:sunpy,代码行数:7,代码来源:test_noaa.py


示例2: test_no_wait_fetch

def test_no_wait_fetch():
        qr = Fido.search(a.Instrument('EVE'),
                         a.Time("2016/10/01", "2016/10/02"),
                         a.Level(0))
        res = Fido.fetch(qr, wait=False)
        assert isinstance(res, DownloadResponse)
        assert isinstance(res.wait(), list)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:7,代码来源:test_fido.py


示例3: test_client_fetch_wrong_type

def test_client_fetch_wrong_type(mock_fetch):
    query = a.Time("2011/01/01", "2011/01/02") & a.Instrument("goes")

    qr = Fido.search(query)

    with pytest.raises(TypeError):
        Fido.fetch(qr)
开发者ID:Cadair,项目名称:sunpy,代码行数:7,代码来源:test_fido.py


示例4: test_fido

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
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:7,代码来源:test_eve.py


示例5: test_save_path

def test_save_path():
    with tempfile.TemporaryDirectory() as target_dir:
        qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))
        files = Fido.fetch(qr, path=os.path.join(target_dir, "{instrument}"+os.path.sep+"{level}"))
        for f in files:
            assert target_dir in f
            assert "eve{}0".format(os.path.sep) in f
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:7,代码来源:test_fido.py


示例6: test_save_path

def test_save_path(tmpdir):
    qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

    # Test when path is str
    files = Fido.fetch(qr, path=str(tmpdir / "{instrument}" / "{level}"))
    for f in files:
        assert str(tmpdir) in f
        assert "eve{}0".format(os.path.sep) in f
开发者ID:Cadair,项目名称:sunpy,代码行数:8,代码来源:test_fido.py


示例7: test_save_path_pathlib

def test_save_path_pathlib(tmpdir):
    qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

    # Test when path is pathlib.Path
    target_dir = tmpdir.mkdir("down")
    path = pathlib.Path(target_dir, "{instrument}", "{level}")
    files = Fido.fetch(qr, path=path)
    for f in files:
        assert target_dir.strpath in f
        assert "eve{}0".format(os.path.sep) in f
开发者ID:Cadair,项目名称:sunpy,代码行数:10,代码来源:test_fido.py


示例8: test_save_path_pathlib

def test_save_path_pathlib():
    pathlib = pytest.importorskip('pathlib')
    qr = Fido.search(a.Instrument('EVE'), a.Time("2016/10/01", "2016/10/02"), a.Level(0))

    # Test when path is pathlib.Path
    with tempfile.TemporaryDirectory() as target_dir:
        path = pathlib.Path(target_dir, "{instrument}", "{level}")
        files = Fido.fetch(qr, path=path)
        for f in files:
            assert target_dir in f
            assert "eve{}0".format(os.path.sep) in f
开发者ID:bwgref,项目名称:sunpy,代码行数:11,代码来源:test_fido.py


示例9: test_fido

def test_fido(mock_wait, mock_search, mock_enqueue):
    qr1 = Fido.search(Time('2012/10/4', '2012/10/6'),
                      Instrument('noaa-indices'))
    Fido.fetch(qr1, path="/some/path/{file}")

    # Here we assert that the `fetch` function has called the parfive
    # Downloader.enqueue_file method with the correct arguments. Everything
    # that happens after this point should either be tested in the
    # GenericClient tests or in parfive itself.
    assert mock_enqueue.called_once_with(("ftp://ftp.swpc.noaa.gov/pub/weekly/RecentIndices.txt",
                                          "/some/path/RecentIndices.txt"))
开发者ID:Cadair,项目名称:sunpy,代码行数:11,代码来源:test_noaa.py


示例10: test_no_time_error

def test_no_time_error():
    query = (a.Instrument('EVE'), a.Level(0))
    with pytest.raises(ValueError) as excinfo:
        Fido.search(*query)
    assert all(str(a) in str(excinfo.value) for a in query)

    query1 = (a.Instrument('EVE') & a.Level(0))
    query2 = (a.Time("2012/1/1", "2012/1/2") & a.Instrument("AIA"))
    with pytest.raises(ValueError) as excinfo:
        Fido.search(query1 | query2)
    assert all(str(a) in str(excinfo.value) for a in query1.attrs)
    assert all(str(a) not in str(excinfo.value) for a in query2.attrs)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:12,代码来源:test_fido.py


示例11: test_vso_errors_with_second_client

def test_vso_errors_with_second_client(mock_download_all):
    query = a.Time("2011/01/01", "2011/01/02") & (a.Instrument("goes") | a.Instrument("EIT"))

    qr = Fido.search(query)

    res = Fido.fetch(qr)
    assert len(res.errors) == 1
    assert len(res) != qr.file_num

    # Assert that all the XRSClient records are in the output.
    for resp in qr.responses:
        if isinstance(resp, XRSClient):
            assert len(resp) == len(res)
开发者ID:Cadair,项目名称:sunpy,代码行数:13,代码来源:test_fido.py


示例12: test_fido_indexing

def test_fido_indexing(queries):
    query1, query2 = queries

    # This is a work around for an aberration where the filter was not catching
    # this.
    assume(query1.attrs[1].start != query2.attrs[1].start)

    res = Fido.search(query1 | query2)

    assert len(res) == 2
    assert len(res[0]) == 1
    assert len(res[1]) == 1

    aa = res[0, 0]
    assert isinstance(aa, UnifiedResponse)
    assert len(aa) == 1
    assert len(aa.get_response(0)) == 1

    aa = res[:, 0]
    assert isinstance(aa, UnifiedResponse)
    assert len(aa) == 2
    assert len(aa.get_response(0)) == 1

    aa = res[0, :]
    assert isinstance(aa, UnifiedResponse)
    assert len(aa) == 1

    with pytest.raises(IndexError):
        res[0, 0, 0]

    with pytest.raises(IndexError):
        res["saldkal"]

    with pytest.raises(IndexError):
        res[1.0132]
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:35,代码来源:test_fido.py


示例13: test_unifiedresponse_slicing_reverse

def test_unifiedresponse_slicing_reverse():
    results = Fido.search(
        a.Time("2012/1/1", "2012/1/5"), a.Instrument("lyra"))
    assert isinstance(results[::-1], UnifiedResponse)
    assert len(results[::-1]) == len(results)
    assert isinstance(results[0, ::-1], UnifiedResponse)
    assert results[0, ::-1]._list[0] == results._list[0][::-1]
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:7,代码来源:test_fido.py


示例14: test_unified_response

def test_unified_response():
    start = parse_time("2012/1/1")
    end = parse_time("2012/1/2")
    qr = Fido.search(a.Instrument('EVE'), a.Level(0), a.Time(start, end))
    assert qr.file_num == 2
    strings = ['eve', 'SDO', start.strftime(TIMEFORMAT), end.strftime(TIMEFORMAT)]
    assert all(s in qr._repr_html_() for s in strings)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:7,代码来源:test_fido.py


示例15: test_repr

def test_repr():
    results = Fido.search(
        a.Time("2012/1/1", "2012/1/5"), a.Instrument("lyra"))

    rep = repr(results)
    rep = rep.split('\n')
    # 6 header lines, the results table and two blank lines at the end
    assert len(rep) == 7 + len(list(results.responses)[0]) + 2
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:8,代码来源:test_fido.py


示例16: test_responses

def test_responses():
    results = Fido.search(
        a.Time("2012/1/1", "2012/1/5"), a.Instrument("lyra"))

    for i, resp in enumerate(results.responses):
        assert isinstance(resp, QueryResponse)

    assert i + 1 == len(results)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:8,代码来源:test_fido.py


示例17: test_levels

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)

    qr = Fido.search(time, eve_a, a.Level(0) | a.Level(1))
    clients = {type(a.client) for a in qr.responses}
    assert clients.symmetric_difference({VSOClient, eve.EVEClient}) == set()
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:17,代码来源:test_eve.py


示例18: test_add_entries_from_fido_search_result_JSOC_client

def test_add_entries_from_fido_search_result_JSOC_client(database):
    assert len(database) == 0
    search_result = Fido.search(
        net_attrs.jsoc.Time('2014-01-01T00:00:00', '2014-01-01T01:00:00'),
        net_attrs.jsoc.Series('hmi.m_45s'),
        net_attrs.jsoc.Notify("[email protected]")
        )
    with pytest.raises(ValueError):
        database.add_from_fido_search_result(search_result)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:9,代码来源:test_database.py


示例19: test_multiple_match

def test_multiple_match():
    """
    Using the builtin clients a multiple match is not possible so we create a
    dummy class.
    """
    new_registry = copy.deepcopy(Fido.registry)
    Fido.registry = new_registry

    class DummyClient():
        @classmethod
        def _can_handle_query(cls, *query):
            return True
    Fido.registry.update({DummyClient: DummyClient._can_handle_query})

    with pytest.raises(MultipleMatchError):
        Fido.search(a.Time("2016/10/1", "2016/10/2"), a.Instrument('lyra'))

    Fido.registry = CLIENTS
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:18,代码来源:test_fido.py


示例20: test_fido_iter

def test_fido_iter(queries):
    query1, query2 = queries

    # This is a work around for an aberration where the filter was not catching
    # this.
    assume(query1.attrs[1].start != query2.attrs[1].start)

    res = Fido.search(query1 | query2)

    for resp in res:
        assert isinstance(resp, QueryResponse)
开发者ID:Hypnus1803,项目名称:sunpy,代码行数:11,代码来源:test_fido.py



注:本文中的sunpy.net.Fido类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python attr.and_函数代码示例发布时间:2022-05-27
下一篇:
Python basemap.BaseMap类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap