本文整理汇总了Python中sentinelsat.sentinel.SentinelAPI.get_product_info方法的典型用法代码示例。如果您正苦于以下问题:Python SentinelAPI.get_product_info方法的具体用法?Python SentinelAPI.get_product_info怎么用?Python SentinelAPI.get_product_info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentinelsat.sentinel.SentinelAPI
的用法示例。
在下文中一共展示了SentinelAPI.get_product_info方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_product_info_scihub_down
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_product_info [as 别名]
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."
示例2: test_get_product_info
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_product_info [as 别名]
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
示例3: test_get_product_info
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_product_info [as 别名]
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
示例4: test_get_product_info_scihub_down
# 需要导入模块: from sentinelsat.sentinel import SentinelAPI [as 别名]
# 或者: from sentinelsat.sentinel.SentinelAPI import get_product_info [as 别名]
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(SentinelAPIError) as excinfo:
api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
rqst.get(
"https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/?$format=json",
text='{"error":{"code":null,"message":{"lang":"en","value":'
'"No Products found with key \'8df46c9e-a20c-43db-a19a-4240c2ed3b8b\' "}}}', status_code=500
)
with pytest.raises(SentinelAPIError) as excinfo:
api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
assert excinfo.value.msg == "No Products found with key \'8df46c9e-a20c-43db-a19a-4240c2ed3b8b\' "
rqst.get(
"https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/?$format=json",
text="Mock SciHub is Down", status_code=200
)
with pytest.raises(SentinelAPIError) as excinfo:
api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
assert excinfo.value.msg == "Mock SciHub is Down"
# Test with a real server response
rqst.get(
"https://scihub.copernicus.eu/apihub/odata/v1/Products('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')/?$format=json",
text=textwrap.dedent("""\
<!doctype html>
<title>The Sentinels Scientific Data Hub</title>
<link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style>
body { text-align: center; padding: 125px; background: #fff;}
h1 { font-size: 50px; }
body { font: 20px 'Open Sans',Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 820px; margin: 0 auto; }
a { color: #0062a4; text-decoration: none; font-size: 26px }
a:hover { color: #1b99da; text-decoration: none; }
</style>
<article>
<img alt="" src="/datahub.png" style="float: left;margin: 20px;">
<h1>The Sentinels Scientific Data Hub will be back soon!</h1>
<div style="margin-left: 145px;">
<p>
Sorry for the inconvenience,<br/>
we're performing some maintenance at the moment.<br/>
</p>
<!--<p><a href="https://scihub.copernicus.eu/news/News00098">https://scihub.copernicus.eu/news/News00098</a></p>-->
<p>
We'll be back online shortly!
</p>
</div>
</article>
"""),
status_code=502)
with pytest.raises(SentinelAPIError) as excinfo:
api.get_product_info('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
print(excinfo.value)
assert "The Sentinels Scientific Data Hub will be back soon!" in excinfo.value.msg