Exemplo n.º 1
0
    def test_bad_rounding(self):
        value = 42.0
        expected_string = "02 48 00.00"

        time_string = degreestohms(value, " ")

        self.assertEqual(expected_string, time_string)
Exemplo n.º 2
0
 def calib_ra_hms(self, obj):
     return degreestohms(obj.ra, ' ')
Exemplo n.º 3
0
 def obs_ra_hms(self, obj):
     return degreestohms(obj.obs_ra, ' ')
Exemplo n.º 4
0
    def format_mpc_line(self, include_catcode=False):
        """Format the contents of 'self' (a SourceMeasurement i.e. the confirmed
        measurement of an object on a particular frame) into MPC 1992 80 column
        format. This handles the discovery asterisk in column 12, some of the mapping
        from flags into the MPC codes in column 14, mapping of non-standard
        filters and potentially inclusion of the catalog code in column 72 (if
        [include_catcode] is True; catalog code should not be included in new
        submissions to the MPC)"""

        if self.body.name:
            name, status = normal_to_packed(self.body.name)
            if status != 0:
                name = "%5s       " % self.body.name
        else:
            name = "     %7s" % self.body.provisional_name

        try:
            mag = "%4.1f" % self.obs_mag
        except TypeError:
            mag = "    "

        microday = True

        valid_MPC_notes = ['A', 'P', 'e', 'C', 'B', 'T', 'M', 'V', 'v', 'R', 'r', 'S', 's',\
            'c', 'E', 'O', 'H', 'N', 'n', 'D', 'Z', 'W', 'w', 'Q', 'q', 'T', 't']
        if self.frame.extrainfo in valid_MPC_notes:
            obs_type = self.frame.extrainfo
            if obs_type == 'A':
                microday = False
        else:
            obs_type = 'C'

        if self.frame.frametype == Frame.SATELLITE_FRAMETYPE:
            obs_type = 'S'
            microday = False
        flags = self.flags
        num_flags = flags.split(',')
        if len(num_flags) == 1:
            if num_flags[0] == '*':
                # Discovery asterisk needs to go into column 13
                flags = '* '
            else:
                flags = ' ' + num_flags[0]
        elif len(num_flags) == 2:
            if '*' in num_flags:
                asterisk_index = num_flags.index('*')
                flags = '*' + num_flags[1 - asterisk_index]
            else:
                logger.warning(
                    "Flags longer than will fit into field - needs mapper")
                flags = ' ' + num_flags[0]
        else:
            logger.warning(
                "Flags longer than will fit into field - needs mapper")
            if '*' in num_flags:
                num_flags.remove('*')
                flags = '*' + num_flags[0]
            else:
                flags = ' ' + num_flags[0]

        # Catalog code for column 72 (if desired)
        catalog_code = ' '
        if include_catcode is True:
            catalog_code = translate_catalog_code(self.astrometric_catalog)
        mpc_line = "%12s%2s%1s%16s%11s %11s          %4s %1s%1s     %3s" % (
            name, flags, obs_type, dttodecimalday(
                self.frame.midpoint, microday), degreestohms(
                    self.obs_ra, ' '), degreestodms(self.obs_dec, ' '), mag,
            self.frame.map_filter(), catalog_code, self.frame.sitecode)
        if self.frame.frametype == Frame.SATELLITE_FRAMETYPE:
            extrainfo = self.frame.extrainfo
            if extrainfo:
                if self.body.name:
                    name, status = normal_to_packed(self.body.name)
                    if status == 0:
                        extrainfo = name + extrainfo[12:]
            else:
                extrainfo = ''
            mpc_line = mpc_line + '\n' + extrainfo
        return mpc_line