Commit da9116fc authored by Yan Zhaojun's avatar Yan Zhaojun
Browse files

update

parent 5070c190
Pipeline #7135 failed with stage
in 0 seconds
...@@ -133,8 +133,8 @@ class CDM03bidir(): ...@@ -133,8 +133,8 @@ class CDM03bidir():
array will be laid out in memory in C-style (row-major order). array will be laid out in memory in C-style (row-major order).
:return: image that has been run through the CDM03 model :return: image that has been run through the CDM03 model
:rtype: ndarray :rtype: ndarray"""""
""""" #
# return data # return data
iflip = iquadrant / 2 iflip = iquadrant / 2
......
...@@ -67,7 +67,7 @@ light. ...@@ -67,7 +67,7 @@ light.
#. Apply non-linearity model to the pixel data. #. Apply non-linearity model to the pixel data.
#. Add readout noise selected from a Gaussian distribution. #. Add readout noise selected from a Gaussian distribution.
#. Convert from electrons to ADUs using a given gain factor. #. Convert from electrons to ADUs using a given gain factor.
#. Add a given bias level and discretise the counts #. Add a given bias level and discretise the counts
#. Finally the simulated image is converted to a FITS file. #. Finally the simulated image is converted to a FITS file.
Warning:: The code is still work in progress and new features are being added. Warning:: The code is still work in progress and new features are being added.
...@@ -82,7 +82,7 @@ Note:: This class is Python 3 compatible. ...@@ -82,7 +82,7 @@ Note:: This class is Python 3 compatible.
2024.5.10 ---updata and correct the bug of frame transfer effect simulation 2024.5.10 ---updata and correct the bug of frame transfer effect simulation
""" """
######################## functions definition ################################ # ####################### functions definition #############################
class CDM03bidir(): class CDM03bidir():
...@@ -211,8 +211,8 @@ class CDM03bidir(): ...@@ -211,8 +211,8 @@ class CDM03bidir():
array will be laid out in memory in C-style (row-major order). array will be laid out in memory in C-style (row-major order).
:return: image that has been run through the CDM03 model :return: image that has been run through the CDM03 model
:rtype: ndarray :rtype: ndarray"""""
""""" #
# return data # return data
iflip = iquadrant / 2 iflip = iquadrant / 2
...@@ -242,7 +242,7 @@ class CDM03bidir(): ...@@ -242,7 +242,7 @@ class CDM03bidir():
################################################################################# #################################################################################
# modify # modify
# sys.path.append('../so') # sys.path.append('../so')
#from .ifs_so import cdm03bidir # from .ifs_so import cdm03bidir
try: try:
from ifs_so import cdm03bidir from ifs_so import cdm03bidir
except: except:
...@@ -314,7 +314,7 @@ def IFSinformation(): ...@@ -314,7 +314,7 @@ def IFSinformation():
The file provides a function that returns IFS related information such as pixel The file provides a function that returns IFS related information such as pixel
size, dark current, gain... size, dark current, gain...
Returns a dictionary describing VIS. The following information is provided Returns a dictionary describing VIS. The following information is provided
(id: value - reference):: (id: value - reference)::
:return: instrument model parameters :return: instrument model parameters
...@@ -322,7 +322,7 @@ def IFSinformation(): ...@@ -322,7 +322,7 @@ def IFSinformation():
""" """
######################################################################################################### #########################################################################################################
#out = dict(readnoise=4, pixel_size=0.1, dark=0.0008333, fullwellcapacity=90000, bluesize=4000, redsize=6000, readtime=300.) # out = dict(readnoise=4, pixel_size=0.1, dark=0.0008333, fullwellcapacity=90000, bluesize=4000, redsize=6000, readtime=300.)
out = dict() out = dict()
out.update({'dob': 0, 'rdose': 8.0e9, out.update({'dob': 0, 'rdose': 8.0e9,
'parallelTrapfile': 'cdm_euclid_parallel.dat', 'serialTrapfile': 'cdm_euclid_serial.dat', 'parallelTrapfile': 'cdm_euclid_parallel.dat', 'serialTrapfile': 'cdm_euclid_serial.dat',
...@@ -332,8 +332,7 @@ def IFSinformation(): ...@@ -332,8 +332,7 @@ def IFSinformation():
def CCDnonLinearityModel(data, beta=6e-7): def CCDnonLinearityModel(data, beta=6e-7):
""" """
The non-linearity is modelled based on the results presented. The non-linearity is modelled based on the results presented.
:param data: data to which the non-linearity model is being applied to :param data: data to which the non-linearity model is being applied to
:type data: ndarray :type data: ndarray
...@@ -344,7 +343,8 @@ def CCDnonLinearityModel(data, beta=6e-7): ...@@ -344,7 +343,8 @@ def CCDnonLinearityModel(data, beta=6e-7):
out = data-beta*data**2 out = data-beta*data**2
return out return out
#
#
############################################################################# #############################################################################
...@@ -387,7 +387,7 @@ class cosmicrays(): ...@@ -387,7 +387,7 @@ class cosmicrays():
# setup logger # setup logger
self.log = log self.log = log
#image and size # image and size
self.image = image.copy() self.image = image.copy()
self.ysize, self.xsize = self.image.shape self.ysize, self.xsize = self.image.shape
...@@ -404,14 +404,14 @@ class cosmicrays(): ...@@ -404,14 +404,14 @@ class cosmicrays():
self._readCosmicrayInformation() self._readCosmicrayInformation()
############################################################################## ##############################################################################
def _cosmicRayIntercepts(self, lum, x0, y0, l, phi): def _cosmicRayIntercepts(self, lum, x0, y0, dl, phi):
""" """
Derive cosmic ray streak intercept points. Derive cosmic ray streak intercept points.
:param lum: luminosities of the cosmic ray tracks :param lum: luminosities of the cosmic ray tracks
:param x0: central positions of the cosmic ray tracks in x-direction :param x0: central positions of the cosmic ray tracks in x-direction
:param y0: central positions of the cosmic ray tracks in y-direction :param y0: central positions of the cosmic ray tracks in y-direction
:param l: lengths of the cosmic ray tracks :param dl: lengths of the cosmic ray tracks
:param phi: orientation angles of the cosmic ray tracks :param phi: orientation angles of the cosmic ray tracks
:return: cosmic ray map (image) :return: cosmic ray map (image)
...@@ -421,14 +421,14 @@ class cosmicrays(): ...@@ -421,14 +421,14 @@ class cosmicrays():
crImage = np.zeros((self.ysize, self.xsize), dtype=np.float64) crImage = np.zeros((self.ysize, self.xsize), dtype=np.float64)
# x and y shifts # x and y shifts
dx = l * np.cos(phi) / 2. dx = dl * np.cos(phi) / 2.
dy = l * np.sin(phi) / 2. dy = dl * np.sin(phi) / 2.
mskdx = np.abs(dx) < 1e-8 mskdx = np.abs(dx) < 1e-8
mskdy = np.abs(dy) < 1e-8 mskdy = np.abs(dy) < 1e-8
dx[mskdx] = 0. dx[mskdx] = 0.
dy[mskdy] = 0. dy[mskdy] = 0.
#pixels in x-direction # pixels in x-direction
ilo = np.round(x0.copy() - dx) ilo = np.round(x0.copy() - dx)
msk = ilo < 0. msk = ilo < 0.
ilo[msk] = 0 ilo[msk] = 0
...@@ -439,7 +439,7 @@ class cosmicrays(): ...@@ -439,7 +439,7 @@ class cosmicrays():
ihi[msk] = self.xsize ihi[msk] = self.xsize
ihi = ihi.astype(int) ihi = ihi.astype(int)
#pixels in y-directions # pixels in y-directions
jlo = np.round(y0.copy() - dy) jlo = np.round(y0.copy() - dy)
msk = jlo < 0. msk = jlo < 0.
jlo[msk] = 0 jlo[msk] = 0
...@@ -659,7 +659,7 @@ def ill2flux(path, E): ...@@ -659,7 +659,7 @@ def ill2flux(path, E):
# use template from sky_bkg (background_spec_hst.dat) # use template from sky_bkg (background_spec_hst.dat)
filename = path+'IFS_inputdata/refs/background_spec_hst.dat' filename = path+'IFS_inputdata/refs/background_spec_hst.dat'
cat_spec = pd.read_csv(filename, sep='\s+', header=None, comment='#') cat_spec = pd.read_csv(filename, sep='\\s+', header=None, comment='#')
wave0 = cat_spec[0].values # A wave0 = cat_spec[0].values # A
spec0 = cat_spec[2].values # erg/s/cm^2/A/arcsec^2 spec0 = cat_spec[2].values # erg/s/cm^2/A/arcsec^2
...@@ -691,8 +691,7 @@ def ill2flux(path, E): ...@@ -691,8 +691,7 @@ def ill2flux(path, E):
def earth_angle(time_jd, x_sat, y_sat, z_sat, ra_obj, dec_obj): def earth_angle(time_jd, x_sat, y_sat, z_sat, ra_obj, dec_obj):
""" """
# #
Parameters Parameters
---------- ----------
time_jd : TYPE time_jd : TYPE
...@@ -829,7 +828,7 @@ class StrayLight(object): ...@@ -829,7 +828,7 @@ class StrayLight(object):
def caculateEarthShineFilter(self, filter='i'): def caculateEarthShineFilter(self, filter='i'):
""" """
# #
#
Parameters Parameters
---------- ----------
filter : TYPE, optional filter : TYPE, optional
...@@ -1017,7 +1016,8 @@ def dt2hmd(dt): ...@@ -1017,7 +1016,8 @@ def dt2hmd(dt):
DESCRIPTION. DESCRIPTION.
""" """
## dt is datetime #
# # dt is datetime
hour = dt.hour hour = dt.hour
minute = dt.minute minute = dt.minute
second = dt.second second = dt.second
...@@ -1211,17 +1211,17 @@ def LSR_velocity(ra, dec, velocity, Obstime): ...@@ -1211,17 +1211,17 @@ def LSR_velocity(ra, dec, velocity, Obstime):
# convert ra and dec to # convert ra and dec to
source = SkyCoord(ra*u.deg, dec*u.deg, frame='icrs', source = SkyCoord(ra*u.deg, dec*u.deg, frame='icrs',
unit=(u.hourangle, u.deg)) unit=(u.hourangle, u.deg))
l = source.galactic.l.deg ll = source.galactic.l.deg
b = source.galactic.b.deg b = source.galactic.b.deg
c = SkyCoord(l=l*u.degree, b=b*u.degree, frame='galactic') c = SkyCoord(ll=ll*u.degree, b=b*u.degree, frame='galactic')
c_icrs = c.transform_to('icrs') c_icrs = c.transform_to('icrs')
barycorr = c_icrs.radial_velocity_correction( barycorr = c_icrs.radial_velocity_correction(
obstime=Time(Obstime), location=local) obstime=Time(Obstime), location=local)
velocity = velocity + barycorr.value/1000 velocity = velocity + barycorr.value/1000
# print(barycorr.value/1000) # print(barycorr.value/1000)
l = l * np.pi / 180 ll = ll * np.pi / 180
b = b * np.pi / 180 b = b * np.pi / 180
return velocity + 9 * np.cos(l) * np.cos(b) + 12 * np.sin(l) * np.cos(b) + 7 * np.sin(b) return velocity + 9 * np.cos(ll) * np.cos(b) + 12 * np.sin(ll) * np.cos(b) + 7 * np.sin(b)
############################################################################### ###############################################################################
...@@ -1512,8 +1512,8 @@ def anySampledPSFnew(wavefront, pupil, Q, sizeout): ...@@ -1512,8 +1512,8 @@ def anySampledPSFnew(wavefront, pupil, Q, sizeout):
% f is focal length; % f is focal length;
% pixelsize is the actural size of the detector; % pixelsize is the actural size of the detector;
% make sure all the varia have the same unit; % make sure all the varia have the same unit;
% the returned PSF has sum value of 1 % the returned PSF has sum value of 1 '''
''' # ##
m, n = np.shape(wavefront) m, n = np.shape(wavefront)
...@@ -1811,30 +1811,27 @@ class IFSsimulator(): ...@@ -1811,30 +1811,27 @@ class IFSsimulator():
save_cosmicrays=self.save_cosmicrays, save_cosmicrays=self.save_cosmicrays,
appbianpai=self.appbianpai) appbianpai=self.appbianpai)
############################################################################ # ###########################################################################
def _createEmpty(self): def _createEmpty(self):
""" """
Creates and empty array of a given x and y size full of zeros. Creates and empty array of a given x and y size full of zeros.
add g r i channel images; add g r i channel images;
Creates lensing parameters; Creates lensing parameters;
""" """
#
#
self.imgtemp = dict() self.imgtemp = dict()
self.pixel = 0.1 # arcsec, pixel scale size; self.pixel = 0.1 # arcsec, pixel scale size;
############################################################################## ##############################################################################
############################################################################## ##############################################################################
def zodiacal(self, ra, dec, time): def zodiacal(self, ra, dec, time):
""" """
Parameters Parameters
---------- ----------
ra : TYPE ra : TYPE
...@@ -1869,7 +1866,10 @@ class IFSsimulator(): ...@@ -1869,7 +1866,10 @@ class IFSsimulator():
# get solar position # get solar position
dt = datetime.fromisoformat(time) dt = datetime.fromisoformat(time)
jd = time2jd(dt) jd = time2jd(dt)
## jd = julian.to_jd(dt, fmt='jd') #
#
#
# # jd = julian.to_jd(dt, fmt='jd')
t = Time(jd, format='jd', scale='utc') t = Time(jd, format='jd', scale='utc')
...@@ -1889,21 +1889,21 @@ class IFSsimulator(): ...@@ -1889,21 +1889,21 @@ class IFSsimulator():
# interpolated zodical surface brightness at 0.5 um # interpolated zodical surface brightness at 0.5 um
zodi = pd.read_csv( zodi = pd.read_csv(
self.information['dir_path']+'IFS_inputdata/refs/zodi_map.dat', sep='\s+', header=None, comment='#') self.information['dir_path']+'IFS_inputdata/refs/zodi_map.dat', sep='\\s+', header=None, comment='#')
beta_angle = np.array([0, 5, 10, 15, 20, 25, 30, 45, 60, 75]) beta_angle = np.array([0, 5, 10, 15, 20, 25, 30, 45, 60, 75])
lamda_angle = np.array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45, lamda_angle = np.array([0, 5, 10, 15, 20, 25, 30, 35, 40, 45,
60, 75, 90, 105, 120, 135, 150, 165, 180]) 60, 75, 90, 105, 120, 135, 150, 165, 180])
xx, yy = np.meshgrid(beta_angle, lamda_angle) xx, yy = np.meshgrid(beta_angle, lamda_angle)
#xx, yy = np.meshgrid(beta_angle, lamda_angle,indexing='ij', sparse=True) # xx, yy = np.meshgrid(beta_angle, lamda_angle,indexing='ij', sparse=True)
f = interpolate.interp2d(xx, yy, zodi, kind='linear') f = interpolate.interp2d(xx, yy, zodi, kind='linear')
#f = interpolate.RegularGridInterpolator((xx, yy), zodi, method='linear') # f = interpolate.RegularGridInterpolator((xx, yy), zodi, method='linear')
zodi_obj = f(beta, lamda) # zodi_obj = f(beta, lamda) #
# read the zodical spectrum in the ecliptic # read the zodical spectrum in the ecliptic
cat_spec = pd.read_csv( cat_spec = pd.read_csv(
self.information['dir_path']+'IFS_inputdata/refs/solar_spec.dat', sep='\s+', header=None, comment='#') self.information['dir_path']+'IFS_inputdata/refs/solar_spec.dat', sep='\\s+', header=None, comment='#')
wave = cat_spec[0].values # A wave = cat_spec[0].values # A
spec0 = cat_spec[1].values # spec0 = cat_spec[1].values #
zodi_norm = 252 # zodi_norm = 252 #
...@@ -2056,7 +2056,7 @@ class IFSsimulator(): ...@@ -2056,7 +2056,7 @@ class IFSsimulator():
'/'+self.source+ss+result_day '/'+self.source+ss+result_day
print(self.information['result_path']) print(self.information['result_path'])
if os.path.isdir(self.result_path) == False: if os.path.isdir(self.result_path) is False:
os.mkdir(self.result_path) os.mkdir(self.result_path)
os.mkdir(self.result_path+'/calibration_Data') os.mkdir(self.result_path+'/calibration_Data')
os.mkdir(self.result_path+'/log_file') os.mkdir(self.result_path+'/log_file')
...@@ -2291,9 +2291,9 @@ class IFSsimulator(): ...@@ -2291,9 +2291,9 @@ class IFSsimulator():
self.image_r[1536:1536+1536, 3072:6144]) # left to right self.image_r[1536:1536+1536, 3072:6144]) # left to right
r_2 = np.sum(temp_r_2, axis=0) r_2 = np.sum(temp_r_2, axis=0)
#r_3 = np.sum(self.image_r[0:1536, 3072:6144], axis=0) # r_3 = np.sum(self.image_r[0:1536, 3072:6144], axis=0)
#r_2 = np.sum(self.image_r[1536:1536+1536, 3072:6144], axis=0) # r_2 = np.sum(self.image_r[1536:1536+1536, 3072:6144], axis=0)
r_1 = np.sum(self.image_r[1536:1536+1536, 0:3072], axis=0) r_1 = np.sum(self.image_r[1536:1536+1536, 0:3072], axis=0)
...@@ -2385,14 +2385,14 @@ class IFSsimulator(): ...@@ -2385,14 +2385,14 @@ class IFSsimulator():
self.information['coveringfraction']*self.information['exptime']/300.0, limit=None) self.information['coveringfraction']*self.information['exptime']/300.0, limit=None)
# paste the information # paste the information
#self.image += CCD_cr # self.image += CCD_cr
self.image_b += CCD_cr_b self.image_b += CCD_cr_b
self.image_r += CCD_cr_r self.image_r += CCD_cr_r
# count the covering factor # count the covering factor
area_cr_b = np.count_nonzero(CCD_cr_b) area_cr_b = np.count_nonzero(CCD_cr_b)
area_cr_r = np.count_nonzero(CCD_cr_r) area_cr_r = np.count_nonzero(CCD_cr_r)
#self.log.info('The cosmic ray covering factor is %i pixels ' % area_cr) # self.log.info('The cosmic ray covering factor is %i pixels ' % area_cr)
self.log.info( self.log.info(
'The cosmic ray in blue channel covering factor is %i pixels ' % area_cr_b) 'The cosmic ray in blue channel covering factor is %i pixels ' % area_cr_b)
self.log.info( self.log.info(
...@@ -2410,12 +2410,9 @@ class IFSsimulator(): ...@@ -2410,12 +2410,9 @@ class IFSsimulator():
######################################################################### #########################################################################
##############################################################################
def applyDarkCurrent(self): def applyDarkCurrent(self):
""" """
Returns Returns
------- -------
None. None.
......
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