本文整理汇总了Python中sentinelsat.SentinelAPI.query方法的典型用法代码示例。如果您正苦于以下问题:Python SentinelAPI.query方法的具体用法?Python SentinelAPI.query怎么用?Python SentinelAPI.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentinelsat.SentinelAPI
的用法示例。
在下文中一共展示了SentinelAPI.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_small_query
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例2: test_scihub_unresponsive
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
def test_scihub_unresponsive():
timeout_connect = 6
timeout_read = 6.6
timeout = (timeout_connect, timeout_read)
api = SentinelAPI("mock_user", "mock_password", timeout=timeout)
with requests_mock.mock() as rqst:
rqst.request(requests_mock.ANY, requests_mock.ANY, exc=requests.exceptions.ConnectTimeout)
with pytest.raises(requests.exceptions.ConnectTimeout):
api.query(**_small_query)
with pytest.raises(requests.exceptions.ConnectTimeout):
api.get_product_odata('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
with pytest.raises(requests.exceptions.ConnectTimeout):
api.download('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
with pytest.raises(requests.exceptions.ConnectTimeout):
api.download_all(['8df46c9e-a20c-43db-a19a-4240c2ed3b8b'])
with requests_mock.mock() as rqst:
rqst.request(requests_mock.ANY, requests_mock.ANY, exc=requests.exceptions.ReadTimeout)
with pytest.raises(requests.exceptions.ReadTimeout):
api.query(**_small_query)
with pytest.raises(requests.exceptions.ReadTimeout):
api.get_product_odata('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
with pytest.raises(requests.exceptions.ReadTimeout):
api.download('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
with pytest.raises(requests.exceptions.ReadTimeout):
api.download_all(['8df46c9e-a20c-43db-a19a-4240c2ed3b8b'])
示例3: test_SentinelAPI_connection
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例4: test_SentinelAPI_wrong_credentials
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例5: test_get_products_invalid_json
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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=geojson_to_wkt(read_geojson(FIXTURES_DIR + "/map.geojson")),
date=("20151219", "20151228"),
platformname="Sentinel-2"
)
assert excinfo.value.msg == "Invalid API response."
示例6: test_date_arithmetic
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例7: products
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例8: test_large_query
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
def test_large_query():
api = SentinelAPI(**_api_kwargs)
full_products = list(api.query(**_large_query))
assert api._last_query == (
'beginPosition:[2015-12-01T00:00:00Z TO 2015-12-31T00:00:00Z] '
'footprint:"Intersects(POLYGON((0 0,0 10,10 10,10 0,0 0)))"')
assert api._last_response.status_code == 200
assert len(full_products) > api.page_size
result = list(api.query(limit=150, **_large_query))
assert result == full_products[:150]
result = list(api.query(limit=20, offset=90, **_large_query))
assert result == full_products[90:110]
result = list(api.query(limit=20, offset=len(full_products) - 10, **_large_query))
assert result == full_products[-10:]
示例9: test_large_query
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例10: products
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例11: test_get_products_size
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例12: test_area_relation
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
def test_area_relation():
api = SentinelAPI(**_api_auth)
params = dict(
area="POLYGON((10.83 53.04,11.64 53.04,11.64 52.65,10.83 52.65,10.83 53.04))",
date=("20151219", "20151226")
)
result = api.query(**params)
n_intersects = len(result)
assert n_intersects > 10
result = api.query(area_relation="contains", **params)
n_contains = len(result)
assert 0 < n_contains < n_intersects
result = api.query(area_relation="IsWithin", **params)
n_iswithin = len(result)
assert n_iswithin == 0
# Check that unsupported relations raise an error
with pytest.raises(ValueError) as excinfo:
api.query(area_relation="disjoint", **params)
示例13: test_SentinelAPI_wrong_credentials
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
with pytest.raises(SentinelAPIError) as excinfo:
api.get_product_odata('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
assert excinfo.value.response.status_code == 401
with pytest.raises(SentinelAPIError) as excinfo:
api.download('8df46c9e-a20c-43db-a19a-4240c2ed3b8b')
assert excinfo.value.response.status_code == 401
with pytest.raises(SentinelAPIError) as excinfo:
api.download_all(['8df46c9e-a20c-43db-a19a-4240c2ed3b8b'])
assert excinfo.value.response.status_code == 401
示例14: test_order_by
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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
示例15: test_s2_cloudcover
# 需要导入模块: from sentinelsat import SentinelAPI [as 别名]
# 或者: from sentinelsat.SentinelAPI import query [as 别名]
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"