Loading ObservationSim/Instrument/Chip/Chip.py +53 −27 Original line number Original line Diff line number Diff line Loading @@ -501,12 +501,14 @@ class Chip(FocalPlane): print(" Output N frame Bias files", flush=True) print(" Output N frame Bias files", flush=True) NBias = int(config["output_setting"]["NBias"]) NBias = int(config["output_setting"]["NBias"]) for i in range(NBias): for i in range(NBias): BiasCombImg, BiasTag = effects.MakeBiasNcomb( ### BiasCombImg, BiasTag = effects.MakeBiasNcomb( self.npix_x, self.npix_y, ### self.npix_x, self.npix_y, bias_level=float(self.bias_level), ### bias_level=float(self.bias_level), ncombine=1, read_noise=self.read_noise, gain=1, ### ncombine=1, read_noise=self.read_noise, gain=1, seed=SeedBiasNonuni+self.chipID, ### seed=SeedBiasNonuni+self.chipID, logger=self.logger) ### logger=self.logger) BiasCombImg = galsim.Image(self.npix_x, self.npix_y, init_value=0) ### # Readout noise for Biases is not generated with random seeds. So readout noise for bias images can't be reproduced. # Readout noise for Biases is not generated with random seeds. So readout noise for bias images can't be reproduced. if config["ins_effects"]["cosmic_ray"] == True: if config["ins_effects"]["cosmic_ray"] == True: if config["ins_effects"]["cray_differ"] == True: if config["ins_effects"]["cray_differ"] == True: Loading @@ -521,6 +523,11 @@ class Chip(FocalPlane): BiasCombImg += cr_map BiasCombImg += cr_map del cr_map del cr_map # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: BiasCombImg = effects.BadColumns(BiasCombImg-float(self.bias_level)+5, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) + float(self.bias_level)-5 # Non-Linearity for Bias # Non-Linearity for Bias if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: Loading @@ -530,6 +537,11 @@ class Chip(FocalPlane): BiasCombImg = effects.NonLinearity(GSImage=BiasCombImg, beta1=5.e-7, beta2=0) BiasCombImg = effects.NonLinearity(GSImage=BiasCombImg, beta1=5.e-7, beta2=0) ###########################START ###########################START pre1 = self.prescan_x #27 over1= self.overscan_x #71 pre2 = self.prescan_y #0 #4 over2= self.overscan_y #84 #80 ### prescan & overscan ### prescan & overscan if config["ins_effects"]["add_prescan"] == True: if config["ins_effects"]["add_prescan"] == True: chip_utils.log_info(msg=" Apply pre/over-scan", logger=self.logger) chip_utils.log_info(msg=" Apply pre/over-scan", logger=self.logger) Loading @@ -543,9 +555,21 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Apply Bad lines ### Add Bias level if config["ins_effects"]["add_badcolumns"] == True: if config["ins_effects"]["add_bias"] == True: BiasCombImg = effects.BadColumns(BiasCombImg-float(self.bias_level)+5, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) + float(self.bias_level)-5 if self.logger is not None: self.logger.info(" Adding Bias level and 16-channel non-uniformity") else: print(" Adding Bias level and 16-channel non-uniformity") BiasCombImg = effects.AddBiasNonUniform16(BiasCombImg, bias_level=biaslevel, nsecy = self.nsecy, nsecx=self.nsecx, seed=SeedBiasNonuni+self.chipID, logger=self.logger) rng = galsim.UniformDeviate() ncombine = 1 NoiseBias = galsim.GaussianNoise(rng=rng, sigma=self.read_noise*ncombine**0.5) BiasCombImg.addNoise(NoiseBias) BiasCombImg, self.gain_channel = effects.ApplyGainNonUniform16(BiasCombImg, gain=self.gain, BiasCombImg, self.gain_channel = effects.ApplyGainNonUniform16(BiasCombImg, gain=self.gain, nsecy = self.nsecy, nsecx=self.nsecx, nsecy = self.nsecy, nsecx=self.nsecx, Loading Loading @@ -613,6 +637,16 @@ class Chip(FocalPlane): FlatCombImg += cr_map FlatCombImg += cr_map del cr_map del cr_map # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) FlatCombImg = effects.DefectivePixels(FlatCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: FlatCombImg = effects.BadColumns(FlatCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: self.logger.info(" Applying Non-Linearity on the Flat image") self.logger.info(" Applying Non-Linearity on the Flat image") Loading Loading @@ -676,15 +710,6 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) FlatCombImg = effects.DefectivePixels(FlatCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: FlatCombImg = effects.BadColumns(FlatCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Add Bias level # Add Bias level if config["ins_effects"]["add_bias"] == True: if config["ins_effects"]["add_bias"] == True: if self.logger is not None: if self.logger is not None: Loading Loading @@ -797,6 +822,16 @@ class Chip(FocalPlane): timestamp=timestamp_obs) timestamp=timestamp_obs) del crmap_gsimg del crmap_gsimg # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) DarkCombImg = effects.DefectivePixels(DarkCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: DarkCombImg = effects.BadColumns(DarkCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Non-Linearity for Dark # Non-Linearity for Dark if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: Loading Loading @@ -861,15 +896,6 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) DarkCombImg = effects.DefectivePixels(DarkCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: DarkCombImg = effects.BadColumns(DarkCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Add Bias level # Add Bias level if config["ins_effects"]["add_bias"] == True: if config["ins_effects"]["add_bias"] == True: if self.logger is not None: if self.logger is not None: Loading Loading
ObservationSim/Instrument/Chip/Chip.py +53 −27 Original line number Original line Diff line number Diff line Loading @@ -501,12 +501,14 @@ class Chip(FocalPlane): print(" Output N frame Bias files", flush=True) print(" Output N frame Bias files", flush=True) NBias = int(config["output_setting"]["NBias"]) NBias = int(config["output_setting"]["NBias"]) for i in range(NBias): for i in range(NBias): BiasCombImg, BiasTag = effects.MakeBiasNcomb( ### BiasCombImg, BiasTag = effects.MakeBiasNcomb( self.npix_x, self.npix_y, ### self.npix_x, self.npix_y, bias_level=float(self.bias_level), ### bias_level=float(self.bias_level), ncombine=1, read_noise=self.read_noise, gain=1, ### ncombine=1, read_noise=self.read_noise, gain=1, seed=SeedBiasNonuni+self.chipID, ### seed=SeedBiasNonuni+self.chipID, logger=self.logger) ### logger=self.logger) BiasCombImg = galsim.Image(self.npix_x, self.npix_y, init_value=0) ### # Readout noise for Biases is not generated with random seeds. So readout noise for bias images can't be reproduced. # Readout noise for Biases is not generated with random seeds. So readout noise for bias images can't be reproduced. if config["ins_effects"]["cosmic_ray"] == True: if config["ins_effects"]["cosmic_ray"] == True: if config["ins_effects"]["cray_differ"] == True: if config["ins_effects"]["cray_differ"] == True: Loading @@ -521,6 +523,11 @@ class Chip(FocalPlane): BiasCombImg += cr_map BiasCombImg += cr_map del cr_map del cr_map # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: BiasCombImg = effects.BadColumns(BiasCombImg-float(self.bias_level)+5, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) + float(self.bias_level)-5 # Non-Linearity for Bias # Non-Linearity for Bias if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: Loading @@ -530,6 +537,11 @@ class Chip(FocalPlane): BiasCombImg = effects.NonLinearity(GSImage=BiasCombImg, beta1=5.e-7, beta2=0) BiasCombImg = effects.NonLinearity(GSImage=BiasCombImg, beta1=5.e-7, beta2=0) ###########################START ###########################START pre1 = self.prescan_x #27 over1= self.overscan_x #71 pre2 = self.prescan_y #0 #4 over2= self.overscan_y #84 #80 ### prescan & overscan ### prescan & overscan if config["ins_effects"]["add_prescan"] == True: if config["ins_effects"]["add_prescan"] == True: chip_utils.log_info(msg=" Apply pre/over-scan", logger=self.logger) chip_utils.log_info(msg=" Apply pre/over-scan", logger=self.logger) Loading @@ -543,9 +555,21 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Apply Bad lines ### Add Bias level if config["ins_effects"]["add_badcolumns"] == True: if config["ins_effects"]["add_bias"] == True: BiasCombImg = effects.BadColumns(BiasCombImg-float(self.bias_level)+5, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) + float(self.bias_level)-5 if self.logger is not None: self.logger.info(" Adding Bias level and 16-channel non-uniformity") else: print(" Adding Bias level and 16-channel non-uniformity") BiasCombImg = effects.AddBiasNonUniform16(BiasCombImg, bias_level=biaslevel, nsecy = self.nsecy, nsecx=self.nsecx, seed=SeedBiasNonuni+self.chipID, logger=self.logger) rng = galsim.UniformDeviate() ncombine = 1 NoiseBias = galsim.GaussianNoise(rng=rng, sigma=self.read_noise*ncombine**0.5) BiasCombImg.addNoise(NoiseBias) BiasCombImg, self.gain_channel = effects.ApplyGainNonUniform16(BiasCombImg, gain=self.gain, BiasCombImg, self.gain_channel = effects.ApplyGainNonUniform16(BiasCombImg, gain=self.gain, nsecy = self.nsecy, nsecx=self.nsecx, nsecy = self.nsecy, nsecx=self.nsecx, Loading Loading @@ -613,6 +637,16 @@ class Chip(FocalPlane): FlatCombImg += cr_map FlatCombImg += cr_map del cr_map del cr_map # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) FlatCombImg = effects.DefectivePixels(FlatCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: FlatCombImg = effects.BadColumns(FlatCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: self.logger.info(" Applying Non-Linearity on the Flat image") self.logger.info(" Applying Non-Linearity on the Flat image") Loading Loading @@ -676,15 +710,6 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) FlatCombImg = effects.DefectivePixels(FlatCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: FlatCombImg = effects.BadColumns(FlatCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Add Bias level # Add Bias level if config["ins_effects"]["add_bias"] == True: if config["ins_effects"]["add_bias"] == True: if self.logger is not None: if self.logger is not None: Loading Loading @@ -797,6 +822,16 @@ class Chip(FocalPlane): timestamp=timestamp_obs) timestamp=timestamp_obs) del crmap_gsimg del crmap_gsimg # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) DarkCombImg = effects.DefectivePixels(DarkCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: DarkCombImg = effects.BadColumns(DarkCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Non-Linearity for Dark # Non-Linearity for Dark if config["ins_effects"]["non_linear"] == True: if config["ins_effects"]["non_linear"] == True: if self.logger is not None: if self.logger is not None: Loading Loading @@ -861,15 +896,6 @@ class Chip(FocalPlane): self.nsecx = 16 self.nsecx = 16 ###########################END ###########################END # Add Hot Pixels or/and Dead Pixels rgbadpix = Generator(PCG64(int(SeedDefective+self.chipID))) badfraction = 5E-5*(rgbadpix.random()*0.5+0.7) DarkCombImg = effects.DefectivePixels(DarkCombImg, IfHotPix=BoolHotPix, IfDeadPix=BoolDeadPix, fraction=badfraction, seed=SeedDefective+self.chipID, biaslevel=0) # Apply Bad lines if config["ins_effects"]["add_badcolumns"] == True: DarkCombImg = effects.BadColumns(DarkCombImg, seed=SeedBadColumns, chipid=self.chipID, logger=self.logger) # Add Bias level # Add Bias level if config["ins_effects"]["add_bias"] == True: if config["ins_effects"]["add_bias"] == True: if self.logger is not None: if self.logger is not None: Loading