*Convert a declination from sexegesimal format to decimal degrees.*

        Precision should be respected. If a float is passed to this method, the same float will be returned (useful if unclear which format coordinates are in).

        The code will attempt to read the sexegesimal value in whatever form it is passed. Any of the following should be handled correctly:

        - ``+1:58:05.45341``
        - ``01:5:05``
        - ``+1 58 05.45341``
        - ``-23h53m05s``

        **Key Arguments:**
            - ``dec`` - DEC in sexegesimal format.

        **Return:**
            - ``decDeg`` -- declination converted to decimal degrees

        **Usage:**

            .. todo::

                - replace dryxPython declination_sexegesimal_to_decimal with this version in all my code
                - replace coords_sex_to_dec in all code

            .. code-block:: python

                from astrocalc.coords import unit_conversion
                converter = unit_conversion(
                    log=log
                )
                dec = converter.dec_sexegesimal_to_decimal(
                    dec="-23:45:21.23232"
                )
                print dec

                # OUTPUT: -23.7558978667

def dec_sexegesimal_to_decimal(
            self,
            dec):
        """
        *Convert a declination from sexegesimal format to decimal degrees.*

        Precision should be respected. If a float is passed to this method, the same float will be returned (useful if unclear which format coordinates are in).

        The code will attempt to read the sexegesimal value in whatever form it is passed. Any of the following should be handled correctly:

        - ``+1:58:05.45341``
        - ``01:5:05``
        - ``+1 58 05.45341``
        - ``-23h53m05s``

        **Key Arguments:**
            - ``dec`` - DEC in sexegesimal format.

        **Return:**
            - ``decDeg`` -- declination converted to decimal degrees

        **Usage:**

            .. todo::

                - replace dryxPython declination_sexegesimal_to_decimal with this version in all my code
                - replace coords_sex_to_dec in all code

            .. code-block:: python

                from astrocalc.coords import unit_conversion
                converter = unit_conversion(
                    log=log
                )
                dec = converter.dec_sexegesimal_to_decimal(
                    dec="-23:45:21.23232"
                )
                print dec

                # OUTPUT: -23.7558978667
        """
        self.log.info(
            'starting the ``dec_sexegesimal_to_decimal`` method')

        import re

        # TEST TO SEE IF DECIMAL DEGREES PASSED
        try:
            dec = float(dec)
            if dec > -90. and dec < 90.:
                self.log.info(
                    'declination seems to already be in decimal degrees, returning original value' % locals())
                return float(dec)
        except:
            pass

        # REMOVE SURROUNDING WHITESPACE
        dec = str(dec).strip()

        # LOOK FOR A MINUS SIGN.  NOTE THAT -00 IS THE SAME AS 00.
        regex = re.compile(
            '^([\+\-]?(\d|[0-8]\d))\D+([0-5]\d)\D+([0-6]?\d(\.\d+)?)$')
        decMatch = regex.match(dec)

        if decMatch:
            degrees = decMatch.group(1)
            minutes = decMatch.group(3)
            seconds = decMatch.group(4)

            if degrees[0] == '-':
                sgn = -1
            else:
                sgn = 1

            degrees = abs(float(degrees))
            minutes = float(minutes)
            seconds = float(seconds)

            # PRECISION TEST
            # 1s = .000277778 DEGREE
            # THEREFORE REPORT SECONDS TO A PRECISION = INPUT PRECISION + 4
            decimalLen = len(repr(seconds).split(".")[-1])
            precision = decimalLen + 4

            decDeg = (degrees + (minutes / 60.0)
                              + (seconds / 3600.0)) * sgn

            decDeg = "%0.*f" % (precision, decDeg)

        else:
            raise IOError(
                "could not convert dec to decimal degrees, could not parse sexegesimal input. Original value was `%(dec)s`" % locals())

        decDeg = float(decDeg)
        self.log.debug('decDeg: %(decDeg)s' % locals())
        self.log.info(
            'completed the ``dec_sexegesimal_to_decimal`` method')

        return float(decDeg)