Commit 7ae8c85f authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 0c74ea42
...@@ -356,7 +356,7 @@ class cosmicrays(): ...@@ -356,7 +356,7 @@ class cosmicrays():
exposure time. exposure time.
""" """
def __init__(self, log, image, crInfo=None, information=None): def __init__(self, log, image, exposuretime,crInfo=None, information=None):
""" """
Cosmic ray generation class. Can either draw events from distributions or Cosmic ray generation class. Can either draw events from distributions or
set the energy of the events to a constant. set the energy of the events to a constant.
...@@ -376,8 +376,7 @@ class cosmicrays(): ...@@ -376,8 +376,7 @@ class cosmicrays():
# set up the information dictionary, first with defaults and then overwrite with inputs if given # set up the information dictionary, first with defaults and then overwrite with inputs if given
self.information = (dict(cosmicraylengths='/home/yan/csst-master/data/cdf_cr_length.dat', self.information = (dict(cosmicraylengths='/home/yan/csst-master/data/cdf_cr_length.dat',
cosmicraydistance='/home/yan/csst-master/data/cdf_cr_total.dat', cosmicraydistance='/home/yan/csst-master/data/cdf_cr_total.dat',exptime=exposuretime))
exptime=565))
if information is not None: if information is not None:
self.information.update(information) self.information.update(information)
...@@ -520,12 +519,6 @@ class cosmicrays(): ...@@ -520,12 +519,6 @@ class cosmicrays():
:return: None :return: None
""" """
if coveringFraction > 1 or coveringFraction < 0.1:
self.log.error(
'coveringFraction error, it shoub be in [0.1, 1]!')
raise ValueError(
'coveringFraction error, it shoub be in [0.1, 1]!')
self.cosmicrayMap = np.zeros((self.ysize, self.xsize)) self.cosmicrayMap = np.zeros((self.ysize, self.xsize))
# how many events to draw at once, too large number leads to exceeding the covering fraction # how many events to draw at once, too large number leads to exceeding the covering fraction
...@@ -2164,74 +2157,76 @@ class IFSsimulator(): ...@@ -2164,74 +2157,76 @@ class IFSsimulator():
return FlatMat return FlatMat
#################################################################### ####################################################################
def getFrameTransferImg(self): def getFrameTransferImg(self):
""" """
Returns Returns
------- -------
None. None.
""" """
""" """
get frame transfer image from original image of self.image_b and self.image_r get frame transfer image from original image of self.image_b and self.image_r
""" """
self.frame_b_4 = np.zeros((1024+320, 2048), dtype=float) overscan=320
self.frame_b_3 = np.zeros((1024+320, 2048), dtype=float) self.frame_b_4 = np.zeros((1024+overscan, 2048), dtype=float)
self.frame_b_2 = np.zeros((1024+320, 2048), dtype=float) self.frame_b_3 = np.zeros((1024+overscan, 2048), dtype=float)
self.frame_b_1 = np.zeros((1024+320, 2048), dtype=float) self.frame_b_2 = np.zeros((1024+overscan, 2048), dtype=float)
self.frame_b_1 = np.zeros((1024+overscan, 2048), dtype=float)
self.frame_r_4 = np.zeros((1536+320, 3072), dtype=float)
self.frame_r_3 = np.zeros((1536+320, 3072), dtype=float) self.frame_r_4 = np.zeros((1536+overscan, 3072), dtype=float)
self.frame_r_2 = np.zeros((1536+320, 3072), dtype=float) self.frame_r_3 = np.zeros((1536+overscan, 3072), dtype=float)
self.frame_r_1 = np.zeros((1536+320, 3072), dtype=float) self.frame_r_2 = np.zeros((1536+overscan, 3072), dtype=float)
self.frame_r_1 = np.zeros((1536+overscan, 3072), dtype=float)
# blue channle
b_4 = np.sum(self.image_b[0:1024, 0:2048], axis=0) # OSH, part2 ,no change
b_2 = np.sum(self.image_b[0:1024, 0:2048], axis=0)
# flip right to left of part3 and part2
temp_b_3 = np.fliplr(self.image_b[0:1024, 2048:4096]) # left to right # flip right to left of part1
b_3 = np.sum(temp_b_3, axis=0) temp_b_1 = np.fliplr(self.image_b[0:1024, 2048:4096]) # left to right
b_1 = np.sum(temp_b_1, axis=0)
temp_b_2 = np.fliplr(
self.image_b[1024:1024+1024, 2048:2048+2048]) # left to right # part 4, left to right and up to down
b_2 = np.sum(temp_b_2, axis=0) temp_b_4 = np.fliplr(
self.image_b[1024:1024+1024, 2048:2048+2048]) # left to right
b_1 = np.sum(self.image_b[1024:1024+1024, 0:2048], axis=0) b_4 = np.sum(temp_b_4, axis=0)
####
# part 3,OSE, up to dwon
for k in range(1024+320): b_3 = np.sum(self.image_b[1024:1024+1024, 0:2048], axis=0)
# part ####
self.frame_b_4[k, :] += b_4*0.09216/self.information['exptime']
self.frame_b_3[k, :] += b_3*0.09216/self.information['exptime'] for k in range(1024+overscan):
self.frame_b_2[k, :] += b_2*0.09216/self.information['exptime'] # part
self.frame_b_1[k, :] += b_1*0.09216/self.information['exptime'] self.frame_b_4[k, :] += b_4*0.09216/self.information['exptime']
self.frame_b_3[k, :] += b_3*0.09216/self.information['exptime']
################### self.frame_b_2[k, :] += b_2*0.09216/self.information['exptime']
# red channle self.frame_b_1[k, :] += b_1*0.09216/self.information['exptime']
r_4 = np.sum(self.image_r[0:1536, 0:3072], axis=0)
###################
# flip right to left of part3 and part2 # red channle
temp_r_3 = np.fliplr(self.image_r[0:1536, 3072:6144]) # left to right # OSH, part2 ,no change
r_3 = np.sum(temp_r_3, axis=0) r_2 = np.sum(self.image_r[0:1536, 0:3072], axis=0)
temp_r_2 = np.fliplr( # # flip right to left of part1
self.image_r[1536:1536+1536, 3072:6144]) # left to right temp_r_1 = np.fliplr(self.image_r[0:1536, 3072:6144]) # left to right
r_2 = np.sum(temp_r_2, axis=0) r_1 = np.sum(temp_r_1, axis=0)
# r_3 = np.sum(self.image_r[0:1536, 3072:6144], axis=0) # part 4, left to right and up to down
temp_r_4 = np.fliplr(
# r_2 = np.sum(self.image_r[1536:1536+1536, 3072:6144], axis=0) self.image_r[1536:1536+1536, 3072:6144]) # left to right
r_4 = np.sum(temp_r_4, axis=0)
r_1 = np.sum(self.image_r[1536:1536+1536, 0:3072], axis=0)
# part 3,OSE, up to dwon
for k in range(1536+320): r_3 = np.sum(self.image_r[1536:1536+1536, 0:3072], axis=0)
# part 4, OSH zone;
self.frame_r_4[k, :] += r_4*0.13824/self.information['exptime'] for k in range(1536+overscan):
self.frame_r_3[k, :] += r_3*0.13824/self.information['exptime'] # part 4, OSH zone;
self.frame_r_2[k, :] += r_2*0.13824/self.information['exptime'] self.frame_r_4[k, :] += r_4*0.13824/self.information['exptime']
self.frame_r_1[k, :] += r_1*0.13824/self.information['exptime'] self.frame_r_3[k, :] += r_3*0.13824/self.information['exptime']
# end self.frame_r_2[k, :] += r_2*0.13824/self.information['exptime']
self.frame_r_1[k, :] += r_1*0.13824/self.information['exptime']
# end
############################################################################### ###############################################################################
def applyflatfield(self, simnumber): def applyflatfield(self, simnumber):
...@@ -2294,6 +2289,12 @@ class IFSsimulator(): ...@@ -2294,6 +2289,12 @@ class IFSsimulator():
support package. support package.
""" """
self.readCosmicRayInformation() self.readCosmicRayInformation()
#
if self.information['coveringfraction'] > 1 or self.information['coveringfraction'] < 0.1:
self.log.error(
'coveringFraction error, it shoub be in [0.1, 1]!')
raise ValueError(
'coveringFraction error, it shoub be in [0.1, 1]!')
# to scale the number of cosmics with exposure time # to scale the number of cosmics with exposure time
self.cr['exptime'] = self.information['exptime'] self.cr['exptime'] = self.information['exptime']
...@@ -2303,8 +2304,8 @@ class IFSsimulator(): ...@@ -2303,8 +2304,8 @@ class IFSsimulator():
crImage_r = np.zeros((3072, 6144), dtype=float) crImage_r = np.zeros((3072, 6144), dtype=float)
# cosmic ray instance # cosmic ray instance
cosmics_b = cosmicrays(self.log, crImage_b, crInfo=self.cr) cosmics_b = cosmicrays(self.log, crImage_b,self.information['exptime'], crInfo=self.cr)
cosmics_r = cosmicrays(self.log, crImage_r, crInfo=self.cr) cosmics_r = cosmicrays(self.log, crImage_r,self.information['exptime'], crInfo=self.cr)
CCD_cr_b = cosmics_b.addUpToFraction( CCD_cr_b = cosmics_b.addUpToFraction(
self.information['coveringfraction']*self.information['exptime']/300.0, limit=None) self.information['coveringfraction']*self.information['exptime']/300.0, limit=None)
...@@ -2729,49 +2730,49 @@ class IFSsimulator(): ...@@ -2729,49 +2730,49 @@ class IFSsimulator():
apply frame transfer effect to the four part images apply frame transfer effect to the four part images
""" """
prescan = 50 prescan = 50
overscan = 8 overscan = 0
# zone 4 , OSH #### 1024, 2048 # zone 1 , OSG #### 1024, 2048
self.image_b[0:1024+overscan, prescan:2048 + self.image_b[0:1024+overscan, prescan:2048 +
prescan] += self.frame_b_4[0:1024+overscan, 0:2048] prescan] += self.frame_b_1[0:1024+overscan, 0:2048]
# ######### zone 3, OSG ################# ########## zone 2, OSH #################
self.image_b[0:1024+overscan, prescan+2418:2418+2048 + self.image_b[0:1024+overscan, prescan+2418:2418+2048 +
prescan] += self.frame_b_3[0:1024+overscan, 0:2048] prescan] += self.frame_b_2[0:1024+overscan, 0:2048]
# ######### zone 1, OSE ################### ########## zone 3, OSE ###################
self.image_b[0:1024+overscan, prescan+2418*2:2418*2 + self.image_b[0:1024+overscan, prescan+2418*2:2418*2 +
2048+prescan] += self.frame_b_1[0:1024+overscan, 0:2048] 2048+prescan] += self.frame_b_3[0:1024+overscan, 0:2048]
# ######### zone 2, OSF ############### ########## zone 4, OSF ###############
self.image_b[0:1024+overscan, prescan+2418*3:2418*3 + self.image_b[0:1024+overscan, prescan+2418*3:2418*3 +
2048+prescan] += self.frame_b_2[0:1024+overscan, 0:2048] 2048+prescan] += self.frame_b_4[0:1024+overscan, 0:2048]
# 3 # 3
self.log.info('readnoise added in blue channel') self.log.info('readnoise added in blue channel')
# red zone 4 , OSH### 1536* 3072 # red zone 1 , OSG### 1536* 3072
self.image_r[0:1536+overscan, prescan+3442*0:3442*0 + self.image_r[0:1536+overscan, prescan+3442*0:3442*0 +
3072+prescan] += self.frame_r_4[0:1536+overscan, 0:3072] 3072+prescan] += self.frame_r_1[0:1536+overscan, 0:3072]
# ######### zone 3 ,OSG ################# ########## zone 2 ,OSh #################
self.image_r[0:1536+overscan, prescan+3442*1:3442*1 + self.image_r[0:1536+overscan, prescan+3442*1:3442*1 +
3072+prescan] += self.frame_r_3[0:1536+overscan, 0:3072] 3072+prescan] += self.frame_r_2[0:1536+overscan, 0:3072]
# ######### zone 1 ,OSE ################### ########## zone 1 ,OSE ###################
self.image_r[0:1536+overscan, prescan+3442*2:3442*2 + self.image_r[0:1536+overscan, prescan+3442*2:3442*2 +
3072+prescan] += self.frame_r_1[0:1536+overscan, 0:3072] 3072+prescan] += self.frame_r_3[0:1536+overscan, 0:3072]
# ######### zone 2,OSF ########### ########## zone 4,OSF ###########
self.image_r[0:1536+overscan, prescan+3442*3:3442*3 + self.image_r[0:1536+overscan, prescan+3442*3:3442*3 +
3072+prescan] += self.frame_r_2[0:1536+overscan, 0:3072] 3072+prescan] += self.frame_r_4[0:1536+overscan, 0:3072]
########################################################################## ##########################################################################
...@@ -5932,7 +5933,7 @@ class IFSsimulator(): ...@@ -5932,7 +5933,7 @@ class IFSsimulator():
if self.nonlinearity: if self.nonlinearity:
self.applyNonlinearity() self.applyNonlinearity()
print('Applying nonlinearity finished.......') print('Applying nonlinearity finished.......')
# cut original CCD image to four parts by four read out channels and zones # cut original CCD image to four parts by four read out channels and zones
self.CCDreadout() self.CCDreadout()
......
This source diff could not be displayed because it is too large. You can view the blob instead.
numpy==1.23.5 #numpy==1.23.5
scipy==1.9.2 #scipy==1.9.2
setuptools==65.6.3 #setuptools==65.6.3
pandas==1.5.3 #pandas==1.5.3
julian==0.14 #julian==0.14
astropy==6.0.0 #astropy==6.0.0
tqdm==4.64.1 #tqdm==4.64.1
galsim==2.4.9 #galsim==2.4.9
...@@ -16,7 +16,7 @@ with open("requirements.txt", "r") as f: ...@@ -16,7 +16,7 @@ with open("requirements.txt", "r") as f:
setuptools.setup( setuptools.setup(
name='csst_ifs_sim', # 包名 name='csst_ifs_sim', # 包名
version="3.0.0", # 版本号 version="3.0.1", # 版本号
author="Zhaojun Yan", # 作者 author="Zhaojun Yan", # 作者
author_email="zhaojunyan@shao.ac.cn", # 邮箱 author_email="zhaojunyan@shao.ac.cn", # 邮箱
description="The CSST IFS simulation - prototype", # 短描述 description="The CSST IFS simulation - prototype", # 短描述
......
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