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-pipeline
csst_common
Commits
aaf0661e
Commit
aaf0661e
authored
Oct 07, 2022
by
BO ZHANG
🏀
Browse files
added Numpydoc-style docstring
parent
7f3355b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
csst_common/data_manager.py
View file @
aaf0661e
...
...
@@ -20,71 +20,70 @@ from .params import CSST_PARAMS as CP
class
CsstMsDataManager
:
""" CSST MS data manager, including MBI and SLS
"""
CSST MS data manager, including MBI and SLS.
This class provides an interface to access L0 data and generate L1 paths.
Here are some examples for simulation with different versions.
C3:
MSC_MS_210525220000_100000020_06_raw.fits
MSC_CRS_210525220000_100000020_06_raw.fits
MSC_210525120000_0000020_06.cat
C5.1:
CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits
CSST_MSC_MS_CRS_20270810081950_20270810082220_100000100_06_L0_1.fits
MSC_10000100_chip_06_filt_y.cat
MSC_10000100_chip_06_filt_y.log
C5.2
CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits
CSST_MSC_MS_CRS_20270810081950_20270810082220_100000100_06_L0_1.fits
MSC_100000100_chip_06_filt_y.cat
MSC_100000100_chip_06_filt_y.log
Parameters
----------
ver_sim : str
The version of simulation data, see csst_common.params.CP .
dir_l0 : str
The L0 directory.
dir_l1 : str
The L1 directory.
dir_pcref : str
The position calibration reference data directory.
Will be removed in the next version.
path_aux : str
The aux data directory (bias, flat, dark).
assert_all_detectors : bool
If True, assert data for all detectors are available.
datatype : str
The options are {"mbi", "sls"}.
Examples
--------
>>> dm_mbi = CsstMbiDataManager(...)
>>> # access L0 directory
>>> dm_mbi.dir_l0
>>> # access L1 directory
>>> dm_mbi.dir_l1
>>> # access dir_pcref
>>> dm_mbi.dir_pcref
>>> # access path_aux
>>> dm_mbi.path_aux
>>> # access ver_sim
>>> dm_mbi.ver_sim
>>> # access target detectors
>>> dm_mbi.target_detectors
>>> # access available detectors
>>> dm_mbi.available_detectors
>>> # define an L1 file (detector-specified)
>>> dm_mbi.l1_detector(detector=6)
>>> # define an L1 file (non-detector-specified)
>>> dm_mbi.l1_file("flipped_image.fits")
"""
def
__init__
(
self
,
ver_sim
=
"C5.2"
,
dir_l0
=
""
,
dir_l1
=
""
,
dir_pcref
=
""
,
path_aux
=
""
,
assert_all_detectors
=
False
,
datatype
=
"mbi"
):
""" initialize the multi-band imaging data manager
Parameters
----------
ver_sim: str
version of simulation data, see csst_common.params.CP
dir_l0: str
L0 directory
dir_l1: str
L1 directory
dir_pcref: str
position calibration data directory
will be removed in the next version
path_aux: str
aux data directory (bias, flat, dark)
assert_all_detectors: bool
if True, assert data for all detectors are available
datatype: str
{"mbi", "sls"}
Examples
--------
>>> dm_mbi = CsstMbiDataManager(...)
>>> # access L0 directory
>>> dm_mbi.dir_l0
>>> # access L1 directory
>>> dm_mbi.dir_l1
>>> # access dir_pcref
>>> dm_mbi.dir_pcref
>>> # access path_aux
>>> dm_mbi.path_aux
>>> # access ver_sim
>>> dm_mbi.ver_sim
>>> # access target detectors
>>> dm_mbi.target_detectors
>>> # access available detectors
>>> dm_mbi.available_detectors
>>> # define an L1 file (detector-specified)
>>> dm_mbi.l1_detector(detector=6)
>>> # define an L1 file (non-detector-specified)
>>> dm_mbi.l1_file("flipped_image.fits")
"""
""" initialize the multi-band imaging data manager """
assert
ver_sim
in
CP
[
"sim"
][
"versions"
]
self
.
ver_sim
=
ver_sim
...
...
@@ -310,17 +309,17 @@ class CsstMsDataManager:
@
staticmethod
def
quickstart
(
ver_sim
=
"C5.2"
,
datatype
=
"mbi"
,
dir_l1
=
"."
,
exposure_id
=
100
):
"""
q
uick dataset generator for tests on dandelion or PMO
"""
Q
uick dataset generator for tests on dandelion or PMO
Parameters
----------
ver_sim
:
ver_sim
: str
{"C5.2"}
datatype: str
datatype
: str
{"mbi", "sls"}
dir_l1
:
dir_l1
: str
output directory
exposure_id
:
exposure_id
: int
21-154 for C5.2
Returns
...
...
csst_common/logger.py
View file @
aaf0661e
...
...
@@ -7,30 +7,38 @@ Created: 2022-10-04
Modified-History:
2022-10-04, Bo Zhang, created
2022-10-04, Bo Zhang, added get_logger
2022-10-07, Bo Zhang, added Numpydoc docstring
"""
import
logging
def
get_logger
(
name
=
"CSST MS L1 Pipeline"
,
filename
=
""
):
""" get a logger for CSST L1 Pipeline
def
get_logger
(
name
=
"CSST L1 Pipeline"
,
filename
=
""
):
"""
Get a logger for CSST L1 Pipeline.
Messages with levels >= DEBUG will be output by stream.
Messages with levels >= INFO will be recorded by a log file.
Parameters
----------
name: str
logger name
filename: str
log file name
name
: str
The
logger name
.
filename
: str
The
log file name
.
Returns
-------
logging.Logger
The configured logger.
References
----------
f
or logging: https://docs.python.org/3/library/logging.html
f
or logging levels
, conf
: https://docs.python.org/3/library/logging.html#logging-levels
F
or logging
module
: https://docs.python.org/3/library/logging.html
F
or logging levels: https://docs.python.org/3/library/logging.html#logging-levels
Examples
--------
>>> logger = get_logger()
"""
# initialize logger
logger
=
logging
.
getLogger
(
name
=
name
)
...
...
csst_common/status.py
View file @
aaf0661e
...
...
@@ -7,15 +7,26 @@ Created: 2022-10-04
Modified-History:
2022-10-04, Bo Zhang, created
2022-10-04, Bo Zhang, added CsstStatus
2022-10-07, Bo Zhang, added Numpydoc docstring
"""
from
enum
import
IntEnum
class
CsstStatus
(
IntEnum
):
"""
The CSST Status class.
This class provides a set of status which should be returned
from each CSST L1 functional module.
Examples
--------
>>> def f(num):
>>> if num > 0:
>>> return CsstStatus.PERFECT
>>> return CsstStatus.ERROR
"""
PERFECT
=
0
WARNING
=
1
ERROR
=
2
# status list to be completed
# def __repr__(self):
# return '<%s.%s>' % (self.__class__.__name__, self.name)
csst_common/top_level_interface.py
0 → 100644
View file @
aaf0661e
from
.data_manager
import
CsstMsDataManager
from
.logger
import
get_logger
from
.status
import
CsstStatus
__all__
=
[
"CsstMsDataManager"
,
"get_logger"
]
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