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):
def is_too_bright(self, mag, margin=-2.5):
return mag <= self.mag_saturation + margin
# return mag <= 14.0
def is_too_dim(self, mag, margin=1.0):
return mag >= self.mag_limiting + margin
......@@ -143,7 +142,7 @@ class Filter(object):
del sl
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:
return
if chip is not None:
......@@ -161,5 +160,9 @@ class Filter(object):
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)
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" %
(self.filter_type, self.mag_limiting, self.mag_saturation))
......@@ -308,15 +308,21 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
if yi == 0 or yi == imgarr.shape[0]-1:
imgarr[yi, xi] = fullwell
break
if direction == 'up':
if imgarr[yi-1, xi] >= fullwell:
imgarr[yi, xi] = fullwell
yi -= 1
# [TEST] charge in the middle
if yi == (imgarr.shape[0] // 2 - 1):
break
continue
elif direction == 'down':
if imgarr[yi+1, xi] >= fullwell:
imgarr[yi, xi] = fullwell
yi += 1
if yi == (imgarr.shape[0] // 2):
break
continue
if aa <= 1:
while imgarr[yi, xi] >= fullwell:
......@@ -325,13 +331,15 @@ def MakeTrail(imgarr, satuyxtuple, charge, fullwell=9e4, direction='up', trailcu
imgarr[yi-1, xi] += charge
charge = imgarr[yi-1, xi]-fullwell
yi -= 1
if yi < 0:
# if yi < 0:
if yi < 0 or yi == (imgarr.shape[0]//2 - 1):
break
elif direction == 'down':
imgarr[yi+1, xi] += charge
charge = imgarr[yi+1, xi]-fullwell
yi += 1
if yi > imgarr.shape[0]:
# if yi > imgarr.shape[0]:
if yi > imgarr.shape[0] or yi == (imgarr.shape[0]//2):
break
else:
# calculate bleeding trail:
......
......@@ -91,6 +91,10 @@ class CatalogBase(metaclass=ABCMeta):
bandpass = target_filt.bandpass_full
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
else:
norm_filt = Table(
......
......@@ -75,7 +75,9 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
for ifilt in range(len(self.all_filters)):
temp_filter = self.all_filters[ifilt]
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():
cut_filter = temp_filter
......@@ -109,6 +111,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
try:
sed_data = cat.load_sed(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(
mag=obj.param["mag_use_normal"],
sed=sed_data,
......@@ -116,11 +119,12 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
norm_filt=norm_filt,
mu=obj.mu
)
_, 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"],
sed=sed_data,
target_filt=cut_filter,
norm_filt=norm_filt,
norm_filt=(norm_filt if norm_filt else filt),
mu=obj.mu
)
except Exception as e:
......@@ -129,6 +133,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
continue
# [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()]))
# Exclude very bright/dim objects (for now)
......@@ -136,7 +141,7 @@ def add_objects(self, chip, filt, tel, pointing, catalog, obs_param):
mag=obj.param["mag_%s" %
self.overall_config["obs_setting"]["cut_in_band"].lower()],
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()]))
bright_obj += 1
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