SNRCalc

SNRCalc plugin

Signal-to-Noise Ratio (SNR) and Surface Background Ratio (SBR) calculations on an image.

Plugin Type: Local

SNRCalc is a local plugin, which means it is associated with a channel. An instance can be opened for each channel.

Usage

This plugin is used to calculate SBR and SNR on an image, as follow.

SBR is as defined by Ball (Acton 2015, private communications), “Take the median value of the pixels within the image. In the case of a defocused spot, this is just the median value within the ‘top hat’ portion of the image. Next, take the standard deviation of the pixels that are clearly in the background, that is, have no incident photons on them. Take the ratio of these two quantities, and you have the signal-to-background ratio.”

Given selected science (\(S\)) and background (\(B\)) regions:

\[\mathrm{SBR} = \frac{\mathrm{MEDIAN}(S)}{\mathrm{STDEV}(B)}\]

For the science region above, as long as the image has an accompanying error array (e.g., the ERR extension), its SNR can also be calculated:

\[ \begin{align}\begin{aligned}a = \frac{S}{\mathrm{ERR}}\\\mathrm{SNR}_{\mathrm{min}} = \mathrm{MIN}(a)\\\mathrm{SNR}_{\mathrm{max}} = \mathrm{MAX}(a)\\\overline{\mathrm{SNR}} = \mathrm{MEAN}(a)\end{aligned}\end{align} \]

While SNR is more popular, SBR is useful for images without existing or reliable error values. User may define a minimum limit for SBR check, so that the GUI can provide a quick visual indication on whether the selected region achieves the desired SBR or not. As part of the statistics, mean background value is also provided albeit not used in SBR nor SNR calculations. Optionally, if data quality (DQ) extension is available, pixels marked as “not good” can be excluded from calculations as well.

It also supports saving/loading parameters to/from JSON file. Calculated values can be saved in the image header using the “Update HDR” button. The image with updated header only exists in the Ginga cache until it is forced out by viewing other images; to save it, use SaveImage (Save File).

It is customizable using ~/.ginga/plugin_SNRCalc.cfg, where ~ is your HOME directory:

#
# SNRCalc plugin preferences file
#
# Place this in file under ~/.ginga with the name "plugin_SNRCalc.cfg"

# Color of signal region for SBR (and SNR)
sbrcolor = 'blue3'

# Color of background region for SBR only
sbrbgcolor = 'magenta'

# Signal calculation parameters. Can also be changed in the GUI.
# sigtype can be 'box', 'circle', or 'polygon'
sigtype = 'circle'

# Background calculation parameters. Can also be changed in the GUI.
bgradius = 200
annulus_width = 10
sigma = 1.8
niter = 10

# This is the min SBR value used unless set_minsbr() method is reimplemented
# in a subclass.
default_minsbr = 100

# If set to True, only use good pixels for calculations.
# This is only applicable if there is an associated DQ extension.
# Can also be changed in the GUI.
ignore_bad_pixels = False