https://github.com/astrofrog/nddata-experiments
Experiments with NDData and subclasses
https://github.com/astrofrog/nddata-experiments
Last synced: 24 days ago
JSON representation
Experiments with NDData and subclasses
- Host: GitHub
- URL: https://github.com/astrofrog/nddata-experiments
- Owner: astrofrog
- Created: 2019-12-12T20:00:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-07T13:09:10.000Z (over 6 years ago)
- Last Synced: 2026-05-24T07:42:13.717Z (about 2 months ago)
- Language: Jupyter Notebook
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Experiments with Converting NDData Types
The objective of this experiment is to provide a protocol for converting
between different subclasses of NDData. So a function designed for a specific
class like `Spectrum1D` can also accept any other NDData subclass by providing
a `Spectrum1D.__from_nddata__` method which takes any `NDData` subclass and
returns a `Spectrum1D`. So specifc to `Spectrum1D` it could reorder the array
to have the spectral dimension last.
The decortator provided in this repo then calls this same `__from_nddata__`
method on the input type after the function is called, so the orginal type is
retuned to the user after the function is called.
For an implementation of `__from_nddata__` see
[this](https://github.com/Cadair/sunpy/commit/247f90a4540caf393170a0d217a128336fd407b6)
commit in SunPy.