Commit 8165a134 authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 07fc48c3
Pipeline #7092 failed with stage
in 0 seconds
...@@ -28,7 +28,6 @@ import astropy.coordinates as coord ...@@ -28,7 +28,6 @@ import astropy.coordinates as coord
import ctypes import ctypes
import sys import sys
##sys.path.append('./csst_ifs_sim') ##sys.path.append('./csst_ifs_sim')
conf.auto_max_age = None conf.auto_max_age = None
...@@ -1149,6 +1148,25 @@ def beta_angle(x_sat, y_sat, z_sat, vx_sat, vy_sat, vz_sat, ra_obj, dec_obj): ...@@ -1149,6 +1148,25 @@ def beta_angle(x_sat, y_sat, z_sat, vx_sat, vy_sat, vz_sat, ra_obj, dec_obj):
return angle return angle
############################################################################### ###############################################################################
def find_min(arr):
min_val = arr[0]
min_index = 0
for i in range(1, len(arr)):
if arr[i] < min_val:
min_val = arr[i]
min_index = i
return min_val, min_index
#################################
def find_max(arr):
max_val = arr[0]
max_index = 0
for i in range(1, len(arr)):
if arr[i] > max_val:
max_val = arr[i]
max_index = i
return max_val, max_index
########################################################## ##########################################################
...@@ -1534,12 +1552,16 @@ def get_dx_dy_blue(wave): ...@@ -1534,12 +1552,16 @@ def get_dx_dy_blue(wave):
""" """
# wave is the wavelength in nm; # wave is the wavelength in nm;
# dx is in dispersion direction, dy is in vertical direction; # dx is in dispersion direction, dy is in vertical direction;
dydl = np.array([-423.256, 0.001, 0.00075, # dydl = np.array([-423.256, 0.001, 0.00075,
0.0000078, -0.0000000000007, 0.0, 0.0]) # 0.0000078, -0.0000000000007, 0.0, 0.0])
# 色散方向 # # 色散方向
dxdl = 0.2*np.array([-9.1519, -1.00000000e-06, 3.50000000e-08, -5.00000000e-09, # dxdl = 0.2*np.array([-9.1519, -1.00000000e-06, 3.50000000e-08, -5.00000000e-09,
-1.70000000e-11, 4.00949787e-12, -6.16873452e-15]) # -1.70000000e-11, 4.00949787e-12, -6.16873452e-15])
# 垂直方向
##### update @2024.10.16
dydl=np.array([ 2447.9, -1/0.141, 0.0000075, 0.00000078, -0.000000000007] ) ; #色散方向
dxdl=np.array([ 5.46, -1.5e-02, 3.5e-08, -5.0e-09]) #垂直方向
dx = 0.0 dx = 0.0
dy = 0.0 dy = 0.0
for i in range(len(dxdl)): for i in range(len(dxdl)):
...@@ -1567,10 +1589,13 @@ def get_dx_dy_red(wave): ...@@ -1567,10 +1589,13 @@ def get_dx_dy_red(wave):
""" """
# wave is the wavelength in nm; # wave is the wavelength in nm;
dydl = np.array([-640.0239901372472, 0.0018, 0.00048, # dydl = np.array([-640.0239901372472, 0.0018, 0.00048,
0.0000028, -0.0000000000007, 0.0, 0.0]) # 色散方向 # 0.0000028, -0.0000000000007, 0.0, 0.0]) # 色散方向
dxdl = 0.00325*np.array([-1638.8, 4.0e-2, 5.500e-3, - # dxdl = 0.00325*np.array([-1638.8, 4.0e-2, 5.500e-3, -
5.2e-10, 1.7000e-10, 7.1e-13, -5.16e-15]) # 垂直方向 # 5.2e-10, 1.7000e-10, 7.1e-13, -5.16e-15]) # 垂直方向
## update @2014.10.17
dydl=np.array([3519.78622, -1/0.1555, 0.0000048, 0.00000028, -0.0000000000007] ) #色散方向
dxdl=np.array([-5.6305, 1.0e-2, 5.500e-7, -5.2e-10]) #垂直方向
dx = 0.0 dx = 0.0
dy = 0.0 dy = 0.0
...@@ -1754,6 +1779,9 @@ class IFSsimulator(): ...@@ -1754,6 +1779,9 @@ class IFSsimulator():
self.readoutNoise = self.config.getboolean( self.readoutNoise = self.config.getboolean(
self.section, 'readoutnoise') self.section, 'readoutnoise')
self.appbianpai = self.config.getboolean(
self.section, 'appbianpai')
self.intscale = True self.intscale = True
###################################################################### ######################################################################
...@@ -1769,7 +1797,8 @@ class IFSsimulator(): ...@@ -1769,7 +1797,8 @@ class IFSsimulator():
bleeding=self.bleeding, bleeding=self.bleeding,
sky_noise=self.sky_noise, sky_noise=self.sky_noise,
intscale=self.intscale, intscale=self.intscale,
save_cosmicrays=self.save_cosmicrays) save_cosmicrays=self.save_cosmicrays,
appbianpai=self.appbianpai)
############################################################################ ############################################################################
...@@ -2134,9 +2163,14 @@ class IFSsimulator(): ...@@ -2134,9 +2163,14 @@ class IFSsimulator():
slice_red['py'][i] = 50+250+randRedpos[i]*4 slice_red['py'][i] = 50+250+randRedpos[i]*4
slice_red['px'][i] = 3.55/0.015*(i-16)+1190.0+118 slice_red['px'][i] = 3.55/0.015*(i-16)+1190.0+118
####### #######
###### flip the fringe up to down,down to up@2024.10.16
self.slice_blue = dict()
self.slice_red = dict()
self.slice_blue['py'] =2000-slice_blue['py']
self.slice_blue['px'] = slice_blue['px']
self.slice_blue = slice_blue self.slice_red['py'] =3000-slice_red['py']
self.slice_red = slice_red self.slice_red['px'] =slice_red['px']
####################################################################### #######################################################################
maskSlice = dict() maskSlice = dict()
...@@ -2439,35 +2473,35 @@ class IFSsimulator(): ...@@ -2439,35 +2473,35 @@ class IFSsimulator():
# blue zone 4 # blue zone 4
self.image_b[0:1024, 0:2048] += self.information['exptime'] * \ self.image_b[0:1024, 0:2048] += self.information['exptime'] * \
self.information['dark4_b'] self.information['dark2_b']
########## zone 1 ################# ########## zone 1 #################
self.image_b[1024:2048, 0:2048] += self.information['exptime'] * \ self.image_b[1024:2048, 0:2048] += self.information['exptime'] * \
self.information['dark1_b'] self.information['dark3_b']
########## zone 3 ################### ########## zone 3 ###################
self.image_b[0:1024, 2048:4096] += self.information['exptime'] * \ self.image_b[0:1024, 2048:4096] += self.information['exptime'] * \
self.information['dark3_b'] self.information['dark1_b']
# zone 2 # zone 2
self.image_b[1024:2048, 2048:4096] += self.information['exptime'] * \ self.image_b[1024:2048, 2048:4096] += self.information['exptime'] * \
self.information['dark2_b'] self.information['dark4_b']
# red zone 4 # red zone 4
self.image_r[0:1536, 0:3072] += self.information['exptime'] * \ self.image_r[0:1536, 0:3072] += self.information['exptime'] * \
self.information['dark4_r'] self.information['dark2_r']
########## zone 1 ################# ########## zone 1 #################
self.image_r[1536:3712, 0:3072] += self.information['exptime'] * \ self.image_r[1536:3712, 0:3072] += self.information['exptime'] * \
self.information['dark1_r'] self.information['dark3_r']
########## zone 3 ################### ########## zone 3 ###################
self.image_r[0:1536, 3072:6144] += self.information['exptime'] * \ self.image_r[0:1536, 3072:6144] += self.information['exptime'] * \
self.information['dark3_r'] self.information['dark1_r']
# zone 2 # zone 2
self.image_r[1536:3072, 3072:6144] += self.information['exptime'] * \ self.image_r[1536:3072, 3072:6144] += self.information['exptime'] * \
self.information['dark2_r'] self.information['dark4_r']
############################################################################## ##############################################################################
...@@ -2715,44 +2749,44 @@ class IFSsimulator(): ...@@ -2715,44 +2749,44 @@ class IFSsimulator():
overscan = 320 overscan = 320
# zone 4 , OSH #### 1024, 2048 # zone 4 , OSH #### 1024, 2048
self.image_b[0:1024+overscan, 0:2048+prescan+overscan] += np.random.normal( self.image_b[0:1024+overscan, 0:2048+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn4_b'], size=(1344, 2418)) loc=0.0, scale=self.information['rn2_b'], size=(1344, 2418))
########## zone 3, OSG ################# ########## zone 3, OSG #################
np.random.seed() np.random.seed()
self.image_b[0:1024+overscan, 2418:2418+2048+prescan+overscan] += np.random.normal( self.image_b[0:1024+overscan, 2418:2418+2048+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn3_b'], size=(1344, 2418)) loc=0.0, scale=self.information['rn1_b'], size=(1344, 2418))
########## zone 1, OSE ################### ########## zone 1, OSE ###################
np.random.seed() np.random.seed()
self.image_b[0:1024+overscan, 2418*2:2418*2+2048+prescan+overscan] += np.random.normal( self.image_b[0:1024+overscan, 2418*2:2418*2+2048+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn1_b'], size=(1344, 2418)) loc=0.0, scale=self.information['rn3_b'], size=(1344, 2418))
########## zone 2, OSF ############### ########## zone 2, OSF ###############
np.random.seed() np.random.seed()
self.image_b[0:1024+overscan, 2418*3:2418*3+2048+prescan+overscan] += np.random.normal( self.image_b[0:1024+overscan, 2418*3:2418*3+2048+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn2_b'], size=(1344, 2418)) loc=0.0, scale=self.information['rn4_b'], size=(1344, 2418))
self.log.info('readnoise added in blue channel') self.log.info('readnoise added in blue channel')
# red zone 4 , OSH### 1536* 3072 # red zone 4 , OSH### 1536* 3072
np.random.seed() np.random.seed()
self.image_r[0:1536+overscan, 0:3072+prescan+overscan] += np.random.normal( self.image_r[0:1536+overscan, 0:3072+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn4_r'], size=(1856, 3442)) loc=0.0, scale=self.information['rn2_r'], size=(1856, 3442))
########## zone 3 ,OSG ################# ########## zone 3 ,OSG #################
np.random.seed() np.random.seed()
self.image_r[0:1536+overscan, 3442:3442+3072+prescan+overscan] += np.random.normal( self.image_r[0:1536+overscan, 3442:3442+3072+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn3_r'], size=(1856, 3442)) loc=0.0, scale=self.information['rn1_r'], size=(1856, 3442))
########## zone 1 ,OSE ################### ########## zone 1 ,OSE ###################
np.random.seed() np.random.seed()
self.image_r[0:1536+overscan, 3442*2:3442*2+3072+prescan+overscan] += np.random.normal( self.image_r[0:1536+overscan, 3442*2:3442*2+3072+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn1_r'], size=(1856, 3442)) loc=0.0, scale=self.information['rn3_r'], size=(1856, 3442))
########## zone 2,OSF ########### ########## zone 2,OSF ###########
np.random.seed() np.random.seed()
self.image_r[0:1536+overscan, 3442*3:3442*3+3072+prescan+overscan] += np.random.normal( self.image_r[0:1536+overscan, 3442*3:3442*3+3072+prescan+overscan] += np.random.normal(
loc=0.0, scale=self.information['rn2_r'], size=(1856, 3442)) loc=0.0, scale=self.information['rn4_r'], size=(1856, 3442))
########################################################################################## ##########################################################################################
...@@ -2880,31 +2914,44 @@ class IFSsimulator(): ...@@ -2880,31 +2914,44 @@ class IFSsimulator():
self.log.info( self.log.info(
'Converting from electrons to ADUs using a factor of gain') 'Converting from electrons to ADUs using a factor of gain')
# blue zone 4 # # blue zone 4
self.image_b[0:1344, 0:2418] /= self.information['gain4_b'] # self.image_b[0:1344, 0:2418] /= self.information['gain4_b']
########## zone 3 ################# # ########## zone 3 #################
self.image_b[0:1344, 2418:2418*2] /= self.information['gain3_b'] # self.image_b[0:1344, 2418:2418*2] /= self.information['gain3_b']
########## zone 1 ################### # ########## zone 1 ###################
self.image_b[0:1344, 2418*2:2418*3] /= self.information['gain1_b'] # self.image_b[0:1344, 2418*2:2418*3] /= self.information['gain1_b']
# zone 2 # # zone 2
self.image_b[0:1344, 2418*3:2418*4] /= self.information['gain2_b'] # self.image_b[0:1344, 2418*3:2418*4] /= self.information['gain2_b']
################# update @2024.10.18 ###
# first part, menas old blue zone 4
self.image_b[0:1344, 0:2418] /= self.information['gain1_b']
##########second part, means old zone 3 #################
self.image_b[0:1344, 2418:2418*2] /= self.information['gain2_b']
##########third part, means old zone 1 ###################
self.image_b[0:1344, 2418*2:2418*3] /= self.information['gain3_b']
#### fourth part, means old zone 2
self.image_b[0:1344, 2418*3:2418*4] /= self.information['gain4_b']
############################################################################ ############################################################################
##########################
# red zone 4 # red zone 4
self.image_r[0:1856, 0:3442] /= self.information['gain4_r'] self.image_r[0:1856, 0:3442] /= self.information['gain1_r']
########## zone 3 ################# ########## zone 3 #################
self.image_r[0:1856, 3442:3442*2] /= self.information['gain3_r'] self.image_r[0:1856, 3442:3442*2] /= self.information['gain2_r']
########## zone 1 ################### ########## zone 1 ###################
self.image_r[0:1856, 3442*2:3442*3] /= self.information['gain1_r'] self.image_r[0:1856, 3442*2:3442*3] /= self.information['gain3_r']
# zone 2 # zone 2
self.image_r[0:1856, 3442*3:3442*4] /= self.information['gain2_r'] self.image_r[0:1856, 3442*3:3442*4] /= self.information['gain4_r']
# 3 # 3
...@@ -2979,16 +3026,16 @@ class IFSsimulator(): ...@@ -2979,16 +3026,16 @@ class IFSsimulator():
######################################################################## ########################################################################
# blue zone 4 # blue zone 4
self.image_b[0:1344, 0:2418] += self.information['bias4_b'] self.image_b[0:1344, 0:2418] += self.information['bias2_b']
########## zone 3 ################# ########## zone 3 #################
self.image_b[0:1344, 2418:2418*2] += self.information['bias3_b'] self.image_b[0:1344, 2418:2418*2] += self.information['bias1_b']
########## zone 1 ################### ########## zone 1 ###################
self.image_b[0:1344, 2418*2:2418*3] += self.information['bias1_b'] self.image_b[0:1344, 2418*2:2418*3] += self.information['bias3_b']
# zone 2 # zone 2
self.image_b[0:1344, 2418*3:2418*4] += self.information['bias2_b'] self.image_b[0:1344, 2418*3:2418*4] += self.information['bias4_b']
############################################################################ ############################################################################
...@@ -2997,16 +3044,16 @@ class IFSsimulator(): ...@@ -2997,16 +3044,16 @@ class IFSsimulator():
####################################################################### #######################################################################
# red zone 4 # red zone 4
self.image_r[0:1856, 0:3442] += self.information['bias4_r'] self.image_r[0:1856, 0:3442] += self.information['bias2_r']
########## zone 3 ################# ########## zone 3 #################
self.image_r[0:1856, 3442:3442*2] += self.information['bias3_r'] self.image_r[0:1856, 3442:3442*2] += self.information['bias1_r']
########## zone 1 ################### ########## zone 1 ###################
self.image_r[0:1856, 3442*2:3442*3] += self.information['bias1_r'] self.image_r[0:1856, 3442*2:3442*3] += self.information['bias3_r']
# zone 2 # zone 2
self.image_r[0:1856, 3442*3:3442*4] += self.information['bias2_r'] self.image_r[0:1856, 3442*3:3442*4] += self.information['bias4_r']
####################################################################### #######################################################################
...@@ -3290,14 +3337,46 @@ class IFSsimulator(): ...@@ -3290,14 +3337,46 @@ class IFSsimulator():
overscan = int(self.information['overscan']) overscan = int(self.information['overscan'])
temp = np.zeros((1344, 9672)) temp = np.zeros((1344, 9672))
# zone 4, OSH ######0:1024, 50:2048+50 # # zone 4, OSH ######0:1024, 50:2048+50
# x1 = 0
# x2 = x1+1024
# y1 = 0+prescan
# y2 = y1+2048
# temp[x1:x2, y1:y2] = imgb[0:1024, 0:2048]
# # zone 3, OSG , left to right #################
# # np.fliplr(b2) ## left to right
# # np.flipud(b3) ## down to up
# x1 = 0
# x2 = x1+1024
# y1 = 2418+prescan
# y2 = y1+2048
# temp[x1:x2, y1:y2] = np.fliplr(imgb[0:1024, 2048:4096])
# # zone 1, OSE,down to up ###################
# x1 = 0
# x2 = x1+1024
# y1 = 2418*2+prescan
# y2 = y1+2048
# temp[x1:x2, y1:y2] = np.flipud(imgb[1024:2048, 0:2048])
# ########## zone 2, OSF down to yp ,left to right #######
# x1 = 0
# x2 = x1+1024
# y1 = 2418*3+prescan
# y2 = y1+2048
# temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgb[1024:2048, 2048:4096]))
### update 2024.10.18
# first part, old OSG part ,## shift: left to right
x1 = 0 x1 = 0
x2 = x1+1024 x2 = x1+1024
y1 = 0+prescan y1 = 0+prescan
y2 = y1+2048 y2 = y1+2048
temp[x1:x2, y1:y2] = imgb[0:1024, 0:2048] temp[x1:x2, y1:y2] = np.fliplr(imgb[0:1024, 2048:4096])
# zone 3, OSG , left to right ################# # second part, old OSH, no shift #################
# np.fliplr(b2) ## left to right # np.fliplr(b2) ## left to right
# np.flipud(b3) ## down to up # np.flipud(b3) ## down to up
x1 = 0 x1 = 0
...@@ -3305,15 +3384,15 @@ class IFSsimulator(): ...@@ -3305,15 +3384,15 @@ class IFSsimulator():
y1 = 2418+prescan y1 = 2418+prescan
y2 = y1+2048 y2 = y1+2048
temp[x1:x2, y1:y2] = np.fliplr(imgb[0:1024, 2048:4096]) temp[x1:x2, y1:y2] = imgb[0:1024, 0:2048]
# zone 1, OSE,down to up ################### ### third part, old OSE, down to up ###################
x1 = 0 x1 = 0
x2 = x1+1024 x2 = x1+1024
y1 = 2418*2+prescan y1 = 2418*2+prescan
y2 = y1+2048 y2 = y1+2048
temp[x1:x2, y1:y2] = np.flipud(imgb[1024:2048, 0:2048]) temp[x1:x2, y1:y2] = np.flipud(imgb[1024:2048, 0:2048])
########## zone 2, OSF down to yp ,left to right ####### ########## fourth part, old OSF part; down to yp ,left to right #######
x1 = 0 x1 = 0
x2 = x1+1024 x2 = x1+1024
...@@ -3321,20 +3400,53 @@ class IFSsimulator(): ...@@ -3321,20 +3400,53 @@ class IFSsimulator():
y2 = y1+2048 y2 = y1+2048
temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgb[1024:2048, 2048:4096])) temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgb[1024:2048, 2048:4096]))
self.image_b = temp self.image_b = temp
####################################################################### #######################################################################
imgr = self.image_r.copy() imgr = self.image_r.copy()
temp = np.zeros((1856, 13768)) temp = np.zeros((1856, 13768))
# zone 4, OSH ######0:1024, 50:2048+50 # # zone 4, OSH ######0:1024, 50:2048+50
# x1 = 0
# x2 = x1+1536
# y1 = 0+prescan
# y2 = y1+3072
# temp[x1:x2, y1:y2] = imgr[0:1536, 0:3072]
# ########## zone 3, OSG , left to right #################
# # np.fliplr(b2) ## left to right
# # np.flipud(b3) ## down to up
# x1 = 0
# x2 = x1+1536
# y1 = 3442+prescan
# y2 = y1+3072
# temp[x1:x2, y1:y2] = np.fliplr(imgr[0:1536, 3072:6144])
# ########## zone 1, OSE,down to up ############################
# x1 = 0
# x2 = x1+1536
# y1 = 3442*2+prescan
# y2 = y1+3072
# temp[x1:x2, y1:y2] = np.flipud(imgr[1536:3072, 0:3072])
# ########## zone 2, OSF down to yp ,left to right ################
# x1 = 0
# x2 = x1+1536
# y1 = 3442*3+prescan
# y2 = y1+3072
# temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgr[1536:3072, 3072:6144]))
###### update @2024.10.18
# readout image ,first part, old OSG, shift: left to right
x1 = 0 x1 = 0
x2 = x1+1536 x2 = x1+1536
y1 = 0+prescan y1 = 0+prescan
y2 = y1+3072 y2 = y1+3072
temp[x1:x2, y1:y2] = imgr[0:1536, 0:3072] temp[x1:x2, y1:y2] = np.fliplr(imgr[0:1536, 3072:6144])
########## zone 3, OSG , left to right ################# ########## second part, old OSH ,no change; #################
# np.fliplr(b2) ## left to right # np.fliplr(b2) ## left to right
# np.flipud(b3) ## down to up # np.flipud(b3) ## down to up
x1 = 0 x1 = 0
...@@ -3342,15 +3454,15 @@ class IFSsimulator(): ...@@ -3342,15 +3454,15 @@ class IFSsimulator():
y1 = 3442+prescan y1 = 3442+prescan
y2 = y1+3072 y2 = y1+3072
temp[x1:x2, y1:y2] = np.fliplr(imgr[0:1536, 3072:6144]) temp[x1:x2, y1:y2] = imgr[0:1536, 0:3072]
########## zone 1, OSE,down to up ############################ ########## third part , old OSE , down to up ############################
x1 = 0 x1 = 0
x2 = x1+1536 x2 = x1+1536
y1 = 3442*2+prescan y1 = 3442*2+prescan
y2 = y1+3072 y2 = y1+3072
temp[x1:x2, y1:y2] = np.flipud(imgr[1536:3072, 0:3072]) temp[x1:x2, y1:y2] = np.flipud(imgr[1536:3072, 0:3072])
########## zone 2, OSF down to yp ,left to right ################ ########## fourth part, old OSF, down to up ,left to right ################
x1 = 0 x1 = 0
x2 = x1+1536 x2 = x1+1536
...@@ -3358,6 +3470,7 @@ class IFSsimulator(): ...@@ -3358,6 +3470,7 @@ class IFSsimulator():
y2 = y1+3072 y2 = y1+3072
temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgr[1536:3072, 3072:6144])) temp[x1:x2, y1:y2] = np.flipud(np.fliplr(imgr[1536:3072, 3072:6144]))
self.image_r = temp self.image_r = temp
return return
...@@ -3383,6 +3496,18 @@ class IFSsimulator(): ...@@ -3383,6 +3496,18 @@ class IFSsimulator():
Updates header with the input values and flags used during simulation. Updates header with the input values and flags used during simulation.
""" """
######
###### add random pointing error to telescope, the telescope poingt parameter in
###### fits header have random pointing error
ud_ra = np.random.random() # Choose a random shift in arcsec
self.information['ra_pnt0']=self.information['dec_pnt0']+0.01*ud_ra
ud_dec= np.random.random()
self.information['dec_pnt0']=self.information['dec_pnt0']+0.01*ud_dec
HeaderTest = 'no' HeaderTest = 'no'
sim_ver = str(self.information['sim_ver']) sim_ver = str(self.information['sim_ver'])
...@@ -4765,16 +4890,30 @@ class IFSsimulator(): ...@@ -4765,16 +4890,30 @@ class IFSsimulator():
# RA_PNT0 =OBJ_RA + DIS_RA/cos(OBJ_DEC), DEC_PNT0= OBJ_DEC DIS_DEC # RA_PNT0 =OBJ_RA + DIS_RA/cos(OBJ_DEC), DEC_PNT0= OBJ_DEC DIS_DEC
self.information['ra_pnt0'] = a[0].header['RA'] + \ self.information['ra_pnt0'] = a[0].header['RA'] + \
disRa/np.cos(a[0].header['DEC']/180.0*np.pi) disRa/np.cos(a[0].header['DEC']/180.0*np.pi)
self.information['dec_pnt0'] = a[0].header['DEC'] + disDec self.information['dec_pnt0'] = a[0].header['DEC'] + disDec
############### calculate the earthshine and zodiacal noise ,new code 2023.11.1 ############ ############### calculate the earthshine and zodiacal noise ,new code 2023.11.1 ############
############### ###############
self.log.info('Real telescope pointing in Ra = %f, Dec = %f' % (self.information['ra_pnt0'], self.information['dec_pnt0']))
ra = self.information['ra_pnt0'] ra = self.information['ra_pnt0']
dec = self.information['dec_pnt0'] dec = self.information['dec_pnt0']
time_jd = time2jd(self.dt) time_jd = time2jd(self.dt)
if self.appbianpai:
sn=self.simnumber-1;
x_sat = float(self.bianpai_data['x_sat'][sn*5+self.exptime_start_index])
y_sat = float(self.bianpai_data['y_sat'][sn*5+self.exptime_start_index])
z_sat = float(self.bianpai_data['z_sat'][sn*5+self.exptime_start_index])
###
else:
x_sat = float(self.orbit_pars[self.orbit_exp_num, 1]) x_sat = float(self.orbit_pars[self.orbit_exp_num, 1])
y_sat = float(self.orbit_pars[self.orbit_exp_num, 2]) y_sat = float(self.orbit_pars[self.orbit_exp_num, 2])
z_sat = float(self.orbit_pars[self.orbit_exp_num, 3]) z_sat = float(self.orbit_pars[self.orbit_exp_num, 3])
...@@ -4856,6 +4995,18 @@ class IFSsimulator(): ...@@ -4856,6 +4995,18 @@ class IFSsimulator():
width_blue = 0 width_blue = 0
################################ ################################
############## doppler effect to photons.wavelength ############# ############## doppler effect to photons.wavelength #############
if self.appbianpai:
sn=self.simnumber-1;
x_sat = float(self.bianpai_data['x_sat'][sn*5+self.exptime_start_index])
y_sat = float(self.bianpai_data['y_sat'][sn*5+self.exptime_start_index])
z_sat = float(self.bianpai_data['z_sat'][sn*5+self.exptime_start_index])
vx_sat = float(self.bianpai_data['vx_sat'][sn*5+self.exptime_start_index])
vy_sat = float(self.bianpai_data['vy_sat'][sn*5+self.exptime_start_index])
vz_sat = float(self.bianpai_data['vz_sat'][sn*5+self.exptime_start_index])
else:
# self.orbit_pars # self.orbit_pars
x_sat = float(self.orbit_pars[self.orbit_exp_num, 1]) x_sat = float(self.orbit_pars[self.orbit_exp_num, 1])
...@@ -4881,6 +5032,19 @@ class IFSsimulator(): ...@@ -4881,6 +5032,19 @@ class IFSsimulator():
self.information['ra_obj'], self.information['dec_obj'], v1, self.TianCe_day) self.information['ra_obj'], self.information['dec_obj'], v1, self.TianCe_day)
################################################# #################################################
if self.appbianpai:
sn=self.simnumber-1;
p1x = float(self.bianpai_data['x_sat'][sn*5+self.exptime_end_index])
p1y = float(self.bianpai_data['y_sat'][sn*5+self.exptime_end_index])
p1z = float(self.bianpai_data['z_sat'][sn*5+self.exptime_end_index])
p1vx = float(self.bianpai_data['vx_sat'][sn*5+self.exptime_end_index])
p1vy = float(self.bianpai_data['vy_sat'][sn*5+self.exptime_end_index])
p1vz = float(self.bianpai_data['vz_sat'][sn*5+self.exptime_end_index])
else:
# exposure end time is t2 ; # exposure end time is t2 ;
t2 = self.dt+timedelta(seconds=self.information['exptime']) t2 = self.dt+timedelta(seconds=self.information['exptime'])
### data read time is the exposure end time plus readouttime ### ### data read time is the exposure end time plus readouttime ###
...@@ -4911,9 +5075,9 @@ class IFSsimulator(): ...@@ -4911,9 +5075,9 @@ class IFSsimulator():
p1vx = self.orbit_pars[k, 4]-(self.orbit_pars[k+1, 4] - p1vx = self.orbit_pars[k, 4]-(self.orbit_pars[k+1, 4] -
self.orbit_pars[k, 4])*deltaT.seconds/120 self.orbit_pars[k, 4])*deltaT.seconds/120
p1vx = self.orbit_pars[k, 5]-(self.orbit_pars[k+1, 5] - p1vy = self.orbit_pars[k, 5]-(self.orbit_pars[k+1, 5] -
self.orbit_pars[k, 5])*deltaT.seconds/120 self.orbit_pars[k, 5])*deltaT.seconds/120
p1vx = self.orbit_pars[k, 6]-(self.orbit_pars[k+1, 6] - p1vz = self.orbit_pars[k, 6]-(self.orbit_pars[k+1, 6] -
self.orbit_pars[k, 6])*deltaT.seconds/120 self.orbit_pars[k, 6])*deltaT.seconds/120
else: else:
...@@ -4961,7 +5125,7 @@ class IFSsimulator(): ...@@ -4961,7 +5125,7 @@ class IFSsimulator():
ilam = klam*alfa ilam = klam*alfa
if ilam >= 6000: if ilam >= 4000:
break break
# print(ilam) # print(ilam)
...@@ -5692,7 +5856,7 @@ class IFSsimulator(): ...@@ -5692,7 +5856,7 @@ class IFSsimulator():
self.debug = self.information['debug'] self.debug = self.information['debug']
self.dt = datetime.utcnow()
if self.information['exptime']>2000 or self.information['exptime']<0: if self.information['exptime']>2000 or self.information['exptime']<0:
...@@ -5719,17 +5883,42 @@ class IFSsimulator(): ...@@ -5719,17 +5883,42 @@ class IFSsimulator():
print('self.skyfilepath = ', self.skyfilepath) print('self.skyfilepath = ', self.skyfilepath)
# self.earthshine_theta=30.0 # in degree ###################################################################
if self.appbianpai:
### load yunxingbianpai csv file
############ load star data catlog #####################
starcat=self.information['bianpai_file']
##starcat='selection_20230517_concat.fits'
###################################################
self.log.info('Stat catlog file name is %s' % (starcat))
##########################################
df=pd.read_csv(self.information['dir_path']+'IFS_inputdata/TianCe/'+starcat)
###################################################################
sn=self.simnumber-1;
arr=np.array(df['time'][sn*5:sn*5+5]);
self.exptime_start_jd,self.exptime_start_index=find_min(arr);
self.exptime_end_jd, self.exptime_end_index =find_max(arr);
###self.earthshine_theta=df['earth_angle'][sn*5+index] # in degree
self.dt = jd2time(self.exptime_start_jd);
self.bianpai_data=df;
################################################################## ##################################################################
else:
#### load orbit parameters ##### #### load orbit parameters #####
flag = 0 flag = 0
self.dt = datetime.utcnow()
self.dt_num = int( self.dt_num = int(
self.simnumber*(self.information['exptime']+self.information['readouttime']+125)/120) self.simnumber*(self.information['exptime']+self.information['readouttime']+125)/120)
now_dt = datetime.utcnow() now_dt = datetime.utcnow()
now_jd = time2jd(now_dt) now_jd = time2jd(now_dt)
for k in range(1, 50, 1): for k in range(1, 50, 1):
# fn=father_path+'/IFS_inputdata/TianCe/orbit20160925/'+str(k)+'.txt'; # fn=father_path+'/IFS_inputdata/TianCe/orbit20160925/'+str(k)+'.txt';
...@@ -5745,7 +5934,7 @@ class IFSsimulator(): ...@@ -5745,7 +5934,7 @@ class IFSsimulator():
if flag == 1: if flag == 1:
break break
################################ ##################################################################
if kk + self.dt_num < len(d[:, 0]): if kk + self.dt_num < len(d[:, 0]):
...@@ -5764,19 +5953,18 @@ class IFSsimulator(): ...@@ -5764,19 +5953,18 @@ class IFSsimulator():
self.orbit_pars = d self.orbit_pars = d
self.orbit_file_num = k+1 self.orbit_file_num = k+1
self.orbit_exp_num = self.dt_num self.orbit_exp_num = self.dt_num
##########################################
########################################################################
#self.dt=julian.from_jd(exptime_start_jd, fmt='jd')
self.dt = jd2time(exptime_start_jd) self.dt = jd2time(exptime_start_jd)
##################################################################
################################################################## ##################################################################
# str(self.dt.year)+'-'+str(self.dt.month)+'-'+str(self.dt.day)
self.TianCe_day = self.dt.strftime("%Y-%m-%d") self.TianCe_day = self.dt.strftime("%Y-%m-%d")
self.TianCe_exp_start = dt2hmd(self.dt) self.TianCe_exp_start = dt2hmd(self.dt)
self.zodiacal_time = self.TianCe_day self.zodiacal_time = self.TianCe_day
###################################################################
skyRa = 0 skyRa = 0
skyDec = 0 skyDec = 0
...@@ -5787,6 +5975,7 @@ class IFSsimulator(): ...@@ -5787,6 +5975,7 @@ class IFSsimulator():
sky_rot = 2 * (ud-0.5) * 5 sky_rot = 2 * (ud-0.5) * 5
dsmax = np.floor(50*np.cos(sky_rot/180*np.pi))-34 dsmax = np.floor(50*np.cos(sky_rot/180*np.pi))-34
np.random.seed(11*self.simnumber) np.random.seed(11*self.simnumber)
ud = np.random.random() # Choose a random shift in arcsec ud = np.random.random() # Choose a random shift in arcsec
telRa = 2 * (ud-0.5) * dsmax * 0.1 # in arcsec telRa = 2 * (ud-0.5) * dsmax * 0.1 # in arcsec
...@@ -5813,6 +6002,7 @@ class IFSsimulator(): ...@@ -5813,6 +6002,7 @@ class IFSsimulator():
####################################################################### #######################################################################
elif self.source == 'FLAT': elif self.source == 'FLAT':
self.dt = datetime.utcnow()
self.information['exptime'] = 200+simnumber*100 self.information['exptime'] = 200+simnumber*100
self.sim_calibration_img(self.information['exptime'], 'FLAT') self.sim_calibration_img(self.information['exptime'], 'FLAT')
self.information['sky_rot'] = 0 self.information['sky_rot'] = 0
...@@ -5820,6 +6010,7 @@ class IFSsimulator(): ...@@ -5820,6 +6010,7 @@ class IFSsimulator():
######## ########
elif self.source == 'LAMP': elif self.source == 'LAMP':
self.dt = datetime.utcnow()
self.information['exptime'] = 200+simnumber*100 self.information['exptime'] = 200+simnumber*100
self.information['sky_rot'] = 0 self.information['sky_rot'] = 0
...@@ -5831,12 +6022,14 @@ class IFSsimulator(): ...@@ -5831,12 +6022,14 @@ class IFSsimulator():
######### #########
elif self.source == 'DARK': elif self.source == 'DARK':
self.dt = datetime.utcnow()
self.information['sky_rot'] = 0 self.information['sky_rot'] = 0
self.information['exptime'] = simnumber*3600*24 self.information['exptime'] = simnumber*3600*24
self.image_b = np.zeros((2048, 4096)) self.image_b = np.zeros((2048, 4096))
self.image_r = np.zeros((3072, 6144)) self.image_r = np.zeros((3072, 6144))
elif self.source == 'BIAS': elif self.source == 'BIAS':
self.dt = datetime.utcnow()
self.information['sky_rot'] = 0 self.information['sky_rot'] = 0
self.information['exptime'] = 0 self.information['exptime'] = 0
self.image_b = np.zeros((2048, 4096)) self.image_b = np.zeros((2048, 4096))
......
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