marvin icon indicating copy to clipboard operation
marvin copied to clipboard

Override numpy ufuncs for Tools

Open bretthandrews opened this issue 6 years ago • 0 comments

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

  1. Override __array_ufunc__ in MarvinToolsClass or each Galaxy Tools class to do ivar (and potentially unit) propagation.
  2. Add _[func]_ivar methods to do the ivar propagation.

Additional context

  • Must handle cases where ivar and/or mask are None.
  • 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 are Maps).
  • Potential use cases:
    • Dividing a data cube by a spectrum.
    • Dividing a map by an analysis property.

bretthandrews avatar Jul 25 '18 19:07 bretthandrews