Example #1
0
 def string(self, units="degrees", decimal=False, sep=" ", precision=5, pad=False): 
     """ Returns a string representation of the angle.
     
         Parameters
         ----------
         units : str
             Specifies the units, value should be one of the allowed units values (see: `Angle`)
         decimal : bool
             Specifies whether to return a sexagesimal representation (e.g. a tuple 
             (hours, minutes, seconds)), or decimal
         sep : str
             The separator between numbers in a sexagesimal representation, e.g. 12:41:11.1241
             where the separator is ":". Also accepts 2 or 3 separators, e.g. 12h41m11.1241s would be sep="hms",
             or 11-21:17.124 would be sep="-:"
     """
     
     lowUnits = units.lower()
     
     if lowUnits == "degrees":
         if decimal:
             return ("{0:0." + str(precision) + "f}").format(self.degrees)
         else:
             return convert.degreesToString(self.degrees, precision=precision, sep=sep, pad=pad)
             
     elif lowUnits == "radians":
         return str(self.radians)
             
     elif lowUnits == "hours":
         if decimal:
             return ("{0:0." + str(precision) + "f}").format(self.hours)
         else:
             return convert.hoursToString(self.hours, precision=precision, sep=sep, pad=pad)
     else:
         raise IllegalUnitsError(units)
Example #2
0
 def __repr__(self):
     return "<{2}: {0} degrees ({1})>".format(math.degrees(self.radians), convert.degreesToString(self.degrees), type(self).__name__)