Skip to content

Commit

Permalink
Merge pull request #35 from GEOSYS/dev
Browse files Browse the repository at this point in the history
v0.0.3
  • Loading branch information
nkarasiak authored Dec 15, 2023
2 parents 24537a2 + 13bc69d commit 7234813
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.3] - 2023-12-15

### Added

- Only query assets directly avaible in the search items (better performance).

## [0.0.2] - 2023-12-15

### Fixed

- Missing json due to pypi installation.
- Multisensors datacube now support `stackstac`
- Multisensors datacube now support `stackstac`.

## [0.0.1] - 2023-12-15

Expand Down
36 changes: 24 additions & 12 deletions earthdaily/earthdatastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,14 @@ def datacube(
raise ValueError(
f"Specified mask '{mask_with}' is not available. Currently available masks provider are : {mask._available_masks}"
)

elif assets is not None:
mask_with = mask._native_mask_def_mapping.get(collections[0], None)
assets.append(mask_with)
if mask_with == "ag_cloud_mask":
search_kwargs = self._update_search_kwargs_for_ag_cloud_mask(
search_kwargs, collections[0]
)

if intersects is not None:
intersects = cube_utils.GeometryManager(intersects).to_geopandas()
items = self.search(
Expand Down Expand Up @@ -559,18 +562,7 @@ def datacube(
if mask_with:
if clear_cover and mask_statistics is False:
mask_statistics = True
warnings.warn(
"Forcing mask_statistics in order to filter by clear coverage.",
category=Warning,
)
if mask_with == "native":
mask_with = mask._native_mask_def_mapping.get(collections[0], None)
if mask_with is None:
raise ValueError(
f"Sorry, there's no native mask available for {collections[0]}. Only these collections have native cloudmask : {list(mask._native_mask_mapping.keys())}."
)
mask_kwargs = dict(mask_statistics=mask_statistics)

if mask_with == "ag_cloud_mask":
acm_items = self.ag_cloud_mask_items(items)
acm_datacube = datacube(
Expand Down Expand Up @@ -623,6 +615,23 @@ def datacube(

return xr_datacube

def _update_search_for_assets(self, assets):
fields = {
"include": [
"id",
"type",
"collection",
"stac_version",
"stac_extensions",
"collection",
"geometry",
"bbox",
"properties",
]
}
fields["include"].extend([f"assets.{asset}" for asset in assets])
return fields

def search(
self,
collections: str | list,
Expand All @@ -631,6 +640,7 @@ def search(
post_query=None,
prefer_alternate=None,
add_default_scale_factor=False,
assets=None,
**kwargs,
):
"""
Expand Down Expand Up @@ -734,6 +744,8 @@ def search(
}
"""
if assets is not None:
kwargs["fields"] = self._update_search_for_assets(assets)
if isinstance(collections, str):
collections = [collections]
if bbox is None and intersects is not None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"rededge78": "rededge3",
"watervapor": "wvp",
"native-cloud-mask": "scl",
"native": "scl",
"aot": "aot",
"visual": "visual",
"aot-jp2": "aot-jp2",
Expand Down Expand Up @@ -52,6 +53,7 @@
"swir16": "swir16",
"swir22": "swir22",
"native-cloud-mask": "qa_pixel",
"native": "qa_pixel",
"SAA": "SAA",
"SZA": "SZA",
"VAA": "VAA",
Expand All @@ -72,6 +74,7 @@
"lwir": "lwir11",
"lwir11": "lwir11",
"native-cloud-mask": "qa_pixel",
"native": "qa_pixel",
"qa": "qa",
"SAA": "SAA",
"SZA": "SZA",
Expand Down Expand Up @@ -111,6 +114,7 @@
"rededge74": "image_file_SRE_B09",
"rededge78": "image_file_SRE_B10",
"native-cloud-mask": "detailed_cloud_mask",
"native": "detailed_cloud_mask",
"mask": "mask",
"license": "license",
"stac_json": "stac_json",
Expand Down
3 changes: 0 additions & 3 deletions examples/compare_scale_s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ def get_cube(rescale=True):
# ----------------------------------------------------

pivot_cube = get_cube(rescale=False) * 0.0001
plt.show()

#####################################################################da#########
# Plots cube with SCL with at least 50% of clear data
# ----------------------------------------------------


pivot_cube.to_array(dim="band").plot.imshow(vmin=0, vmax=0.33, col="time", col_wrap=3)

plt.show()

#####################################################################da#########
Expand Down

0 comments on commit 7234813

Please sign in to comment.