Commit 20053b69 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

raise FileNotFoundError when dm cannot find files

parent e9027b53
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -463,7 +463,8 @@ class CsstMsDataManager:
        assert detector in self.available_detectors
        fn = f"{self.instrument}_{self.obs_id}_chip_{detector:02d}_filt_{self.detector2filter[detector]}.cat"
        fp = os.path.join(self.dir_l0, fn)
        assert os.path.exists(fp)
        if not os.path.exists(fp):
            raise FileNotFoundError(f"File not found: {fp}")
        return fp

    def l0_log(self, detector=6):
@@ -471,7 +472,8 @@ class CsstMsDataManager:
        assert detector in self.available_detectors
        fn = f"{self.instrument}_{self.obs_id}_chip_{detector:02d}_filt_{self.detector2filter[detector]}.log"
        fp = os.path.join(self.dir_l0, fn)
        assert os.path.exists(fp)
        if not os.path.exists(fp):
            raise FileNotFoundError(f"File not found: {fp}")
        return fp

    def l0_detector(self, detector=6):
@@ -484,8 +486,9 @@ class CsstMsDataManager:
            fn = f"{self.telescope}_{self.instrument}_{self.project}_{self.obs_type}_{self.exp_start}_" \
                 f"{self.exp_stop}_{self.obs_id}_{detector:02d}_L{self.level}_V{self.version}.{self.ext}"
        fp = os.path.join(self.dir_l0, fn)
        assert os.path.exists(fp)
        return os.path.join(self.dir_l0, fn)
        if not os.path.exists(fp):
            raise FileNotFoundError(f"File not found: {fp}")
        return fp

    def l0_crs(self, detector=6):
        """ L0 cosmic ray file path """
@@ -497,8 +500,9 @@ class CsstMsDataManager:
            fn = f"{self.telescope}_{self.instrument}_{self.project}_CRS_{self.exp_start}_" \
                 f"{self.exp_stop}_{self.obs_id}_{detector:02d}_L{self.level}_V{self.version}.{self.ext}"
        fp = os.path.join(self.dir_l0, fn)
        assert os.path.exists(fp)
        return os.path.join(self.dir_l0, fn)
        if not os.path.exists(fp):
            raise FileNotFoundError(f"File not found: {fp}")
        return fp

    def l1_detector(self, detector=6, post="IMG.fits"):
        """ generate L1 file path