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
a4587b61
Commit
a4587b61
authored
Jan 08, 2025
by
Wei Chengliang
Browse files
update codestyle-PEP8
parent
95e6759c
Pipeline
#7732
passed with stage
in 0 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
observation_sim/ObservationSim.py
View file @
a4587b61
...
@@ -63,7 +63,7 @@ class Observation(object):
...
@@ -63,7 +63,7 @@ class Observation(object):
chip
.
flat_img
,
_
=
chip_utils
.
get_flat
(
chip
.
flat_img
,
_
=
chip_utils
.
get_flat
(
img
=
chip
.
img
,
seed
=
int
(
self
.
config
[
"random_seeds"
][
"seed_flat"
]))
img
=
chip
.
img
,
seed
=
int
(
self
.
config
[
"random_seeds"
][
"seed_flat"
]))
if
chip
.
chipID
<=
30
:
if
chip
.
chipID
<=
30
:
chip
.
flat_img
=
chip
.
flat_img
*
chip_utils
.
get_innerflat
(
chip
=
chip
)
chip
.
flat_img
=
chip
.
flat_img
*
chip_utils
.
get_innerflat
(
chip
=
chip
)
if
chip
.
chipID
>
30
:
if
chip
.
chipID
>
30
:
chip
.
shutter_img
=
np
.
ones_like
(
chip
.
img
.
array
)
chip
.
shutter_img
=
np
.
ones_like
(
chip
.
img
.
array
)
else
:
else
:
...
...
observation_sim/instruments/chip/chip_utils.py
View file @
a4587b61
...
@@ -172,7 +172,8 @@ def get_flat(img, seed):
...
@@ -172,7 +172,8 @@ def get_flat(img, seed):
flat_normal
=
flat_img
/
np
.
mean
(
flat_img
.
array
)
flat_normal
=
flat_img
/
np
.
mean
(
flat_img
.
array
)
return
flat_img
,
flat_normal
return
flat_img
,
flat_normal
def
get_innerflat
(
chip
=
None
,
filt
=
None
):
def
get_innerflat
(
chip
=
None
,
filt
=
None
):
from
observation_sim.mock_objects
import
FlatLED
from
observation_sim.mock_objects
import
FlatLED
led_obj
=
FlatLED
(
chip
,
filt
)
led_obj
=
FlatLED
(
chip
,
filt
)
flat_img
=
led_obj
.
getInnerFlat
()
flat_img
=
led_obj
.
getInnerFlat
()
...
...
observation_sim/mock_objects/FlatLED.py
View file @
a4587b61
...
@@ -51,7 +51,7 @@ fluxLED = {'LED1': 15, 'LED2': 15, 'LED3': 12.5, 'LED4': 9, 'LED5': 9,
...
@@ -51,7 +51,7 @@ fluxLED = {'LED1': 15, 'LED2': 15, 'LED3': 12.5, 'LED4': 9, 'LED5': 9,
mirro_eff
=
{
'GU'
:
0.61
,
'GV'
:
0.8
,
'GI'
:
0.8
}
mirro_eff
=
{
'GU'
:
0.61
,
'GV'
:
0.8
,
'GI'
:
0.8
}
bandtoLed
=
{
'NUV'
:[
'LED1'
,
'LED2'
],
'u'
:[
'LED13'
,
'LED14'
],
'g'
:[
'LED3'
,
'LED4'
,
'LED5'
],
'r'
:[
'LED6'
,
'LED7'
],
'i'
:[
'LED8'
],
'z'
:[
'LED9'
,
'LED10'
],
'y'
:[
'LED10'
],
'GU'
:[
'LED1'
,
'LED2'
,
'LED13'
,
'LED14'
],
'GV'
:[
'LED3'
,
'LED4'
,
'LED5'
,
'LED6'
],
'GI'
:[
'LED7'
,
'LED8'
,
'LED9'
,
'LED10'
]}
bandtoLed
=
{
'NUV'
:
[
'LED1'
,
'LED2'
],
'u'
:
[
'LED13'
,
'LED14'
],
'g'
:
[
'LED3'
,
'LED4'
,
'LED5'
],
'r'
:
[
'LED6'
,
'LED7'
],
'i'
:
[
'LED8'
],
'z'
:
[
'LED9'
,
'LED10'
],
'y'
:
[
'LED10'
],
'GU'
:
[
'LED1'
,
'LED2'
,
'LED13'
,
'LED14'
],
'GV'
:
[
'LED3'
,
'LED4'
,
'LED5'
,
'LED6'
],
'GI'
:
[
'LED7'
,
'LED8'
,
'LED9'
,
'LED10'
]}
# mirro_eff = {'GU':1, 'GV':1, 'GI':1}
# mirro_eff = {'GU':1, 'GV':1, 'GI':1}
...
@@ -71,19 +71,18 @@ class FlatLED(MockObject):
...
@@ -71,19 +71,18 @@ class FlatLED(MockObject):
with
pkg_resources
.
path
(
'observation_sim.mock_objects.data.led'
,
""
)
as
ledDir
:
with
pkg_resources
.
path
(
'observation_sim.mock_objects.data.led'
,
""
)
as
ledDir
:
self
.
flatDir
=
ledDir
.
as_posix
()
self
.
flatDir
=
ledDir
.
as_posix
()
def
getInnerFlat
(
self
):
def
getInnerFlat
(
self
):
ledflats
=
bandtoLed
[
self
.
chip
.
filter_type
]
ledflats
=
bandtoLed
[
self
.
chip
.
filter_type
]
iFlat
=
np
.
zeros
([
self
.
chip
.
npix_y
,
self
.
chip
.
npix_x
])
iFlat
=
np
.
zeros
([
self
.
chip
.
npix_y
,
self
.
chip
.
npix_x
])
for
nled
in
ledflats
:
for
nled
in
ledflats
:
iFlat
=
iFlat
+
self
.
getLEDImage
(
led_type
=
nled
,
LED_Img_flag
=
False
)
iFlat
=
iFlat
+
self
.
getLEDImage
(
led_type
=
nled
,
LED_Img_flag
=
False
)
iFlat
=
iFlat
/
len
(
ledflats
)
iFlat
=
iFlat
/
len
(
ledflats
)
return
iFlat
return
iFlat
###
###
# return LED flat, e/s
# return LED flat, e/s
###
###
def
getLEDImage
(
self
,
led_type
=
'LED1'
,
LED_Img_flag
=
True
):
def
getLEDImage
(
self
,
led_type
=
'LED1'
,
LED_Img_flag
=
True
):
# cwave = cwaves[led_type]
# cwave = cwaves[led_type]
flat
=
fits
.
open
(
os
.
path
.
join
(
self
.
flatDir
,
'model_'
+
flat
=
fits
.
open
(
os
.
path
.
join
(
self
.
flatDir
,
'model_'
+
cwaves_name
[
led_type
]
+
'nm.fits'
))
cwaves_name
[
led_type
]
+
'nm.fits'
))
...
...
observation_sim/mock_objects/Galaxy.py
View file @
a4587b61
...
@@ -340,7 +340,7 @@ class Galaxy(MockObject):
...
@@ -340,7 +340,7 @@ class Galaxy(MockObject):
if
self
.
getMagFilter
(
filt
)
<=
filt
.
mag_saturation
-
2.
:
if
self
.
getMagFilter
(
filt
)
<=
filt
.
mag_saturation
-
2.
:
EXTRA
=
True
EXTRA
=
True
psf
,
pos_shear
=
psf_model
.
get_PSF
(
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
,
pos_img_local
=
pos_img_local
,
bandNo
=
i
+
1
,
galsimGSObject
=
True
,
g_order
=
order
,
grating_split_pos
=
grating_split_pos
,
extrapolate
=
EXTRA
,
ngg
=
3072
)
chip
,
pos_img_local
=
pos_img_local
,
bandNo
=
i
+
1
,
galsimGSObject
=
True
,
g_order
=
order
,
grating_split_pos
=
grating_split_pos
,
extrapolate
=
EXTRA
,
ngg
=
3072
)
star_p
=
galsim
.
Convolve
(
psf
,
gal
)
star_p
=
galsim
.
Convolve
(
psf
,
gal
)
if
nnx
==
0
:
if
nnx
==
0
:
galImg
=
star_p
.
drawImage
(
galImg
=
star_p
.
drawImage
(
...
...
observation_sim/psf/PSFInterpSLS.py
View file @
a4587b61
...
@@ -452,14 +452,14 @@ class PSFInterpSLS(PSFModel):
...
@@ -452,14 +452,14 @@ class PSFInterpSLS(PSFModel):
(
n1
,
n2
,
n01
))
(
n1
,
n2
,
n01
))
if
extrapolate
is
True
:
if
extrapolate
is
True
:
# for rep_i in np.arange(0, 2, 1):
# for rep_i in np.arange(0, 2, 1):
#
PSF_int_trans[rep_i,:] = 1e9*pow(10,rep_i)
#
PSF_int_trans[rep_i,:] = 1e9*pow(10,rep_i)
#
PSF_int_trans[-1-rep_i,:] = 1e9*pow(10,rep_i)
#
PSF_int_trans[-1-rep_i,:] = 1e9*pow(10,rep_i)
#
PSF_int_trans[:,rep_i] = 1e9*pow(10,rep_i)
#
PSF_int_trans[:,rep_i] = 1e9*pow(10,rep_i)
#
PSF_int_trans[:,-1-rep_i] = 1e9*pow(10,rep_i)
#
PSF_int_trans[:,-1-rep_i] = 1e9*pow(10,rep_i)
PSF_int_trans
=
psf_extrapolate1
(
PSF_int_trans
,
ngg
=
ngg
)
PSF_int_trans
=
psf_extrapolate1
(
PSF_int_trans
,
ngg
=
ngg
)
# fits.writeto('/home/zhangxin/CSST_SIM/CSST_sim_develop/psf_test/psf_large.fits',PSF_int_trans)
# fits.writeto('/home/zhangxin/CSST_SIM/CSST_sim_develop/psf_test/psf_large.fits',PSF_int_trans)
####
####
# from astropy.io import fits
# from astropy.io import fits
# fits.writeto(str(bandNo) + '_' + g_order+ '_psf_o.fits', PSF_int_trans)
# fits.writeto(str(bandNo) + '_' + g_order+ '_psf_o.fits', PSF_int_trans)
...
...
observation_sim/psf/_util.py
View file @
a4587b61
...
@@ -64,6 +64,7 @@ def psf_extrapolate(psf, rr_trim=64, ngg=256):
...
@@ -64,6 +64,7 @@ def psf_extrapolate(psf, rr_trim=64, ngg=256):
imPSF
=
imPSF
/
np
.
nansum
(
imPSF
)
imPSF
=
imPSF
/
np
.
nansum
(
imPSF
)
return
imPSF
return
imPSF
def
psf_extrapolate1
(
psf
,
rr_trim
=
64
,
ngg
=
256
):
def
psf_extrapolate1
(
psf
,
rr_trim
=
64
,
ngg
=
256
):
# ngg = 256
# ngg = 256
# extrapolate PSF
# extrapolate PSF
...
@@ -83,7 +84,6 @@ def psf_extrapolate1(psf, rr_trim=64, ngg=256):
...
@@ -83,7 +84,6 @@ def psf_extrapolate1(psf, rr_trim=64, ngg=256):
# radii_log = radii[1:]
# radii_log = radii[1:]
means_log
=
np
.
log
(
means
[
1
:])
means_log
=
np
.
log
(
means
[
1
:])
# xim = np.arange(256)-128
# xim = np.arange(256)-128
# xim, yim = np.meshgrid(xim, xim)
# xim, yim = np.meshgrid(xim, xim)
# rim = np.sqrt(xim**2 + yim**2)
# rim = np.sqrt(xim**2 + yim**2)
...
...
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