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

Add support for anemoi-datasets #383

Merged
merged 25 commits into from
May 28, 2024
Merged

Add support for anemoi-datasets #383

merged 25 commits into from
May 28, 2024

Conversation

sandorkertesz
Copy link
Collaborator

@sandorkertesz sandorkertesz commented May 17, 2024

This PR adds support for anemoi-datasets.

Major changes

  1. New properties/methods added to Field:
  • mars_grid
    for a latlon grid returns [dx,dy] otherwise metadata("gridName")
  • mars_area
    returns [north, west, south, east]
  • resolution
       if grid_type in ("reduced_gg", "reduced_rotated_gg"):
           return self.metadata.get("gridName")
    
       if grid_type == "regular_ll":
           x = self.metadata.get("DxInDegrees")
           y = self.metadata.get("DyInDegrees")
           assert x == y, (x, y)
           return x
    
       if grid_type == "lambert":
           x = self.metadata.get("DxInMetres")
           y = self.metadata.get("DyInMetres")
           assert x == y, (x, y)
           return str(x / 1000).replace(".", "p") + "km"
  • grid_points()
    returns (lats, lons)
  • grid_points_unrotated()
  • rotation
       return (
              self.metadata.get("latitudeOfSouthernPoleInDegrees"),
              self.metadata.get("longitudeOfSouthernPoleInDegrees"),
              self.metadata.get("angleOfRotationInDegrees"),
          )
  1. Added new FieldList type: FieldArray. Name should be reviewed since earthkit-data already has ArrayFieldList

  2. Added the FieldCube and Cubelet classes. A version of it already exists in the feature/tensor branch.

  3. The "valid_datetime" metadata key now returns a str instead of datetime.datetime

  4. Add dependency on earthkit-geo

@sandorkertesz sandorkertesz marked this pull request as draft May 17, 2024 12:18
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.63%. Comparing base (08a404b) to head (c94f37d).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #383      +/-   ##
===========================================
- Coverage    89.75%   89.63%   -0.13%     
===========================================
  Files          119      119              
  Lines         7515     7513       -2     
  Branches       662      662              
===========================================
- Hits          6745     6734      -11     
- Misses         640      649       +9     
  Partials       130      130              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sandorkertesz sandorkertesz marked this pull request as ready for review May 22, 2024 10:30
@sandorkertesz sandorkertesz changed the title WIP: add support for anemoi-datasets Add support for anemoi-datasets May 22, 2024
@@ -207,7 +207,7 @@ def _get_custom_key(self, key, default=None, raise_on_missing=True, **kwargs):
if self._is_custom_key(key):
try:
if key == DATETIME:
return self._valid_datetime()
return self._valid_datetime().isoformat()
Copy link
Member

Choose a reason for hiding this comment

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

It feels a little strange to return a str rather than a datetime here. Could the client (anemoi-datasets) not perform the conversion to string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This requires further discussion.

return Remapping(mapping)

return mapping


class Patch(dict):
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have a little description of what Patch is for

from earthkit.data.core.fieldlist import FieldList


class FieldArray(FieldList):
Copy link
Member

Choose a reason for hiding this comment

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

It's not clear to me why we need this, it does not seem to be used in earthkit.data. Is it used directly by anemoi-datasets, and what does it address that the current FieldList does not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

With it you can create a fieldlist out of a set/list of fields. FieldList does not store a list of fields (it is more generic) so cannot do it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is used directly in anemoi-datasets.

return self.metadata.get("gridName")

def mars_area(self):
north = self.metadata.get("latitudeOfFirstGridPointInDegrees")
Copy link
Member

Choose a reason for hiding this comment

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

Not all grids will have these metadata keys (e.g. Lambert), but I guess we'd want to fail for these ones anyway

@sandorkertesz sandorkertesz merged commit f1fddd0 into develop May 28, 2024
82 checks passed
@sandorkertesz sandorkertesz deleted the feature/anemoi branch May 28, 2024 14:44
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