AxisArrays.jl
AxisArrays.jl copied to clipboard
Making AxisArray Abstract
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 AxisArray
s 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).
Could you have AxisArray{_,_,NCVar,_}
instead?
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
.
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.