Commit aaf0661e authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

added Numpydoc-style docstring

parent 7f3355b1
...@@ -20,48 +20,43 @@ from .params import CSST_PARAMS as CP ...@@ -20,48 +20,43 @@ from .params import CSST_PARAMS as CP
class CsstMsDataManager: 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: C3:
MSC_MS_210525220000_100000020_06_raw.fits MSC_MS_210525220000_100000020_06_raw.fits
MSC_CRS_210525220000_100000020_06_raw.fits MSC_CRS_210525220000_100000020_06_raw.fits
MSC_210525120000_0000020_06.cat MSC_210525120000_0000020_06.cat
C5.1: C5.1:
CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits
CSST_MSC_MS_CRS_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.cat
MSC_10000100_chip_06_filt_y.log MSC_10000100_chip_06_filt_y.log
C5.2 C5.2
CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits CSST_MSC_MS_SCI_20270810081950_20270810082220_100000100_06_L0_1.fits
CSST_MSC_MS_CRS_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.cat
MSC_100000100_chip_06_filt_y.log MSC_100000100_chip_06_filt_y.log
"""
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 Parameters
---------- ----------
ver_sim: str ver_sim : str
version of simulation data, see csst_common.params.CP The version of simulation data, see csst_common.params.CP .
dir_l0: str dir_l0 : str
L0 directory The L0 directory.
dir_l1: str dir_l1 : str
L1 directory The L1 directory.
dir_pcref: str dir_pcref : str
position calibration data directory The position calibration reference data directory.
will be removed in the next version Will be removed in the next version.
path_aux: str path_aux : str
aux data directory (bias, flat, dark) The aux data directory (bias, flat, dark).
assert_all_detectors: bool assert_all_detectors : bool
if True, assert data for all detectors are available If True, assert data for all detectors are available.
datatype: str datatype : str
{"mbi", "sls"} The options are {"mbi", "sls"}.
Examples Examples
-------- --------
...@@ -85,6 +80,10 @@ class CsstMsDataManager: ...@@ -85,6 +80,10 @@ class CsstMsDataManager:
>>> # define an L1 file (non-detector-specified) >>> # define an L1 file (non-detector-specified)
>>> dm_mbi.l1_file("flipped_image.fits") >>> 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 """
assert ver_sim in CP["sim"]["versions"] assert ver_sim in CP["sim"]["versions"]
self.ver_sim = ver_sim self.ver_sim = ver_sim
...@@ -310,17 +309,17 @@ class CsstMsDataManager: ...@@ -310,17 +309,17 @@ class CsstMsDataManager:
@staticmethod @staticmethod
def quickstart(ver_sim="C5.2", datatype="mbi", dir_l1=".", exposure_id=100): def quickstart(ver_sim="C5.2", datatype="mbi", dir_l1=".", exposure_id=100):
""" quick dataset generator for tests on dandelion or PMO """Quick dataset generator for tests on dandelion or PMO
Parameters Parameters
---------- ----------
ver_sim: ver_sim : str
{"C5.2"} {"C5.2"}
datatype: str datatype : str
{"mbi", "sls"} {"mbi", "sls"}
dir_l1: dir_l1 : str
output directory output directory
exposure_id: exposure_id : int
21-154 for C5.2 21-154 for C5.2
Returns Returns
......
...@@ -7,30 +7,38 @@ Created: 2022-10-04 ...@@ -7,30 +7,38 @@ Created: 2022-10-04
Modified-History: Modified-History:
2022-10-04, Bo Zhang, created 2022-10-04, Bo Zhang, created
2022-10-04, Bo Zhang, added get_logger 2022-10-04, Bo Zhang, added get_logger
2022-10-07, Bo Zhang, added Numpydoc docstring
""" """
import logging import logging
def get_logger(name="CSST MS L1 Pipeline", filename=""): def get_logger(name="CSST L1 Pipeline", filename=""):
""" get a logger for CSST L1 Pipeline """
Get a logger for CSST L1 Pipeline.
Messages with levels >= DEBUG will be output by stream. Messages with levels >= DEBUG will be output by stream.
Messages with levels >= INFO will be recorded by a log file. Messages with levels >= INFO will be recorded by a log file.
Parameters Parameters
---------- ----------
name: str name : str
logger name The logger name.
filename: str filename : str
log file name The log file name.
Returns Returns
------- -------
logging.Logger
The configured logger.
References References
---------- ----------
for logging: https://docs.python.org/3/library/logging.html For logging module: https://docs.python.org/3/library/logging.html
for logging levels, conf: https://docs.python.org/3/library/logging.html#logging-levels For logging levels: https://docs.python.org/3/library/logging.html#logging-levels
Examples
--------
>>> logger = get_logger()
""" """
# initialize logger # initialize logger
logger = logging.getLogger(name=name) logger = logging.getLogger(name=name)
......
...@@ -7,15 +7,26 @@ Created: 2022-10-04 ...@@ -7,15 +7,26 @@ Created: 2022-10-04
Modified-History: Modified-History:
2022-10-04, Bo Zhang, created 2022-10-04, Bo Zhang, created
2022-10-04, Bo Zhang, added CsstStatus 2022-10-04, Bo Zhang, added CsstStatus
2022-10-07, Bo Zhang, added Numpydoc docstring
""" """
from enum import IntEnum from enum import IntEnum
class CsstStatus(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 PERFECT = 0
WARNING = 1 WARNING = 1
ERROR = 2 ERROR = 2
# status list to be completed # status list to be completed
# def __repr__(self):
# return '<%s.%s>' % (self.__class__.__name__, self.name)
from .data_manager import CsstMsDataManager
from .logger import get_logger
from .status import CsstStatus
__all__ = ["CsstMsDataManager", "get_logger"]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment