Master Classes 

of

Astrophotography

 

 

 

Gain and Read Noise

Published 01/31/2019

 

Learn a little about Poisson Noise and calculate the Gain and Read noise of your detector. These concepts pervade image processing generally and are used in some Pixinsight tools.  This lesson demonstrates the use of the BasicCCDParameters script. See below the video for more information. 

UPDATE: An easier tool is now available. In Scripts under "Noise Reduction" use the MureDenoise Dectector Settings script. It uses two biases and two flats exactly as I demonstrate.

 

 

Download the Gain and Readnoise calculator (Excel File)

Python Script:

You must know how to run a python program. Simply put files named "flat1.fit, flat2.fit,bias1.fit,bias2.fit" in the same directory you run the script and the console output will show the Gain and Readnoise. 

 

#!python
#
#Usage:
# Learning Numpy stuff
# Given two bias files named bias1.fit and bias2.fit as well as
# two flat files named flat1.fit and flat2.fit
# this program computes the Gain and Readnoise of the CCD camera

import numpy as np
import math
from astropy.io import fits

def main():

#Read in Fits files
bias1 = fits.getdata('bias1.fit')
bias2 = fits.getdata('bias2.fit')
bias1 = bias1.astype(np.float)
bias2 = bias2.astype(np.float)
flat1 = fits.getdata('flat1.fit')
flat2 = fits.getdata('flat2.fit')
flat1 = flat1.astype(np.float)
flat2 = flat2.astype(np.float)


#Calculate average of Biases and Flats and their differences.
mean_flat1 = flat1.mean()
mean_flat2 = flat2.mean()
mean_bias1 = bias1.mean()
mean_bias2 = bias2.mean()
bias_diff = np.subtract(bias1, bias2)
flat_diff = np.subtract(flat1,flat2)
flat_diff_std = np.std(flat_diff)
bias_diff_std = np.std(bias_diff)

#Construct and calculate Gain and Readnoise
top = (mean_flat1 + mean_flat2) - (mean_bias1 + mean_bias2)
bottom = (np.power(flat_diff_std,2)) - (np.power(bias_diff_std,2))
Gain = top/bottom
Readnoise = (Gain * bias_diff_std / math.sqrt(2))

print("\nThe Mean value of Flat1 is %.2f ADU and Flat2 is %.2f ADU .\n" % (mean_flat1,mean_flat2))
print("The Mean value of Bias1 is %.2f ADU and Bias2 is %.2f ADU .\n" % (mean_bias1,mean_bias2))
print("The standard deviation of the Flat difference image is %.2f .\n" % flat_diff_std)
print("The standard deviation of the Bias difference image is %.2f .\n" % bias_diff_std)
print("The Gain for this camera given these files is %.2f electrons per ADU.\n" % Gain)
print("The Readnoise is %.2f .\n" % Readnoise)

# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
main()