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

added Numpydoc-style docstring

parent 7f3355b1
Loading
Loading
Loading
Loading
+49 −50
Original line number Diff line number Diff line
@@ -20,48 +20,43 @@ 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

    """

    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
        The version of simulation data, see csst_common.params.CP .
    dir_l0 : str
            L0 directory
        The L0 directory.
    dir_l1 : str
            L1 directory
        The L1 directory.
    dir_pcref : str
            position calibration data directory
            will be removed in the next version
        The position calibration reference data directory.
        Will be removed in the next version.
    path_aux : str
            aux data directory (bias, flat, dark)
        The aux data directory (bias, flat, dark).
    assert_all_detectors : bool
            if True, assert data for all detectors are available
        If True, assert data for all detectors are available.
    datatype : str
            {"mbi", "sls"}
        The options are {"mbi", "sls"}.

    Examples
    --------
@@ -85,6 +80,10 @@ class CsstMsDataManager:
    >>> # 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 """
        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):
        """ quick dataset generator for tests on dandelion or PMO
        """Quick dataset generator for tests on dandelion or PMO

        Parameters
        ----------
        ver_sim:
        ver_sim : str
            {"C5.2"}
        datatype : str
            {"mbi", "sls"}
        dir_l1:
        dir_l1 : str
            output directory
        exposure_id:
        exposure_id : int
            21-154 for C5.2

        Returns
+16 −8
Original line number Diff line number Diff line
@@ -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
        The logger name.
    filename : str
        log file name
        The log file name.

    Returns
    -------
    logging.Logger
        The configured logger.

    References
    ----------
    for logging: https://docs.python.org/3/library/logging.html
    for logging levels, conf: https://docs.python.org/3/library/logging.html#logging-levels
    For logging module: https://docs.python.org/3/library/logging.html
    For logging levels: https://docs.python.org/3/library/logging.html#logging-levels

    Examples
    --------
    >>> logger = get_logger()
    """
    # initialize logger
    logger = logging.getLogger(name=name)
+14 −3
Original line number Diff line number Diff line
@@ -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)
+5 −0
Original line number Diff line number Diff line
from .data_manager import CsstMsDataManager
from .logger import get_logger
from .status import CsstStatus

__all__ = ["CsstMsDataManager", "get_logger"]