Spitzer Documentation & Tools
MOPEX User's Guide

6.5.8        APEX Modules: Detect MedFilter

Command Line Equivalent: run_detect_medfilter

Default Output Directory: <output_dir>/Medfilter-apex

Depends On: Mosaic Interpolate

Relevant Pipelines: All

 

PURPOSE

This module is an instance of the same MedFilter that is run during outlier rejection in the Mosaic pipeline. In this case, it performs the background subtraction of the mosaicked image (or tiles), which will be used for source detection. There are two options - the Median case (default) and the Sbkg case, which uses a background estimate like that of SExtractor.

 

INPUT

Window X, Y: (int) the X, Y size in input pixels of the window used to compute the background value.

 

Outliers / Window: (int) the number of high outlier pixels rejected from the X*Y window when computing the Median background. For a very crowded field, the fraction of rejected pixels should be higher than for a less crowded field. Values of a few percent should be acceptable for uncrowded fields. If Outliers / Window is set too high, the background will be under-estimated.

 

Min Good Pixels in Window: (int) The minimum number of good (non-NaN, non-masked) pixels needed to compute the median. This parameter should generally not need to be adjusted. If insufficient good pixels are present, the background is recorded as "missing" and the "missing" output pixel is replaced by interpolation of its neighbors if possible.

 

Min Good Neighbors Number: (int) The minimum number of good neighbor pixels needed to perform the replacement of "missing" output pixels. This parameter should generally not need to be adjusted.

 

Use SExtractor background estimation: (int) A value of 1 invokes the Sbkg background estimate based on SExtractor. Any other value gives the default Median estimate.

 

SExtractor background filter size: (int) Median filter box size for the Panels when this option is set. A value less than 2 means no filtering. If greater than the minimum number of panels across an image, it will use the minimum.

 

Med Filter output subdirectory: The subdirectory of <output_dir> that you wish to use for the output files. Default is Medfilter-apex.

 

COMMAND LINE INPUT

&DETECT_MEDFILTER

 Window_X = 45,

 Window_Y = 45,

 N_Outliers_Per_Window = 50,

 Min_Good_Pixels_In_Window = 9,

 Min_GoodNeighbors_Number = 4,

 Max_Bad_Pixels_OutputImage = 100,

 Sbkg_Filt_Size_for_Med = 1,

 Use_Sbkg_for_Med = 1,

&END

In Global Parameters:

MEDFILTER_DIR = Medfilter-apex

 

Max_Bad_Pixels_OutputImage: (int; command line only) The maximum number of allowed bad (NaN) pixels in the output image.

 

OUTPUT

Generated FITS (*_Image_minback.fits in Multiframe or mosaic_minus_median_detect.fits in Single Frame): The output is the background subtracted mosaic image (or tiles). In Single Frame mode, the mosaic is written to the main output directory, but in Multiframe mode the tiles are stored in the Coadd-apex subdirectory.

 

DISCUSSION

The module is run on the detection image. In Single Frame pipelines, this is the input image. In Multiframe pipelines, the mosaic may be a single image produced during the Mosaic or APEX pipeline, or it may be the several tiles produced by Mosaic CoAdder.

 

With the default Median option, the program computes a background value using the median of a running rectangular window of Window X by Window Y pixels, after omitting the Outliers / Window highest pixels. This is done for each pixel so can be very slow.

 

If Use SExtractor background estimation is set, the module switches to the Sbkg background estimation based on that of SExtractor (Bertin and Arnouts, AASupp 117, 393, 1996). The image is divided into Panels with size given by Window X(Y). In each Panel, iterative clipping is used to find a single estimate of the background in the Panel. You can optionally median filter the Panel background values, e.g. to avoid ones where bright objects skewed the background estimate. The median filter size is given by SExtractor background filter size. It then interpolates the Panel values to find the background at each pixel. This is much faster than calculating the median of a big window at each pixel.

 

Both background estimates generally give reasonable results, but if the data volume is large, the Sbkg option is strongly recommended, as it is much faster. It also does not require an estimate of Outliers / Window.

 

There is a minimum required number of good (not-NaN and not marked by any mask) pixels per window Min Good Pixels In Window. If the number of good pixels is below this threshold then the corresponding pixel in the output image is marked as a "missing" pixel. When the median calculation is finished, the values of the marked pixels are interpolated from the neighboring pixels for which the median has been found. In order to do so the program scans around the pixel in question and accumulates values of good pixels. When the number of accumulated values reaches or exceeds the minimum number given by the input parameter Min Good Neighbors Number the program finds the average and outputs this value for the pixel in question.

 

The same module is typically run twice in the APEX flow. In general, the input parameters for Detect Medfilter can be "tighter" than for Extract Medfilter, i.e. smaller window and number of outliers, since the goal is detection of a peak, not the best estimate of the background.