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
Liu Dezi
csst_msc_sim
Commits
1635e47d
Commit
1635e47d
authored
Dec 05, 2021
by
Fang Yuedong
Browse files
modified to absolute import, change location of runExposure.py and run.pbs
parent
c3247cab
Changes
18
Hide whitespace changes
Inline
Side-by-side
ObservationSim/Instrument/Chip/Chip.py
View file @
1635e47d
import
galsim
import
os
import
numpy
as
np
import
Instrument.Chip.Effects
as
effects
from
Instrument.FocalPlane
import
FocalPlane
from
astropy.table
import
Table
from
numpy.random
import
Generator
,
PCG64
from
Config.Header
import
generatePrimaryHeader
,
generateExtensionHeader
from
astropy.io
import
fits
from
datetime
import
datetime
from
ObservationSim.Instrument.Chip
import
Effects
as
effects
from
ObservationSim.Instrument.FocalPlane
import
FocalPlane
from
ObservationSim.Config.Header
import
generatePrimaryHeader
,
generateExtensionHeader
class
Chip
(
FocalPlane
):
def
__init__
(
self
,
chipID
,
ccdEffCurve_dir
,
CRdata_dir
,
normalize_dir
=
None
,
sls_dir
=
None
,
config
=
None
,
treering_func
=
None
):
# Get focal plane (instance of paraent class) info
# TODO: use chipID to config individual chip?
super
().
__init__
()
# if config is not None:
# self.npix_x = config["npix_x"]
# self.npix_y = config["npix_y"]
# self.read_noise = config["read_noise"]
# self.dark_noise = config["dark_noise"]
# self.pix_scale = config["pix_scale"]
# self.gain = config["gain"]
# self.bias_level = config["bias_level"]
# self.overscan = config["overscan"]
# else:
# Default setting
self
.
npix_x
=
9216
self
.
npix_y
=
9232
self
.
read_noise
=
5.0
# e/pix
...
...
ObservationSim/Instrument/Filter.py
View file @
1635e47d
...
...
@@ -2,8 +2,9 @@ import galsim
import
pylab
as
pl
import
os
import
numpy
as
np
from
._util
import
photonEnergy
from
.FilterParam
import
FilterParam
from
ObservationSim.Instrument._util
import
photonEnergy
from
ObservationSim.Instrument.FilterParam
import
FilterParam
class
Filter
(
object
):
def
__init__
(
self
,
filter_id
,
filter_type
,
filter_param
,
ccd_bandpass
):
...
...
ObservationSim/MockObject/Catalog.py
View file @
1635e47d
...
...
@@ -4,13 +4,14 @@ import random
import
galsim
import
h5py
as
h5
import
healpy
as
hp
from
.Star
import
Star
from
.Galaxy
import
Galaxy
from
.Quasar
import
Quasar
from
._util
import
seds
,
sed_assign
,
extAv
from
astropy.table
import
Table
from
astropy.coordinates
import
spherical_to_cartesian
from
ObservationSim.MockObject.Star
import
Star
from
ObservationSim.MockObject.Galaxy
import
Galaxy
from
ObservationSim.MockObject.Quasar
import
Quasar
from
ObservationSim.MockObject._util
import
seds
,
sed_assign
,
extAv
NSIDE
=
128
class
Catalog
(
object
):
...
...
ObservationSim/MockObject/CosmicRay.py
View file @
1635e47d
import
MockObject
from
ObservationSim.MockObject.MockObject
import
MockObject
class
CosmicRay
(
MockObject
):
pass
\ No newline at end of file
ObservationSim/MockObject/Galaxy.py
View file @
1635e47d
...
...
@@ -3,11 +3,12 @@ import galsim
import
os
,
sys
import
astropy.constants
as
cons
from
astropy.table
import
Table
from
._util
import
eObs
,
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
,
convolveGaussXorders
from
.SpecDisperser
import
SpecDisperser
from
.MockObject
import
MockObject
from
scipy
import
interpolate
from
ObservationSim.MockObject._util
import
eObs
,
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
,
convolveGaussXorders
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
from
ObservationSim.MockObject.MockObject
import
MockObject
class
Galaxy
(
MockObject
):
def
__init__
(
self
,
param
,
rotation
=
None
):
super
().
__init__
(
param
)
...
...
ObservationSim/MockObject/MockObject.py
View file @
1635e47d
...
...
@@ -2,9 +2,10 @@ import galsim
import
numpy
as
np
import
astropy.constants
as
cons
from
astropy.table
import
Table
from
._util
import
magToFlux
,
vc_A
,
convolveGaussXorders
from
._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
from
.SpecDisperser
import
SpecDisperser
from
ObservationSim.MockObject._util
import
magToFlux
,
vc_A
,
convolveGaussXorders
from
ObservationSim.MockObject._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
class
MockObject
(
object
):
def
__init__
(
self
,
param
):
...
...
ObservationSim/MockObject/Quasar.py
View file @
1635e47d
...
...
@@ -2,11 +2,11 @@ import galsim
import
os
,
sys
import
numpy
as
np
import
astropy.constants
as
cons
from
.MockObject
import
MockObject
from
astropy.table
import
Table
from
scipy
import
interpolate
from
._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
from
.MockObject
import
MockObject
from
ObservationSim.MockObject.MockObject
import
MockObject
from
ObservationSim.MockObject._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
class
Quasar
(
MockObject
):
def
__init__
(
self
,
param
):
...
...
ObservationSim/MockObject/SkybackgroundMap.py
View file @
1635e47d
from
.SpecDisperser
import
SpecDisperser
from
.SpecDisperser
import
rotate90
from
ObservationSim.MockObject.SpecDisperser
import
SpecDisperser
from
ObservationSim.MockObject.SpecDisperser
import
rotate90
import
galsim
import
numpy
as
np
...
...
ObservationSim/MockObject/Star.py
View file @
1635e47d
...
...
@@ -3,11 +3,11 @@ import os, sys
import
numpy
as
np
import
astropy.constants
as
cons
from
astropy.table
import
Table
from
._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
,
tag_sed
from
.SpecDisperser
import
SpecDisperser
from
.MockObject
import
MockObject
from
scipy
import
interpolate
from
ObservationSim.MockObject._util
import
integrate_sed_bandpass
,
getNormFactorForSpecWithABMAG
,
getObservedSED
,
getABMAG
,
tag_sed
from
ObservationSim.MockObject.MockObject
import
MockObject
class
Star
(
MockObject
):
def
__init__
(
self
,
param
):
super
().
__init__
(
param
)
...
...
ObservationSim/ObservationSim.py
View file @
1635e47d
from
Config
import
ConfigDir
,
ChipOutput
from
Config.Header
import
generatePrimaryHeader
,
generateExtensionHeader
from
Instrument
import
Telescope
,
Filter
,
FilterParam
,
FocalPlane
,
Chip
from
MockObject
import
Catalog
,
MockObject
,
Star
,
Galaxy
,
Quasar
,
calculateSkyMap_split_g
from
PSF
import
PSFGauss
,
FieldDistortion
,
PSFInterp
from
_util
import
getShearFiled
,
makeSubDir_PointingList
import
sys
import
os
from
ObservationSim.Config
import
ConfigDir
,
ChipOutput
from
ObservationSim.Config.Header
import
generatePrimaryHeader
,
generateExtensionHeader
from
ObservationSim.Instrument
import
Telescope
,
Filter
,
FilterParam
,
FocalPlane
,
Chip
from
ObservationSim.MockObject
import
Catalog
,
MockObject
,
Star
,
Galaxy
,
Quasar
,
calculateSkyMap_split_g
from
ObservationSim.PSF
import
PSFGauss
,
FieldDistortion
,
PSFInterp
from
ObservationSim._util
import
getShearFiled
,
makeSubDir_PointingList
from
astropy.io
import
fits
from
datetime
import
datetime
import
numpy
as
np
import
mpi4py.MPI
as
MPI
import
galsim
import
os
,
sys
import
logging
import
psutil
...
...
@@ -345,10 +348,11 @@ class Observation(object):
timestamp_obs
=
np
.
tile
(
timestamp_obs
,
len
(
ra_cen
))
pointing_type
=
np
.
tile
(
pointing_type
,
len
(
ra_cen
))
timestamp_obs
=
timestamp_obs
[
pRange
]
pointing_type
=
pointing_type
[
pRange
]
ra_cen
=
ra_cen
[
pRange
]
dec_cen
=
dec_cen
[
pRange
]
if
pRange
is
not
None
:
timestamp_obs
=
timestamp_obs
[
pRange
]
pointing_type
=
pointing_type
[
pRange
]
ra_cen
=
ra_cen
[
pRange
]
dec_cen
=
dec_cen
[
pRange
]
# The Starting pointing ID
if
pRange
is
not
None
:
...
...
ObservationSim/PSF/PSFGauss.py
View file @
1635e47d
...
...
@@ -2,8 +2,8 @@ import galsim
import
sep
import
numpy
as
np
from
scipy.interpolate
import
interp1d
from
.PSFModel
import
PSFModel
import
os
,
sys
from
ObservationSim.PSF.PSFModel
import
PSFModel
class
PSFGauss
(
PSFModel
):
def
__init__
(
self
,
chip
,
fwhm
=
0.187
,
sigSpin
=
0.
,
psfRa
=
0.15
):
...
...
ObservationSim/PSF/PSFInterp/PSFInterp.py
View file @
1635e47d
...
...
@@ -6,14 +6,13 @@ NOTE: [iccd, iwave, ipsf] are counted from 1 to n, but [tccd, twave, tpsf] are c
import
galsim
import
numpy
as
np
import
os
import
time
import
copy
from
.
import
PSFConfig
as
myConfig
from
.
import
PSFUtil
as
myUtil
from
.
.PSFModel
import
PSFModel
from
ObservationSim.PSF.PSFInterp
import
PSFConfig
as
myConfig
from
ObservationSim.PSF.PSFInterp
import
PSFUtil
as
myUtil
from
ObservationSim.PSF
.PSFModel
import
PSFModel
LOG_DEBUG
=
False
#***#
NPSF
=
900
#***# 30*30
...
...
ObservationSim/PSF/PSFInterp/PSFProcess.py
View file @
1635e47d
...
...
@@ -3,13 +3,8 @@ import numpy as np
import
scipy.io
import
mpi4py.MPI
as
MPI
#sys.path.append("/public/home/weichengliang/lnData/CSST_new_framwork/csstPSF_20201222")
# import PSFConfig as myConfig
# import PSFUtil as myUtil
import
PSFConfig
import
PSFUtil
import
ObservationSim.PSF.PSFInterp.PSFConfig
as
PSFConfig
import
ObservationSim.PSF.PSFInterp.PSFUtil
as
PSFUtil
def
mkdir
(
path
):
isExists
=
os
.
path
.
exists
(
path
)
...
...
ObservationSim/__init__.py
View file @
1635e47d
import
numpy
as
np
import
galsim
\ No newline at end of file
ObservationSim/_util.py
View file @
1635e47d
...
...
@@ -36,18 +36,6 @@ def imgName(tt=0):
return
namekey
# def makeSubDir(path_dict, config):
# subImgdir = path_dict["output_img_dir"] + config["mockImgDir"] + '/'
# if not os.path.exists(subImgdir):
# os.system("mkdir %s"%subImgdir)
# imgKey0 = imgName(tt=0)
# imgKey1 = imgName(tt=1)
# imgKey2 = imgName(tt=2)
# subImgdir = subImgdir + imgKey0 + config["reIndex"] + config["reShear"] + "/"
# if not os.path.exists(subImgdir):
# os.system("mkdir %s"%subImgdir)
# return subImgdir, imgKey0, imgKey1, imgKey2
def
makeSubDir_PointingList
(
path_dict
,
config
,
pointing_ID
=
0
):
imgDir
=
os
.
path
.
join
(
path_dict
[
"work_dir"
],
config
[
"run_name"
])
if
not
os
.
path
.
exists
(
imgDir
):
...
...
config/config_sim.yaml
View file @
1635e47d
...
...
@@ -10,11 +10,15 @@
# 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: "/public/home/fangyuedong/sim_code_release/CSST/test/"
work_dir
:
"
/public/home/fangyuedong/
test_release
/CSST/workplace/"
work_dir
:
"
/public/home/fangyuedong/
20211203
/CSST/workplace/"
data_dir
:
"
/data/simudata/CSSOSDataProductsSims/data/"
run_name
:
"
TEST"
# (Optional) a file of point list
# if you just want to run default pointing:
# - pointing_dir: null
# - pointing_file: null
pointing_dir
:
"
/data/simudata/CSSOSDataProductsSims/data/"
pointing_file
:
"
pointing10_20210202.dat"
# Whether to use MPI
...
...
@@ -63,13 +67,17 @@ obs_setting:
# Note: only valid when a pointing list is specified
np_cal
:
0
# (Optional) only run specific pointing(s).
# 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
:
[
5
,
6
]
# (Optional) only run specific chip(s)
# 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: [
6
, 25]
run_chips
:
[
1
,
25
]
###############################################
# Input path setting
...
...
ObservationSim/
run.pbs
→
run.pbs
View file @
1635e47d
...
...
@@ -16,4 +16,4 @@ NP=40
date
echo
$NP
mpirun
-np
$NP
python /public/home/fangyuedong/
test_release/CSST/ObservationSim
/runExposure.py config_sim.yaml
-c
/public/home/fangyuedong/
test_release
/CSST/config
mpirun
-np
$NP
python /public/home/fangyuedong/
20211203/CSST
/runExposure.py config_sim.yaml
-c
/public/home/fangyuedong/
20211203
/CSST/config
ObservationSim/
runExposure.py
→
runExposure.py
View file @
1635e47d
from
ObservationSim
import
Observation
from
_util
import
parse_args
from
ObservationSim
.ObservationSim
import
Observation
from
ObservationSim.
_util
import
parse_args
from
datetime
import
datetime
import
os
import
numpy
as
np
...
...
@@ -9,20 +9,24 @@ import yaml
import
gc
gc
.
enable
()
def
Pointing
(
config
,
pointing_filename
,
data_dir
):
pointing_file
=
os
.
path
.
join
(
data_dir
,
pointing_filename
)
f
=
open
(
pointing_file
,
'r'
)
for
_
in
range
(
1
):
header
=
f
.
readline
()
iline
=
0
def
Pointing
(
config
,
pointing_filename
=
None
,
data_dir
=
None
):
pRA
=
[]
pDEC
=
[]
for
line
in
f
:
line
=
line
.
strip
()
columns
=
line
.
split
()
pRA
.
append
(
float
(
columns
[
0
]))
pDEC
.
append
(
float
(
columns
[
1
]))
f
.
close
()
if
pointing_filename
and
data_dir
:
pointing_file
=
os
.
path
.
join
(
data_dir
,
pointing_filename
)
f
=
open
(
pointing_file
,
'r'
)
for
_
in
range
(
1
):
header
=
f
.
readline
()
iline
=
0
for
line
in
f
:
line
=
line
.
strip
()
columns
=
line
.
split
()
pRA
.
append
(
float
(
columns
[
0
]))
pDEC
.
append
(
float
(
columns
[
1
]))
f
.
close
()
else
:
pRa
.
append
(
config
[
"obs_setting"
][
"ra_center"
])
pDec
.
append
(
config
[
"obs_setting"
][
"dec_center"
])
pRA
=
np
.
array
(
pRA
)
pDEC
=
np
.
array
(
pDEC
)
...
...
@@ -43,7 +47,7 @@ def Pointing(config, pointing_filename, data_dir):
for
i
in
range
(
len
(
pointing_type
)):
timestamp_obs
.
append
(
t
)
if
pointing_type
[
i
]
==
'CAL'
:
t
+=
3
*
delta_t
*
60
# 3 calibration exposure
t
+=
3
*
delta_t
*
60
# 3 calibration exposure
s for each pointing
elif
pointing_type
[
i
]
==
'MS'
:
t
+=
delta_t
*
60
timestamp_obs
=
np
.
array
(
timestamp_obs
)
...
...
@@ -98,22 +102,13 @@ def runSim():
if
args
.
work_dir
is
not
None
:
config
[
'work_dir'
]
=
args
.
work_dir
pRA
,
pDEC
,
timestamp_obs
,
pointing_type
=
Pointing
(
config
=
config
,
pointing_filename
=
config
[
'pointing_file'
],
data_dir
=
config
[
'
data
_dir'
])
pRA
,
pDEC
,
timestamp_obs
,
pointing_type
=
Pointing
(
config
=
config
,
pointing_filename
=
config
[
'pointing_file'
],
data_dir
=
config
[
'
pointing
_dir'
])
MakeDirectories
(
work_dir
=
config
[
'work_dir'
],
run_name
=
config
[
'run_name'
],
nPointings
=
len
(
pRA
),
pRange
=
config
[
'obs_setting'
][
'run_pointings'
])
if
"run_chips"
in
config
[
"obs_setting"
]:
run_chips
=
config
[
"obs_setting"
][
"run_chips"
]
else
:
run_chips
=
None
# from Config import ConfigDir
# path_dict = ConfigDir(config=config, work_dir=config["work_dir"], data_dir=config["data_dir"])
# for key, value in path_dict.items():
# print (key + " : " + str(value))
obs
=
Observation
(
config
=
config
,
work_dir
=
config
[
'work_dir'
],
data_dir
=
config
[
'data_dir'
])
if
config
[
"pointing_file"
]
is
None
:
obs
.
runExposure
(
chips
=
run_chips
)
obs
.
runExposure
(
chips
=
config
[
"obs_setting"
][
"
run_chips
"
]
)
else
:
obs
.
runExposure_MPI_PointingList
(
ra_cen
=
pRA
,
...
...
@@ -123,24 +118,8 @@ def runSim():
pointing_type
=
pointing_type
,
exptime
=
config
[
"obs_setting"
][
"exp_time"
],
use_mpi
=
config
[
"run_option"
][
"use_mpi"
],
chips
=
run_chips
chips
=
config
[
"obs_setting"
][
"
run_chips
"
]
)
print
(
"run finished"
)
if
__name__
==
'__main__'
:
runSim
()
#############################################
# Testing run one exposure (NOT using MPI)
# ipoint = 2
# pointRa = float('{:8.4f}'.format(pRA[ipoint]))
# pointDec = float('{:8.4f}'.format(pDEC[ipoint]))
# obs = Observation(work_dir=work_dir, data_dir=data_dir)
# obs.runExposure(ra_cen=pointRa, dec_cen=pointDec, pointing_ID=ipoint, oneChip=16)
#############################################
# Testing run pointing list (using MPI)
# obs = Observation(work_dir=work_dir, data_dir=data_dir)
# # obs.runExposure_MPI_PointingList(ra_cen=pRA, dec_cen=pDEC, pRange=pRange, timestamp_obs=timestamp_obs, pointing_type=pointing_type)
# obs.runExposure_MPI_PointingList(ra_cen=pRA, dec_cen=pDEC, pRange=pRange, timestamp_obs=timestamp_obs, pointing_type=pointing_type, exptime=exp_time)
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