You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SHGrid class is a custom class that was initially designed to support grids of data for use with spherical harmonic transforms, metadata, standard arithemetic operations, spherical harmonic transforms, and simple plotting. Most of these operations are currently supported by the xarray package using the DataArray class. Though SHGrid class instances can be converted to an xarray DataArray, for simplicity, and for additional features that are included in the DataArray class, it might instead be best to do away with the custom SHGrid class, and simply make SHGrid a subclass of DataArray.
Problems to resolve
There are two ways of doing this.
First, you could subclass DataArray, add the custom method .expand() for spherical harmonic transforms, add the metadata in the DataArray attributes, and override the xarray .plot() routine with the custom pyshtools .plot() routine.
Second, as opposed to overriding the xarray .plot() routine, one could instead create a custom shtoolsdataset accessor that would allow the new routines to be called as
The benefit of using an accessor is that the original xarray function remains untouched. The drawback is that the notation is rather heavy, and the user is certain to call grid.plot() many times by accident. At some point in the future DataArray.plot() might do everything that SHGrid.plot() does, but we are not yet to that point.
Lastly, thought should be given to remaining backward compatible with the original SHGrid class. For example, with an xarray DataArray, it will no longer be necessary to have the .lats() and .lons() methods, as the latitudes and longitudes are stored directly in the DataArray class. The choice is thus either to deprecate these old functions or to keep them for backwards compatibility (perhaps without providing documentation to keep this hidden).
If this feature is implemented, this would be released as pyshtools 5.0 if backward compatibility could not be assured.
The text was updated successfully, but these errors were encountered:
Desired feature
The
SHGrid
class is a custom class that was initially designed to support grids of data for use with spherical harmonic transforms, metadata, standard arithemetic operations, spherical harmonic transforms, and simple plotting. Most of these operations are currently supported by the xarray package using theDataArray
class. ThoughSHGrid
class instances can be converted to an xarrayDataArray
, for simplicity, and for additional features that are included in theDataArray
class, it might instead be best to do away with the customSHGrid
class, and simply makeSHGrid
a subclass ofDataArray
.Problems to resolve
There are two ways of doing this.
First, you could subclass
DataArray
, add the custom method.expand()
for spherical harmonic transforms, add the metadata in theDataArray
attributes, and override the xarray.plot()
routine with the custom pyshtools.plot()
routine.Second, as opposed to overriding the xarray
.plot()
routine, one could instead create a custom shtools dataset accessor that would allow the new routines to be called asThe benefit of using an accessor is that the original xarray function remains untouched. The drawback is that the notation is rather heavy, and the user is certain to call
grid.plot()
many times by accident. At some point in the futureDataArray.plot()
might do everything thatSHGrid.plot()
does, but we are not yet to that point.Lastly, thought should be given to remaining backward compatible with the original
SHGrid
class. For example, with an xarrayDataArray
, it will no longer be necessary to have the.lats()
and.lons()
methods, as the latitudes and longitudes are stored directly in theDataArray
class. The choice is thus either to deprecate these old functions or to keep them for backwards compatibility (perhaps without providing documentation to keep this hidden).If this feature is implemented, this would be released as pyshtools 5.0 if backward compatibility could not be assured.
The text was updated successfully, but these errors were encountered: