From e1cf83c2c6ebe85cc783ec0149390cefad7e9206 Mon Sep 17 00:00:00 2001 From: shoulinwei Date: Thu, 14 Apr 2022 21:34:17 +0800 Subject: [PATCH] split level0data --- csst_dfs_commons/models/facility.py | 58 ---------------------- csst_dfs_commons/models/ifs.py | 70 +++++++++++++++++++++----- csst_dfs_commons/models/mci.py | 77 +++++++++++++++++++++++++++++ csst_dfs_commons/models/msc.py | 69 +++++++++++++++++++++++--- csst_dfs_commons/models/sls.py | 71 +++++++++++++++++++++----- csst_dfs_commons/utils/__init__.py | 1 + csst_dfs_commons/utils/fits.py | 5 ++ 7 files changed, 262 insertions(+), 89 deletions(-) create mode 100644 csst_dfs_commons/models/mci.py create mode 100644 csst_dfs_commons/utils/__init__.py create mode 100644 csst_dfs_commons/utils/fits.py diff --git a/csst_dfs_commons/models/facility.py b/csst_dfs_commons/models/facility.py index 686d19b..547fb2b 100644 --- a/csst_dfs_commons/models/facility.py +++ b/csst_dfs_commons/models/facility.py @@ -1,4 +1,3 @@ - import dataclasses from typing import List from .common import BaseModel @@ -20,53 +19,6 @@ class Observation(BaseModel): create_time: str="" import_status: int = 0 -@dataclasses.dataclass -class Level0PrcRecord(BaseModel): - id: int = 0 - level0_id: str = "" - pipeline_id: str = "" - prc_module: str = "" - params_file_path: str="" - prc_status: int = 0 - prc_time: str="" - result_file_path: str="" - -@dataclasses.dataclass -class Level0Record(BaseModel): - id: int = 0 - level0_id: str = "" - obs_id: str = "" - detector_no: str = "" - obs_type: str = "" - obs_time: str="" - exp_time: float = 0 - detector_status_id: int = 0 - filename: str="" - file_path: str="" - qc0_status: int = 0 - qc0_time: str="" - prc_status: int = 0 - prc_time: str="" - create_time: str="" - -@dataclasses.dataclass -class CalMergeRecord(BaseModel): - id: int = 0 - cal_id: str = "" - detector_no: str = "" - ref_type: str = "" - obs_time: str="" - exp_time: float = 0 - filename: str="" - file_path: str="" - qc1_status: int = 0 - qc1_time: str="" - prc_status: int = 0 - prc_time: str="" - prc_time: str="" - create_time: str="" - level0_ids: list = dataclasses.field(default_factory=list) - @dataclasses.dataclass class Detector(BaseModel): no: str = "" @@ -85,13 +37,3 @@ class DetectorStatus(BaseModel): create_time: str="" status_time: str="" -@dataclasses.dataclass -class Level1PrcRecord(BaseModel): - id: int = 0 - level1_id: int = 0 - pipeline_id: str = "" - prc_module: str = "" - params_file_path: str="" - prc_status: int = 0 - prc_time: str="" - result_file_path: str="" \ No newline at end of file diff --git a/csst_dfs_commons/models/ifs.py b/csst_dfs_commons/models/ifs.py index 14fb76b..562240c 100644 --- a/csst_dfs_commons/models/ifs.py +++ b/csst_dfs_commons/models/ifs.py @@ -1,8 +1,54 @@ - -from dataclasses import dataclass +import dataclasses from typing import Dict from .common import BaseModel, default_field -@dataclass + +@dataclasses.dataclass +class Level0PrcRecord(BaseModel): + id: int = 0 + level0_id: str = "" + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" + +@dataclasses.dataclass +class Level0Record(BaseModel): + id: int = 0 + level0_id: str = "" + obs_id: str = "" + detector_no: str = "" + obs_type: str = "" + obs_time: str="" + exp_time: float = 0 + detector_status_id: int = 0 + filename: str="" + file_path: str="" + qc0_status: int = 0 + qc0_time: str="" + prc_status: int = 0 + prc_time: str="" + create_time: str="" + +@dataclasses.dataclass +class CalMergeRecord(BaseModel): + id: int = 0 + cal_id: str = "" + detector_no: str = "" + ref_type: str = "" + obs_time: str="" + exp_time: float = 0 + filename: str="" + file_path: str="" + qc1_status: int = 0 + qc1_time: str="" + prc_status: int = 0 + prc_time: str="" + prc_time: str="" + create_time: str="" + level0_ids: list = dataclasses.field(default_factory=list) +@dataclasses.dataclass class Level1Record(BaseModel): id: int = 0 level0_id : str = "" @@ -19,11 +65,13 @@ class Level1Record(BaseModel): pipeline_id: str="" refs: Dict[str,int] = default_field({}) - - - - - - - - +@dataclasses.dataclass +class Level1PrcRecord(BaseModel): + id: int = 0 + level1_id: int = 0 + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" diff --git a/csst_dfs_commons/models/mci.py b/csst_dfs_commons/models/mci.py new file mode 100644 index 0000000..562240c --- /dev/null +++ b/csst_dfs_commons/models/mci.py @@ -0,0 +1,77 @@ +import dataclasses +from typing import Dict +from .common import BaseModel, default_field + +@dataclasses.dataclass +class Level0PrcRecord(BaseModel): + id: int = 0 + level0_id: str = "" + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" + +@dataclasses.dataclass +class Level0Record(BaseModel): + id: int = 0 + level0_id: str = "" + obs_id: str = "" + detector_no: str = "" + obs_type: str = "" + obs_time: str="" + exp_time: float = 0 + detector_status_id: int = 0 + filename: str="" + file_path: str="" + qc0_status: int = 0 + qc0_time: str="" + prc_status: int = 0 + prc_time: str="" + create_time: str="" + +@dataclasses.dataclass +class CalMergeRecord(BaseModel): + id: int = 0 + cal_id: str = "" + detector_no: str = "" + ref_type: str = "" + obs_time: str="" + exp_time: float = 0 + filename: str="" + file_path: str="" + qc1_status: int = 0 + qc1_time: str="" + prc_status: int = 0 + prc_time: str="" + prc_time: str="" + create_time: str="" + level0_ids: list = dataclasses.field(default_factory=list) +@dataclasses.dataclass +class Level1Record(BaseModel): + id: int = 0 + level0_id : str = "" + data_type: str="" + cor_sci_id: int = 0 + prc_params: str="" + filename : str="" + file_path: str="" + qc1_status: int = 0 + qc1_time: str="" + prc_status: int = 0 + prc_time: str="" + create_time: str="" + pipeline_id: str="" + refs: Dict[str,int] = default_field({}) + +@dataclasses.dataclass +class Level1PrcRecord(BaseModel): + id: int = 0 + level1_id: int = 0 + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" diff --git a/csst_dfs_commons/models/msc.py b/csst_dfs_commons/models/msc.py index f34209e..7a9d048 100644 --- a/csst_dfs_commons/models/msc.py +++ b/csst_dfs_commons/models/msc.py @@ -1,7 +1,55 @@ -from dataclasses import dataclass +import dataclasses from typing import Dict from .common import BaseModel, default_field -@dataclass + +@dataclasses.dataclass +class Level0PrcRecord(BaseModel): + id: int = 0 + level0_id: str = "" + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" + +@dataclasses.dataclass +class Level0Record(BaseModel): + id: int = 0 + level0_id: str = "" + obs_id: str = "" + detector_no: str = "" + obs_type: str = "" + obs_time: str="" + exp_time: float = 0 + detector_status_id: int = 0 + filename: str="" + file_path: str="" + qc0_status: int = 0 + qc0_time: str="" + prc_status: int = 0 + prc_time: str="" + create_time: str="" + +@dataclasses.dataclass +class CalMergeRecord(BaseModel): + id: int = 0 + cal_id: str = "" + detector_no: str = "" + ref_type: str = "" + obs_time: str="" + exp_time: float = 0 + filename: str="" + file_path: str="" + qc1_status: int = 0 + qc1_time: str="" + prc_status: int = 0 + prc_time: str="" + prc_time: str="" + create_time: str="" + level0_ids: list = dataclasses.field(default_factory=list) + +@dataclasses.dataclass class Level1Record(BaseModel): id: int = 0 level0_id : str = "" @@ -18,7 +66,7 @@ class Level1Record(BaseModel): pipeline_id: str="" refs: Dict[str,int] = default_field({}) -@dataclass +@dataclasses.dataclass class MSCLevel2CatalogRecord(BaseModel): source_id: int = 0 obs_id : str = "" @@ -223,8 +271,13 @@ class MSCLevel2CatalogRecord(BaseModel): disk_theta_j2000: float = -1 obs_time: str = '' - - - - - +@dataclasses.dataclass +class Level1PrcRecord(BaseModel): + id: int = 0 + level1_id: int = 0 + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" diff --git a/csst_dfs_commons/models/sls.py b/csst_dfs_commons/models/sls.py index 3847dcc..4ad82d0 100644 --- a/csst_dfs_commons/models/sls.py +++ b/csst_dfs_commons/models/sls.py @@ -1,8 +1,54 @@ -from dataclasses import dataclass +import dataclasses from typing import Dict from .common import BaseModel, default_field -@dataclass +@dataclasses.dataclass +class Level0PrcRecord(BaseModel): + id: int = 0 + level0_id: str = "" + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" + +@dataclasses.dataclass +class Level0Record(BaseModel): + id: int = 0 + level0_id: str = "" + obs_id: str = "" + detector_no: str = "" + obs_type: str = "" + obs_time: str="" + exp_time: float = 0 + detector_status_id: int = 0 + filename: str="" + file_path: str="" + qc0_status: int = 0 + qc0_time: str="" + prc_status: int = 0 + prc_time: str="" + create_time: str="" + +@dataclasses.dataclass +class CalMergeRecord(BaseModel): + id: int = 0 + cal_id: str = "" + detector_no: str = "" + ref_type: str = "" + obs_time: str="" + exp_time: float = 0 + filename: str="" + file_path: str="" + qc1_status: int = 0 + qc1_time: str="" + prc_status: int = 0 + prc_time: str="" + prc_time: str="" + create_time: str="" + level0_ids: list = dataclasses.field(default_factory=list) +@dataclasses.dataclass class Level1Record(BaseModel): id: int = 0 level0_id : str = "" @@ -17,8 +63,7 @@ class Level1Record(BaseModel): create_time: str="" pipeline_id: str="" refs: Dict[str,int] = default_field({}) - -@dataclass +@dataclasses.dataclass class Level2Spectra(BaseModel): id: int = 0 spectra_id : str = "" @@ -33,11 +78,13 @@ class Level2Spectra(BaseModel): create_time: str="" pipeline_id: str="" - - - - - - - - +@dataclasses.dataclass +class Level1PrcRecord(BaseModel): + id: int = 0 + level1_id: int = 0 + pipeline_id: str = "" + prc_module: str = "" + params_file_path: str="" + prc_status: int = 0 + prc_time: str="" + result_file_path: str="" diff --git a/csst_dfs_commons/utils/__init__.py b/csst_dfs_commons/utils/__init__.py new file mode 100644 index 0000000..57d631c --- /dev/null +++ b/csst_dfs_commons/utils/__init__.py @@ -0,0 +1 @@ +# coding: utf-8 diff --git a/csst_dfs_commons/utils/fits.py b/csst_dfs_commons/utils/fits.py new file mode 100644 index 0000000..9bdd256 --- /dev/null +++ b/csst_dfs_commons/utils/fits.py @@ -0,0 +1,5 @@ +def get_header_value(key: str, header, default_value = None): + try: + return header[key] + except Exception as e: + return default_value \ No newline at end of file -- GitLab