make_median_image

jwst.clean_flicker_noise.tso_median_image.make_median_image(input_model, rateints_model, soss_refmodel=None)[source]

Make a scaled median image across integrations to subtract before cleaning.

The procedure is:

  1. Subtract a reference background from the input ramp and rate data (NIRISS SOSS only).

  2. Compute a representative flux for scaling for each integration from the rate data.

    1. For TSO spectral modes, extract a spectrum from a simple box and compute the whitelight flux for each integration.

    2. For TSO imaging modes, sum the flux over an aperture at the expected source location for each integration.

    3. For any other mode, take the median of the flux in each integration.

  3. Median combine all data across integrations to make a median ramp or image.

  4. Scale the median image by the representative flux for each integration.

  5. Add the subtracted background level to the median image (NIRISS SOSS only).

Parameters:
input_modelRampModel or CubeModel

Ramp or rateints model to be cleaned.

rateints_modelCubeModel

Draft rateints model corresponding to the input model. May be the same as input_model.

soss_refmodelPastasossModel, optional

Used to identify NIRISS SOSS traces for box extraction. If not provided, a default model will be retrieved.

Returns:
scaled_medianndarray

The scaled median image to subtract, matching the dimensions of the input model.

Raises:
ValueError

If the input does not have multiple integrations or extracted fluxes are all invalid.