Skip to content

Commit

Permalink
Don't try to add dark current to bias frames; set rng parameters by k…
Browse files Browse the repository at this point in the history
…eyword name
  • Loading branch information
jchiang87 committed Dec 6, 2018
1 parent 47a402f commit 0f30f42
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions python/desc/imsim/camera_readout.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ def __init__(self, image_array, exptime, sensor_id, visit=42, logger=None):
logging.Logger object to use. If None, then a logger with level
INFO will be used.
"""
if logger is None:
self.logger = get_logger('INFO')
else:
self.logger = logger

self.eimage = fits.HDUList()
self.eimage.append(fits.PrimaryHDU(image_array))
self.eimage_data = self.eimage[0].data.transpose()
Expand All @@ -94,11 +99,6 @@ def __init__(self, image_array, exptime, sensor_id, visit=42, logger=None):

self._make_amp_images()

if logger is None:
self.logger = get_logger('INFO')
else:
self.logger = logger

self.ratel = 0
self.dectel = 0
self.rotangle = 0
Expand Down Expand Up @@ -290,12 +290,14 @@ def _make_amp_image(self, amp_name):
imaging_segment.getArray()[:] = data

# Add dark current.
dark_current = config['electronics_readout']['dark_current']
imaging_arr = imaging_segment.getArray()
rng = galsim.PoissonDeviate(self.seed, dark_current*self.exptime)
dc_data = np.zeros(np.prod(imaging_arr.shape))
rng.generate(dc_data)
imaging_arr += dc_data.reshape(imaging_arr.shape)
if self.exptime > 0:
dark_current = config['electronics_readout']['dark_current']
imaging_arr = imaging_segment.getArray()
rng = galsim.PoissonDeviate(seed=self.seed,
mean=dark_current*self.exptime)
dc_data = np.zeros(np.prod(imaging_arr.shape))
rng.generate(dc_data)
imaging_arr += dc_data.reshape(imaging_arr.shape)

# Add defects.

Expand Down Expand Up @@ -328,7 +330,8 @@ def _add_read_noise_and_bias(self, amp_name):
"""
amp_info = self.camera_info.get_amp_info(amp_name)
full_arr = self.amp_images[amp_name].getArray()
rng = galsim.GaussianDeviate(self.seed, amp_info.getReadNoise())
rng = galsim.GaussianDeviate(seed=self.seed,
sigma=amp_info.getReadNoise())
rn_data = np.zeros(np.prod(full_arr.shape))
rng.generate(rn_data)
full_arr += rn_data.reshape(full_arr.shape)
Expand Down

0 comments on commit 0f30f42

Please sign in to comment.