Skip to content

Improvements to dealing with masked/nonfinite data in Specreduce operations #192

@cshanahan1

Description

@cshanahan1

This issue is meant to be a catchall issue to summarize meetings and internal tickets at Space Telescope on the topic of improving masks / treatment of NaNs in data across the package. Link any related issues here, and the floor is open for discussion on this!

Current issue(s) with masking

  • In both Horne and Boxcar extract, 2D masks are allowed as input on NDData. However, these masks are then collapsed to 1D and entire columns are excluded in the presence of one NaN. This has been creating issues for JWST data which are littered with NaNs, so there should be an options to treat this to avoid holes in extractions/traces. (Improper use of mask in HorneExtract #167)

  • In FitTrace, fits to individual columns within a bin filter masked values, and fall back to an the 'all-bin fit' when fully masked (which is different default behavior than Extract). This can produce strange results, and would benefit from additional masking options (interpolation, or setting to 0).

Options for treating NaNs

In all operations where masking is relevant (trace / extract at least), provide options for treatment of NaNs:

  1. When possible, filter nonfinite values before computation (e.g in FitTrace).
  2. Omit columns with nonfinite values when the mask is collapsed from 1D to 2D (current behavior for Extract)
  3. Have a fill value of 0 for non-finite values
  4. Interpolate between good values.

Proposal:

  • New arg mask_treatment on all operations (at least extractions, fit trace)
  • options = ['filter', 'omit', interpolate', 'zero-fill'], set to either 'filter' or 'omit' to maintain current behavior as default for each operations
    extract = specreduce.extract.HorneExtract(image-bg, trace, variance=var_array, nan_treatment='zero-fill')

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions