Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
csst-sims
csst_ifs_sim
Commits
da9116fc
Commit
da9116fc
authored
Oct 28, 2024
by
Yan Zhaojun
Browse files
update
parent
5070c190
Pipeline
#7135
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
csst_ifs_sim/CTI/CTI.py
View file @
da9116fc
...
...
@@ -133,8 +133,8 @@ class CDM03bidir():
array will be laid out in memory in C-style (row-major order).
:return: image that has been run through the CDM03 model
:rtype: ndarray
"""""
:rtype: ndarray
"""""
#
# return data
iflip
=
iquadrant
/
2
...
...
csst_ifs_sim/csst_ifs_sim.py
View file @
da9116fc
...
...
@@ -67,7 +67,7 @@ light.
#. Apply non-linearity model to the pixel data.
#. Add readout noise selected from a Gaussian distribution.
#. 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.
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.
2024.5.10 ---updata and correct the bug of frame transfer effect simulation
"""
######################## functions definition #############################
###
#
####################### functions definition #############################
class
CDM03bidir
():
...
...
@@ -211,8 +211,8 @@ class CDM03bidir():
array will be laid out in memory in C-style (row-major order).
:return: image that has been run through the CDM03 model
:rtype: ndarray
"""""
:rtype: ndarray
"""""
#
# return data
iflip
=
iquadrant
/
2
...
...
@@ -242,7 +242,7 @@ class CDM03bidir():
#################################################################################
# modify
# sys.path.append('../so')
#from .ifs_so import cdm03bidir
#
from .ifs_so import cdm03bidir
try
:
from
ifs_so
import
cdm03bidir
except
:
...
...
@@ -314,7 +314,7 @@ def IFSinformation():
The file provides a function that returns IFS related information such as pixel
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)::
:return: instrument model parameters
...
...
@@ -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
.
update
({
'dob'
:
0
,
'rdose'
:
8.0e9
,
'parallelTrapfile'
:
'cdm_euclid_parallel.dat'
,
'serialTrapfile'
:
'cdm_euclid_serial.dat'
,
...
...
@@ -332,8 +332,7 @@ def IFSinformation():
def
CCDnonLinearityModel
(
data
,
beta
=
6e-7
):
"""
"""
The non-linearity is modelled based on the results presented.
:param data: data to which the non-linearity model is being applied to
:type data: ndarray
...
...
@@ -344,7 +343,8 @@ def CCDnonLinearityModel(data, beta=6e-7):
out
=
data
-
beta
*
data
**
2
return
out
#
#
#############################################################################
...
...
@@ -387,7 +387,7 @@ class cosmicrays():
# setup logger
self
.
log
=
log
#image and size
#
image and size
self
.
image
=
image
.
copy
()
self
.
ysize
,
self
.
xsize
=
self
.
image
.
shape
...
...
@@ -404,14 +404,14 @@ class cosmicrays():
self
.
_readCosmicrayInformation
()
##############################################################################
def
_cosmicRayIntercepts
(
self
,
lum
,
x0
,
y0
,
l
,
phi
):
def
_cosmicRayIntercepts
(
self
,
lum
,
x0
,
y0
,
d
l
,
phi
):
"""
Derive cosmic ray streak intercept points.
:param lum: luminosities of the cosmic ray tracks
: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 l: lengths of the cosmic ray tracks
:param
d
l: lengths of the cosmic ray tracks
:param phi: orientation angles of the cosmic ray tracks
:return: cosmic ray map (image)
...
...
@@ -421,14 +421,14 @@ class cosmicrays():
crImage
=
np
.
zeros
((
self
.
ysize
,
self
.
xsize
),
dtype
=
np
.
float64
)
# x and y shifts
dx
=
l
*
np
.
cos
(
phi
)
/
2.
dy
=
l
*
np
.
sin
(
phi
)
/
2.
dx
=
d
l
*
np
.
cos
(
phi
)
/
2.
dy
=
d
l
*
np
.
sin
(
phi
)
/
2.
mskdx
=
np
.
abs
(
dx
)
<
1e-8
mskdy
=
np
.
abs
(
dy
)
<
1e-8
dx
[
mskdx
]
=
0.
dy
[
mskdy
]
=
0.
#pixels in x-direction
#
pixels in x-direction
ilo
=
np
.
round
(
x0
.
copy
()
-
dx
)
msk
=
ilo
<
0.
ilo
[
msk
]
=
0
...
...
@@ -439,7 +439,7 @@ class cosmicrays():
ihi
[
msk
]
=
self
.
xsize
ihi
=
ihi
.
astype
(
int
)
#pixels in y-directions
#
pixels in y-directions
jlo
=
np
.
round
(
y0
.
copy
()
-
dy
)
msk
=
jlo
<
0.
jlo
[
msk
]
=
0
...
...
@@ -659,7 +659,7 @@ def ill2flux(path, E):
# use template from sky_bkg (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
spec0
=
cat_spec
[
2
].
values
# erg/s/cm^2/A/arcsec^2
...
...
@@ -691,8 +691,7 @@ def ill2flux(path, E):
def
earth_angle
(
time_jd
,
x_sat
,
y_sat
,
z_sat
,
ra_obj
,
dec_obj
):
"""
#
#
Parameters
----------
time_jd : TYPE
...
...
@@ -829,7 +828,7 @@ class StrayLight(object):
def
caculateEarthShineFilter
(
self
,
filter
=
'i'
):
"""
#
#
Parameters
----------
filter : TYPE, optional
...
...
@@ -1017,7 +1016,8 @@ def dt2hmd(dt):
DESCRIPTION.
"""
## dt is datetime
#
# # dt is datetime
hour
=
dt
.
hour
minute
=
dt
.
minute
second
=
dt
.
second
...
...
@@ -1211,17 +1211,17 @@ def LSR_velocity(ra, dec, velocity, Obstime):
# convert ra and dec to
source
=
SkyCoord
(
ra
*
u
.
deg
,
dec
*
u
.
deg
,
frame
=
'icrs'
,
unit
=
(
u
.
hourangle
,
u
.
deg
))
l
=
source
.
galactic
.
l
.
deg
b
=
source
.
galactic
.
b
.
deg
c
=
SkyCoord
(
l
=
l
*
u
.
degree
,
b
=
b
*
u
.
degree
,
frame
=
'galactic'
)
l
l
=
source
.
galactic
.
l
.
deg
b
=
source
.
galactic
.
b
.
deg
c
=
SkyCoord
(
l
l
=
l
l
*
u
.
degree
,
b
=
b
*
u
.
degree
,
frame
=
'galactic'
)
c_icrs
=
c
.
transform_to
(
'icrs'
)
barycorr
=
c_icrs
.
radial_velocity_correction
(
obstime
=
Time
(
Obstime
),
location
=
local
)
velocity
=
velocity
+
barycorr
.
value
/
1000
# print(barycorr.value/1000)
l
=
l
*
np
.
pi
/
180
l
l
=
l
l
*
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
(
l
l
)
*
np
.
cos
(
b
)
+
12
*
np
.
sin
(
l
l
)
*
np
.
cos
(
b
)
+
7
*
np
.
sin
(
b
)
###############################################################################
...
...
@@ -1512,8 +1512,8 @@ def anySampledPSFnew(wavefront, pupil, Q, sizeout):
% f is focal length;
% pixelsize is the actural size of the detector;
% 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
)
...
...
@@ -1811,30 +1811,27 @@ class IFSsimulator():
save_cosmicrays
=
self
.
save_cosmicrays
,
appbianpai
=
self
.
appbianpai
)
############################################################################
#
###########################################################################
def
_createEmpty
(
self
):
"""
Creates and empty array of a given x and y size full of zeros.
add g r i channel images;
Creates lensing parameters;
Creates lensing parameters;
"""
#
#
self
.
imgtemp
=
dict
()
self
.
pixel
=
0.1
# arcsec, pixel scale size;
##############################################################################
##############################################################################
def
zodiacal
(
self
,
ra
,
dec
,
time
):
"""
Parameters
----------
ra : TYPE
...
...
@@ -1869,7 +1866,10 @@ class IFSsimulator():
# get solar position
dt
=
datetime
.
fromisoformat
(
time
)
jd
=
time2jd
(
dt
)
## jd = julian.to_jd(dt, fmt='jd')
#
#
#
# # jd = julian.to_jd(dt, fmt='jd')
t
=
Time
(
jd
,
format
=
'jd'
,
scale
=
'utc'
)
...
...
@@ -1889,21 +1889,21 @@ class IFSsimulator():
# interpolated zodical surface brightness at 0.5 um
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
])
lamda_angle
=
np
.
array
([
0
,
5
,
10
,
15
,
20
,
25
,
30
,
35
,
40
,
45
,
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,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.RegularGridInterpolator((xx, yy), zodi, method='linear')
#
f = interpolate.RegularGridInterpolator((xx, yy), zodi, method='linear')
zodi_obj
=
f
(
beta
,
lamda
)
#
# read the zodical spectrum in the ecliptic
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
spec0
=
cat_spec
[
1
].
values
#
zodi_norm
=
252
#
...
...
@@ -2056,7 +2056,7 @@ class IFSsimulator():
'/'
+
self
.
source
+
ss
+
result_day
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
+
'/calibration_Data'
)
os
.
mkdir
(
self
.
result_path
+
'/log_file'
)
...
...
@@ -2291,9 +2291,9 @@ class IFSsimulator():
self
.
image_r
[
1536
:
1536
+
1536
,
3072
:
6144
])
# left to right
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
)
...
...
@@ -2385,14 +2385,14 @@ class IFSsimulator():
self
.
information
[
'coveringfraction'
]
*
self
.
information
[
'exptime'
]
/
300.0
,
limit
=
None
)
# paste the information
#self.image += CCD_cr
#
self.image += CCD_cr
self
.
image_b
+=
CCD_cr_b
self
.
image_r
+=
CCD_cr_r
# count the covering factor
area_cr_b
=
np
.
count_nonzero
(
CCD_cr_b
)
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
(
'The cosmic ray in blue channel covering factor is %i pixels '
%
area_cr_b
)
self
.
log
.
info
(
...
...
@@ -2410,12 +2410,9 @@ class IFSsimulator():
#########################################################################
##############################################################################
def
applyDarkCurrent
(
self
):
"""
Returns
-------
None.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment