marvin
marvin copied to clipboard
Override numpy ufuncs for Tools
Is your feature request related to a problem? Please describe.
Using NumPy universal functions (ufunc) on Tools objects only applies the function to the value
attribute and does not do ivar propagation. PR #488 raises a NotImplementedError
to alert the user if they try to use any ufunc besides np.log10
.
Describe the solution you'd like
- Override
__array_ufunc__
inMarvinToolsClass
or each Galaxy Tools class to do ivar (and potentially unit) propagation. - Add
_[func]_ivar
methods to do the ivar propagation.
Additional context
- Must handle cases where
ivar
and/ormask
areNone
. - Need to figure out how to generically pass in ivars and values to the correct
_[func]_ivar
method (could try something like[getattr(it, 'ivar') for it in inputs]
where inputs areMap
s). - Potential use cases:
- Dividing a data cube by a spectrum.
- Dividing a map by an analysis property.