<jupyter_start><jupyter_text>Nonuniform sensitivity  BackgroundNot all pixels in a camera have the same sensitivity to light: there are intrinsic differences from pixel-to-pixel. Vignetting, a dimming near the corners of an image caused by the optical system to which the camera is attached, and dust on optical elements such as filters, the glass window covering the CCD, and the CCD chip itself can also block some light.Vingetting and dust can reduce the amount of light reaching the CCD chip while pixel-to-pixel sensitivity variations affects the counts read from the chip.The code to produce the simulated sensitivty map (aka flat image) is long enough that is not included in this notebook. We load it instead from [image_sim.py](image_sim.py).<jupyter_code>import numpy as np

from convenience_functions import show_image
from image_sim import *<jupyter_output><empty_output><jupyter_text>A sample flat imageThe sample flat image below has the same size as the simulated image in the previous notebook.<jupyter_code>image = np.zeros([2000, 2000])
flat = sensitivity_variations(image)
show_image(flat, cmap='gray')<jupyter_output>(10.0, 10)<jupyter_text>Note that the size of the variations is small, a few percent at most.   Effect of nonuniform sensitivity on imagesRecall that an image read off a CCD, ignoring variations in sensitivity, can be thought of as a combination of several pieces:$$\text{image} = \text{bias} + \text{noise} + \text{dark current} + \text{sky} + \text{stars}$$The effect of sensitivity variations is to reduce the amount of *light* reaching the sensor. In the equation above, that means that the flat multiplies just the sky and stars portion of the input:$$\text{image} = \text{bias} + \text{noise} + \text{dark current} + \text{flat} \times (\text{sky} + \text{stars})$$  A realistic image In the cell below we construct the last image from the previous notebook. Recall that there we used a read noise of 5 electrons/pixel, dark current of 0.1 electron/pix/sec, bias level of 1100, and sky background of 20 counts.<jupyter_code>gain = 1.0
exposure = 30.0
dark = 0.1
sky_counts = 20
bias_level = 1100
read_noise_electrons = 5
max_star_counts = 2000
bias_only = bias(image, bias_level, realistic=True)
noise_only = read_noise(image, read_noise_electrons, gain=gain)
dark_only = dark_current(image, dark, exposure, gain=gain, hot_pixels=True)
sky_only = sky_background(image, sky_counts, gain=gain)
stars_only = stars(image, 50, max_counts=max_star_counts)
final_image = bias_only + noise_only + dark_only + flat * (sky_only + stars_only)
show_image(final_image, cmap='gray', percu=99.9)<jupyter_output>(10.0, 10)<jupyter_text>Visually, this does not look any different than the final image in the previous notebook; the effects of sensitivity variations are typically not evident in raw images unless the sky background is large. You can see the effect by artificially increasing the sky background.<jupyter_code>final_image2 = bias_only + noise_only + dark_only + flat * (sky_background(image, 100 * sky_counts, gain=gain) + stars_only)
show_image(final_image2, cmap='gray')<jupyter_output>(10.0, 10)
{'fraction_non_alphanumeric': 0.07743785850860421, 'fraction_numerical': 0.019120458891013385, 'mean_word_length': 5.736051502145923, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '250975', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 964, 'n_tokens_neox': 883, 'n_words': 380, 'path': 'notebooks/01.04-Nonuniform-sensitivity.ipynb', 'repo_name': 'aadlander/ccd-reduction-and-photometry-guide', 'size': '3138'}