def add_virtual_columns_distance_from_parallax(self, parallax="parallax", distance_name="distance", parallax_uncertainty=None, uncertainty_postfix="_uncertainty"):
    """Convert parallax to distance (i.e. 1/parallax)

    :param parallax: expression for the parallax, e.g. "parallax"
    :param distance_name: name for the virtual column of the distance, e.g. "distance"
    :param parallax_uncertainty: expression for the uncertainty on the parallax, e.g. "parallax_error"
    :param uncertainty_postfix: distance_name + uncertainty_postfix is the name for the virtual column, e.g. "distance_uncertainty" by default
    :return:
    """
    """


    """
    import astropy.units
    unit = self.unit(parallax)
    # if unit:
    #   convert = unit.to(astropy.units.mas)
    #   distance_expression = "%f/(%s)" % (convert, parallax)
    # else:
    distance_expression = "1/%s" % (parallax)
    self.ucds[distance_name] = "pos.distance"
    self.descriptions[distance_name] = "Derived from parallax (%s)" % parallax
    if unit:
        if unit == astropy.units.milliarcsecond:
            self.units[distance_name] = astropy.units.kpc
        if unit == astropy.units.arcsecond:
            self.units[distance_name] = astropy.units.parsec
    self.add_virtual_column(distance_name, distance_expression)
    if parallax_uncertainty:
        """
        y = 1/x
        sigma_y**2 = (1/x**2)**2 sigma_x**2
        sigma_y = (1/x**2) sigma_x
        sigma_y = y**2 sigma_x
        sigma_y/y = (1/x) sigma_x
        """
        name = distance_name + uncertainty_postfix
        distance_uncertainty_expression = "{parallax_uncertainty}/({parallax})**2".format(**locals())
        self.add_virtual_column(name, distance_uncertainty_expression)
        self.descriptions[name] = "Uncertainty on parallax (%s)" % parallax
        self.ucds[name] = "stat.error;pos.distance"
def add_virtual_columns_distance_from_parallax(self, parallax="parallax", distance_name="distance", parallax_uncertainty=None, uncertainty_postfix="_uncertainty"):
    """Convert parallax to distance (i.e. 1/parallax)

    :param parallax: expression for the parallax, e.g. "parallax"
    :param distance_name: name for the virtual column of the distance, e.g. "distance"
    :param parallax_uncertainty: expression for the uncertainty on the parallax, e.g. "parallax_error"
    :param uncertainty_postfix: distance_name + uncertainty_postfix is the name for the virtual column, e.g. "distance_uncertainty" by default
    :return:
    """
    """


    """
    import astropy.units
    unit = self.unit(parallax)
    # if unit:
    #   convert = unit.to(astropy.units.mas)
    #   distance_expression = "%f/(%s)" % (convert, parallax)
    # else:
    distance_expression = "1/%s" % (parallax)
    self.ucds[distance_name] = "pos.distance"
    self.descriptions[distance_name] = "Derived from parallax (%s)" % parallax
    if unit:
        if unit == astropy.units.milliarcsecond:
            self.units[distance_name] = astropy.units.kpc
        if unit == astropy.units.arcsecond:
            self.units[distance_name] = astropy.units.parsec
    self.add_virtual_column(distance_name, distance_expression)
    if parallax_uncertainty:
        """
        y = 1/x
        sigma_y**2 = (1/x**2)**2 sigma_x**2
        sigma_y = (1/x**2) sigma_x
        sigma_y = y**2 sigma_x
        sigma_y/y = (1/x) sigma_x
        """
        name = distance_name + uncertainty_postfix
        distance_uncertainty_expression = "{parallax_uncertainty}/({parallax})**2".format(**locals())
        self.add_virtual_column(name, distance_uncertainty_expression)
        self.descriptions[name] = "Uncertainty on parallax (%s)" % parallax
        self.ucds[name] = "stat.error;pos.distance"
def add_virtual_columns_distance_from_parallax ( self , parallax = "parallax" , distance_name = "distance" , parallax_uncertainty = None , uncertainty_postfix = "_uncertainty" ) : """


    """ import astropy . units unit = self . unit ( parallax ) # if unit: #   convert = unit.to(astropy.units.mas) #   distance_expression = "%f/(%s)" % (convert, parallax) # else: distance_expression = "1/%s" % ( parallax ) self . ucds [ distance_name ] = "pos.distance" self . descriptions [ distance_name ] = "Derived from parallax (%s)" % parallax if unit : if unit == astropy . units . milliarcsecond : self . units [ distance_name ] = astropy . units . kpc if unit == astropy . units . arcsecond : self . units [ distance_name ] = astropy . units . parsec self . add_virtual_column ( distance_name , distance_expression ) if parallax_uncertainty : """
        y = 1/x
        sigma_y**2 = (1/x**2)**2 sigma_x**2
        sigma_y = (1/x**2) sigma_x
        sigma_y = y**2 sigma_x
        sigma_y/y = (1/x) sigma_x
        """ name = distance_name + uncertainty_postfix distance_uncertainty_expression = "{parallax_uncertainty}/({parallax})**2" . format ( * * locals ( ) ) self . add_virtual_column ( name , distance_uncertainty_expression ) self . descriptions [ name ] = "Uncertainty on parallax (%s)" % parallax self . ucds [ name ] = "stat.error;pos.distance"
Convert parallax to distance (i.e. 1/parallax)

    :param parallax: expression for the parallax, e.g. "parallax"
    :param distance_name: name for the virtual column of the distance, e.g. "distance"
    :param parallax_uncertainty: expression for the uncertainty on the parallax, e.g. "parallax_error"
    :param uncertainty_postfix: distance_name + uncertainty_postfix is the name for the virtual column, e.g. "distance_uncertainty" by default
    :return:
Convert parallax to distance ( i . e . 1 / parallax )