Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve accessories #170

Merged
merged 5 commits into from
Jan 30, 2025
Merged

Preserve accessories #170

merged 5 commits into from
Jan 30, 2025

Conversation

Ariana-B
Copy link
Contributor

@Ariana-B Ariana-B commented Sep 3, 2024

See #168
Assume that any assets that are not bands are accessories, and make sure they are captured in the Dataset metadata doc

Copy link

github-actions bot commented Sep 3, 2024

@github-actions github-actions bot temporarily deployed to pull request September 3, 2024 04:28 Inactive
@alexgleith alexgleith requested a review from Kirill888 September 3, 2024 06:15
Copy link
Contributor

@alexgleith alexgleith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I'm happy to approve, but I think we should wait for Kirill before we merge.

@github-actions github-actions bot temporarily deployed to pull request January 22, 2025 07:07 Inactive
@Ariana-B Ariana-B force-pushed the preserve_accessories branch from 7856c5e to 679e34e Compare January 22, 2025 07:10
@github-actions github-actions bot temporarily deployed to pull request January 22, 2025 07:12 Inactive
@Ariana-B
Copy link
Contributor Author

@Kirill888 could you please review

@@ -681,6 +682,9 @@ def _get_grid(grid_name: str, asset: pystac.asset.Asset) -> GeoBox:
asset = _assets.get(asset_name)
if asset is None:
continue
# the assets that aren't bands should be accessories
if asset_name in _acc_names:
_acc_names.remove(asset_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why start full then remove?
Let's start empty and add as we go instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I can't think of a better way of determining which assets are accessories other than by discounting the ones we know to be bands. Instead of _acc_names I could define a list of band_names and then do a set difference, but I don't think that's a cleaner solution than the current one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • remove is O(n), repeated in a O(n) loop, so this is O(n^2) operation after this change

I'd rather this was a set operation, this also makes it easier to read to me, as it would be a single line that fully defines what _acc_names is, rather than currently where you start with "all asset names" then need to search code below to understand that this then becomes "all asset names except for data assets". Also if asset_name in _acc_names: will always be true in this logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair; updated.

@Kirill888
Copy link
Member

@Ariana-B can you please add code to strip function

odc-stac/odc/stac/model.py

Lines 394 to 398 in b46d41c

def strip(self) -> "ParsedItem":
"""
Copy of self but with stripped bands.
"""
return replace(self, bands={k: band.strip() for k, band in self.bands.items()})

to set accessories to an empty dict

@github-actions github-actions bot temporarily deployed to pull request January 28, 2025 04:00 Inactive
@Ariana-B Ariana-B requested a review from Kirill888 January 29, 2025 23:50
@Kirill888 Kirill888 merged commit 8b2e5a0 into develop Jan 30, 2025
25 checks passed
@Kirill888 Kirill888 deleted the preserve_accessories branch January 30, 2025 01:31
@Kirill888
Copy link
Member

Thanks for this @Ariana-B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants