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

Python sentinelsat.SentinelAPI类代码示例

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

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



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

示例1: test_small_query

def test_small_query():
    api = SentinelAPI(**_api_kwargs)
    api.query(**_small_query)
    assert api._last_query == (
        '(beginPosition:[2015-01-01T00:00:00Z TO 2015-01-02T00:00:00Z]) '
        'AND (footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))")')
    assert api._last_status_code == 200
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:7,代码来源:test_mod.py


示例2: test_download_all

def test_download_all(tmpdir):
    api = SentinelAPI(**_api_auth)
    # From https://scihub.copernicus.eu/apihub/odata/v1/Products?$top=5&$orderby=ContentLength
    filenames = ["S1A_WV_OCN__2SSH_20150603T092625_20150603T093332_006207_008194_521E",
                 "S1A_WV_OCN__2SSV_20150526T211029_20150526T211737_006097_007E78_134A",
                 "S1A_WV_OCN__2SSV_20150526T081641_20150526T082418_006090_007E3E_104C"]

    ids = list(api.query_raw(" OR ".join(filenames)))
    assert len(ids) == len(filenames)

    # Download normally
    product_infos, failed_downloads = api.download_all(ids, str(tmpdir))
    assert len(failed_downloads) == 0
    assert len(product_infos) == len(filenames)
    for product_id, product_info in product_infos.items():
        pypath = py.path.local(product_info['path'])
        assert pypath.purebasename in filenames
        assert pypath.check(exists=1, file=1)
        assert pypath.size() == product_info["size"]

    # Force one download to fail
    id, product_info = list(product_infos.items())[0]
    path = product_info['path']
    py.path.local(path).remove()
    with requests_mock.mock(real_http=True) as rqst:
        url = "https://scihub.copernicus.eu/apihub/odata/v1/Products('%s')?$format=json" % id
        json = api.session.get(url).json()
        json["d"]["Checksum"]["Value"] = "00000000000000000000000000000000"
        rqst.get(url, json=json)
        product_infos, failed_downloads = api.download_all(
            ids, str(tmpdir), max_attempts=1, checksum=True)
        assert len(failed_downloads) == 1
        assert len(product_infos) + len(failed_downloads) == len(filenames)
        assert id in failed_downloads
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:34,代码来源:test_mod.py


示例3: test_date_arithmetic

def test_date_arithmetic():
    api = SentinelAPI(**_api_kwargs)
    products = api.query('ENVELOPE(0, 10, 10, 0)',
                         ('2016-12-01T00:00:00Z-1DAY',
                          '2016-12-01T00:00:00Z+1DAY-1HOUR'))
    assert api._last_response.status_code == 200
    assert len(products) > 0
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:7,代码来源:test_mod.py


示例4: test_format_url_custom_api_url

def test_format_url_custom_api_url():
    api = SentinelAPI("user", "pw", api_url='https://scihub.copernicus.eu/dhus/')
    url = api._format_url()
    assert url.startswith('https://scihub.copernicus.eu/dhus/search')

    api = SentinelAPI("user", "pw", api_url='https://scihub.copernicus.eu/dhus')
    url = api._format_url()
    assert url.startswith('https://scihub.copernicus.eu/dhus/search')
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例5: test_large_query

def test_large_query():
    api = SentinelAPI(**_api_kwargs)
    products = api.query(**_large_query)
    assert api._last_query == (
        '(beginPosition:[2015-12-01T00:00:00Z TO 2015-12-31T00:00:00Z]) '
        'AND (footprint:"Intersects(POLYGON((0 0,0 10,10 10,10 0,0 0)))")')
    assert api._last_status_code == 200
    assert len(products) > api.page_size
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例6: products

def products():
    """A fixture for tests that need some non-specific set of products as input."""
    api = SentinelAPI(**_api_auth)
    products = api.query(
        geojson_to_wkt(read_geojson('tests/map.geojson')),
        "20151219", "20151228"
    )
    return products
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例7: raw_products

def raw_products():
    """A fixture for tests that need some non-specific set of products in the form of a raw response as input."""
    api = SentinelAPI(**_api_auth)
    raw_products = api._load_query(api.format_query(
        geojson_to_wkt(read_geojson('tests/map.geojson')),
        "20151219", "20151228")
    )
    return raw_products
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例8: test_SentinelAPI_connection

def test_SentinelAPI_connection():
    api = SentinelAPI(**_api_auth)
    api.query(**_small_query)

    assert api._last_query == (
        'beginPosition:[2015-01-01T00:00:00Z TO 2015-01-02T00:00:00Z] '
        'footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))"')
    assert api._last_response.status_code == 200
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例9: raw_products

def raw_products(api_kwargs, vcr, test_wkt):
    """A fixture for tests that need some non-specific set of products in the form of a raw response as input."""
    with vcr.use_cassette('products_fixture', decode_compressed_response=False):
        api = SentinelAPI(**api_kwargs)
        raw_products = api._load_query(
            api.format_query(test_wkt, ("20151219", "20151228"))
        )[0]
    return raw_products
开发者ID:valgur,项目名称:sentinelsat,代码行数:8,代码来源:conftest.py


示例10: test_SentinelAPI_wrong_credentials

def test_SentinelAPI_wrong_credentials():
    api = SentinelAPI(
        "wrong_user",
        "wrong_password"
    )
    with pytest.raises(SentinelAPIError) as excinfo:
        api.query(**_small_query)
    assert excinfo.value.response.status_code == 401
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例11: test_quote_symbol_bug

def test_quote_symbol_bug():
    # A test to check if plus symbol handling works correctly on the server side
    # It used to raise an error but has since been fixed
    # https://github.com/SentinelDataHub/DataHubSystem/issues/23
    api = SentinelAPI(**_api_kwargs)

    q = 'beginposition:[2017-05-30T00:00:00Z TO 2017-05-31T00:00:00Z+1DAY]'
    count = api.count(raw=q)
    assert count > 0
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:9,代码来源:test_mod.py


示例12: products

def products(api_kwargs, vcr, test_wkt):
    """A fixture for tests that need some non-specific set of products as input."""
    with vcr.use_cassette('products_fixture', decode_compressed_response=False):
        api = SentinelAPI(**api_kwargs)
        products = api.query(
            test_wkt,
            ("20151219", "20151228")
        )
    assert len(products) > 20
    return products
开发者ID:valgur,项目名称:sentinelsat,代码行数:10,代码来源:conftest.py


示例13: test_get_products_size

def test_get_products_size(products):
    assert SentinelAPI.get_products_size(products) == 90.94

    # load a new very small query
    api = SentinelAPI(**_api_auth)
    with my_vcr.use_cassette('test_get_products_size'):
        products = api.query_raw("S1A_WV_OCN__2SSH_20150603T092625_20150603T093332_006207_008194_521E")
    assert len(products) > 0
    # Rounded to zero
    assert SentinelAPI.get_products_size(products) == 0
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:10,代码来源:test_mod.py


示例14: test_get_products_size

def test_get_products_size(api, vcr, products):
    assert SentinelAPI.get_products_size(products) == 75.4

    # load a new very small query
    with vcr.use_cassette('test_get_products_size'):
        products = api.query(
            raw="S1A_WV_OCN__2SSH_20150603T092625_20150603T093332_006207_008194_521E")
    assert len(products) > 0
    # Rounded to zero
    assert SentinelAPI.get_products_size(products) == 0
开发者ID:valgur,项目名称:sentinelsat,代码行数:10,代码来源:test_mod.py


示例15: test_missing_dependency_dataframe

def test_missing_dependency_dataframe(monkeypatch):
    api = SentinelAPI("mock_user", "mock_password")

    with pytest.raises(ImportError):
        monkeypatch.setitem(sys.modules, "pandas", None)                
        api.to_dataframe({"test":"test"})

    with pytest.raises(ImportError):
        monkeypatch.setitem(sys.modules, "geopandas", None)
        api.to_geodataframe({"test":"tst"})
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:10,代码来源:test_mod.py


示例16: test_api_query_format_escape_spaces

def test_api_query_format_escape_spaces(api):
    query = SentinelAPI.format_query(ingestiondate=('NOW-1DAY', 'NOW'))
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(ingestiondate='[NOW-1DAY TO NOW]')
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(ingestiondate=' [NOW-1DAY TO NOW] ')
    assert query == 'ingestiondate:[NOW-1DAY TO NOW]'

    query = SentinelAPI.format_query(relativeorbitnumber=' {101 TO 103} ')
    assert query == 'relativeorbitnumber:{101 TO 103}'

    query = SentinelAPI.format_query(filename='S3A_OL_2* ')
    assert query == 'filename:S3A_OL_2*'

    query = SentinelAPI.format_query(timeliness='Non Time Critical')
    assert query == r'timeliness:Non\ Time\ Critical'

    query = SentinelAPI.format_query(timeliness='Non\tTime\tCritical')
    assert query == r'timeliness:Non\ Time\ Critical'

    assert api.count(timeliness='Non Time Critical') > 0

    # Allow for regex weirdness
    query = SentinelAPI.format_query(timeliness='.+ Critical')
    assert query == r'timeliness:.+\ Critical'
    assert api.count(timeliness='.+ Critical') > 0

    query = SentinelAPI.format_query(identifier='/S[123 ]A.*/')
    assert query == r'identifier:/S[123 ]A.*/'
    assert api.count(identifier='/S[123 ]A.*/') > 0
开发者ID:valgur,项目名称:sentinelsat,代码行数:32,代码来源:test_mod.py


示例17: test_trigger_lta_accepted

def test_trigger_lta_accepted():
    api = SentinelAPI("mock_user", "mock_password")

    request_url = "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/$value"

    with requests_mock.mock() as rqst:
        rqst.get(
            request_url,
            text="Mock trigger accepted", status_code=202
        )
        assert api._trigger_offline_retrieval(request_url) == 202
开发者ID:valgur,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例18: test_trigger_lta_failed

def test_trigger_lta_failed(http_status_code):
    api = SentinelAPI("mock_user", "mock_password")
    request_url = "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/$value"

    with requests_mock.mock() as rqst:
        rqst.get(
            request_url,
            status_code=http_status_code
        )
        with pytest.raises(SentinelAPILTAError) as excinfo:
            api._trigger_offline_retrieval(request_url)
开发者ID:valgur,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例19: test_order_by

def test_order_by():
    api = SentinelAPI(**_api_auth)
    products = api.query(
        geojson_to_wkt(read_geojson(FIXTURES_DIR + '/map.geojson')),
        ("20151219", "20151228"),
        platformname="Sentinel-2",
        cloudcoverpercentage=(0, 10),
        order_by="cloudcoverpercentage, -beginposition"
    )
    assert len(products) == 3
    vals = [x["cloudcoverpercentage"] for x in products.values()]
    assert sorted(vals) == vals
开发者ID:NiklasKeck,项目名称:sentinelsat,代码行数:12,代码来源:test_mod.py


示例20: test_s2_cloudcover

def test_s2_cloudcover():
    api = SentinelAPI(**_api_auth)
    products = api.query(
        geojson_to_wkt(read_geojson('tests/map.geojson')),
        "20151219", "20151228",
        platformname="Sentinel-2",
        cloudcoverpercentage="[0 TO 10]"
    )
    assert len(products) == 3

    product_ids = list(products)
    assert product_ids[0] == "6ed0b7de-3435-43df-98bf-ad63c8d077ef"
    assert product_ids[1] == "37ecee60-23d8-4ec2-a65f-2de24f51d30e"
    assert product_ids[2] == "0848f6b8-5730-4759-850e-fc9945d42296"
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:14,代码来源:test_mod.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sentinel.SentinelAPI类代码示例发布时间:2022-05-27
下一篇:
Python sentimentfinding.IOtools类代码示例发布时间: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