Commit 8e5af267 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add dm.dfs_rc_auto() to download rc automatically

parent 51b32253
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -638,6 +638,49 @@ class CsstMsDataManager:
        except:
            return False

    def get_coord(self):
        """ Get pointing coordinate. """
        header = fits.getheader(self.l0_detector(detector=self.target_detectors[0]))
        pointing_ra = header["RA_OBJ"]
        pointing_dec = header["DEC_OBJ"]
        return pointing_ra, pointing_dec

    def dfs_rc_auto(self):
        """ Download RC. """
        assert self.dfs_is_available()
        assert len(self.target_detectors) >= 1
        pointing_ra, pointing_dec = self.get_coord()
        refcat = self.dfs_rc_query(
            ra=pointing_ra,
            dec=pointing_dec,
            columns=(
                    'ref_epoch',
                    'ra',
                    'ra_error',
                    'dec',
                    'dec_error',
                    'parallax',
                    'parallax_error',
                    'pmra',
                    'pmra_error',
                    'pmdec',
                    'pmdec_error',
                    'phot_g_mean_mag',
                    'source_id'
            ),
            radius=2,
            min_mag=0,
            max_mag=30,
            obstime=-1,
            limit=-1
        )
        print(
            f"RA, Dec = [{pointing_ra}, {pointing_dec}], "
            f"Status = {isinstance(refcat, Table)}, "
            f"N_entries = {len(refcat)}"
        )
        return refcat

    def dfs_rc_query(
            self,
            ra=180,