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_msc_sim
Commits
72f70d57
Commit
72f70d57
authored
Dec 14, 2023
by
Wei Chengliang
Browse files
update calibration in Chip.py
parent
3ed9b904
Changes
2
Hide whitespace changes
Inline
Side-by-side
ObservationSim/Instrument/Chip/Chip.py
View file @
72f70d57
...
...
@@ -529,12 +529,26 @@ class Chip(FocalPlane):
print
(
" Applying Non-Linearity on the Bias image"
,
flush
=
True
)
BiasCombImg
=
effects
.
NonLinearity
(
GSImage
=
BiasCombImg
,
beta1
=
5.e-7
,
beta2
=
0
)
###########################START
### prescan & overscan
if
config
[
"ins_effects"
][
"add_prescan"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply pre/over-scan"
,
logger
=
self
.
logger
)
BiasCombImg
=
chip_utils
.
AddPreScan
(
GSImage
=
BiasCombImg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
over2
)
### 1*16 output
if
config
[
"ins_effects"
][
"format_output"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply 1*16 format"
,
logger
=
self
.
logger
)
BiasCombImg
=
chip_utils
.
formatOutput
(
GSImage
=
BiasCombImg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
###########################END
# Apply Bad lines
if
config
[
"ins_effects"
][
"add_badcolumns"
]
==
True
:
BiasCombImg
=
effects
.
BadColumns
(
BiasCombImg
-
float
(
self
.
bias_level
)
+
5
,
seed
=
SeedBadColumns
,
chipid
=
self
.
chipID
,
logger
=
self
.
logger
)
+
float
(
self
.
bias_level
)
-
5
BiasCombImg
,
self
.
gain_channel
=
effects
.
ApplyGainNonUniform16
(
BiasCombImg
,
gain
=
self
.
gain
,
nsecy
=
2
,
nsecx
=
8
,
nsecy
=
self
.
nsecy
,
nsecx
=
self
.
nsecx
,
seed
=
SeedGainNonuni
+
self
.
chipID
,
logger
=
self
.
logger
)
# BiasCombImg = effects.AddOverscan(
...
...
@@ -606,8 +620,61 @@ class Chip(FocalPlane):
print
(
" Applying Non-Linearity on the Flat image"
,
flush
=
True
)
FlatCombImg
=
effects
.
NonLinearity
(
GSImage
=
FlatCombImg
,
beta1
=
5.e-7
,
beta2
=
0
)
###if config["ins_effects"]["cte_trail"] == True:
### FlatCombImg = effects.CTE_Effect(GSImage=FlatCombImg, threshold=3)
###########################START
pre1
=
self
.
prescan_x
#27
over1
=
self
.
overscan_x
#71
pre2
=
self
.
prescan_y
#0 #4
over2
=
self
.
overscan_y
#84 #80
if
config
[
"ins_effects"
][
"cte_trail"
]
==
True
:
FlatCombImg
=
effects
.
CTE_Effect
(
GSImage
=
FlatCombImg
,
threshold
=
3
)
chip_utils
.
log_info
(
msg
=
" Apply CTE Effect"
,
logger
=
self
.
logger
)
###img = effects.CTE_Effect(GSImage=img, threshold=27)
###CTI_modeling
### 2*8 -> 1*16 img-layout
FlatCombImg
=
chip_utils
.
formatOutput
(
GSImage
=
FlatCombImg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
img_arr
=
FlatCombImg
.
array
ny
,
nx
=
img_arr
.
shape
dx
=
int
(
nx
/
self
.
nsecx
)
dy
=
int
(
ny
/
self
.
nsecy
)
newimg
=
galsim
.
Image
(
nx
,
int
(
ny
+
over2
),
init_value
=
0
)
for
ichannel
in
range
(
16
):
print
(
'
\n
***add CTI effects: pointing-{:} chip-{:} channel-{:}***'
.
format
(
pointing_ID
,
self
.
chipID
,
ichannel
+
1
))
#nx,ny,noverscan,nsp,nmax = 4608,4616,84,3,10
noverscan
,
nsp
,
nmax
=
over2
,
3
,
10
beta
,
w
,
c
=
0.478
,
84700
,
0
t
=
np
.
array
([
0.74
,
7.7
,
37
],
dtype
=
np
.
float32
)
rho_trap
=
np
.
array
([
0.6
,
1.6
,
1.4
],
dtype
=
np
.
float32
)
trap_seeds
=
np
.
array
([
0
,
1000
,
10000
],
dtype
=
np
.
int32
)
+
ichannel
+
self
.
chipID
*
16
release_seed
=
50
+
ichannel
+
pointing_ID
*
30
+
self
.
chipID
*
16
newimg
.
array
[:,
0
+
ichannel
*
dx
:
dx
+
ichannel
*
dx
]
=
CTI_sim
(
img_arr
[:,
0
+
ichannel
*
dx
:
dx
+
ichannel
*
dx
],
dx
,
dy
,
noverscan
,
nsp
,
nmax
,
beta
,
w
,
c
,
t
,
rho_trap
,
trap_seeds
,
release_seed
)
newimg
.
wcs
=
FlatCombImg
.
wcs
del
FlatCombImg
FlatCombImg
=
newimg
### 1*16 -> 2*8 img-layout
img
=
chip_utils
.
formatRevert
(
GSImage
=
FlatCombImg
)
self
.
nsecy
=
2
self
.
nsecx
=
8
### prescan & overscan
if
config
[
"ins_effects"
][
"add_prescan"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply pre/over-scan"
,
logger
=
self
.
logger
)
if
config
[
"ins_effects"
][
"cte_trail"
]
==
False
:
FlatCombImg
=
chip_utils
.
AddPreScan
(
GSImage
=
FlatCombImg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
over2
)
if
config
[
"ins_effects"
][
"cte_trail"
]
==
True
:
FlatCombImg
=
chip_utils
.
AddPreScan
(
GSImage
=
FlatCombImg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
0
)
### 1*16 output
if
config
[
"ins_effects"
][
"format_output"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply 1*16 format"
,
logger
=
self
.
logger
)
FlatCombImg
=
chip_utils
.
formatOutput
(
GSImage
=
FlatCombImg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
###########################END
# Add Hot Pixels or/and Dead Pixels
rgbadpix
=
Generator
(
PCG64
(
int
(
SeedDefective
+
self
.
chipID
)))
...
...
@@ -627,7 +694,7 @@ class Chip(FocalPlane):
# img += float(config["ins_effects"]["bias_level"])
FlatCombImg
=
effects
.
AddBiasNonUniform16
(
FlatCombImg
,
bias_level
=
biaslevel
,
nsecy
=
2
,
nsecx
=
8
,
nsecy
=
self
.
nsecy
,
nsecx
=
self
.
nsecx
,
seed
=
SeedBiasNonuni
+
self
.
chipID
,
logger
=
self
.
logger
)
...
...
@@ -639,7 +706,7 @@ class Chip(FocalPlane):
FlatCombImg
.
addNoise
(
readout_noise
)
FlatCombImg
,
self
.
gain_channel
=
effects
.
ApplyGainNonUniform16
(
FlatCombImg
,
gain
=
self
.
gain
,
nsecy
=
2
,
nsecx
=
8
,
nsecy
=
self
.
nsecy
,
nsecx
=
self
.
nsecx
,
seed
=
SeedGainNonuni
+
self
.
chipID
,
logger
=
self
.
logger
)
# FlatCombImg = effects.AddOverscan(FlatCombImg, overscan=overscan, gain=self.gain, widthl=27, widthr=27, widtht=8, widthb=8)
...
...
@@ -702,6 +769,19 @@ class Chip(FocalPlane):
cr_map
[
cr_map
<
0
]
=
0
crmap_gsimg
=
galsim
.
Image
(
cr_map
,
dtype
=
np
.
uint16
)
del
cr_map
###########################START
### prescan & overscan
if
config
[
"ins_effects"
][
"add_prescan"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply pre/over-scan"
,
logger
=
self
.
logger
)
crmap_gsimg
=
chip_utils
.
AddPreScan
(
GSImage
=
crmap_gsimg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
over2
)
### 1*16 output
if
config
[
"ins_effects"
][
"format_output"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply 1*16 format"
,
logger
=
self
.
logger
)
crmap_gsimg
=
chip_utils
.
formatOutput
(
GSImage
=
crmap_gsimg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
###########################END
chip_utils
.
outputCal
(
chip
=
self
,
img
=
crmap_gsimg
,
...
...
@@ -725,8 +805,61 @@ class Chip(FocalPlane):
print
(
" Applying Non-Linearity on the Dark image"
,
flush
=
True
)
DarkCombImg
=
effects
.
NonLinearity
(
GSImage
=
DarkCombImg
,
beta1
=
5.e-7
,
beta2
=
0
)
###if config["ins_effects"]["cte_trail"] == True:
### DarkCombImg = effects.CTE_Effect(GSImage=DarkCombImg, threshold=3)
###########################START
pre1
=
self
.
prescan_x
#27
over1
=
self
.
overscan_x
#71
pre2
=
self
.
prescan_y
#0 #4
over2
=
self
.
overscan_y
#84 #80
if
config
[
"ins_effects"
][
"cte_trail"
]
==
True
:
DarkCombImg
=
effects
.
CTE_Effect
(
GSImage
=
DarkCombImg
,
threshold
=
3
)
chip_utils
.
log_info
(
msg
=
" Apply CTE Effect"
,
logger
=
self
.
logger
)
###img = effects.CTE_Effect(GSImage=img, threshold=27)
###CTI_modeling
### 2*8 -> 1*16 img-layout
DarkCombImg
=
chip_utils
.
formatOutput
(
GSImage
=
DarkCombImg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
img_arr
=
DarkCombImg
.
array
ny
,
nx
=
img_arr
.
shape
dx
=
int
(
nx
/
self
.
nsecx
)
dy
=
int
(
ny
/
self
.
nsecy
)
newimg
=
galsim
.
Image
(
nx
,
int
(
ny
+
over2
),
init_value
=
0
)
for
ichannel
in
range
(
16
):
print
(
'
\n
***add CTI effects: pointing-{:} chip-{:} channel-{:}***'
.
format
(
pointing_ID
,
self
.
chipID
,
ichannel
+
1
))
#nx,ny,noverscan,nsp,nmax = 4608,4616,84,3,10
noverscan
,
nsp
,
nmax
=
over2
,
3
,
10
beta
,
w
,
c
=
0.478
,
84700
,
0
t
=
np
.
array
([
0.74
,
7.7
,
37
],
dtype
=
np
.
float32
)
rho_trap
=
np
.
array
([
0.6
,
1.6
,
1.4
],
dtype
=
np
.
float32
)
trap_seeds
=
np
.
array
([
0
,
1000
,
10000
],
dtype
=
np
.
int32
)
+
ichannel
+
self
.
chipID
*
16
release_seed
=
50
+
ichannel
+
pointing_ID
*
30
+
self
.
chipID
*
16
newimg
.
array
[:,
0
+
ichannel
*
dx
:
dx
+
ichannel
*
dx
]
=
CTI_sim
(
img_arr
[:,
0
+
ichannel
*
dx
:
dx
+
ichannel
*
dx
],
dx
,
dy
,
noverscan
,
nsp
,
nmax
,
beta
,
w
,
c
,
t
,
rho_trap
,
trap_seeds
,
release_seed
)
newimg
.
wcs
=
DarkCombImg
.
wcs
del
DarkCombImg
DarkCombImg
=
newimg
### 1*16 -> 2*8 img-layout
DarkCombImg
=
chip_utils
.
formatRevert
(
GSImage
=
DarkCombImg
)
self
.
nsecy
=
2
self
.
nsecx
=
8
### prescan & overscan
if
config
[
"ins_effects"
][
"add_prescan"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply pre/over-scan"
,
logger
=
self
.
logger
)
if
config
[
"ins_effects"
][
"cte_trail"
]
==
False
:
DarkCombImg
=
chip_utils
.
AddPreScan
(
GSImage
=
DarkCombImg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
over2
)
if
config
[
"ins_effects"
][
"cte_trail"
]
==
True
:
DarkCombImg
=
chip_utils
.
AddPreScan
(
GSImage
=
DarkCombImg
,
pre1
=
pre1
,
pre2
=
pre2
,
over1
=
over1
,
over2
=
0
)
### 1*16 output
if
config
[
"ins_effects"
][
"format_output"
]
==
True
:
chip_utils
.
log_info
(
msg
=
" Apply 1*16 format"
,
logger
=
self
.
logger
)
DarkCombImg
=
chip_utils
.
formatOutput
(
GSImage
=
DarkCombImg
)
self
.
nsecy
=
1
self
.
nsecx
=
16
###########################END
# Add Hot Pixels or/and Dead Pixels
rgbadpix
=
Generator
(
PCG64
(
int
(
SeedDefective
+
self
.
chipID
)))
...
...
@@ -746,7 +879,7 @@ class Chip(FocalPlane):
# img += float(config["ins_effects"]["bias_level"])
DarkCombImg
=
effects
.
AddBiasNonUniform16
(
DarkCombImg
,
bias_level
=
biaslevel
,
nsecy
=
2
,
nsecx
=
8
,
nsecy
=
self
.
nsecy
,
nsecx
=
self
.
nsecx
,
seed
=
SeedBiasNonuni
+
self
.
chipID
,
logger
=
self
.
logger
)
...
...
@@ -759,7 +892,7 @@ class Chip(FocalPlane):
DarkCombImg
,
self
.
gain_channel
=
effects
.
ApplyGainNonUniform16
(
DarkCombImg
,
gain
=
self
.
gain
,
nsecy
=
2
,
nsecx
=
8
,
nsecy
=
self
.
nsecy
,
nsecx
=
self
.
nsecx
,
seed
=
SeedGainNonuni
+
self
.
chipID
,
logger
=
self
.
logger
)
# DarkCombImg = effects.AddOverscan(
...
...
config/config_C6_dev.yaml
View file @
72f70d57
...
...
@@ -9,15 +9,15 @@
# Base diretories and naming setup
# Can add some of the command-line arguments here as well;
# OK to pass either way or both, as long as they are consistent
work_dir
:
"
/
Users/zhangxin/Work/SlitlessSim/CSST_SIM/CSST_new_sim/csst-simulation
/"
data_dir
:
"
/
Volumes/EAGET/C6_data/inputD
ata/"
run_name
:
"
C6_new_sim_2sq_run1
"
work_dir
:
"
/
share/simudata/CSSOSDataProductsSims/data/CSSTSimImage_C8
/"
data_dir
:
"
/
share/simudata/CSSOSDataProductsSims/d
ata/"
run_name
:
"
testRun_cal
"
project_cycle
:
6
run_counter
:
1
# Whether to use MPI
run_option
:
use_mpi
:
NO
use_mpi
:
YES
# NOTE: "n_threads" paramters is currently not used in the backend
# simulation codes. It should be implemented later in the web frontend
# in order to config the number of threads to request from NAOC cluster
...
...
@@ -67,7 +67,7 @@ obs_setting:
# "FGS": simulate FGS chips only (31-42)
# "All": simulate full focal plane
# "CALIBRATION": falt, bias, dark with or without postflash
survey_type
:
"
CALIBRATION
"
survey_type
:
"
Photometric
"
#"LED": ['LED1','LED2','LED3','LED4','LED5','LED6','LED7','LED8','LED9','LED10','LED11','LED12','LED13','LED14'] or null
#'LED1': '275', 'LED2': '310', 'LED3': '430', 'LED4': '505', 'LED5': '545', 'LED6': '590', 'LED7': '670',
#'LED8': '760', 'LED9': '940', 'LED10': '940', 'LED11': '1050', 'LED12': '1050','LED13': '340', 'LED14': '365'
...
...
@@ -95,11 +95,11 @@ obs_setting:
# if you just want to run default pointing:
# - pointing_dir: null
# - pointing_file: null
pointing_dir
:
"
/
Volumes/EAGET/C6_data/inputD
ata/"
pointing_dir
:
"
/
share/simudata/CSSOSDataProductsSims/d
ata/"
pointing_file
:
"
pointing_radec_246.5_40.dat"
# Number of calibration pointings
np_cal
:
0
np_cal
:
3
# Run specific pointing(s):
# - give a list of indexes of pointings: [ip_1, ip_2...]
...
...
@@ -111,10 +111,10 @@ obs_setting:
# - give a list of indexes of chips: [ip_1, ip_2...]
# - run all chips: null
# Note: for all pointings
run_chips
:
[
5
]
run_chips
:
null
# Whether to enable astrometric modeling
enable_astrometric_model
:
Fals
e
enable_astrometric_model
:
Tru
e
# Whether to enable straylight model
enable_straylight_model
:
True
...
...
@@ -137,7 +137,7 @@ psf_setting:
# Which PSF model to use:
# "Gauss": simple gaussian profile
# "Interp": Interpolated PSF from sampled ray-tracing data
psf_model
:
"
Gauss
"
psf_model
:
"
Interp
"
# PSF size [arcseconds]
# radius of 80% energy encircled
...
...
@@ -169,12 +169,12 @@ ins_effects:
# switches
# Note: bias_16channel, gain_16channel, and shutter_effect
# is currently not applicable to "FGS" observations
field_dist
:
NO
# Whether to add field distortions
field_dist
:
YES
# Whether to add field distortions
add_back
:
YES
# Whether to add sky background
add_dark
:
YES
# Whether to add dark noise
add_readout
:
YES
# Whether to add read-out (Gaussian) noise
add_bias
:
YES
# Whether to add bias-level to images
add_prescan
:
OFF
add_prescan
:
YES
bias_16channel
:
YES
# Whether to add different biases for 16 channels
gain_16channel
:
YES
# Whether to make different gains for 16 channels
shutter_effect
:
YES
# Whether to add shutter effect
...
...
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