Commit 631ae616 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

added dm.dfs_l0_query()

parent 986d0a45
Loading
Loading
Loading
Loading
+14 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ import os
import re
import re
from typing import Union
from typing import Union


import numpy as np
from astropy.io import fits
from astropy.io import fits
from astropy.table import Table
from astropy.table import Table
from csst_dfs_api.msc.calmerge import CalMergeApi
from csst_dfs_api.msc.calmerge import CalMergeApi
@@ -570,9 +571,20 @@ class CsstMsDataManager:
        """ Push SLS spectra to DFS. """
        """ Push SLS spectra to DFS. """
        pass
        pass


    def dfs_l0_query(self, obs_id):
    def dfs_l0_query(self, obs_id: str = "100000100"):
        """ Query L0 data from DFS. """
        """ Query L0 data from DFS. """
        pass
        result = self.dfs_L0DataApi.find(obs_id=str(obs_id))
        print(f"{result.totalCount} entries returned from DFS.")
        if not result.code == 0:
            raise ValueError(f"DFS returns non-zero code! ({result.code})")
        tbl = Table([_.__dict__ for _ in result.data])
        tbl.sort(["detector_no", "obs_type"])
        # Check if all 30 detectors are available
        for detector in CP["all"]["detectors"]:
            for obs_type in ["sci", "cosmic_ray"]:
                if np.sum((tbl["detector_no"] == f"{detector:02d}") & (tbl["obs_type"] == obs_type)) == 0:
                    self.logger_ppl.warning(f"Record not found for detector {detector:02d} and obs_type {obs_type}")
        return tbl


    def dfs_l1_query(self, obs_id, detector):
    def dfs_l1_query(self, obs_id, detector):
        """ Query L1 data from DFS. """
        """ Query L1 data from DFS. """