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

Python sentinel.SentinelAPI类代码示例

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

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



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

示例1: download_scene

def download_scene(scene):
    """Download a scene and change its status """
    from sentinelsat.sentinel import SentinelAPI
    from django.conf import settings

    path = join(settings.MEDIA_ROOT, scene.sat, scene.identifier)
    check_create_folder(path)

    try:
        api = SentinelAPI(
            settings.SENTINEL_USER,
            settings.SENTINEL_PASSWORD,
            settings.SENTINEL_API_URL
        )
    except AttributeError:
        api = SentinelAPI(settings.SENTINEL_USER, settings.SENTINEL_PASSWORD)
    try:
        print('Changing status of scene %s to downloading' % scene.identifier)
        scene.change_status('downloading')
        print('Starting download of product %s on path %s' %
              (scene.product, path))
        api.download(scene.product, path)
        print('Changing status of scene %s to downloaded' % scene.identifier)
        scene.change_status('downloaded')
    except Exception as exp:
        print('Unexpected error: %s' % exp)
        print('Changing status of scene %s to dl_failed' % scene.identifier)
        scene.change_status('dl_failed')
开发者ID:hexgis,项目名称:sentinel-catalog,代码行数:28,代码来源:tasks.py


示例2: 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:Fernerkundung,项目名称:sentinelsat,代码行数:7,代码来源:test_mod.py


示例3: test_get_product_info

def test_get_product_info():
    api = SentinelAPI(**_api_auth)

    expected_s1 = {
        'id': '8df46c9e-a20c-43db-a19a-4240c2ed3b8b',
        'size': 143549851,
        'md5': 'D5E4DF5C38C6E97BF7E7BD540AB21C05',
        'url': "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/$value",
        'date': '2015-11-21T10:03:56Z',
        'footprint': '-63.852531 -5.880887,-67.495872 -5.075419,-67.066071 -3.084356,-63.430576 -3.880541,'
                     '-63.852531 -5.880887',
        'title': 'S1A_EW_GRDM_1SDV_20151121T100356_20151121T100429_008701_00C622_A0EC'
    }

    expected_s2 = {
        'date': '2015-12-27T14:22:29Z',
        'footprint': '-58.80274769505742 -4.565257232533263,-58.80535376268811 -5.513960396525286,'
                     '-57.90315169909761 -5.515947033626909,-57.903151791669515 -5.516014389089381,-57.85874693129081 -5.516044812342758,'
                     '-57.814323596961835 -5.516142631941845,-57.81432351345917 -5.516075248310466,-57.00018056571297 -5.516633044843839,'
                     '-57.000180565731384 -5.516700066819259,-56.95603179187787 -5.51666329264377,-56.91188395837315 -5.516693539799448,'
                     '-56.91188396736038 -5.51662651925904,-56.097209386295305 -5.515947927683427,-56.09720929423562 -5.516014937246069,'
                     '-56.053056977999596 -5.5159111504805916,-56.00892491028779 -5.515874390220655,-56.00892501130261 -5.515807411549814,'
                     '-55.10621586418906 -5.513685455771881,-55.108821882251775 -4.6092845892233,-54.20840287327946 -4.606372862374043,'
                     '-54.21169990975238 -3.658594390979672,-54.214267703869346 -2.710949551849636,-55.15704255065496 -2.7127451087194463,'
                     '-56.0563616875051 -2.71378646425769,-56.9561852630143 -2.7141556791285275,-57.8999998009875 -2.713837142510183,'
                     '-57.90079161941062 -3.6180222056692726,-58.800616247288836 -3.616721351843382,-58.80274769505742 -4.565257232533263',
        'id': '44517f66-9845-4792-a988-b5ae6e81fd3e',
        'md5': '48C5648C2644CE07207B3C943DEDEB44',
        'size': 5854429622,
        'title': 'S2A_OPER_PRD_MSIL1C_PDMC_20151228T112523_R110_V20151227T142229_20151227T142229',
        'url': "https://scihub.copernicus.eu/apihub/odata/v1/Products('44517f66-9845-4792-a988-b5ae6e81fd3e')/$value"
    }

    assert api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b') == expected_s1
    assert api.get_product_info('44517f66-9845-4792-a988-b5ae6e81fd3e') == expected_s2
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:35,代码来源:test_mod.py


示例4: test_large_query

def test_large_query():
    api = SentinelAPI(**_api_kwargs)
    api.query(**_large_query)
    assert api.last_query == (
        '(beginPosition:[2015-01-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(api.products) > api.page_size
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例5: 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.http_status == 401
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例6: 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:Fernerkundung,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例7: test_format_url

def test_format_url():
    api = SentinelAPI(**_api_kwargs)
    start_row = 0
    url = api.format_url(start_row=start_row)

    assert url is api.url
    assert api.url == 'https://scihub.copernicus.eu/apihub/search?format=json&rows={rows}&start={start}'.format(
        rows=api.page_size, start=start_row)
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:8,代码来源:test_mod.py


示例8: test_get_products_size

def test_get_products_size():
    api = SentinelAPI(
        environ.get('SENTINEL_USER'),
        environ.get('SENTINEL_PASSWORD')
        )
    api.query(
        get_coordinates('tests/map.geojson'),
        "20151219", "20151228", platformname="Sentinel-2"
        )
    assert api.get_products_size() == 63.58
开发者ID:hexgis,项目名称:sentinelsat,代码行数:10,代码来源:test_mod.py


示例9: test_footprints

def test_footprints():
    api = SentinelAPI(
    environ.get('SENTINEL_USER'),
    environ.get('SENTINEL_PASSWORD')
    )
    api.query(get_coordinates('tests/map.geojson'), datetime(2014, 10, 10), datetime(2014, 12, 31), producttype="GRD")

    expected_footprints = geojson.loads(open('tests/expected_search_footprints.geojson', 'r').read())

    # to compare unordered lists (JSON objects) they need to be sorted or changed to sets
    assert set(api.get_footprints()) == set(expected_footprints)
开发者ID:gijs,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例10: test_SentinelAPI_connection

def test_SentinelAPI_connection():
    api = SentinelAPI(
        environ.get('SENTINEL_USER'),
        environ.get('SENTINEL_PASSWORD')
        )
    api.query('0 0,1 1,0 1,0 0', datetime(2015, 1, 1), datetime(2015, 1, 2))

    assert api.url == 'https://scihub.copernicus.eu/apihub/search?format=json&rows=15000' + \
        '&q=(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.content.status_code == 200
开发者ID:hexgis,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例11: test_footprints_s1

def test_footprints_s1():
    api = SentinelAPI(**_api_auth)
    api.query(
        get_coordinates('tests/map.geojson'),
        datetime(2014, 10, 10), datetime(2014, 12, 31), producttype="GRD"
    )

    with open('tests/expected_search_footprints_s1.geojson', 'r') as geojson_file:
        expected_footprints = geojson.loads(geojson_file.read())
        # to compare unordered lists (JSON objects) they need to be sorted or changed to sets
        assert set(api.get_footprints()) == set(expected_footprints)
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例12: test_get_product_info_scihub_down

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

    with requests_mock.mock() as rqst:
        rqst.get(
            "https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/?$format=json",
            text="Mock SciHub is Down", status_code=503
            )
        with pytest.raises(ValueError) as val_err:
            api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
            assert val_err.value.message == "Invalid API response. JSON decoding failed."
开发者ID:hexgis,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例13: test_footprints_s2

def test_footprints_s2():
    api = SentinelAPI(**_api_auth)
    api.query(
        get_coordinates('tests/map.geojson'),
        "20151219", "20151228", platformname="Sentinel-2"
    )

    with open('tests/expected_search_footprints_s2.geojson', 'r') as geojson_file:
        expected_footprints = geojson.loads(geojson_file.read())
        # to compare unordered lists (JSON objects) they need to be sorted or changed to sets
        assert set(api.get_footprints()) == set(expected_footprints)
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:11,代码来源:test_mod.py


示例14: download

def download(user, password, productid, path, md5, url):
    """Download a Sentinel Product. It just needs your SciHub user and password
    and the id of the product you want to download.
    """
    api = SentinelAPI(user, password, url)
    try:
        api.download(productid, path, md5)
    except SentinelAPIError as e:
        if 'Invalid key' in e.msg:
            logger.error('No product with ID \'%s\' exists on server', productid)
        else:
            raise
开发者ID:ibamacsr,项目名称:sentinelsat,代码行数:12,代码来源:cli.py


示例15: test_get_product_info

def test_get_product_info():
    api = SentinelAPI(
        environ.get('SENTINEL_USER'),
        environ.get('SENTINEL_PASSWORD')
    )

    expected = {'id': '079ed72f-b330-4918-afb8-b63854e375a5',
        'title': 'S1A_IW_GRDH_1SDV_20150527T081303_20150527T081328_006104_007EB2_E65B',
        'size': 1051461964,
        'footprint': '-21.032057 -39.925808,-20.472944 -42.301277,-18.975924 -41.904408,-19.528255 -39.549416,-21.032057 -39.925808',
        'url': "https://scihub.esa.int/dhus/odata/v1/Products('079ed72f-b330-4918-afb8-b63854e375a5')/$value"
        }
    assert api.get_product_info('079ed72f-b330-4918-afb8-b63854e375a5') == expected
开发者ID:gijs,项目名称:sentinelsat,代码行数:13,代码来源:test_mod.py


示例16: test_api_query_format

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

    now = datetime.now()
    query = api.format_query('0 0,1 1,0 1,0 0', end_date=now)
    last_24h = format_date(now - timedelta(hours=24))
    assert query == '(beginPosition:[%s TO %s]) ' % (last_24h, format_date(now)) + \
                    'AND (footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))")'

    query = api.format_query('0 0,1 1,0 1,0 0', end_date=now, producttype='SLC')
    assert query == '(beginPosition:[%s TO %s]) ' % (last_24h, format_date(now)) + \
                    'AND (footprint:"Intersects(POLYGON((0 0,1 1,0 1,0 0)))") ' + \
                    'AND (producttype:SLC)'
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:13,代码来源:test_mod.py


示例17: test_SentinelAPI_connection

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

    assert api.url.startswith(
        'https://scihub.copernicus.eu/apihub/search?format=json&rows={rows}'.format(
            rows=api.page_size
            )
        )
    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:Fernerkundung,项目名称:sentinelsat,代码行数:13,代码来源:test_mod.py


示例18: test_s2_cloudcover

def test_s2_cloudcover():
    api = SentinelAPI(
        environ.get('SENTINEL_USER'),
        environ.get('SENTINEL_PASSWORD')
        )
    api.query(
        get_coordinates('tests/map.geojson'),
        "20151219", "20151228",
        platformname="Sentinel-2",
        cloudcoverpercentage="[0 TO 10]"
        )
    assert len(api.get_products()) == 2
    assert api.get_products()[0]["id"] == "37ecee60-23d8-4ec2-a65f-2de24f51d30e"
    assert api.get_products()[1]["id"] == "0848f6b8-5730-4759-850e-fc9945d42296"
开发者ID:harryjfowen,项目名称:sentinelsat,代码行数:14,代码来源:test_mod.py


示例19: test_get_products_invalid_json

def test_get_products_invalid_json():
    api = SentinelAPI("mock_user", "mock_password")
    with requests_mock.mock() as rqst:
        rqst.get(
            'https://scihub.copernicus.eu/apihub/search?format=json&rows=15000&q=(beginPosition:[2015-12-19T00:00:00Z TO 2015-12-28T00:00:00Z]) AND (footprint:"Intersects(POLYGON((-66.2695312 -8.0592296,-66.2695312 0.7031074,-57.3046875 0.7031074,-57.3046875 -8.0592296,-66.2695312 -8.0592296)))") AND (platformname:Sentinel-2)',
            text="Invalid JSON response", status_code=200
            )
        api.query(
            area=get_coordinates("tests/map.geojson"),
            initial_date="20151219",
            end_date="20151228",
            platformname="Sentinel-2"
        )
        with pytest.raises(ValueError) as val_err:
            api.get_products()
            assert val_err.value.message == "API response not valid. JSON decoding failed."
开发者ID:hexgis,项目名称:sentinelsat,代码行数:16,代码来源:test_mod.py


示例20: test_get_products_invalid_json

def test_get_products_invalid_json():
    api = SentinelAPI("mock_user", "mock_password")
    with requests_mock.mock() as rqst:
        rqst.post(
            'https://scihub.copernicus.eu/apihub/search?format=json',
            text="{Invalid JSON response", status_code=200
        )
        with pytest.raises(SentinelAPIError) as excinfo:
            api.query(
                area=get_coordinates("tests/map.geojson"),
                initial_date="20151219",
                end_date="20151228",
                platformname="Sentinel-2"
            )
            api.get_products()
        assert excinfo.value.msg == "API response not valid. JSON decoding failed."
开发者ID:Fernerkundung,项目名称:sentinelsat,代码行数:16,代码来源:test_mod.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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