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

use yaml file for parameters

parent c4938e08
...@@ -40,9 +40,9 @@ sh -c "$(curl -fsSL https://csst-tb.bao.ac.cn/code/csst-l1/csst_common/-/raw/mai ...@@ -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: how to import CSST parameters:
```python ```python
from csst_common.params import cp from csst_common.params import CSST_PARAMS as CP
print(cp) print(CP)
print(cp.mbi.DETECTOR2FILTER) print(CP["mbi"]["detector2filter"])
``` ```
how to use data_manager how to use data_manager
...@@ -69,6 +69,12 @@ dm.l1_detector(detector=6) ...@@ -69,6 +69,12 @@ dm.l1_detector(detector=6)
dm.l1_file("flipped_image.fits") 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 ## algorithm description
The `csst_common` provides some common modules for CSST pipeline. The `csst_common` provides some common modules for CSST pipeline.
......
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
import yaml
from . import PACKAGE_PATH
with open(PACKAGE_PATH + "/data/csst_params.yml") as f:
CSST_PARAMS = yaml.safe_load(f)
class BasicParams: class BasicParams:
""" the basic parameter class """ """ the basic parameter class """
def __repr__(self): def __repr__(self):
_class_name = self.__class__.__name__ _class_name = self.__class__.__name__
_str = "<{} length={}>".format(_class_name, len(self.__dict__)) _str = "<{} length={}>".format(_class_name, len(self.__dict__))
...@@ -20,6 +27,7 @@ class BasicParams: ...@@ -20,6 +27,7 @@ class BasicParams:
class CsstParams(BasicParams): class CsstParams(BasicParams):
""" CSST parameters -- a collection of """ """ CSST parameters -- a collection of """
def __init__(self): def __init__(self):
""" """
This class defines the CSST parameters. This class defines the CSST parameters.
...@@ -50,8 +58,8 @@ class CsstParams(BasicParams): ...@@ -50,8 +58,8 @@ class CsstParams(BasicParams):
class CsstMbiParams(BasicParams): class CsstMbiParams(BasicParams):
""" multi-band imaging parameters """ """ multi-band imaging parameters """
def __init__(self):
def __init__(self):
# define DETECTOR ID list # define DETECTOR ID list
self.DETECTORS = [6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25] 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): ...@@ -87,13 +95,14 @@ class CsstSlsParams(BasicParams):
class CsstSimParams(BasicParams): class CsstSimParams(BasicParams):
""" simulation parameters """ """ simulation parameters """
def __init__(self): def __init__(self):
# define versions of simulation # define versions of simulation
# C denotes for Cycle # C denotes for Cycle
self.VERSIONS = ["C3", "C5.1", "C5.2"] self.VERSIONS = ["C3", "C5.1", "C5.2"]
cp = CsstParams() # cp = CsstParams()
if __name__ == "__main__": if __name__ == "__main__":
cp = CsstParams() cp = CsstParams()
......
...@@ -2,4 +2,6 @@ numpy~=1.20.3 ...@@ -2,4 +2,6 @@ numpy~=1.20.3
joblib~=1.1.0 joblib~=1.1.0
setuptools~=58.0.4 setuptools~=58.0.4
astropy~=5.1 astropy~=5.1
pytest pytest
\ No newline at end of file yaml~=0.2.5
pyyaml~=6.0
\ No newline at end of file
...@@ -28,7 +28,7 @@ setuptools.setup( ...@@ -28,7 +28,7 @@ setuptools.setup(
package_dir={'csst': 'csst'}, package_dir={'csst': 'csst'},
# include_package_data=True, # include_package_data=True,
package_data={"": ["LICENSE", "README.md"], package_data={"": ["LICENSE", "README.md"],
"csst_common": []}, "csst_common": ["data/*"]},
# install_requires=['sphinx', # install_requires=['sphinx',
# 'numpy', # 'numpy',
# 'scipy', 'matplotlib', # 'scipy', 'matplotlib',
......
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