예제 #1
0
파일: unit.py 프로젝트: Guillemdb/asdf
    def to_tree(cls, node, ctx):
        from astropy.units import Unit, UnitBase

        if isinstance(node, six.string_types):
            node = Unit(node, format='vounit', parse_strict='warn')
        if isinstance(node, UnitBase):
            return node.to_string(format='vounit')
        raise TypeError("'{0}' is not a valid unit".format(node))
예제 #2
0
def units_to_fits(unit):
    """ Convert an astropy unit to a FITS format string.

    uses the to_string() method built-in to astropy Unit()

    Notes
    -----
    The output will be the format defined in the FITS standard:
    http://fits.gsfc.nasa.gov/fits_standard.html

    A roundtrip from fits_to_units -> units_to_fits may not return
    the original string, as people often don't follow the standard.
    """
    if unit is None:
        unit = Unit('')
    return unit.to_string("fits").upper()
예제 #3
0
def units_to_fits(unit):
    """ Convert an astropy unit to a FITS format string.

    uses the to_string() method built-in to astropy Unit()

    Notes
    -----
    The output will be the format defined in the FITS standard:
    http://fits.gsfc.nasa.gov/fits_standard.html

    A roundtrip from fits_to_units -> units_to_fits may not return
    the original string, as people often don't follow the standard.
    """
    if unit is None:
        unit = Unit('')
    return unit.to_string("fits").upper()
예제 #4
0
파일: unit.py 프로젝트: ArtShp/DataScience
 def to_tree(cls, node, ctx):
     if isinstance(node, six.string_types):
         node = Unit(node, format='vounit', parse_strict='warn')
     if isinstance(node, UnitBase):
         return node.to_string(format='vounit')
     raise TypeError(f"'{node}' is not a valid unit")
예제 #5
0
파일: unit.py 프로젝트: Cadair/astropy
 def to_tree(cls, node, ctx):
     if isinstance(node, six.string_types):
         node = Unit(node, format='vounit', parse_strict='warn')
     if isinstance(node, UnitBase):
         return node.to_string(format='vounit')
     raise TypeError("'{0}' is not a valid unit".format(node))