Commit 3c8691f8 authored by Zhang Xin's avatar Zhang Xin
Browse files

add led flat file; fix a bug for led normalize

parent 446862eb
...@@ -15,6 +15,13 @@ from scipy import interpolate ...@@ -15,6 +15,13 @@ from scipy import interpolate
from ObservationSim.MockObject.MockObject import MockObject from ObservationSim.MockObject.MockObject import MockObject
# from ObservationSim.Straylight import calculateSkyMap_split_g # from ObservationSim.Straylight import calculateSkyMap_split_g
try:
import importlib.resources as pkg_resources
except ImportError:
# Try backported to PY<37 'importlib_resources'
import importlib_resources as pkg_resources
# flatDir = '/Volumes/EAGET/LED_FLAT/' # flatDir = '/Volumes/EAGET/LED_FLAT/'
LED_name = ['LED1', 'LED2', 'LED3', 'LED4', 'LED5', 'LED6', 'LED7', 'LED8', 'LED9', 'LED10', 'LED11', 'LED12', 'LED13', LED_name = ['LED1', 'LED2', 'LED3', 'LED4', 'LED5', 'LED6', 'LED7', 'LED8', 'LED9', 'LED10', 'LED11', 'LED12', 'LED13',
'LED14'] 'LED14']
...@@ -36,19 +43,27 @@ fluxLED = {'LED1': 0.16478729, 'LED2': 0.084220931, 'LED3': 2.263360617, 'LED4': ...@@ -36,19 +43,27 @@ fluxLED = {'LED1': 0.16478729, 'LED2': 0.084220931, 'LED3': 2.263360617, 'LED4':
mirro_eff = {'GU':0.61, 'GV':0.8, 'GI':0.8} mirro_eff = {'GU':0.61, 'GV':0.8, 'GI':0.8}
class FlatLED(object): class FlatLED(object):
def __init__(self, chip,filt, flatDir = '/Users/zhangxin/Work/SlitlessSim/csst_sls_calibration/flat_field_cube/models/', logger=None): def __init__(self, chip,filt, flatDir = None, logger=None):
# self.led_type_list = led_type_list # self.led_type_list = led_type_list
self.flatDir = flatDir
self.filt = filt self.filt = filt
self.chip = chip self.chip = chip
self.logger = logger self.logger = logger
if flatDir is not None:
self.flatDir = flatDir
else:
try:
with pkg_resources.files('ObservationSim.MockObject.data.led').joinpath("") as ledDir:
self.flatDir = ledDir.as_posix()
except AttributeError:
with pkg_resources.path('ObservationSim.MockObject.data.led', "") as ledDir:
self.flatDir = ledDir.as_posix()
### ###
### return LED flat, e/s ### return LED flat, e/s
### ###
def getLEDImage(self, led_type='LED1'): def getLEDImage(self, led_type='LED1'):
# cwave = cwaves[led_type] # cwave = cwaves[led_type]
flat = fits.open(self.flatDir + 'model_' + cwaves_name[led_type] + 'nm.fits') flat = fits.open(os.path.join(self.flatDir, 'model_' + cwaves_name[led_type] + 'nm.fits'))
xlen = flat[0].header['NAXIS1'] xlen = flat[0].header['NAXIS1']
ylen = 601 ylen = 601
x = np.linspace(0, self.chip.npix_x * 6, xlen) x = np.linspace(0, self.chip.npix_x * 6, xlen)
......
...@@ -439,13 +439,13 @@ class Observation(object): ...@@ -439,13 +439,13 @@ class Observation(object):
pf_map = led_flat pf_map = led_flat
# whether to output zero, dark, flat calibration images. # whether to output zero, dark, flat calibration images.
expTime = self.config["obs_setting"]["exp_time"] expTime = self.config["obs_setting"]["exp_time"]
norm_scaler = skyback_level/expTime * self.filter_param.param[chip.filter_type][5] / self.filter_param.param[sky_level_filt][5] norm_scaler = skyback_level/expTime / self.filter_param.param[sky_level_filt][5]
if skyback_level == 0: if skyback_level == 0:
self.config["ins_effects"]["shutter_effect"] = False self.config["ins_effects"]["shutter_effect"] = False
if chip.survey_type == "photometric": if chip.survey_type == "photometric":
sky_map = np.ones_like(chip.img.array) * norm_scaler / self.tel.pupil_area sky_map = np.ones_like(chip.img.array) * norm_scaler * self.filter_param.param[chip.filter_type][5] / self.tel.pupil_area
elif chip.survey_type == "spectroscopic": elif chip.survey_type == "spectroscopic":
flat_normal = np.ones_like(chip.img.array) flat_normal = np.ones_like(chip.img.array)
if self.config["ins_effects"]["flat_fielding"] == True: if self.config["ins_effects"]["flat_fielding"] == True:
......
...@@ -72,6 +72,7 @@ setup(name='CSSTSim', ...@@ -72,6 +72,7 @@ setup(name='CSSTSim',
'ObservationSim.Instrument.Chip.libBF': ['libmoduleBF.so'], 'ObservationSim.Instrument.Chip.libBF': ['libmoduleBF.so'],
'ObservationSim.Instrument.Chip.libCTI': ['libmoduleCTI.so'], 'ObservationSim.Instrument.Chip.libCTI': ['libmoduleCTI.so'],
'ObservationSim.MockObject.data': ['*.dat'], 'ObservationSim.MockObject.data': ['*.dat'],
'ObservationSim.MockObject.data.led': ['*.fits'],
'ObservationSim.Instrument.data': ['*.txt', '*.dat', '*.json'], 'ObservationSim.Instrument.data': ['*.txt', '*.dat', '*.json'],
'ObservationSim.Instrument.data.field_distortion': ['*.pickle'], 'ObservationSim.Instrument.data.field_distortion': ['*.pickle'],
'ObservationSim.Instrument.data.ccd': ['*.txt'], 'ObservationSim.Instrument.data.ccd': ['*.txt'],
......
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