AxisArrays.jl icon indicating copy to clipboard operation
AxisArrays.jl copied to clipboard

Making AxisArray Abstract

Open BobPortmann opened this issue 7 years ago • 3 comments

Not sure if this has been discussed before (a quick search didn't turn up much) but I'm wondering if it is possible to make AxisArray abstract (or have an AbstractAxisArray that AxisArray inherits from) and defining an interface that a new AxisArray type must implement to get the indexing behavior of an AxisArray? I ask because for variables in NetCDF files it seems natural for them to be AxisArrays since all arrays in NetCDF files have the dimension information included in the file. But they have other information (e.g., attributes) that it is natural for a NCVar type to include as well. Thus one could have NCVar <: AbstractAxisArray. This would also allow NCVar to have the option of being lazily read when indexed instead of being completely in memory (NetCDF files can be large).

BobPortmann avatar Aug 11 '17 02:08 BobPortmann

Could you have AxisArray{_,_,NCVar,_} instead?

iamed2 avatar Aug 11 '17 02:08 iamed2

Yes, perhaps. But that would force one to keep a reference to both the NcVar and the AxisArray to be able to get all the functionality that would be available if NcVar was a subtype of AxisArray.

BobPortmann avatar Aug 11 '17 13:08 BobPortmann

I also think AbstractAxisArray would be very useful. I would personally like to create my own custom types that have fixed dimension and axis names. And create plot recipes and other functions on these custom types. While being able to "inherit" all the functionalities of AxisArrays. I'm aware of python projects that subclass xarray in this way.

cmichelenstrofer avatar Jul 03 '23 22:07 cmichelenstrofer