14
AST 325/326 (Fall 2017) Lab #1 V22.9.2017 1 Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday, October 11, 2017, before 11:59 pm EDT 1. Overview This handout provides a description of the activities that we will explore in the first lab. Because we use this first lab to introduce many new skills, especially Python programming, this handout is a straightforward guide that your lab group should follow sequentially. 1.1 Schedule This is a four-week lab with activities and lectures on September 11, 18, 25, and October 2. You should have completed up to Section 4.1 and acquired data for Section 4.2 by September 25 th . By October 2 nd you should aim to reach Section 4.5. Your lab report is due electronically on October 11, 2017 before 11:59 pm EDT. 1.2 Goals Explore physical limitations on the detection of light. Investigate how CCD imaging sensors work and how to manipulate image data. Determine how precisely brightness can be specified, and what determines that precision. Consider how Poisson and Normal distributions can be used to explain measurements. Finally, learn how to calibrate the image sensor to produce measurements in physical units. 1.3 Reading assignments (available online on course website) Linux o To master the first lab, you will need basic Linux system skills so that you can collect data and manipulate files. Python o Work through the Python/IPython tutorials to learn how to use this powerful programming language to compute statistical quantities and make plots. Check out the lab we page and “Getting started” at: § https://www.scipy.org/getting-started.html o Fundamental Python references are: § Numerical computing: http://www.numpy.org § Plotting: http://matplotlib.org Document preparation o You can use the TeX/LaTeX document preparation system to create publication quality reports. Download the examples and make sure that you can generate PDF output. You can then use this example as a template for your first report. Skim the statistics handout on the class web page. 1.4 Key steps You will execute eight key steps in this lab: 1. Familiarize yourself with the CCD image sensor and its adjustable parameters. Learn to acquire and process imaging data using Python. 2. Identify photon detection events using the CCD image sensor and Fe55 soft X-ray source and make plots of the counts per sample versus time.

Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 1

Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday, October 11, 2017, before 11:59 pm EDT

1. Overview This handout provides a description of the activities that we will explore in the first lab. Because we use this first lab to introduce many new skills, especially Python programming, this handout is a straightforward guide that your lab group should follow sequentially. 1.1 Schedule This is a four-week lab with activities and lectures on September 11, 18, 25, and October 2. You should have completed up to Section 4.1 and acquired data for Section 4.2 by September 25th. By October 2nd you should aim to reach Section 4.5. Your lab report is due electronically on October 11, 2017 before 11:59 pm EDT. 1.2 Goals Explore physical limitations on the detection of light. Investigate how CCD imaging sensors work and how to manipulate image data. Determine how precisely brightness can be specified, and what determines that precision. Consider how Poisson and Normal distributions can be used to explain measurements. Finally, learn how to calibrate the image sensor to produce measurements in physical units. 1.3 Reading assignments (available online on course website)

• Linux o To master the first lab, you will need basic Linux system skills so that you can

collect data and manipulate files. • Python

o Work through the Python/IPython tutorials to learn how to use this powerful programming language to compute statistical quantities and make plots. Check out the lab we page and “Getting started” at:

§ https://www.scipy.org/getting-started.html o Fundamental Python references are:

§ Numerical computing: http://www.numpy.org § Plotting: http://matplotlib.org

• Document preparation o You can use the TeX/LaTeX document preparation system to create publication

quality reports. Download the examples and make sure that you can generate PDF output. You can then use this example as a template for your first report.

• Skim the statistics handout on the class web page. 1.4 Key steps You will execute eight key steps in this lab:

1. Familiarize yourself with the CCD image sensor and its adjustable parameters. Learn to acquire and process imaging data using Python.

2. Identify photon detection events using the CCD image sensor and Fe55 soft X-ray source and make plots of the counts per sample versus time.

Page 2: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 2

3. Plot histograms to visualize the statistical properties of different data sets. 4. Compute the mean and standard deviation for your samples and investigate the variability

of the count rate. Explore how the mean and standard deviation vary as the mean counts per sample increases.

5. Compare the observed histograms with the theoretical Poisson probability distribution function.

6. For datasets consisting of multiple sequences compute the mean of the mean (MOM) and the standard deviation of the mean (SDOM). Explore how the MOM and the SDOM vary with the length of the sequences.

7. Determine the conversion gain (e-/ADU) of the CCD image sensor using the Fe55 X-ray spectrum.

8. Write your lab report. 2. Familiarizing yourself with the camera At X-ray, ultraviolet, optical and infrared wavelengths most astronomical instruments employ the photoelectric effect to convert photons into electrons, which can then be counted and recorded. Since the 1930’s astronomers have used photomultiplier tubes, which employ the photoelectric effect in vacuum. Modern detectors are based on the solid-state devices constructed from semiconductor materials. In this lab, we will investigate the properties of a CCD-style integrated circuit that uses the photoelectric effect in silicon to record visible and X-ray light.

Figure 1: Basic image illustrating the photoelectric effect.

The process of photon detection and counting is not perfect—detectors have flaws that introduce noise and various systematic errors into the measurement process. The purpose of this lab is to construct a soft X-ray photon detector using a commercial optical CCD camera, which has had its glass window removed. In the process, you will explore the operation of a CCD sensor, the detection individual photons, and discover the statistics of light. You will carry out X-ray spectroscopy in the process, which will be used to calibrate the CCD camera. 2.1 The CCD image sensor We will use an image sensor based on a CCD (charge-coupled device) integrated circuit. A CCD sensor is a two-dimensional array of pixels where charges are shifted down each column one row at a time to a horizontal shift register. Charge is generated in each pixel by the photoelectric effect in proportion to the number of visible-light photons or the energy of an X-ray photon incident at that location. The charge within pixels in each row is then shifted onto a capacitor and read one pixel at a time. This voltage is then amplified by a preamplifier within the sensor and by another adjustable gain amplifier within the camera. Finally, this analog signal is digitized by an analog-to-digital convertor, and the data is conveyed to a computer.

Page 3: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 3

Figure 2: Analog signal chain for a CCD sensor.

The digital signal is recorded in units known as analog to digital units (ADU) after being amplified by both the sensor and the camera electronics as shown in Figure 1. Assuming that the measuring circuits are linear there is a linear relationship between ADU and the number of photoelectrons collected; this constant of proportionality is known as the gain. The entire CCD array is reset before the start of an exposure by clearing any remaining charge built up on the sensor. This establishes a well-defined charge state at the start of the subsequent exposure. The photo-charge, QPE , is determined by measuring the voltage induced on a capacitor of capacitance, C,

V =QPE C . (1) This voltage is therefore directly proportional to the number of incident visible-light photons or the energy of a single X-ray photon detection. 2.1.1 Point Grey Chameleon3 Camera We use a two-dimensional sensor manufactured by Point Grey comprising a silicon CCD array (Figure 2). This device uses the solid-state photoelectric effect, where a UV/optical photon of sufficient energy (hv > 1.13 eV for silicon at room temperature) creates an electron-hole pair the vicinity of the depletion region of a reverse-biased diode junction. The version of the camera we are using is a monochrome version (see Table 1). The monochrome version will be used in this lab.

Table 1: Point Grey Sensor Properties Specification Value

Sensor type 1/3-inch Model Sony EXview HAD Monochrome CCD ICX445 Pixels count 1288 (H) x 964 (V) – 1.3 Megapixels Pixel size (square) 3.75 µm Digitization Up to12-bit (8-bits are used) Gain Range 0 – 24 dB Shutter Range 0.046 ms – 32 seconds Saturation Capacity ~9000 e-

Page 4: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 4

Figure 3: The Point Grey Chameleon3 image sensor. The light grey area at the center is the

CCD array (4.86mm x 3.62mm).

Figure 4: The C-mount 25-mm camera lens. The lens screws into the camera body. The

designation C on the aperture ring means closed. 2.1.2 Camera Controls The first step of this lab is to log into a Linux laptop and start the FlyCap2 software application. Be sure that the USB cable is plugged into the laptop and the yellow indicator light is illuminated on the back of the camera. When you start FlyCap2, you’ll be asked to select the camera—only one option should be offered. The control window should open with a live display from the camera (be sure that the lens cap is removed). The FlyCap2 tool bar presents some useful options including the camera control window (“Toggle Camera Control Dialog”) and histogram tool. Open the control window and examine the Camera Settings. This is where you control the exposure time, gain (conversion from output voltage to

Page 5: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 5

ADUs), and frame rate. To adjust the parameters manually “uncheck” AUTO besides each setting.

Figure 5: FlyCap2 camera control window. The automatic Brightness and Exposure controls

have been disabled and the effect of those parameters have been turned off, the Shutter (exposure time) is set manually to 32 ms and the gain is set at maximum (24dB).

The Camera Settings panel (Figure 5) lists a number of options including Brightness, Exposure, Gamma, Shutter, Gain and Frame Rate.

• Brightness modifies the display by adding a constant to the data value. • Exposure means auto exposure and controls the Shutter and/or Gain if the AUTO option

if either of these is enabled. • Sharpness either smooths or sharpens the image. This should be turned off for our

measurements. • Gamma effects how images are displayed by introducing a non-linear relation between the

measured signal from the ADC and the value presented in the image. • Shutter determines the exposure time. The exposure time can be adjusted between 0.046

ms – 32 s (Most important parameter). • Gain the gain of the ADC can be commanded and is variable from 0 to 24dB. This adjusts

the external amplifier in the signal chain (Figure 1), and therefore the sensitivity and also the dynamic range of the camera. This is similar to the ISO settings in modern digital cameras (Most important parameter).

• Frame rate determines the maximum rate at which frames are read out. For example, if the frame rate is set to 30 fps (frames per second; default setting) and exposure time is 100ms, then a 10 fps frame rate will be used.

Page 6: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 6

3. Getting Started: Taking and Saving your First Images The first part of the lab activity is about familiarizing yourself with the camera controls and methods for acquiring images. For this activity, you need to install a 25 mm lens (Figure 4) on your camera to take visible-light images of your surrounding scene. You will need to play with the focus knob to get images in focus and adjust the aperture knob to let in more or less light. Make sure all AUTO and ON/OFF checkboxes are turned off. Try to understand how the different parameters (particularly exposure time and gain) affect your measurement. This will be important later when you set up your camera for X-ray photon measurements. The cursor readout (bottom of the live display window) and the histogram tool (Figure 6) can be used to examine the image data values.

Figure 6: (Left) The histogram tool showing a histogram of values centered near the lower-range

of possible values. Note that the “Grey” channel is checked and the y-axis range has been adjusted (Max Percent) to 10% so that the peak is clearly visible. (Right) The histogram tool can

be used to plot rows or columns. On the course website, we have provided a captureImages.py script that can take a sequence of frames from the camera and save them in a specified directory. The image files from the Point Grey camera are saved in an 8-bit uncompressed TIFF format. The live view in the FlyCap software will need to be paused when use this Python script to acquire data. You can always save individual files using the FlyCap software, but not a sequence of files. We have also provided a viewImage.py file as an example of how you can read in and display a TIFF file using matplotlib. 4. Key Lab Activities This section provides the key areas you will need to investigate in this lab and discuss the results of in your lab report. The goal is to understand the properties of the image sensor

For quantitative work make sure that all the AUTO buttons are unchecked and all On/Off buttons are also unchecked (i.e. off). Otherwise the software may vary the exposure time, gain, and frame rate in response to the illumination level, causing unexpected results. Set the gain to maximum to start.

Page 7: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 7

4.1 Measuring image sensor properties The CCD image sensor has a limited dynamic range. The maximum attainable precision of the signal is determined by the number of bits in its analog-to-digital converter (ADC) and the maximum signal it can detect is determined by the well-depth. Both are directly affected by the camera gain setting. Explore how the either the precision and maximum signal is affected by the camera gain setting. Answer the following questions:

• How many bits is the ADC? • At what ADC value does the signal saturate? • What happens to the image information in the saturated regions?

Thermal excitation of electrons in the sensor (dark current) can also be an issue in measurements as it is a signal that is not related to incident photons. Place the lens cap on the camera and explore how the average value changes with longer integration times. Also observe how the image itself changes. Because we are taking long exposures in the next section. We need to pay attention to the effect of dark current. Because it is an additive effect, dark images with the same exposure time can be subtracted from images exposed to light to remove the effect. 4.2 Detecting X-ray photons We are going to use the method of direct detection to observe the X-ray photons in this component of the lab. When the X-ray photon hits the CCD, it generates not one, but several electron-hole pairs. The number of electron-hole pairs the photon generates is proportional to its energy, which is why we can turn our CCD camera into an X-ray spectrometer. The electrons are captured and measured just like they are when we use optical light, but in this case, we will be able to see individual X-ray photons emitted by the Fe55 source! The Fe-55 source you will use has a very low activity of 0.025 milliCurie and is sealed. It is relatively safe to handle. However, only the lab coordinators who are properly trained will physically handle the X-ray source. Do not try to handle it yourself. Do not take the source back with you! I will get into a lot of trouble!

Collect a sequence of images after placing the X-ray source facing the camera sensor. Make sure the camera is in a dark environment. Compare with a sequence of images taken without the source and see if you observe any differences. One way to look for differences is to subtract one image from another. Consider the following questions:

• What do you observe? • If there are changes between the multiple difference images, can you explain why? What

is the reason for using difference images? • Do you observe any negative values, and if so what is the reason?

Note: You will need relatively long exposures (> 1 s) to see a significant number of X-ray photons.

For this section of the lab, you will have to remove the lens as the sensor needs to view the X-ray source directly. Be careful as the sensor is exposed and is very fragile! Do not put your finger into the camera barrel or drop anything on the sensor. If the camera is not in use, please put the supplied camera cover on.

Page 8: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 8

It is important that we set the dynamic range correctly so that the X-ray photon measurements do not saturate the detector. Look at the histogram plot to see if a significant portion of the X-ray photon hits are saturated. If they are, you will need to lower the detector gain and redo the measurement. On the same token, you do not want the X-ray photon hits to have too low values either. Try to adjust the camera gain so that you maximize the dynamic range, i.e. use up as many of the bits of the image value as possible. The camera gain is given in decibel units in the GUI, and you can estimate how much the conversion gain changes using the following equation:

𝑔" 𝑔# = 10(()*+,()*-)/#0 (2) where g1 and g2 are in linear units while gDB1 and gDB2 are in decibel units. Once you have settled on a proper gain setting, now comes the challenge of identifying X-ray photon hits. When an X-ray photon hits a sensor, it does not distinguish between pixel boundaries, and sometimes it does not deposit all of its energy within a single pixel. It appears as if multiple adjacent pixels have experienced X-ray photon hits. To properly carry out a statistical analysis of X-ray photons, we need to find “single pixel” events, which we are certain are from a single X-ray photon. We are effectively counting individual photons here. In order to do this, you will need to write an algorithm that looks at the values of neighbouring pixels around an X-ray photon detection to ensure their values are not elevated as shown by the following diagram:

You need to decide what you consider to be an elevated pixel value. If you pick a very low value, you will aggressively filter out even good single pixel events. If you pick too high of a value, you could let through multi-pixel events. Another way is to only pick events that are above a certain pixel value threshold. If you observe in Figure 6, most events are clustered at high values. This is associated with a bright X-ray emission line (see following paragraph for an explanation). If you set a threshold high enough to only select events that have pixel values associated with this emission line, you are also likely to only pick single pixel events. This is because a multi-pixel event will spread the pixel value over multiple pixels, thereby lowering an individual pixel value below the threshold. Another important piece of information to take advantage of is the number of electrons produced in a pixel from an X-ray photon hit is proportional to its energy:

𝐸2 = 𝑁4×𝑊89 (3) where 𝐸2 is the energy of the photon in eV, 𝑁4 is the number of electrons detected per X-ray photon hit, and 𝑊89 is the electron-hole pair production energy within silicon of 3.66 eV at room temperature (Scholze et al. 1998). This means a 6.5 keV X-ray photon will generate 1776 e- of charge in a silicon detector. The electron-hole pair production energy is a fixed property of materials, though 𝑊 has a slight dependence on temperature. This is different from the energy (1.13 eV) required for an optical photon to create a single electron-hole pair in silicon because the

Page 9: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 9

high energy photons also inject additional energy into modes within the crystal lattice and heat it up. If you are successful in properly filtering the single X-ray photon hits, you should obtain a figure like this which shows the pixel value of each identified single X-ray photon hit. At this point, the pixel value is arbitrary as we do not know the conversion gain. We will come back to that in Section 4.7.

Figure 6: Pixel values of identified single X-ray photon events. The large overdensity of X-ray photon pixel values of 220 is the detection of a bright soft X-ray emission line. Remember that

this plot was generated for a specific camera gain setting I used. Different gain settings will yield a different pixel value.

4.3 Statistics - Plotting histograms and computing the mean and standard deviation Now that we are detecting individual X-ray photons we can attempt to carry out statistical analyses. First, review and understand basic descriptive statistics including mean, standard deviation, and histograms. We will need to obtain sequences for each data set, which are a set of images taken at the same integration time and gain setting. The following plot is the number of single photon events discovered in a sequence of 50 images:

Page 10: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 10

Figure 7: Number of single photon events found in each of the 50 successive images taken observing the Fe55 source. The exposure time of each image is not given.

IPython has all sorts of handy functions in matplotlib and numpy for statistical analysis, e.g., mean for computing mean and hist for plotting histograms. Do not use these! First, we want you understand the basic algorithms—you will not learn these by using a canned routine. Second, you should always exhibit a healthy skepticism about someone else’s program—if you can write the function yourself, you should. Third, we want you to learn Python. By using basic arithmetic operators (+, -, *, /) and primitive functions such as numpy.sum, you can compute these quantities with a few lines of code (and do this faster than it takes to read the appropriate documentation.) For example, to compute the mean try where x is your data array: In [89]: import numpy as np In [90]: m1 = np.sum(x)/(np.size(x)) # first moment <x> = mean In [91]: m2 = np.sum(x*x)/(np.size(x)) # second moment <x^2> In [92]: std = np.sqrt(m2 - m1*m1) # std deviation (<x^2>-<x>^2)^1/2 In [93]: print 'Mean = ', m1 Mean = 4 In [94]: print 'Standard deviation = ',std Standard deviation = 3.60555127546

Although this looks right, something is seriously wrong! What? Making a histogram involves sorting the data into unique categories (binning), and counting the number of occurrences of each of those categories. The following example makes a histogram of the quantity x: In [18]: hmin = 0 # lowest bin in histogram to plot In [19]: hmax = 12 # highest bin in histogram to plot In [20]: hr = np.arange(hmin,hmax+1) # list of bin values In [21]: hist = np.array([np.where(x == i)[0].size for i in hr] ) In [23]: plt.plot(hr,hist,drawstyle='steps-mid')

Figure 8: A histogram (right) for a sequence of data (left).

Page 11: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 11

The power of Python is apparent in two statements that make the histogram. First, we decide the highest and lowest bins we want to sample by setting hmin and hmax and then construct a list of bin values using arange: In [20]: hr = np.arange(hmin,hmax+1) In [21]: hr Out[21]: array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])

The key step in making the histogram is counting the occurrences in each of our bin values, i.e, occurrences of the values in the list [0,1,2…12]. The function where does this as it finds where the array x has certain values, e.g., In [53]: np.where(x == 1) Out[53]: (array([20, 67, 71, 72]),) shows that elements 20, 67, 71, and 72 of x equal 1. The round brackets or parenthesis denote that where returns a Python tuple which is the list of array indices where x==1. The syntax [0] extracts the list as the first element of the tuple, e.g., In [81]: np.where(x == 1)[0] Out[81]: array([20, 67, 71, 72])

We do not care where the instances of x==1 occur, only how many occurrences there are. We can count these occurrences by using the size attribute: In [116]: np.where(x == 1)[0].size Out [116]: 4 Python often has multiple many ways to achieve the same thing; equally functional would be: In [129]: np.size(np.where(x==1)) Out[129]: 4 Now we want to repeat this counting for every element of x. To do this we iterate x using a for loop, e.g., In [134]: for i in x: print i 2 5 4 3 . . . Here i is a dummy variable which represents, in order, each element of x. Notice the colon, which indicates the beginning of commands included in the loop. We can use a for loop to iterate over each bin, e.g., In [14]: hmin = 0 In [15]: hmax = 12 In [16]: hr = np.arange(hmin,hmax+1,1) # make the list of bins

Page 12: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 12

In [17]: hist = np.zeros(hmax-hmin+1,dtype=np.int) # store the counts here In [18]: for i in hr: hist[i] = np.where(x == i)[0].size # count In [19]: plt.plot(hr,hist,drawstyle='steps-mid') Notice that the explicit declaration of the variable hist and the for loop replaces the enigmatic “list comprehension” construction: In [20]: hist = np.array([np.where(x == i)[0].size for i in hr] ) Either version works—there is no single “right answer.” The list comprehension construction may be significantly faster in some circumstances. Now check that the histogram plot actually reflects your data. Compare the list of counts in the data file and the plot. Do a “reality check” on a data set where you can rapidly compute the histogram with pencil and paper1. Once you can plot histograms with confidence, repeat the experiment, say, a few times and compare the results of your experiments. Does the histogram change? Do you always get the same mean count rate? Become adept at inspecting the histogram plot and guessing the mean and standard deviations. Calculate the mean and standard deviation of your sequences you just measured. Try measuring the photon flux within smaller regions of your sensor. You can simply look at a smaller section of the numpy array for each image to accomplish this. Measure the mean and standard deviation. Does the flux scale by pixel area? Make a plot of the mean versus the variance (the standard deviation squared). Now over plot a line with unit slope, i.e. x = y. What does this tell you about the relation between mean and variance for counting (Poisson) statistics? Is the scatter about the line x = y uniform of does it vary with the mean count? Do passion statistics break down for large means? Try plotting your data on a log-log plot by using: In [35]: plt.yscale(‘log’) In [36]: plt.xscale(‘log’)

Note: You can also break up each image into several statistically independent sub-regions and use each one as a separate measurement instead of using the whole image as a single measurement. The only difference will be the mean photon flux will be correspondingly lower because it should scale as the area of the sub-region. You can use this method to probe how different count rates affect the Poisson distribution in the next section. 4.5 Poisson distribution Plot a histogram for one of your sequences with a small count rate, e.g, 2-4 counts per sample and lots of samples. Use the trick mentioned in the note above to accomplish this. Otherwise, you will need to take many images, a few hundred!, to carry out this measurement. Calculate the mean count rate and compare the resultant histogram with the theoretical Poisson probability distribution:

1 This is perhaps the most important programming lesson here. Always test your program on a problem where you know the answer. For example test your histogram program with x =[0,0,0,1,1,1] and x=[0,1,2,3,4,5,6].

Page 13: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 13

𝑃 𝑥; 𝜇 = >?

@!𝑒,> (4)

where P(x; µ) is the probability x events will be measured within an interval given a mean of µ events. How do you compare a histogram, which represents measured counts with a theoretical distribution!? The Poisson distribution gives a probability. You have measured counts. Explain how to choose the correct scaling factor (or normalization) to compare the measured and theoretical distributions. Can you use a theoretical probability to predict counts or can you express your measured counts as a probability? Does the Poisson distribution provide a good description of the data? Now arrange so that the events per sample is increased. Aim for a few hundred events per sample. Plot the histogram again. What has happened to the shape of the histogram—is it qualitatively different? Does the Poission distribution still apply? Calculate the mean and standard deviation and over-plot the corresponding Gaussian probability distribution,

𝑃 𝑥; 𝜇, 𝜎 = "E #F

𝑒𝑥𝑝 − "#

@,>E

# . (5)

Is a Gaussian curve a good approximation to the Poisson distribution? Under what conditions is the Gaussian probability distribution a good approximation? 4.6 Standard deviation of the mean The more events you count the more accurately you can measure the number of counts per sample (i.e., the mean count rate). To illustrate the effect, take ten sets of data consisting of 10 exposures. Compute the number of events within a 100x100 region in each image. For each of these ten sets calculate the mean. Due to the statistical variations the ten means will be different, so also calculate the mean of the means (MOM) and the standard deviation of the means (SDOM). The MOM is the best estimate of the counts per sample and the SDOM is a measure of how precisely we know the average counts per sample. How does the SDOM vary with the number of samples in the individual sequences? Experience suggests that if we have more samples in each of our ten measurements the SDOM will be smaller. To quantify this effect, repeat by taking more 100x100 sub-regions within each image. Try including 2, 4, 8, 16, 32, 64, etc. sub-regions in each image. For each number of sub-regions consider the ten data sets and calculate the mean of the means (MOM) and the standard deviation of the means (SDOM). Plot the MOM and the SDOM as a function of the number of sub-regions. Describe how the MOM and SDOM vary as the sub-region increases. If you want, you can try using smaller sub-regions to increase the maximum number of sub-regions within an image. Based on your knowledge of Poisson statistics and error propagation predict the SDOM given the measured mean count per sample and the sample size. Makes plots that compare your prediction with the data.

• If I want to improve the accuracy of a measurement of the mean by a factor of two, by what factor do I need to increase the number of samples?

Page 14: Lab #1: X-ray Photon Counting & the Statistics of Lightastrolab/files/Lab1_AST325-326_2017_Fall.pdf · Lab #1: X-ray Photon Counting & the Statistics of Light Lab report is due Wednesday,

AST 325/326 (Fall 2017) Lab #1

V22.9.2017 14

• How accurate is your best estimate of the count rate, i.e., how accurate is the MOM? 4.7 X-ray spectrum and calibration of image sensor The decay of Fe55 produces bright soft X-ray emission lines in the few keV energy range. Fe55 decays by electron capture to manganese-55 (Mn55). As described in Section 4.2, the CCD image sensor acts as a spectrometer because for every X-ray photon event it produces a certain number of photoelectrons, which is proportional to the X-ray photon energy. Our camera can resolve up to three X-ray emission lines from our source. To view the spectrum of the source, generate a histogram of the pixel value for each X-ray event. You should see at least one strong peak which is associated with the Ka line of Mn55. Given that we know the energy of the Ka line, we can calculate the corresponding number of photoelectrons generated from a photon with this energy using Equation 3. Since we know the pixel value in ADU and the number of electrons associated with a given photon event, we can calculate the conversion gain: e-/ADU. This allows the conversion of arbitrary pixel values (ADUs) into real physical units (e-). Compute your conversion gain for the data you used in the previous sections. Be sure to indicate your camera gain setting in the FlyCap software. This method is actually used to calibrate astronomical CCDs that are used in the field. The measurement of conversion is critical to understanding the noise properties of CCDs, their charge transfer efficiency, and their throughput on sky.