Commit 7465f1d8 authored by Fang Yuedong's avatar Fang Yuedong
Browse files

* Bug fixes:

1. bright objects were missing in some bands.
2. saturation cut magnitudes were different for the same objects in different bands

* Now use exp_time for single exposure for saturation mag calculation. Use for depth exp_time for limiting mag calculation.
parent 60a424bf
...@@ -45,7 +45,6 @@ class Filter(object): ...@@ -45,7 +45,6 @@ class Filter(object):
def is_too_bright(self, mag, margin=-2.5): def is_too_bright(self, mag, margin=-2.5):
return mag <= self.mag_saturation + margin return mag <= self.mag_saturation + margin
# return mag <= 14.0
def is_too_dim(self, mag, margin=1.0): def is_too_dim(self, mag, margin=1.0):
return mag >= self.mag_limiting + margin return mag >= self.mag_limiting + margin
...@@ -143,7 +142,7 @@ class Filter(object): ...@@ -143,7 +142,7 @@ class Filter(object):
del sl del sl
gc.collect() gc.collect()
def update_limit_saturation_mags(self, exptime=150., psf_fwhm=0.1969, skyFn='sky_emiss_hubble_50_50_A.dat', chip=None): def update_limit_saturation_mags(self, exptime=150., psf_fwhm=0.1969, skyFn='sky_emiss_hubble_50_50_A.dat', chip=None, full_depth_exptime=None):
if self.filter_type in _util.SPEC_FILTERS: if self.filter_type in _util.SPEC_FILTERS:
return return
if chip is not None: if chip is not None:
...@@ -160,6 +159,10 @@ class Filter(object): ...@@ -160,6 +159,10 @@ class Filter(object):
self.mag_limiting, self.mag_saturation = _util.calculateLimitMag( self.mag_limiting, self.mag_saturation = _util.calculateLimitMag(
psf_fwhm=psf_fwhm, pixelSize=pix_scale, throughputFn=throughput_file, readout=5.0, skyFn=skyFn, darknoise=dark_noise, exTime=exptime, fw=full_well) psf_fwhm=psf_fwhm, pixelSize=pix_scale, throughputFn=throughput_file, readout=5.0, skyFn=skyFn, darknoise=dark_noise, exTime=exptime, fw=full_well)
if full_depth_exptime is not None:
self.mag_limiting, _ = _util.calculateLimitMag(
psf_fwhm=psf_fwhm, pixelSize=pix_scale, throughputFn=throughput_file, readout=5.0, skyFn=skyFn, darknoise=dark_noise, exTime=full_depth_exptime, fw=full_well)
print("for filter %s: mag_limiting: %.3f, mag_saturation: %.3f" % print("for filter %s: mag_limiting: %.3f, mag_saturation: %.3f" %
(self.filter_type, self.mag_limiting, self.mag_saturation)) (self.filter_type, self.mag_limiting, self.mag_saturation))
...@@ -308,15 +308,21 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu ...@@ -308,15 +308,21 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
if yi == 0 or yi == imgarr.shape[0]-1: if yi == 0 or yi == imgarr.shape[0]-1:
imgarr[yi, xi] = fullwell imgarr[yi, xi] = fullwell
break break
if direction == 'up': if direction == 'up':
if imgarr[yi-1, xi] >= fullwell: if imgarr[yi-1, xi] >= fullwell:
imgarr[yi, xi] = fullwell imgarr[yi, xi] = fullwell
yi -= 1 yi -= 1
# [TEST] charge in the middle
if yi == (imgarr.shape[0] // 2 - 1):
break
continue continue
elif direction == 'down': elif direction == 'down':
if imgarr[yi+1, xi] >= fullwell: if imgarr[yi+1, xi] >= fullwell:
imgarr[yi, xi] = fullwell imgarr[yi, xi] = fullwell
yi += 1 yi += 1
if yi == (imgarr.shape[0] // 2):
break
continue continue
if aa <= 1: if aa <= 1:
while imgarr[yi, xi] >= fullwell: while imgarr[yi, xi] >= fullwell:
...@@ -325,13 +331,15 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu ...@@ -325,13 +331,15 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
imgarr[yi-1, xi] += charge imgarr[yi-1, xi] += charge
charge = imgarr[yi-1, xi]-fullwell charge = imgarr[yi-1, xi]-fullwell
yi -= 1 yi -= 1
if yi < 0: # if yi < 0:
if yi < 0 or yi == (imgarr.shape[0]//2 - 1):
break break
elif direction == 'down': elif direction == 'down':
imgarr[yi+1, xi] += charge imgarr[yi+1, xi] += charge
charge = imgarr[yi+1, xi]-fullwell charge = imgarr[yi+1, xi]-fullwell
yi += 1 yi += 1
if yi > imgarr.shape[0]: # if yi > imgarr.shape[0]:
if yi > imgarr.shape[0] or yi == (imgarr.shape[0]//2):
break break
else: else:
# calculate bleeding trail: # calculate bleeding trail:
......
...@@ -91,6 +91,10 @@ class CatalogBase(metaclass=ABCMeta): ...@@ -91,6 +91,10 @@ class CatalogBase(metaclass=ABCMeta):
bandpass = target_filt.bandpass_full bandpass = target_filt.bandpass_full
if norm_filt is not None: if norm_filt is not None:
if hasattr(norm_filt, 'bandpass_full'):
norm_filt = Table(
np.array(np.array([norm_filt.bandpass_full.wave_list*10.0, norm_filt.bandpass_full.func(
norm_filt.bandpass_full.wave_list)])).T, names=(['WAVELENGTH', 'SENSITIVITY']))
norm_thr_rang_ids = norm_filt['SENSITIVITY'] > 0.001 norm_thr_rang_ids = norm_filt['SENSITIVITY'] > 0.001
else: else:
norm_filt = Table( norm_filt = Table(
......
...@@ -75,7 +75,9 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): ...@@ -75,7 +75,9 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
for ifilt in range(len(self.all_filters)): for ifilt in range(len(self.all_filters)):
temp_filter = self.all_filters[ifilt] temp_filter = self.all_filters[ifilt]
temp_filter.update_limit_saturation_mags( temp_filter.update_limit_saturation_mags(
exptime=pointing.get_full_depth_exptime(temp_filter.filter_type), chip=chip) exptime=pointing.exp_time,
full_depth_exptime=pointing.get_full_depth_exptime(temp_filter.filter_type),
chip=chip)
if temp_filter.filter_type.lower() == self.overall_config["obs_setting"]["cut_in_band"].lower(): if temp_filter.filter_type.lower() == self.overall_config["obs_setting"]["cut_in_band"].lower():
cut_filter = temp_filter cut_filter = temp_filter
...@@ -109,6 +111,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): ...@@ -109,6 +111,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
try: try:
sed_data = cat.load_sed(obj) sed_data = cat.load_sed(obj)
norm_filt = cat.load_norm_filt(obj) norm_filt = cat.load_norm_filt(obj)
obj.sed, obj.param["mag_%s" % filt.filter_type.lower()], obj.param["flux_%s" % filt.filter_type.lower()] = cat.convert_sed( obj.sed, obj.param["mag_%s" % filt.filter_type.lower()], obj.param["flux_%s" % filt.filter_type.lower()] = cat.convert_sed(
mag=obj.param["mag_use_normal"], mag=obj.param["mag_use_normal"],
sed=sed_data, sed=sed_data,
...@@ -116,11 +119,12 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): ...@@ -116,11 +119,12 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
norm_filt=norm_filt, norm_filt=norm_filt,
mu=obj.mu mu=obj.mu
) )
_, obj.param["mag_%s" % cut_filter.filter_type.lower()], obj.param["flux_%s" % cut_filter.filter_type.lower()] = cat.convert_sed( _, obj.param["mag_%s" % cut_filter.filter_type.lower()], obj.param["flux_%s" % cut_filter.filter_type.lower()] = cat.convert_sed(
mag=obj.param["mag_use_normal"], mag=obj.param["mag_use_normal"],
sed=sed_data, sed=sed_data,
target_filt=cut_filter, target_filt=cut_filter,
norm_filt=norm_filt, norm_filt=(norm_filt if norm_filt else filt),
mu=obj.mu mu=obj.mu
) )
except Exception as e: except Exception as e:
...@@ -129,6 +133,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): ...@@ -129,6 +133,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
continue continue
# [TODO] Testing # [TODO] Testing
# print(obj.param["mag_%s" % filt.filter_type.lower()], obj.param["mag_%s" % cut_filter.filter_type.lower()])
# self.chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()])) # self.chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()]))
# Exclude very bright/dim objects (for now) # Exclude very bright/dim objects (for now)
...@@ -136,7 +141,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param): ...@@ -136,7 +141,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
mag=obj.param["mag_%s" % mag=obj.param["mag_%s" %
self.overall_config["obs_setting"]["cut_in_band"].lower()], self.overall_config["obs_setting"]["cut_in_band"].lower()],
margin=self.overall_config["obs_setting"]["mag_sat_margin"]): margin=self.overall_config["obs_setting"]["mag_sat_margin"]):
self.chip_output.Log_info("obj %s too birght!! mag_%s = %.3f" % ( self.chip_output.Log_info("obj %s too bright!! mag_%s = %.3f" % (
obj.id, cut_filter.filter_type, obj.param["mag_%s" % self.overall_config["obs_setting"]["cut_in_band"].lower()])) obj.id, cut_filter.filter_type, obj.param["mag_%s" % self.overall_config["obs_setting"]["cut_in_band"].lower()]))
bright_obj += 1 bright_obj += 1
obj.unload_SED() obj.unload_SED()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment