Skip to content

Commit

Permalink
Release version 3.8.3, Merge pull request #408 from sentinel-hub/develop
Browse files Browse the repository at this point in the history
Release version 3.8.3
  • Loading branch information
zigaLuksic committed Feb 16, 2023
2 parents 27fff20 + 47b407c commit c320ff6
Show file tree
Hide file tree
Showing 44 changed files with 723 additions and 786 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: debug-statements

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
language_version: python3
Expand All @@ -25,7 +25,7 @@ repos:
name: isort (python)

- repo: https://github.com/PyCQA/autoflake
rev: v2.0.0
rev: v2.0.1
hooks:
- id: autoflake
args:
Expand Down
8 changes: 4 additions & 4 deletions examples/aws_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"outputs": [],
"source": [
"import os\n",
"from datetime import datetime as dt\n",
"from datetime import datetime\n",
"\n",
"from sentinelhub import CRS, BBox, DataCollection, SentinelHubCatalog, SHConfig\n",
"from sentinelhub.aws import AwsDownloadClient\n",
Expand All @@ -48,8 +48,8 @@
"metadata": {},
"outputs": [],
"source": [
"search_bbox = BBox(bbox=[46.16, -16.15, 46.51, -5.58], crs=CRS.WGS84)\n",
"search_time_interval = (dt(2022, 12, 11), dt(2022, 12, 17))\n",
"search_bbox = BBox(bbox=(46.16, -16.15, 46.51, -5.58), crs=CRS.WGS84)\n",
"search_time_interval = (datetime(2022, 12, 11), datetime(2022, 12, 17))\n",
"data_collection = DataCollection.SENTINEL2_L1C # use DataCollection.SENTINEL2_L1C or DataCollection.SENTINEL2_L2A"
]
},
Expand Down Expand Up @@ -260,7 +260,7 @@
}
],
"source": [
"search_bbox = BBox(bbox=[46.16, -16.15, 46.51, -15.58], crs=CRS.WGS84)\n",
"search_bbox = BBox(bbox=(46.16, -16.15, 46.51, -15.58), crs=CRS.WGS84)\n",
"search_time_interval = (\"2017-12-01T00:00:00\", \"2017-12-15T23:59:59\")\n",
"\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/byoc_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@
"metadata": {},
"outputs": [],
"source": [
"caspian_sea_bbox = BBox([49.9604, 44.7176, 51.0481, 45.2324], crs=CRS.WGS84)"
"caspian_sea_bbox = BBox((49.9604, 44.7176, 51.0481, 45.2324), crs=CRS.WGS84)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/data_collections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"\n",
"\n",
"# Columbia Glacier, Alaska\n",
"glacier_bbox = BBox([-147.8, 60.96, -146.5, 61.38], crs=CRS.WGS84)\n",
"glacier_bbox = BBox((-147.8, 60.96, -146.5, 61.38), crs=CRS.WGS84)\n",
"glacier_size = (700, 466)\n",
"time_interval = \"2020-07-15\", \"2020-07-16\"\n",
"\n",
Expand Down Expand Up @@ -525,7 +525,7 @@
"source": [
"from sentinelhub import bbox_to_dimensions\n",
"\n",
"slovenia_bbox = BBox([13.353882, 45.402307, 16.644287, 46.908998], crs=CRS.WGS84)\n",
"slovenia_bbox = BBox((13.353882, 45.402307, 16.644287, 46.908998), crs=CRS.WGS84)\n",
"slovenia_size = bbox_to_dimensions(slovenia_bbox, resolution=240)\n",
"\n",
"evalscript_byoc = \"\"\"\n",
Expand Down
6 changes: 3 additions & 3 deletions examples/data_search.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
}
],
"source": [
"caspian_sea_bbox = BBox([49.9604, 44.7176, 51.0481, 45.2324], crs=CRS.WGS84)\n",
"caspian_sea_bbox = BBox((49.9604, 44.7176, 51.0481, 45.2324), crs=CRS.WGS84)\n",
"time_interval = \"2020-12-10\", \"2021-02-01\"\n",
"\n",
"search_iterator = catalog.search(\n",
Expand Down Expand Up @@ -858,7 +858,7 @@
}
],
"source": [
"caspian_sea_bbox = BBox([49.9604, 44.7176, 51.0481, 45.2324], crs=CRS.WGS84)\n",
"caspian_sea_bbox = BBox((49.9604, 44.7176, 51.0481, 45.2324), crs=CRS.WGS84)\n",
"time_interval = \"2020-12-10\", \"2021-02-01\"\n",
"\n",
"wfs_iterator = WebFeatureService(\n",
Expand Down Expand Up @@ -961,7 +961,7 @@
"source": [
"from sentinelhub import get_area_info\n",
"\n",
"caspian_sea_bbox = BBox([49.9604, 44.7176, 51.0481, 45.2324], crs=CRS.WGS84)\n",
"caspian_sea_bbox = BBox((49.9604, 44.7176, 51.0481, 45.2324), crs=CRS.WGS84)\n",
"time_interval = \"2020-12-10\", \"2021-02-01\"\n",
"\n",
"opensearch_iterator = get_area_info(caspian_sea_bbox, time_interval, maxcc=0.05)\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/fis_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
"metadata": {},
"outputs": [],
"source": [
"bbox1 = BBox([46.16, -16.15, 46.51, -15.58], CRS.WGS84)\n",
"bbox1 = BBox((46.16, -16.15, 46.51, -15.58), CRS.WGS84)\n",
"bbox2 = BBox((1292344.0, 5195920.0, 1310615.0, 5214191.0), CRS.POP_WEB)\n",
"\n",
"geometry1 = Geometry(Polygon([(-5.13, 48), (-5.23, 48.09), (-5.13, 48.17), (-5.03, 48.08), (-5.13, 48)]), CRS.WGS84)\n",
Expand Down
10 changes: 5 additions & 5 deletions examples/ogc_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"metadata": {},
"outputs": [],
"source": [
"betsiboka_coords_wgs84 = [46.16, -16.15, 46.51, -15.58]"
"betsiboka_coords_wgs84 = (46.16, -16.15, 46.51, -15.58)"
]
},
{
Expand Down Expand Up @@ -977,7 +977,7 @@
"metadata": {},
"outputs": [],
"source": [
"betsiboka_bbox_large = BBox([45.88, -16.12, 47.29, -15.45], crs=CRS.WGS84)\n",
"betsiboka_bbox_large = BBox((45.88, -16.12, 47.29, -15.45), crs=CRS.WGS84)\n",
"\n",
"wms_true_color_request = WmsRequest(\n",
" data_collection=DataCollection.SENTINEL2_L1C,\n",
Expand Down Expand Up @@ -1492,7 +1492,7 @@
}
],
"source": [
"volcano_bbox = BBox(bbox=[(-2217485.0, 9228907.0), (-2150692.0, 9284045.0)], crs=CRS.POP_WEB)\n",
"volcano_bbox = BBox(bbox=(-2217485.0, 9228907.0, -2150692.0, 9284045.0), crs=CRS.POP_WEB)\n",
"\n",
"l2a_request = WmsRequest(\n",
" data_collection=DataCollection.SENTINEL2_L2A,\n",
Expand Down Expand Up @@ -1831,7 +1831,7 @@
"metadata": {},
"outputs": [],
"source": [
"byoc_bbox = BBox([13.82387, 45.85221, 13.83313, 45.85901], crs=CRS.WGS84)\n",
"byoc_bbox = BBox((13.82387, 45.85221, 13.83313, 45.85901), crs=CRS.WGS84)\n",
"\n",
"collection_id = \"<your BYOC collection id>\"\n",
"layer = \"<layer that uses the BYOC collection, defined in SentinelHub dashboard>\"\n",
Expand All @@ -1848,7 +1848,7 @@
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/process_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"metadata": {},
"outputs": [],
"source": [
"betsiboka_coords_wgs84 = [46.16, -16.15, 46.51, -15.58]"
"betsiboka_coords_wgs84 = (46.16, -16.15, 46.51, -15.58)"
]
},
{
Expand Down Expand Up @@ -1173,7 +1173,7 @@
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/reading_pu_from_headers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"metadata": {},
"outputs": [],
"source": [
"betsiboka_coords_wgs84 = [46.16, -16.15, 46.51, -15.58]\n",
"betsiboka_coords_wgs84 = (46.16, -16.15, 46.51, -15.58)\n",
"resolution = 60\n",
"betsiboka_bbox = BBox(bbox=betsiboka_coords_wgs84, crs=CRS.WGS84)\n",
"betsiboka_size = bbox_to_dimensions(betsiboka_bbox, resolution=resolution)"
Expand Down
4 changes: 2 additions & 2 deletions examples/statistical_request.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"metadata": {},
"outputs": [],
"source": [
"betsiboka_bbox = BBox([46.16, -16.15, 46.51, -15.58], CRS.WGS84)\n",
"betsiboka_bbox = BBox((46.16, -16.15, 46.51, -15.58), CRS.WGS84)\n",
"\n",
"rgb_evalscript = \"\"\"\n",
"//VERSION=3\n",
Expand Down Expand Up @@ -1836,7 +1836,7 @@
"\n",
"for band in BANDS:\n",
" for stat in STATISTICAL_QUANTITIES:\n",
" column_name = f\"bands_{band}_{stat}\"\n",
" column_name = f\"bands_{band.name}_{stat}\"\n",
" column = features_df[column_name]\n",
"\n",
" column = column / 10000.0\n",
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ disable = [
"unsubscriptable-object",
"invalid-unary-operand-type",
"unspecified-encoding",
"unnecessary-ellipsis"
"unnecessary-ellipsis",
"use-dict-literal"
]

[tool.pylint.design]
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pre-commit
pylint>=2.14.0
pytest>=4.0.0
pytest-cov
pytest-dependency
pytest-lazy-fixture
pytest-mock
ray[default]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ shapely
shared-memory38;python_version<"3.8"
tifffile>=2020.9.30
tqdm
typing-extensions;python_version<"3.11"
typing-extensions
utm
14 changes: 3 additions & 11 deletions sentinelhub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
monitor_batch_statistical_job,
opensearch,
)
from .api.fis import HistogramType
from .api.ogc import CustomUrlParam
from .api.opensearch import get_area_dates, get_area_info, get_tile_info, get_tile_info_id
from .areas import (
BatchSplitter,
Expand All @@ -41,17 +43,7 @@
UtmZoneSplitter,
)
from .config import SHConfig
from .constants import (
CRS,
CustomUrlParam,
HistogramType,
MimeType,
MosaickingOrder,
ResamplingType,
ServiceType,
ServiceUrl,
SHConstants,
)
from .constants import CRS, MimeType, MosaickingOrder, ResamplingType, ServiceType, ServiceUrl, SHConstants
from .data_collections import DataCollection
from .data_collections_bands import Band, Unit
from .download import (
Expand Down
2 changes: 1 addition & 1 deletion sentinelhub/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of the sentinelhub package."""

__version__ = "3.8.2"
__version__ = "3.8.3"
7 changes: 1 addition & 6 deletions sentinelhub/api/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
Module implementing some utility functions not suitable for other utility modules
"""
import sys
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass, field
from datetime import datetime
Expand All @@ -11,6 +10,7 @@
from dataclasses_json import CatchAll, LetterCase, Undefined
from dataclasses_json import config as dataclass_config
from dataclasses_json import dataclass_json
from typing_extensions import Protocol

from ..base import FeatureIterator
from ..config import SHConfig
Expand All @@ -20,11 +20,6 @@
from ..types import JsonDict
from .utils import datetime_config, remove_undefined

if sys.version_info < (3, 8):
from typing_extensions import Protocol
else:
from typing import Protocol # pylint: disable=ungrouped-imports


class SentinelHubService(metaclass=ABCMeta):
"""A base class for classes interacting with different Sentinel Hub APIs"""
Expand Down
12 changes: 4 additions & 8 deletions sentinelhub/api/batch/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,28 +533,24 @@ def evalscript(self) -> str:
return self.process_request["evalscript"]

@property
def bbox(self) -> BBox:
def bbox(self) -> Optional[BBox]:
"""Provides a bounding box used by a batch request
:return: An area bounding box together with CRS
:raises: ValueError
"""
bbox, _, crs = self._parse_bounds_payload()
if bbox is None:
raise ValueError("Bounding box is not defined for this batch request")
return BBox(bbox, crs)
return None if bbox is None else BBox(bbox, crs) # type: ignore[arg-type]

@property
def geometry(self) -> Geometry:
def geometry(self) -> Optional[Geometry]:
"""Provides a geometry used by a batch request
:return: An area geometry together with CRS
:raises: ValueError
"""
_, geometry, crs = self._parse_bounds_payload()
if geometry is None:
raise ValueError("Geometry is not defined for this batch request")
return Geometry(geometry, crs)
return None if geometry is None else Geometry(geometry, crs)

def _parse_bounds_payload(self) -> Tuple[Optional[List[float]], Optional[list], CRS]:
"""Parses bbox, geometry and crs from batch request payload. If bbox or geometry don't exist it returns None
Expand Down
7 changes: 1 addition & 6 deletions sentinelhub/api/batch/statistical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,20 @@
"""
import datetime as dt
import logging
import sys
from dataclasses import dataclass, field
from typing import Any, Optional, Sequence, Union

from dataclasses_json import CatchAll, LetterCase, Undefined
from dataclasses_json import config as dataclass_config
from dataclasses_json import dataclass_json
from typing_extensions import NotRequired, TypedDict

from ...types import Json, JsonDict
from ..base_request import InputDataDict
from ..statistical import SentinelHubStatistical
from ..utils import datetime_config, enum_config, remove_undefined
from .base import BaseBatchClient, BaseBatchRequest, BatchRequestStatus, BatchUserAction

if sys.version_info < (3, 11):
from typing_extensions import NotRequired, TypedDict
else:
from typing import NotRequired, TypedDict # pylint: disable=ungrouped-imports

LOGGER = logging.getLogger(__name__)

BatchStatisticalRequestType = Union[str, dict, "BatchStatisticalRequest"]
Expand Down
4 changes: 3 additions & 1 deletion sentinelhub/api/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
import datetime as dt
from typing import Any, Dict, Iterable, List, Optional, Union

from typing_extensions import Literal

from ..base import FeatureIterator
from ..data_collections import DataCollection, OrbitDirection
from ..geometry import CRS, BBox, Geometry
from ..time_utils import parse_time, parse_time_interval, serialize_time
from ..types import JsonDict, Literal, RawTimeIntervalType, RawTimeType
from ..types import JsonDict, RawTimeIntervalType, RawTimeType
from .base import SentinelHubService
from .utils import remove_undefined

Expand Down
14 changes: 13 additions & 1 deletion sentinelhub/api/fis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""
import datetime
import warnings
from enum import Enum
from typing import Any, List, Optional, Union

from ..constants import HistogramType, MimeType, RequestType, ServiceType
from ..constants import MimeType, RequestType, ServiceType
from ..download import DownloadRequest
from ..exceptions import SHDeprecationWarning
from ..geometry import BBox, Geometry
Expand All @@ -14,6 +15,17 @@
from .wfs import WebFeatureService


class HistogramType(Enum):
"""Enum class for types of histogram supported by Sentinel Hub FIS service
Supported histogram types are EQUALFREQUENCY, EQUIDISTANT and STREAMING
"""

EQUALFREQUENCY = "equalfrequency"
EQUIDISTANT = "equidistant"
STREAMING = "streaming"


class FisRequest(OgcRequest):
"""``Deprecated - use Statistical API instead!``
Expand Down
Loading

0 comments on commit c320ff6

Please sign in to comment.