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
96abee7b
Commit
96abee7b
authored
Jun 19, 2023
by
Fang Yuedong
Browse files
wcs definition: x:E, y:-N, add transpose to psf image
parent
81589f9d
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Catalog/wcs_test_C6.py
0 → 100644
View file @
96abee7b
This diff is collapsed.
Click to expand it.
ObservationSim/Config/Header/ImageHeader.py
View file @
96abee7b
...
...
@@ -287,7 +287,8 @@ def WCS_def(xlen = 9216, ylen = 9232, gapy = 898.0, gapx1 = 534, gapx2 = 1309, r
r_dat
[
'CRPIX1'
]
=
-
x1
r_dat
[
'CRPIX2'
]
=
-
y1
cd
=
np
.
array
([[
pixel_scale
,
0
],
[
0
,
pixel_scale
]])
/
3600.
*
flag_x
[
1
]
# cd = np.array([[ pixel_scale, 0], [0, pixel_scale]])/3600.*flag_x[1]
cd
=
np
.
array
([[
pixel_scale
,
0
],
[
0
,
-
pixel_scale
]])
/
3600.
cd_rot
=
rotate_CD_matrix
(
cd
,
pa_aper
)
r_dat
[
'CD1_1'
]
=
cd_rot
[
0
,
0
]
r_dat
[
'CD1_2'
]
=
cd_rot
[
0
,
1
]
...
...
ObservationSim/Instrument/Chip/Chip.py
View file @
96abee7b
...
...
@@ -115,7 +115,7 @@ class Chip(FocalPlane):
self
.
_getCRdata
()
# Define the sensor model
if
config
[
"ins_effects"
][
"bright_fatter"
]
==
True
and
self
.
survey_type
==
"photometric"
:
if
"bright_fatter"
in
config
[
"ins_effects"
]
and
config
[
"ins_effects"
][
"bright_fatter"
]
==
True
and
self
.
survey_type
==
"photometric"
:
self
.
sensor
=
galsim
.
SiliconSensor
(
strength
=
self
.
df_strength
,
treering_func
=
treering_func
)
else
:
self
.
sensor
=
galsim
.
Sensor
()
...
...
ObservationSim/Instrument/FocalPlane.py
View file @
96abee7b
...
...
@@ -86,15 +86,16 @@ class FocalPlane(object):
if
(
xcen
==
None
)
or
(
ycen
==
None
):
xcen
=
self
.
cen_pix_x
ycen
=
self
.
cen_pix_y
# dudx = -np.cos(img_rot.rad) * pix_scale
# dudy = -np.sin(img_rot.rad) * pix_scale
# dvdx = -np.sin(img_rot.rad) * pix_scale
# dvdy = +np.cos(img_rot.rad) * pix_scale
dudx
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dudy
=
-
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dudy
=
+
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdx
=
-
np
.
sin
(
img_rot
.
rad
)
*
pix_scale
dvdy
=
+
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
dvdy
=
-
np
.
cos
(
img_rot
.
rad
)
*
pix_scale
# dudx = +np.sin(img_rot.rad) * pix_scale
# dudy = +np.cos(img_rot.rad) * pix_scale
# dvdx = -np.cos(img_rot.rad) * pix_scale
# dvdy = +np.sin(img_rot.rad) * pix_scale
moscen
=
galsim
.
PositionD
(
x
=
xcen
,
y
=
ycen
)
sky_center
=
galsim
.
CelestialCoord
(
ra
=
ra
*
galsim
.
degrees
,
dec
=
dec
*
galsim
.
degrees
)
affine
=
galsim
.
AffineTransform
(
dudx
,
dudy
,
dvdx
,
dvdy
,
origin
=
moscen
)
...
...
ObservationSim/MockObject/Galaxy.py
View file @
96abee7b
...
...
@@ -51,7 +51,8 @@ class Galaxy(MockObject):
full
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
filt
.
bandpass_full
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
return
-
1
for
i
in
range
(
len
(
bandpass_list
)):
bandpass
=
bandpass_list
[
i
]
...
...
@@ -59,7 +60,8 @@ class Galaxy(MockObject):
sub
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
bandpass
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
return
-
1
ratio
=
sub
/
full
...
...
@@ -78,12 +80,15 @@ class Galaxy(MockObject):
gal
=
self
.
bfrac
*
bulge
+
(
1.0
-
self
.
bfrac
)
*
disk
gal
=
gal
.
withFlux
(
nphotons
)
if
fd_shear
is
not
None
:
g1
+=
fd_shear
.
g1
g2
+=
fd_shear
.
g2
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
gal
=
gal
.
shear
(
gal_shear
)
gal
=
galsim
.
Convolve
(
psf
,
gal
)
if
fd_shear
is
not
None
:
gal
=
gal
.
shear
(
fd_shear
)
#
if fd_shear is not None:
#
gal = gal.shear(fd_shear)
objs
.
append
(
gal
)
final
=
galsim
.
Sum
(
objs
)
return
final
...
...
@@ -97,7 +102,8 @@ class Galaxy(MockObject):
full
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
filt
.
bandpass_full
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
return
2
,
None
nphotons_sum
=
0
...
...
@@ -131,6 +137,13 @@ class Galaxy(MockObject):
real_wcs_local
=
self
.
real_wcs
.
local
(
self
.
real_pos
)
disk
=
galsim
.
Sersic
(
n
=
self
.
disk_sersic_idx
,
half_light_radius
=
self
.
hlr_disk
,
flux
=
1.0
,
gsparams
=
gsp
)
disk_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_disk
,
g2
=
self
.
e2_disk
)
disk
=
disk
.
shear
(
disk_shape
)
bulge
=
galsim
.
Sersic
(
n
=
self
.
bulge_sersic_idx
,
half_light_radius
=
self
.
hlr_bulge
,
flux
=
1.0
,
gsparams
=
gsp
)
bulge_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_bulge
,
g2
=
self
.
e2_bulge
)
bulge
=
bulge
.
shear
(
bulge_shape
)
for
i
in
range
(
len
(
bandpass_list
)):
bandpass
=
bandpass_list
[
i
]
...
...
@@ -138,7 +151,8 @@ class Galaxy(MockObject):
sub
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
bandpass
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
# return False
continue
...
...
@@ -153,40 +167,49 @@ class Galaxy(MockObject):
# print("nphotons_sub-band_%d = %.2f"%(i, nphotons))
psf
,
pos_shear
=
psf_model
.
get_PSF
(
chip
=
chip
,
pos_img
=
pos_img
,
bandpass
=
bandpass
,
folding_threshold
=
folding_threshold
)
disk
=
galsim
.
Sersic
(
n
=
self
.
disk_sersic_idx
,
half_light_radius
=
self
.
hlr_disk
,
flux
=
1.0
,
gsparams
=
gsp
)
disk_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_disk
,
g2
=
self
.
e2_disk
)
disk
=
disk
.
shear
(
disk_shape
)
bulge
=
galsim
.
Sersic
(
n
=
self
.
bulge_sersic_idx
,
half_light_radius
=
self
.
hlr_bulge
,
flux
=
1.0
,
gsparams
=
gsp
)
bulge_shape
=
galsim
.
Shear
(
g1
=
self
.
e1_bulge
,
g2
=
self
.
e2_bulge
)
bulge
=
bulge
.
shear
(
bulge_shape
)
# disk = galsim.Sersic(n=self.disk_sersic_idx, half_light_radius=self.hlr_disk, flux=1.0, gsparams=gsp)
# disk_shape = galsim.Shear(g1=self.e1_disk, g2=self.e2_disk)
# disk = disk.shear(disk_shape)
# bulge = galsim.Sersic(n=self.bulge_sersic_idx, half_light_radius=self.hlr_bulge, flux=1.0, gsparams=gsp)
# bulge_shape = galsim.Shear(g1=self.e1_bulge, g2=self.e2_bulge)
# bulge = bulge.shear(bulge_shape)
gal_temp
=
self
.
bfrac
*
bulge
+
(
1.0
-
self
.
bfrac
)
*
disk
gal
=
self
.
bfrac
*
bulge
+
(
1.0
-
self
.
bfrac
)
*
disk
gal_temp
=
gal_temp
.
withFlux
(
nphotons
)
if
not
big_galaxy
:
# Not apply PSF for very big galaxy
gal_temp
=
galsim
.
Convolve
(
psf
,
gal_temp
)
if
i
==
0
:
gal
=
gal_temp
else
:
gal
=
gal
+
gal_temp
# (TEST) Random knots
# knots = galsim.RandomKnots(npoints=100, profile=disk)
# kfrac = np.random.random()*(1.0 - self.bfrac)
# gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots
gal
=
gal
.
withFlux
(
nphotons
)
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
gal
=
gal
.
shear
(
gal_shear
)
#
gal = gal.withFlux(nphotons)
#
gal_shear = galsim.Shear(g1=g1, g2=g2)
#
gal = gal.shear(gal_shear)
if
not
big_galaxy
:
# Not apply PSF for very big galaxy
gal
=
galsim
.
Convolve
(
psf
,
gal
)
if
fd_shear
is
not
None
:
gal
=
gal
.
shear
(
fd_shear
)
#
if not big_galaxy: # Not apply PSF for very big galaxy
#
gal = galsim.Convolve(psf, gal)
#
#
if fd_shear is not None:
#
#
gal = gal.shear(fd_shear)
# Use (explicit) stamps to draw
stamp
=
gal
.
drawImage
(
wcs
=
real_wcs_local
,
method
=
'phot'
,
offset
=
offset
,
save_photons
=
True
)
#
#
Use (explicit) stamps to draw
#
stamp = gal.drawImage(wcs=real_wcs_local, method='phot', offset=offset, save_photons=True)
xmax
=
max
(
xmax
,
stamp
.
xmax
-
stamp
.
xmin
)
ymax
=
max
(
ymax
,
stamp
.
ymax
-
stamp
.
ymin
)
#
xmax = max(xmax, stamp.xmax - stamp.xmin)
#
ymax = max(ymax, stamp.ymax - stamp.ymin)
photons
=
stamp
.
photons
photons
.
x
+=
x_nominal
photons
.
y
+=
y_nominal
photons_list
.
append
(
photons
)
del
gal
#
photons = stamp.photons
#
photons.x += x_nominal
#
photons.y += y_nominal
#
photons_list.append(photons)
#
del gal
# # [C6 TEST]
# print('xmax = %d, ymax = %d '%(xmax, ymax))
...
...
@@ -195,8 +218,21 @@ class Galaxy(MockObject):
# top_stats = snapshot.statistics('lineno')
# for stat in top_stats[:10]:
# print(stat)
if
fd_shear
:
g1
+=
fd_shear
.
g1
g2
+=
fd_shear
.
g2
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
gal
=
gal
.
shear
(
gal_shear
)
# if fd_shear is not None:
# gal = gal.shear(fd_shear)
stamp
=
gal
.
drawImage
(
wcs
=
real_wcs_local
,
method
=
'phot'
,
offset
=
offset
,
save_photons
=
True
)
photons
=
stamp
.
photons
photons
.
x
+=
x_nominal
photons
.
y
+=
y_nominal
photons_list
.
append
(
photons
)
stamp
=
galsim
.
ImageF
(
int
(
xmax
*
1.1
),
int
(
ymax
*
1.1
))
#
stamp = galsim.ImageF(int(xmax * 1.1), int(ymax * 1.1))
stamp
.
wcs
=
real_wcs_local
stamp
.
setCenter
(
x_nominal
,
y_nominal
)
bounds
=
stamp
.
bounds
&
galsim
.
BoundsI
(
0
,
chip
.
npix_x
-
1
,
0
,
chip
.
npix_y
-
1
)
...
...
@@ -226,7 +262,8 @@ class Galaxy(MockObject):
else
:
# Return code 0: object photons missed this detector
print
(
"obj %s missed"
%
(
self
.
id
))
self
.
logger
.
info
(
"obj %s missed"
%
(
self
.
id
))
if
self
.
logger
:
self
.
logger
.
info
(
"obj %s missed"
%
(
self
.
id
))
return
0
,
pos_shear
# # [C6 TEST]
...
...
@@ -297,14 +334,17 @@ class Galaxy(MockObject):
# gal = self.bfrac * bulge + (1.0 - self.bfrac - kfrac) * disk + kfrac * knots
gal
=
gal
.
withFlux
(
tel
.
pupil_area
*
exptime
)
if
fd_shear
:
g1
+=
fd_shear
.
g1
g2
+=
fd_shear
.
g2
gal_shear
=
galsim
.
Shear
(
g1
=
g1
,
g2
=
g2
)
gal
=
gal
.
shear
(
gal_shear
)
gal
=
galsim
.
Convolve
(
psf
,
gal
)
if
not
big_galaxy
:
# Not apply PSF for very big galaxy
gal
=
galsim
.
Convolve
(
psf
,
gal
)
if
fd_shear
is
not
None
:
gal
=
gal
.
shear
(
fd_shear
)
#
if fd_shear is not None:
#
gal = gal.shear(fd_shear)
starImg
=
gal
.
drawImage
(
wcs
=
real_wcs_local
,
offset
=
offset
)
...
...
ObservationSim/MockObject/MockObject.py
View file @
96abee7b
...
...
@@ -32,6 +32,7 @@ class MockObject(object):
# Place holder for outputs
self
.
additional_output_str
=
""
self
.
fd_shear
=
None
self
.
logger
=
logger
...
...
@@ -61,7 +62,7 @@ class MockObject(object):
dec
=
self
.
param
[
"dec"
]
return
galsim
.
CelestialCoord
(
ra
=
ra
*
galsim
.
degrees
,
dec
=
dec
*
galsim
.
degrees
)
def
getPosImg_Offset_WCS
(
self
,
img
,
fdmodel
=
None
,
chip
=
None
,
verbose
=
True
,
img_header
=
None
):
def
getPosImg_Offset_WCS
(
self
,
img
,
fdmodel
=
None
,
chip
=
None
,
verbose
=
True
,
chip_wcs
=
None
,
img_header
=
None
):
self
.
posImg
=
img
.
wcs
.
toImage
(
self
.
getPosWorld
())
self
.
localWCS
=
img
.
wcs
.
local
(
self
.
posImg
)
if
(
fdmodel
is
not
None
)
and
(
chip
is
not
None
):
...
...
@@ -79,8 +80,10 @@ class MockObject(object):
dx
=
x
-
self
.
x_nominal
dy
=
y
-
self
.
y_nominal
self
.
offset
=
galsim
.
PositionD
(
dx
,
dy
)
if
img_header
is
not
None
:
if
chip_wcs
is
not
None
:
self
.
real_wcs
=
chip_wcs
elif
img_header
is
not
None
:
self
.
real_wcs
=
galsim
.
FitsWCS
(
header
=
img_header
)
else
:
self
.
real_wcs
=
None
...
...
@@ -132,7 +135,8 @@ class MockObject(object):
full
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
filt
.
bandpass_full
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
return
2
,
None
nphotons_sum
=
0
...
...
@@ -149,6 +153,8 @@ class MockObject(object):
self
.
real_pos
=
self
.
getRealPos
(
chip
.
img
,
global_x
=
self
.
posImg
.
x
,
global_y
=
self
.
posImg
.
y
,
img_real_wcs
=
self
.
real_wcs
)
print
(
self
.
real_pos
.
x
,
self
.
real_pos
.
y
)
x
,
y
=
self
.
real_pos
.
x
+
0.5
,
self
.
real_pos
.
y
+
0.5
x_nominal
=
int
(
np
.
floor
(
x
+
0.5
))
y_nominal
=
int
(
np
.
floor
(
y
+
0.5
))
...
...
@@ -164,7 +170,8 @@ class MockObject(object):
sub
=
integrate_sed_bandpass
(
sed
=
self
.
sed
,
bandpass
=
bandpass
)
except
Exception
as
e
:
print
(
e
)
self
.
logger
.
error
(
e
)
if
self
.
logger
:
self
.
logger
.
error
(
e
)
# return False
continue
...
...
@@ -214,7 +221,8 @@ class MockObject(object):
else
:
# Return code 0: object photons missed this detector
print
(
"obj %s missed"
%
(
self
.
id
))
self
.
logger
.
info
(
"obj %s missed"
%
(
self
.
id
))
if
self
.
logger
:
self
.
logger
.
info
(
"obj %s missed"
%
(
self
.
id
))
return
0
,
pos_shear
del
photons_list
...
...
ObservationSim/ObservationSim.py
View file @
96abee7b
...
...
@@ -152,7 +152,7 @@ class Observation(object):
cut_filter
=
temp_filter
if
self
.
config
[
"ins_effects"
][
"field_dist"
]
==
True
:
self
.
fd_model
=
FieldDistortion
(
chip
=
chip
)
self
.
fd_model
=
FieldDistortion
(
chip
=
chip
,
img_rot
=
pointing
.
img_pa
.
deg
)
else
:
self
.
fd_model
=
None
...
...
@@ -177,6 +177,8 @@ class Observation(object):
xcen
=
chip
.
x_cen
,
ycen
=
chip
.
y_cen
,
extName
=
'raw'
)
chip_wcs
=
galsim
.
FitsWCS
(
header
=
h_ext
)
for
j
in
range
(
self
.
nobj
):
...
...
@@ -208,7 +210,7 @@ class Observation(object):
continue
# [TODO] Testing
#
chip_output.Log_info("mag_%s = %.3f"%(filt.filter_type.lower(), obj.param["mag_%s"%filt.filter_type.lower()]))
chip_output
.
Log_info
(
"mag_%s = %.3f"
%
(
filt
.
filter_type
.
lower
(),
obj
.
param
[
"mag_%s"
%
filt
.
filter_type
.
lower
()]))
# Exclude very bright/dim objects (for now)
if
cut_filter
.
is_too_bright
(
...
...
@@ -245,7 +247,9 @@ class Observation(object):
raise
ValueError
(
"Unknown shear input"
)
# Get position of object on the focal plane
pos_img
,
offset
,
local_wcs
,
real_wcs
,
fd_shear
=
obj
.
getPosImg_Offset_WCS
(
img
=
chip
.
img
,
fdmodel
=
self
.
fd_model
,
chip
=
chip
,
verbose
=
False
,
img_header
=
h_ext
)
pos_img
,
offset
,
local_wcs
,
real_wcs
,
fd_shear
=
obj
.
getPosImg_Offset_WCS
(
img
=
chip
.
img
,
fdmodel
=
self
.
fd_model
,
chip
=
chip
,
verbose
=
False
,
chip_wcs
=
chip_wcs
,
img_header
=
h_ext
)
print
(
pos_img
.
x
,
pos_img
.
y
)
# [TODO] For now, only consider objects which their centers (after field distortion) are projected within the focal plane
# Otherwise they will be considered missed objects
...
...
ObservationSim/PSF/FieldDistortion.py
View file @
96abee7b
import
galsim
import
numpy
as
np
import
cmath
class
FieldDistortion
(
object
):
def
__init__
(
self
,
chip
,
fdModel
=
None
,
fdModel_path
=
None
):
def
__init__
(
self
,
chip
,
fdModel
=
None
,
fdModel_path
=
None
,
img_rot
=
0.
):
if
fdModel
is
None
:
if
hasattr
(
chip
,
'fdModel'
):
self
.
fdModel
=
chip
.
fdModel
...
...
@@ -15,6 +16,7 @@ class FieldDistortion(object):
raise
ValueError
(
"Error: no field distortion model has been specified!"
)
else
:
self
.
fdModel
=
fdModel
self
.
img_rot
=
img_rot
self
.
ifdModel
=
self
.
fdModel
[
"wave1"
]
self
.
ixfdModel
=
self
.
ifdModel
[
"xImagePos"
]
self
.
iyfdModel
=
self
.
ifdModel
[
"yImagePos"
]
...
...
@@ -42,7 +44,7 @@ class FieldDistortion(object):
return
False
return
True
def
get_distorted
(
self
,
chip
,
pos_img
,
bandpass
=
None
):
def
get_distorted
(
self
,
chip
,
pos_img
,
bandpass
=
None
,
img_rot
=
None
):
""" Get the distored position for an undistorted image position
Parameters:
...
...
@@ -58,14 +60,14 @@ class FieldDistortion(object):
"""
if
not
self
.
isContainObj_FD
(
chip
=
chip
,
pos_img
=
pos_img
):
return
galsim
.
PositionD
(
-
1
,
-
1
),
None
if
not
img_rot
:
img_rot
=
np
.
radians
(
self
.
img_rot
)
else
:
img_rot
=
np
.
radians
(
img_rot
)
x
,
y
=
pos_img
.
x
,
pos_img
.
y
x
=
self
.
ixfdModel
(
x
,
y
)[
0
][
0
]
y
=
self
.
iyfdModel
(
x
,
y
)[
0
][
0
]
ix_dx
=
self
.
ifx_dx
(
x
,
y
)
ix_dy
=
self
.
ifx_dy
(
x
,
y
)
iy_dx
=
self
.
ify_dx
(
x
,
y
)
iy_dy
=
self
.
ify_dy
(
x
,
y
)
if
self
.
irsModel
is
not
None
:
if
self
.
irsModel
:
# x1LowI, x1UpI, y1LowI, y1UpI = self.irsModel["interpLimit"]
# if (x1LowI-x)*(x1UpI-x) <=0 and (y1LowI-y)*(y1UpI-y)<=0:
# dx = self.ixrsModel(x, y)[0][0]
...
...
@@ -88,8 +90,25 @@ class FieldDistortion(object):
ix_dy
=
self
.
ifx_dy
(
x
,
y
)
+
self
.
irx_dy
(
x
,
y
)
iy_dx
=
self
.
ify_dx
(
x
,
y
)
+
self
.
iry_dx
(
x
,
y
)
iy_dy
=
self
.
ify_dy
(
x
,
y
)
+
self
.
iry_dy
(
x
,
y
)
else
:
ix_dx
=
self
.
ifx_dx
(
x
,
y
)
ix_dy
=
self
.
ifx_dy
(
x
,
y
)
iy_dx
=
self
.
ify_dx
(
x
,
y
)
iy_dy
=
self
.
ify_dy
(
x
,
y
)
g1k_fd
=
0.0
+
(
iy_dy
-
ix_dx
)
/
(
iy_dy
+
ix_dx
)
g2k_fd
=
0.0
-
(
iy_dx
+
ix_dy
)
/
(
iy_dy
+
ix_dx
)
# [TODO] [TESTING] Rotate the shear:
g_abs
=
np
.
sqrt
(
g1k_fd
**
2
+
g2k_fd
**
2
)
phi
=
cmath
.
phase
(
complex
(
g1k_fd
,
g2k_fd
))
# g_abs = 0.7
g1k_fd
=
g_abs
*
np
.
cos
(
phi
-
2
*
img_rot
)
g2k_fd
=
g_abs
*
np
.
sin
(
phi
-
2
*
img_rot
)
# g1k_fd = g_abs * np.cos(phi - 2*img_rot)
# g2k_fd = -g_abs * np.sin(phi - 2*img_rot)
# g1k_fd = g_abs * np.cos(0. - 2*img_rot)
# g2k_fd = -g_abs * np.sin(0. - 2*img_rot)
fd_shear
=
galsim
.
Shear
(
g1
=
g1k_fd
,
g2
=
g2k_fd
)
return
galsim
.
PositionD
(
x
,
y
),
fd_shear
ObservationSim/PSF/PSFInterp.py
View file @
96abee7b
...
...
@@ -341,6 +341,8 @@ class PSFInterp(PSFModel):
if
findNeighMode
==
'hoclistFind'
:
assert
(
self
.
hoc
!=
0
),
'hoclist should be built correctly!'
imPSF
=
psfMaker_IDW
(
px
,
py
,
PSFMat
,
cen_col
,
cen_row
,
IDWindex
=
2
,
OnlyNeighbors
=
True
,
hoc
=
self
.
hoc
[
twave
],
hoclist
=
self
.
hoclist
[
twave
],
PSFCentroidWgt
=
True
)
imPSf
=
np
.
transpose
(
imPSF
)
############TEST: START
TestGaussian
=
False
...
...
config/config_C6.yaml
View file @
96abee7b
...
...
@@ -9,13 +9,13 @@
# 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
:
"
/share/home/fangyuedong/
fgs_
sim/csst-simulation/workplace/"
work_dir
:
"
/share/home/fangyuedong/sim
_v2
/csst-simulation/workplace/"
data_dir
:
"
/share/simudata/CSSOSDataProductsSims/data/"
run_name
:
"
C6_
spectroscopic_20230225
"
run_name
:
"
C6_
test_profiler
"
# Whether to use MPI
run_option
:
use_mpi
:
YES
use_mpi
:
NO
# 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
...
...
@@ -100,7 +100,7 @@ obs_setting:
# - give a list of indexes of chips: [ip_1, ip_2...]
# - run all chips: null
# Note: for all pointings
run_chips
:
[
24
]
run_chips
:
[
8
]
# Whether to enable astrometric modeling
enable_astrometric_model
:
True
...
...
config/config_C6_test_wcs.yaml
0 → 100644
View file @
96abee7b
---
###############################################
#
# Configuration file for CSST simulation
# CSST-Sim Group, 2023/04/25
#
###############################################
# 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
:
"
/share/home/fangyuedong/sim_v2/csst-simulation/workplace/"
data_dir
:
"
/share/simudata/CSSOSDataProductsSims/data/"
run_name
:
"
wcs_test"
# Whether to use MPI
run_option
:
use_mpi
:
NO
# 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
n_threads
:
80
# Output catalog only?
# If yes, no imaging simulation will run
out_cat_only
:
NO
###############################################
# Catalog setting
###############################################
# Configure your catalog: options to be implemented
# in the corresponding (user defined) 'Catalog' class
catalog_options
:
input_path
:
cat_dir
:
"
Catalog_C6_20221212"
star_cat
:
"
C6_MMW_GGC_Astrometry_healpix.hdf5"
galaxy_cat
:
"
cat2CSSTSim_bundle/"
AGN_cat
:
"
AGN_C6_ross13_rand_pos_rmax-1.3.fits"
SED_templates_path
:
star_SED
:
"
Catalog_20210126/SpecLib.hdf5"
galaxy_SED
:
"
Catalog_C6_20221212/sedlibs/"
AGN_SED
:
"
quickspeclib_ross13.fits"
AGN_SED_WAVE
:
"
wave_ross13.npy"
# Only simulate stars?
star_only
:
YES
# Only simulate galaxies?
galaxy_only
:
NO
# rotate galaxy ellipticity
rotateEll
:
0.
# [degree]
seed_Av
:
121212
# Seed for generating random intrinsic extinction
###############################################
# Observation setting
###############################################
obs_setting
:
# Options for survey types:
# "Photometric": simulate photometric chips only
# "Spectroscopic": simulate slitless spectroscopic chips only
# "FGS": simulate FGS chips only (31-42)
# "All": simulate full focal plane
survey_type
:
"
Photometric"
# Exposure time [seconds]
exp_time
:
150.
# Observation starting date & time
date_obs
:
"
210525"
# [yymmdd]
time_obs
:
"
120000"
# [hhmmss]
# Default Pointing [degrees]
# Note: NOT valid when a pointing list file is specified
ra_center
:
192.8595
dec_center
:
27.1283
# Image rotation [degree]
image_rot
:
-113.4333
# (Optional) a file of point list
# if you just want to run default pointing:
# - pointing_dir: null
# - pointing_file: null
pointing_dir
:
"
/share/simudata/CSSOSDataProductsSims/data/"
pointing_file
:
"
pointing_radec_246.5_40.dat"
# Number of calibration pointings
np_cal
:
0
# Run specific pointing(s):
# - give a list of indexes of pointings: [ip_1, ip_2...]
# - run all pointings: null
# Note: only valid when a pointing list is specified
run_pointings
:
[
0
]
# Run specific chip(s):
# - give a list of indexes of chips: [ip_1, ip_2...]
# - run all chips: null
# Note: for all pointings
run_chips
:
[
9
]
# Whether to enable astrometric modeling
enable_astrometric_model
:
True
# Cut by saturation magnitude in which band?
cut_in_band
:
"
z"
# saturation magnitude margin
mag_sat_margin
:
-2.5
# limiting magnitude margin
mag_lim_margin
:
+1.0
###############################################
# PSF setting
###############################################
psf_setting
:
# Which PSF model to use:
# "Gauss": simple gaussian profile
# "Interp": Interpolated PSF from sampled ray-tracing data
psf_model
:
"
Interp"
# PSF size [arcseconds]
# radius of 80% energy encircled
# NOTE: only valid for "Gauss" PSF
psf_rcont
:
0.15
# path to PSF data
# NOTE: only valid for "Interp" PSF
psf_dir
:
"
/share/simudata/CSSOSDataProductsSims/data/psfCube1"
###############################################
# Shear setting
###############################################
shear_setting
:
# Options to generate mock shear field:
# "constant": all galaxies are assigned a constant reduced shear
# "catalog": from catalog
# "extra": from seprate file
shear_type
:
"
catalog"
# For constant shear filed
reduced_g1
:
0.
reduced_g2
:
0.
# Extra shear catalog
# (currently not used)
# shear_cat: "mockShear.cat"
###############################################
# Instrumental effects setting
###############################################
ins_effects
:
# switches
# Note: bias_16channel, gain_16channel, and shutter_effect
# is currently not applicable to "FGS" observations
field_dist
:
OFF
# Whether to add field distortions
add_back
:
OFF
# Whether to add sky background
add_dark
:
OFF
# Whether to add dark noise
add_readout
:
OFF
# Whether to add read-out (Gaussian) noise
add_bias
:
OFF
# Whether to add bias-level to images
bias_16channel
:
OFF
# Whether to add different biases for 16 channels
gain_16channel
:
OFF
# Whether to make different gains for 16 channels
shutter_effect
:
OFF
# Whether to add shutter effect
flat_fielding
:
OFF
# Whether to add flat-fielding effect
prnu_effect
:
OFF
# Whether to add PRNU effect
non_linear
:
OFF
# Whether to add non-linearity
cosmic_ray
:
OFF
# Whether to add cosmic-ray
cray_differ
:
OFF
# Whether to generate different cosmic ray maps CAL and MS output
cte_trail
:
OFF
# Whether to simulate CTE trails
saturbloom
:
OFF
# Whether to simulate Saturation & Blooming
add_badcolumns
:
OFF
# Whether to add bad columns
add_hotpixels
:
OFF
# Whether to add hot pixels
add_deadpixels
:
OFF
# Whether to add dead(dark) pixels
bright_fatter
:
OFF
# Whether to simulate Brighter-Fatter (also diffusion) effect
# Values:
# default values have been defined individually for each chip in:
# ObservationSim/Instrument/data/ccd/chip_definition.json
# Set them here will override the default values
# dark_exptime: 300 # Exposure time for dark current frames [seconds]
# flat_exptime: 150 # Exposure time for flat-fielding frames [seconds]
# readout_time: 40 # The read-out time for each channel [seconds]
# df_strength: 2.3 # Sillicon sensor diffusion strength
# bias_level: 500 # bias level [e-/pixel]
# gain: 1.1 # Gain
# full_well: 90000 # Full well depth [e-]
###############################################
# Output options (for calibration pointings only)
###############################################
output_setting
:
readout16
:
OFF
# Whether to export as 16 channels (subimages) with pre- and over-scan
shutter_output
:
OFF
# Whether to export shutter effect 16-bit image
bias_output
:
ON
# Whether to export bias frames
dark_output
:
ON
# Whether to export the combined dark current files
flat_output
:
ON
# Whether to export the combined flat-fielding files
prnu_output
:
OFF
# Whether to export the PRNU (pixel-to-pixel flat-fielding) files
NBias
:
1
# Number of bias frames to be exported for each exposure
NDark
:
1
# Number of dark frames to be exported for each exposure
NFlat
:
1
# Number of flat frames to be exported for each exposure
###############################################
# Random seeds
###############################################
random_seeds
:
seed_poisson
:
20210601
# Seed for Poisson noise
seed_CR
:
20210317
# Seed for generating random cosmic ray maps
seed_flat
:
20210101
# Seed for generating random flat fields
seed_prnu
:
20210102
# Seed for photo-response non-uniformity
seed_gainNonUniform
:
20210202
# Seed for gain nonuniformity
seed_biasNonUniform
:
20210203
# Seed for bias nonuniformity
seed_rnNonUniform
:
20210204
# Seed for readout-noise nonuniformity
seed_badcolumns
:
20240309
# Seed for bad columns
seed_defective
:
20210304
# Seed for defective (bad) pixels
seed_readout
:
20210601
# Seed for read-out gaussian noise
...
\ No newline at end of file
profile_C6.sh
0 → 100755
View file @
96abee7b
#!/bin/bash
date
python
-m
cProfile
-o
C6_profiler_test.pstats /share/home/fangyuedong/sim_v2/csst-simulation/run_sim.py
\
--config_file
config_C6_test_wcs.yaml
\
--catalog
wcs_test_C6
\
-c
/share/home/fangyuedong/sim_v2/csst-simulation/config
# --config_file test_fd_C6.yaml \
# --catalog fd_test_C6 \
# --config_file config_C6.yaml \
# --catalog C6_Catalog \
run_C6.pbs
View file @
96abee7b
#!/bin/bash
#PBS -N SIMS
#PBS -l nodes=wcl-
1
:ppn=
6
0
#PBS -l nodes=wcl-
2
:ppn=
4
0
###PBS -l nodes=wcl-1:ppn=24+wcl-2:ppn=24+wcl-3:ppn=24+wcl-4:ppn=24+wcl-5:ppn=24+wcl-6:ppn=24
#PBS -u fangyuedong
###PBS -j oe
cd
$PBS_O_WORKDIR
NP
=
6
0
NP
=
4
0
date
mpirun
-np
$NP
python3 /share/home/fangyuedong/
fgs_
sim/csst-simulation/run_sim.py
\
mpirun
-np
$NP
python3 /share/home/fangyuedong/sim
_v2
/csst-simulation/run_sim.py
\
--config_file
config_C6.yaml
\
--catalog
C6_Catalog
\
-c
/share/home/fangyuedong/
fgs_
sim/csst-simulation/config
-c
/share/home/fangyuedong/sim
_v2
/csst-simulation/config
test_C6.sh
View file @
96abee7b
...
...
@@ -2,8 +2,8 @@
date
python3 /share/home/fangyuedong/
fgs_
sim/csst-simulation/run_sim.py
\
python3 /share/home/fangyuedong/sim
_v2
/csst-simulation/run_sim.py
\
--config_file
config_C6.yaml
\
--catalog
C6_Catalog
\
-c
/share/home/fangyuedong/
fgs_
sim/csst-simulation/config
-c
/share/home/fangyuedong/sim
_v2
/csst-simulation/config
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