Loading catalog/C9_Catalog.py +3 −2 Original line number Diff line number Diff line Loading @@ -470,6 +470,7 @@ class Catalog(CatalogBase): self.objs.append(obj) def free_mem(self, **kward): if not self.config["catalog_options"]["galaxy_only"]: self.starDDL.freeGlobeData() del self.starDDL Loading observation_sim/ObservationSim.py +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class Observation(object): # Get flat, shutter, and PRNU images chip.flat_img, _ = chip_utils.get_flat( img=chip.img, seed=int(self.config["random_seeds"]["seed_flat"])) if chip.chipID <= 30: chip.flat_img = chip.flat_img*chip_utils.get_innerflat(chip = chip) if chip.chipID > 30: chip.shutter_img = np.ones_like(chip.img.array) else: Loading observation_sim/instruments/chip/chip_utils.py +6 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,12 @@ def get_flat(img, seed): flat_normal = flat_img / np.mean(flat_img.array) return flat_img, flat_normal def get_innerflat(chip = None, filt = None): from observation_sim.mock_objects import FlatLED led_obj = FlatLED(chip, filt) flat_img = led_obj.getInnerFlat() return flat_img def add_cosmic_rays(img, chip, exptime=150, seed=0): cr_map, cr_event_num = effects.produceCR_Map( Loading observation_sim/mock_objects/FlatLED.py +16 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ fluxLED = {'LED1': 15, 'LED2': 15, 'LED3': 12.5, 'LED4': 9, 'LED5': 9, # 'LED14': 10} mirro_eff = {'GU': 0.61, 'GV': 0.8, 'GI': 0.8} bandtoLed = {'NUV':['LED1','LED2'], 'u':['LED13','LED14'], 'g':['LED3','LED4','LED5'], 'r':['LED6','LED7'], 'i':['LED8'], 'z':['LED9','LED10'], 'y':['LED10'], 'GU':['LED1','LED2','LED13','LED14'], 'GV':['LED3','LED4','LED5','LED6'], 'GI':['LED7','LED8','LED9','LED10']} # mirro_eff = {'GU':1, 'GV':1, 'GI':1} Loading @@ -69,10 +71,19 @@ class FlatLED(MockObject): with pkg_resources.path('observation_sim.mock_objects.data.led', "") as ledDir: self.flatDir = ledDir.as_posix() def getInnerFlat(self): ledflats = bandtoLed[self.chip.filter_type] iFlat = np.zeros([self.chip.npix_y, self.chip.npix_x]) for nled in ledflats: iFlat = iFlat + self.getLEDImage(led_type=nled, LED_Img_flag =False) iFlat = iFlat / len(ledflats) return iFlat ### # return LED flat, e/s ### def getLEDImage(self, led_type='LED1'): def getLEDImage(self, led_type='LED1', LED_Img_flag =True): # cwave = cwaves[led_type] flat = fits.open(os.path.join(self.flatDir, 'model_' + cwaves_name[led_type] + 'nm.fits')) Loading Loading @@ -102,7 +113,10 @@ class FlatLED(MockObject): N[self.chip.npix_y * i:self.chip.npix_y * (i + 1), self.chip.npix_x * j:self.chip.npix_x * (j + 1)]), method='linear') U = U/np.mean(U) flatImage = U*fluxLED[led_type]*1000 flatImage = U if LED_Img_flag: flatImage = flatImage*fluxLED[led_type]*1000 gc.collect() return flatImage Loading observation_sim/mock_objects/Galaxy.py +7 −4 Original line number Diff line number Diff line Loading @@ -335,18 +335,21 @@ class Galaxy(MockObject): pos_img_local[1] = pos_img.y - y_start nnx = 0 nny = 0 for order in ["A", "B"]: for order in ["B", "A"]: EXTRA = False if self.getMagFilter(filt) <= filt.mag_saturation-2.: EXTRA = True psf, pos_shear = psf_model.get_PSF( chip, pos_img_local=pos_img_local, bandNo=i+1, galsimGSObject=True, g_order=order, grating_split_pos=grating_split_pos) chip, pos_img_local=pos_img_local, bandNo=i+1, galsimGSObject=True, g_order=order, grating_split_pos=grating_split_pos, extrapolate = EXTRA, ngg=3072) star_p = galsim.Convolve(psf, gal) if nnx == 0: galImg = star_p.drawImage( wcs=chip_wcs_local, offset=offset) wcs=chip_wcs_local, offset=offset, method='no_pixel') nnx = galImg.xmax - galImg.xmin + 1 nny = galImg.ymax - galImg.ymin + 1 else: galImg = star_p.drawImage( nx=nnx, ny=nny, wcs=chip_wcs_local, offset=offset) nx=nnx, ny=nny, wcs=chip_wcs_local, offset=offset, method='no_pixel') galImg.setOrigin(0, 0) # n1 = np.sum(np.isinf(galImg.array)) # n2 = np.sum(np.isnan(galImg.array)) Loading Loading
catalog/C9_Catalog.py +3 −2 Original line number Diff line number Diff line Loading @@ -470,6 +470,7 @@ class Catalog(CatalogBase): self.objs.append(obj) def free_mem(self, **kward): if not self.config["catalog_options"]["galaxy_only"]: self.starDDL.freeGlobeData() del self.starDDL Loading
observation_sim/ObservationSim.py +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class Observation(object): # Get flat, shutter, and PRNU images chip.flat_img, _ = chip_utils.get_flat( img=chip.img, seed=int(self.config["random_seeds"]["seed_flat"])) if chip.chipID <= 30: chip.flat_img = chip.flat_img*chip_utils.get_innerflat(chip = chip) if chip.chipID > 30: chip.shutter_img = np.ones_like(chip.img.array) else: Loading
observation_sim/instruments/chip/chip_utils.py +6 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,12 @@ def get_flat(img, seed): flat_normal = flat_img / np.mean(flat_img.array) return flat_img, flat_normal def get_innerflat(chip = None, filt = None): from observation_sim.mock_objects import FlatLED led_obj = FlatLED(chip, filt) flat_img = led_obj.getInnerFlat() return flat_img def add_cosmic_rays(img, chip, exptime=150, seed=0): cr_map, cr_event_num = effects.produceCR_Map( Loading
observation_sim/mock_objects/FlatLED.py +16 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,8 @@ fluxLED = {'LED1': 15, 'LED2': 15, 'LED3': 12.5, 'LED4': 9, 'LED5': 9, # 'LED14': 10} mirro_eff = {'GU': 0.61, 'GV': 0.8, 'GI': 0.8} bandtoLed = {'NUV':['LED1','LED2'], 'u':['LED13','LED14'], 'g':['LED3','LED4','LED5'], 'r':['LED6','LED7'], 'i':['LED8'], 'z':['LED9','LED10'], 'y':['LED10'], 'GU':['LED1','LED2','LED13','LED14'], 'GV':['LED3','LED4','LED5','LED6'], 'GI':['LED7','LED8','LED9','LED10']} # mirro_eff = {'GU':1, 'GV':1, 'GI':1} Loading @@ -69,10 +71,19 @@ class FlatLED(MockObject): with pkg_resources.path('observation_sim.mock_objects.data.led', "") as ledDir: self.flatDir = ledDir.as_posix() def getInnerFlat(self): ledflats = bandtoLed[self.chip.filter_type] iFlat = np.zeros([self.chip.npix_y, self.chip.npix_x]) for nled in ledflats: iFlat = iFlat + self.getLEDImage(led_type=nled, LED_Img_flag =False) iFlat = iFlat / len(ledflats) return iFlat ### # return LED flat, e/s ### def getLEDImage(self, led_type='LED1'): def getLEDImage(self, led_type='LED1', LED_Img_flag =True): # cwave = cwaves[led_type] flat = fits.open(os.path.join(self.flatDir, 'model_' + cwaves_name[led_type] + 'nm.fits')) Loading Loading @@ -102,7 +113,10 @@ class FlatLED(MockObject): N[self.chip.npix_y * i:self.chip.npix_y * (i + 1), self.chip.npix_x * j:self.chip.npix_x * (j + 1)]), method='linear') U = U/np.mean(U) flatImage = U*fluxLED[led_type]*1000 flatImage = U if LED_Img_flag: flatImage = flatImage*fluxLED[led_type]*1000 gc.collect() return flatImage Loading
observation_sim/mock_objects/Galaxy.py +7 −4 Original line number Diff line number Diff line Loading @@ -335,18 +335,21 @@ class Galaxy(MockObject): pos_img_local[1] = pos_img.y - y_start nnx = 0 nny = 0 for order in ["A", "B"]: for order in ["B", "A"]: EXTRA = False if self.getMagFilter(filt) <= filt.mag_saturation-2.: EXTRA = True psf, pos_shear = psf_model.get_PSF( chip, pos_img_local=pos_img_local, bandNo=i+1, galsimGSObject=True, g_order=order, grating_split_pos=grating_split_pos) chip, pos_img_local=pos_img_local, bandNo=i+1, galsimGSObject=True, g_order=order, grating_split_pos=grating_split_pos, extrapolate = EXTRA, ngg=3072) star_p = galsim.Convolve(psf, gal) if nnx == 0: galImg = star_p.drawImage( wcs=chip_wcs_local, offset=offset) wcs=chip_wcs_local, offset=offset, method='no_pixel') nnx = galImg.xmax - galImg.xmin + 1 nny = galImg.ymax - galImg.ymin + 1 else: galImg = star_p.drawImage( nx=nnx, ny=nny, wcs=chip_wcs_local, offset=offset) nx=nnx, ny=nny, wcs=chip_wcs_local, offset=offset, method='no_pixel') galImg.setOrigin(0, 0) # n1 = np.sum(np.isinf(galImg.array)) # n2 = np.sum(np.isnan(galImg.array)) Loading