*Convert a distance from MPC to redshift*

        The code works by iteratively converting a redshift to a distance, correcting itself and honing in on the true answer (within a certain precision)

        **Key Arguments:**
            - ``mpc`` -- distance in MPC (assumes a luminousity distance).

        **Return:**
            - ``redshift``

        .. todo::

            - replace convert_mpc_to_redshift in all code

        **Usage:**

            .. code-block:: python

                from astrocalc.distances import converter
                c = converter(log=log)
                z = c.distance_to_redshift(
                    mpc=500
                )

                print z

                # OUTPUT: 0.108

def distance_to_redshift(
            self,
            mpc):
        """*Convert a distance from MPC to redshift*

        The code works by iteratively converting a redshift to a distance, correcting itself and honing in on the true answer (within a certain precision)

        **Key Arguments:**
            - ``mpc`` -- distance in MPC (assumes a luminousity distance).

        **Return:**
            - ``redshift``

        .. todo::

            - replace convert_mpc_to_redshift in all code

        **Usage:**

            .. code-block:: python

                from astrocalc.distances import converter
                c = converter(log=log)
                z = c.distance_to_redshift(
                    mpc=500
                )

                print z

                # OUTPUT: 0.108
        """
        self.log.info('starting the ``distance_to_redshift`` method')

        lowerLimit = 0.
        upperLimit = 30.
        redshift = upperLimit - lowerLimit
        distGuess = float(self.redshift_to_distance(redshift)['dl_mpc'])

        distDiff = mpc - distGuess

        while math.fabs(distDiff) > 0.0001:
            if distGuess < mpc:
                lowerLimit = redshift
                redshift = lowerLimit + (upperLimit - lowerLimit) / 2.
                distGuess = float(
                    self.redshift_to_distance(redshift)['dl_mpc'])
            elif distGuess > mpc:
                upperLimit = redshift
                redshift = lowerLimit + (upperLimit - lowerLimit) / 2.
                distGuess = float(
                    self.redshift_to_distance(redshift)['dl_mpc'])
            distDiff = mpc - distGuess

        redshift = float("%5.4f" % (redshift,))

        self.log.info('completed the ``distance_to_redshift`` method')
        return redshift