- 
                Notifications
    You must be signed in to change notification settings 
- Fork 51
feat: Add CoordArray dimensional arrays with coordinate support #1086
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: main
Are you sure you want to change the base?
Conversation
## Summary
This PR introduces CoordArray, a new dimensional array type that extends AbstractDimArray to support both dimension coordinates (for indexing and alignment) and non-dimension coordinates (for metadata and spatial information).
## Key Features
🚀 Intuitive Construction Syntax
da = CoordArray(
    data, 
    (time_dim, x_dim, y_dim, z_dim),
    coords=(; 
        latitude = ((X, Y), lat_grid),
        longitude = ((X, Y), lon_grid),
        elevation = ((Z,), elevation)
    ),
    name="temperature"
)
🔄 Automatic Coordinate Slicing
When indexing a CoordArray, coordinates are automatically sliced to match:
subset = da[X(1:2), Y(2:3), Ti(At(DateTime(2020,1,5)))]
# coordinates are automatically sliced: lat_grid[1:2, 2:3], etc.
Co-Authored-By: Claude [email protected]
    | Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@           Coverage Diff           @@
##             main    #1086   +/-   ##
=======================================
  Coverage        ?   85.84%           
=======================================
  Files           ?       56           
  Lines           ?     5370           
  Branches        ?        0           
=======================================
  Hits            ?     4610           
  Misses          ?      760           
  Partials        ?        0           ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
| Hang on a bit... we really try not to introduce new array types, because then your functionality is not available to Rasters.jl or YAXArrays.jl or the other major dependents of this package. Basically  It also wont work in DimStack or DimTree without an explosion of new CoordStack, CoordTree etc etc objects. So we need to build this functionality into the structure of the dimensions, then its generic. I do like how simple the  But if we can do it with just the  This means inverting the relationships in your coords objects and stuffing the extra dimensions into fields on the lookups of the main  (And I want to say otherwise this is a great contribution I'm honestly sorry to put the brakes on it like this!! But this package really differentiates itself from AxisArrays.jl, AxisKeys.jl and the other options by intentionally acting as the abstract infrastructure for an ecosystem of other packages with more specific goals. The original reason to write DD at all was that I couldn't extend the array or lookup types in the other package to add my own fields and method dispatches for functionality, plotting, etc specific to spatial data in Rasters.jl) | 
| Yes I understand. I am also concerned about the design here (so put into a draft and open space for discussion). I have tried to play with  I am wondering why it won't work with DimStack or DimTree, since it's just another  | 
| Yeah, the interface on these things could be improved. Did you read the tests? As for why it won't work, both DimStack and DimTree decompose their content DimArrays to the parent objects, the dims Tuple, and lists if dims and metadata for each layer. The reason for this is consistency: there can only be one source of truth for a dimension. For example, if one layer has cords and the other does not, what would indexing with coord values mean? And what dimensions columns go into  There are endless problems like this if DimStack is a collection of DimArray | 
Summary
This PR introduces CoordArray, a new dimensional array type that extends AbstractDimArray to support both dimension and non-dimension coordinates.
Key Features
🚀 Intuitive Construction Syntax
🔄 Automatic Coordinate Slicing
When indexing a CoordArray, coordinates are automatically sliced to match: subset = da[X(1:2), Y(2:3), Ti(At(DateTime(2020,1,5)))] # coordinates are automatically sliced: lat_grid[1:2, 2:3], etc.
Co-Authored-By: Claude [email protected]