-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add augment_from_xarray for EOProduct #113
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
base: develop
Are you sure you want to change the base?
Conversation
7d40d45 to
556fc1a
Compare
556fc1a to
9ec4e69
Compare
eodag_cube/api/product/_product.py
Outdated
| dimensions = {} | ||
| variables = {} | ||
|
|
||
| for _, ds in xd.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for _, ds in xd.items(): | |
| for ds in xd.values(): |
eodag_cube/api/product/_product.py
Outdated
|
|
||
| for _, ds in xd.items(): | ||
| # Dimensions | ||
| for dim_name, _ in ds.sizes.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for dim_name, _ in ds.sizes.items(): | |
| for dim_name in ds.sizes.keys(): |
eodag_cube/api/product/_product.py
Outdated
| for var_name, var in ds.data_vars.items(): | ||
| variables[str(var_name)] = {"dimensions": list(var.dims), "type": "data"} | ||
|
|
||
| asset.setdefault("properties", {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put metadata directly at asset level, do not add .properties attribute, see https://github.com/stac-extensions/datacube/blob/main/examples/item_asset.json
eodag_cube/api/product/_product.py
Outdated
| information from its xarray representation. | ||
| :returns: updated EOProduct | ||
| """ | ||
| for asset_key, asset in self.assets.items(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some EOProducts may not have assets. In that case, directly run product.to_xarray() and put metadata in product.properties.
See example https://github.com/stac-extensions/datacube/blob/main/examples/item.json
|
|
||
| return xd | ||
|
|
||
| def augment_from_xarray(self) -> EOProduct: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also add reference_system if available (try reading data from different collections: S2_MSI_L1C, S3_SLSTR_L1RBT, MERIS_ALAMO_L2_V2.2, CAMS_EAC4 https://eodag.readthedocs.io/en/latest/notebooks/tutos/tuto_cds.html)
https://github.com/stac-extensions/datacube/tree/main?tab=readme-ov-file#dimension-object
cb42244 to
2732f2d
Compare
Fixes #112
Add augment_from_xarray function to EOProduct.
It takes values from to_xarray and add cube:dimensions and cube:variables to product properties