Skip to content

Commit

Permalink
Fix chunks with and without dask
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Nov 1, 2022
1 parent 1c1f611 commit b1c8779
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sarsen/sentinel1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@

from . import datamodel, geocoding

try:
import dask # noqa: F401

DEFAULT_MEASUREMENT_CHUNKS: Optional[int] = 2048
except ModuleNotFoundError:
DEFAULT_MEASUREMENT_CHUNKS = None


def open_dataset_autodetect(
product_urlpath: str,
Expand Down Expand Up @@ -74,22 +81,15 @@ def azimuth_slant_range_grid(
class Sentinel1SarProduct(datamodel.SarProduct):
product_urlpath: str
measurement_group: str
measurement_chunks: Optional[int] = None
measurement_chunks: Optional[int] = DEFAULT_MEASUREMENT_CHUNKS
kwargs: Dict[str, Any] = {}

@property
def measurement(self) -> xr.Dataset:
try:
import dask # noqa: F401

measurement_chunks = self.measurement_chunks or 1024
except ModuleNotFoundError:
pass

ds, self.kwargs = open_dataset_autodetect(
self.product_urlpath,
group=self.measurement_group,
chunks=measurement_chunks,
chunks=self.measurement_chunks,
**self.kwargs,
)
return ds
Expand Down

0 comments on commit b1c8779

Please sign in to comment.