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

use yaml file for parameters

parent c4938e08
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -40,9 +40,9 @@ sh -c "$(curl -fsSL https://csst-tb.bao.ac.cn/code/csst-l1/csst_common/-/raw/mai

how to import CSST parameters:
```python
from csst_common.params import cp
print(cp)
print(cp.mbi.DETECTOR2FILTER)
from csst_common.params import CSST_PARAMS as CP
print(CP)
print(CP["mbi"]["detector2filter"])
```

how to use data_manager
@@ -69,6 +69,12 @@ dm.l1_detector(detector=6)
dm.l1_file("flipped_image.fits")
```

a shortcut for test dataset
```python
from csst_common.data_manager import CsstMbiDataManager
CsstMbiDataManager.quick_dataset(hostname="dandelion", ver_sim="C5.2", dir_l1=".", exposure_id=100)
```

## algorithm description

The `csst_common` provides some common modules for CSST pipeline.
+103 −0
Original line number Diff line number Diff line
mbi: # multi-band imaging
  detectors:
    - 6
    - 7
    - 8
    - 9
    - 11
    - 12
    - 13
    - 14
    - 15
    - 16
    - 17
    - 18
    - 19
    - 20
    - 22
    - 23
    - 24
    - 25
  filters:
    - 'N'
    - 'u'
    - 'g'
    - 'r'
    - 'i'
    - 'z'
    - 'y'
  detector2filter: # used for simulation image path
    6: "y"
    7: "i"
    8: "g"
    9: "r"
    11: "z"
    12: "nuv"
    13: "nuv"
    14: "u"
    15: "y"
    16: "y"
    17: "u"
    18: "nuv"
    19: "nuv"
    20: "z"
    22: "r"
    23: "g"
    24: "i"
    25: "y"


sls: # slit-less spectra
  detectors:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 10
    - 21
    - 26
    - 27
    - 28
    - 29
    - 30

sim: # simulation
  versions:
    - C5.2
    - C5.1
    - C3

basic:
  detectors:
    - 1
    - 2
    - 3
    - 4
    - 5
    - 6
    - 7
    - 8
    - 9
    - 10
    - 11
    - 12
    - 13
    - 14
    - 15
    - 16
    - 17
    - 18
    - 19
    - 20
    - 21
    - 22
    - 23
    - 24
    - 25
    - 26
    - 27
    - 28
    - 29
    - 30
+11 −2
Original line number Diff line number Diff line
import yaml
from . import PACKAGE_PATH

with open(PACKAGE_PATH + "/data/csst_params.yml") as f:
    CSST_PARAMS = yaml.safe_load(f)


class BasicParams:
    """ the basic parameter class """

    def __repr__(self):
        _class_name = self.__class__.__name__
        _str = "<{} length={}>".format(_class_name, len(self.__dict__))
@@ -20,6 +27,7 @@ class BasicParams:

class CsstParams(BasicParams):
    """ CSST parameters -- a collection of """

    def __init__(self):
        """
        This class defines the CSST parameters.
@@ -50,8 +58,8 @@ class CsstParams(BasicParams):

class CsstMbiParams(BasicParams):
    """ multi-band imaging parameters """
    def __init__(self):

    def __init__(self):
        # define DETECTOR ID list
        self.DETECTORS = [6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25]

@@ -87,13 +95,14 @@ class CsstSlsParams(BasicParams):

class CsstSimParams(BasicParams):
    """ simulation parameters """

    def __init__(self):
        # define versions of simulation
        # C denotes for Cycle
        self.VERSIONS = ["C3", "C5.1", "C5.2"]


cp = CsstParams()
# cp = CsstParams()

if __name__ == "__main__":
    cp = CsstParams()
+3 −1
Original line number Diff line number Diff line
@@ -3,3 +3,5 @@ joblib~=1.1.0
setuptools~=58.0.4
astropy~=5.1
pytest
yaml~=0.2.5
pyyaml~=6.0
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ setuptools.setup(
    package_dir={'csst': 'csst'},
    # include_package_data=True,
    package_data={"": ["LICENSE", "README.md"],
                  "csst_common": []},
                  "csst_common": ["data/*"]},
    # install_requires=['sphinx',
    #                   'numpy',
    #                   'scipy', 'matplotlib',