## Saturday, 3 May 2014

### Using median filters in quicklook plots

When we make our plots of spectrum vs. time, we often use a median filter to improve the contrast. The reason for the median filter is that the amplifiers have a certain spectral response associated with them. What you are interested in is the proportional variation of the signal with respect to what it would be if there was no signal.

You can do this by really careful bandpass calibration, but for "quicklook" plots, dividing by the median works and it is very quick. So that's what I use for these plots that I put on the web.
 Some subband statistics with a median filter.

 The same data, but without the filter.

The Python code fragment looks like this:

```        # Determine the median
med=np.median(data, axis=1)

# Apply the median to the data
for i in xrange(data.shape[1]): data[:,i] /= med```

Here, "data" is a 2D array with the axes being subband and time.

If you didn't use a median filter, you would expect to see a strong band at about subband 300 (approx. 55-60 MHz). This is due to the peak response of the amplifiers at that region (EXAMPLE). By using the median filter, you remove this bias.

Of course, you still need to be careful. The median filter relies on their being a stable background and more background than signal. In the first plot above, there is a slight negative band around 55-60 MHz, as there was probably a bit too much signal, thus skewing the data. For the purposes of seeing the features, it is not too much of a problem though.

The only way to really do this is with a full bandpass calibration but, as mentioned, for a quicklook the median filter gives you a good, easy, high-contrast plot.