Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions euclidlike_imsim/ccd.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


class EuclidlikeCCDImageBuilder(ScatteredImageBuilder):

def setup(self, config, base, image_num, obj_num, ignore, logger):
"""Do the initialization and setup for building the image.

Expand Down Expand Up @@ -105,7 +104,9 @@ def buildImage(self, config, base, image_num, obj_num, logger):
full_image.header = galsim.FitsHeader()
full_image.header["EXPTIME"] = self.exptime
full_image.header["MJD-OBS"] = self.mjd
full_image.header["DATE-OBS"] = str(Time(self.mjd, format="mjd").datetime)
full_image.header["DATE-OBS"] = str(
Time(self.mjd, format="mjd").datetime
)
full_image.header["FILTER"] = self.filter
full_image.header["GAIN"] = gain
full_image.header["ZPTMAG"] = 2.5 * np.log10(
Expand Down Expand Up @@ -146,7 +147,11 @@ def buildImage(self, config, base, image_num, obj_num, logger):
end_obj_num,
)
stamps, current_vars = galsim.config.BuildStamps(
nobj_batch, base, logger=logger, obj_num=start_obj_num, do_noise=False
nobj_batch,
base,
logger=logger,
obj_num=start_obj_num,
do_noise=False,
)
base["index_key"] = "image_num"

Expand All @@ -162,7 +167,9 @@ def buildImage(self, config, base, image_num, obj_num, logger):
continue

logger.debug(
"image %d: full bounds = %s", image_num, str(full_image.bounds)
"image %d: full bounds = %s",
image_num,
str(full_image.bounds),
)
logger.debug(
"image %d: stamp %d bounds = %s",
Expand All @@ -176,7 +183,9 @@ def buildImage(self, config, base, image_num, obj_num, logger):

return full_image, None

def addNoise(self, image, config, base, image_num, obj_num, current_var, logger):
def addNoise(
self, image, config, base, image_num, obj_num, current_var, logger
):
"""Add the final noise to a Scattered image

Parameters:
Expand All @@ -189,7 +198,7 @@ def addNoise(self, image, config, base, image_num, obj_num, current_var, logger)
logger: If given, a logger object to log progress.
"""
# check ignore noise
if self.cfg_noise["ignore_noise"]:
if not self.cfg_noise["use_noise"]:
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the only actual change is. This is a simple fix since we switch the noise.

Copy link
Copy Markdown
Collaborator

@FedericoBerlfein FedericoBerlfein Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will approve then.

return

if "noise_image" not in base.keys():
Expand All @@ -200,13 +209,13 @@ def addNoise(self, image, config, base, image_num, obj_num, current_var, logger)
image.quantize()

image += base["noise_image"]

# Apply saturation
saturation_ADU = np.round(saturation/gain)
saturation_ADU = np.round(saturation / gain)
mask_saturated = image.array > saturation_ADU
base["saturated_mask"] = mask_saturated
image.array[mask_saturated] = saturation_ADU

if self.cfg_noise["sky_subtract"]:
image -= base["sky_image"]

Expand Down