Coverage for /home/warp/casa/atejeda/coverage/build/linux-x86_64/python/2.7/__casac__/quanta : 1%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file was automatically generated by SWIG (http://www.swig.org). # Version 2.0.4 # # Do not make changes to this file unless you know what you are doing--modify # the SWIG interface file instead.
from sys import version_info if version_info >= (2,6,0): def swig_import_helper(): from os.path import dirname import imp fp = None try: fp, pathname, description = imp.find_module('_quanta', [dirname(__file__)]) except ImportError: import _quanta return _quanta if fp is not None: try: _mod = imp.load_module('_quanta', fp, pathname, description) finally: fp.close() return _mod _quanta = swig_import_helper() del swig_import_helper else: import _quanta del version_info try: _swig_property = property except NameError: pass # Python < 2.2 doesn't have 'property'. def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'SwigPyObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError(name)
def _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try: _object = object _newclass = 1 except AttributeError: class _object : pass _newclass = 0
class quanta(_object): """Proxy of C++ casac::quanta class""" __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, quanta, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, quanta, name) __repr__ = _swig_repr def __init__(self): """__init__(self) -> quanta""" this = _quanta.new_quanta() try: self.this.append(this) except: self.this = this __swig_destroy__ = _quanta.delete_quanta __del__ = lambda self : None; def convertfreq(self, *args, **kwargs): """ convertfreq(self, v = initialize_variant("1.0"), outunit = string("Hz")) -> record
Summary convert a frequency quantity to another unit
Description
convertfreq converts a frequency quantity to another unit.
Input Parameters: v quantity to convert 1.0 outunit unit to convert to Hz
Example:
''' # print ' ---- convertfreq Ex 1 ----' print qa.convertfreq('5GHz','cm') #{'value': 5.9958491599999997, 'unit': 'cm'} print qa.convertfreq('5cm','GHz') #{'value': 5.9958491599999997, 'unit': 'GHz'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_convertfreq(self, *args, **kwargs)
def convertdop(self, *args, **kwargs): """ convertdop(self, v = initialize_variant("0.0"), outunit = string("km/s")) -> record
Summary convert a doppler velocity quantity to another unit
Description
convertfreq converts a velocity quantity to another unit. Units are either velocity or dimensionless.
Input Parameters: v quantity to convert 0.0 outunit unit to convert to km/s
Example:
''' # print ' ---- convertdop Ex 1 ----' print qa.convertdop('1','km/s') #{'value': 299792.45799999998, 'unit': 'km/s'} print qa.convertdop('10km/s','1') #{'value': 3.3356409519815205e-05, 'unit': '1'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_convertdop(self, *args, **kwargs)
def quantity(self, *args, **kwargs): """ quantity(self, v, unitname = string("")) -> record
Summary make a quantity from a string or from a numeric value and a unit string
Description
quantity makes a quantity from a string, or from a value and a string. Note that a function unit exists which is a synonym for quantity. If only a string is given, it can be a scalar string. The result will be a scalar quantity.
If a numeric value and a unit string are given, the numeric value can be any numeric type, and can also be a vector of numeric values. print qa.map() to get a list of recognized units. 'd' is usually days, but can be degrees (see example).
Input Parameters: v quantity or numeric or string to convert to quantity unitname unit string if v numeric
Example:
''' # print ' ---- quantity Ex 1 ----' tu = qa.quantity('1Jy') # make quantity print tu #{'value': 1.0, 'unit': 'Jy'} print qa.quantity(tu) # also accepts a quantity #{'value': 1.0, 'unit': 'Jy'} tu = qa.unit('1Jy') # make quantity with synonym print tu #{'value': 1.0, 'unit': 'Jy'} print qa.quantity(-1.3, 'Jy') # make quantity with separate value #{'value': -1.3, 'unit': 'Jy'} q1 = qa.quantity([8.57132661e+09, 1.71426532e+10], 'km/s') # Composite unit print q1 #{'value': array([ 8.57132661e+09, 1.71426532e+10]), 'unit': 'km/s'} q = qa.quantity('5d'); print q #{'value': 5.0, 'unit': 'd'} # d = days q = qa.quantity('5 d'); print q #{'value': 5.0, 'unit': 'd'} # even if there's a space, as of 5/28/09 q = qa.quantity('5d30m'); print q #{'value': 5.5, 'unit': 'deg'} # Unless followed by an m! qa.quantity('5d30s') # WRONG # {'unit': 'd30s', 'value': 5.0} # I told you... qa.quantity('5d0m30s') # OK # {'unit': 'deg', 'value': 5.0083333333333337} '''
--------------------------------------------------------------------------------
"""
def getvalue(self, *args, **kwargs): """ getvalue(self, v) -> std::vector<(double)>
Summary get the internal value of a quantity
Description
getvalue returns the internal value of a quantity. It also can handle an array of quantities.
Input Parameters: v quantity
Example:
''' # print ' ---- getvalue Ex 1 ----' tu = qa.quantity(-1.3, 'Jy') # make quantity print tu #{'value': -1.3, 'unit': 'Jy'} print qa.getvalue(tu) #-1.3 print qa.getunit(tu) #Jy a = qa.quantity([3,5],'cm') print a #{'value': array([ 3., 5.]), 'unit': 'cm'} print qa.getvalue(a) #[3.0, 5.0] # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_getvalue(self, *args, **kwargs)
def getunit(self, *args, **kwargs): """ getunit(self, v) -> string
Summary get the internal unit of a quantity
Description
getunit returns the internal unit string of a quantity
Input Parameters: v quantity
Example:
''' # print ' ---- getunit Ex 1 ----' tu = qa.quantity(-1.3, 'Jy') # make quantity print tu #{'value': -1.3, 'unit': 'Jy'} print qa.getvalue(tu) #-1.3 print qa.getunit(tu) #Jy # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_getunit(self, *args, **kwargs)
def canonical(self, *args, **kwargs): """ canonical(self, v = initialize_variant("1.0")) -> record
Summary get canonical value of quantity
Description
canonical (with alias canon) gets the canonical value of a quantity
Input Parameters: v value to convert 1.0
Example:
''' # print ' ---- canonical Ex 1 ----' print qa.canonical('1Jy') # canonical value of a string #{'value': 1e-26, 'unit': 'kg.s-2'} print qa.canon(qa.quantity('1Jy')) # canonical value of a unit #{'value': 1e-26, 'unit': 'kg.s-2'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_canonical(self, *args, **kwargs)
def canon(self, *args, **kwargs): """ canon(self, v) -> record
Summary get canonical value of quantity
Description
canon gets the canonical value of a quantity
Input Parameters: v value to convert
Example:
''' # print ' ---- canon Ex 1 ----' print qa.canon('1Jy') # canonical value of a string #{'value': 1e-26, 'unit': 'kg.s-2'} print qa.canonical(qa.quantity('1Jy')) # canonical value of a unit #{'value': 1e-26, 'unit': 'kg.s-2'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_canon(self, *args, **kwargs)
def convert(self, *args, **kwargs): """ convert(self, v, outunit) -> record
Summary convert a quantity to another unit
Description
convert converts a quantity to another unit. If no output unit given, conversion is to canonical units
Input Parameters: v quantity to convert outunit unit to convert to
Example:
''' # print ' ---- convert Ex 1 ----' tu = qa.quantity('5Mm/s') # specify a quantity print tu #{'value': 5.0, 'unit': 'Mm/s'} print qa.convert(tu, 'pc/a') # convert it to parsec per year #{'value': 0.0051135608266237404, 'unit': 'pc/a'} print qa.convert(tu) # convert to canonical units #{'value': 5000000.0, 'unit': 'm.s-1'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_convert(self, *args, **kwargs)
def define(self, *args, **kwargs): """ define(self, name, v = initialize_variant("1")) -> bool
Summary define a new unit name
Description
define defines the name and value of a user defined unit
Input Parameters: name name of unit to define v quantity value of new unit 1
Example:
''' # print ' ---- define Ex 1 ----' print qa.define('JY','1Jy') # your misspelling #True print qa.define('VLAunit', '0.898 JY') # a special unit using it #True print qa.quantity('5 VLAunit') # check its use #{'value': 5.0, 'unit': 'VLAunit'} print qa.convert('5 VLAunit','Jy') #{'value': 4.4900000000000002, 'unit': 'Jy'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_define(self, *args, **kwargs)
def map(self, *args, **kwargs): """ map(self, v = string("all")) -> string
Summary list known unit names and constants
Description
map lists the known mapping of units and constants. It has a single argument, which can be a coded string (no-case, minimax match): egin{description} \item[all] all of the following units (not constants): also the default \item[Prefix] known decimal prefixes \item[SI] known SI units \item[Customary] a set of customary units known to programs \item[User] units defined by the user \item[Constants] known constants (note: only 'const', 'Const', 'constants' and 'Constants' recognised). nd{description}
Input Parameters: v type of information to list - coded string all
Example:
''' # print ' ---- map Ex 1 ----' print qa.map('pre') # list decimal prefixes # == Prefix ==== 20 ==== # E (exa) 1e+18 # G (giga) 1000000000 # M (mega) 1000000 # P (peta) 1e+15 # T (tera) 1e+12 # Y (yotta) 1e+24 # Z (zetta) 1e+21 # a (atto) 1e-18 # c (centi) 0.01 # d (deci) 0.1 # da (deka) 10 # f (femto) 1e-15 # h (hecto) 100 # k (kilo) 1000 # m (milli) 0.001 # n (nano) 1e-09 # p (pico) 1e-12 # u (micro) 1e-06 # y (yocto) 1e-24 # z (zepto) 1e-21 print qa.map('Constants') # list known constants # == Constants ==== # pi 3.14.. 3.14159 # ee 2.71.. 2.71828 # c light vel. 2.99792e+08 m/s # G grav. const 6.67259e-11 N.m2/kg2 # h Planck const 6.62608e-34 J.s # HI HI line 1420.41 MHz # R gas const 8.31451 J/K/mol # NA Avogadro # 6.02214e+23 mol-1 # e electron charge 1.60218e-19 C # mp proton mass 1.67262e-27 kg # mp_me mp/me 1836.15 # mu0 permeability vac. 1.25664e-06 H/m # eps0 permittivity vac. 1.60218e-19 C # k Boltzmann const 1.38066e-23 J/K # F Faraday const 96485.3 C/mol # me electron mass 9.10939e-31 kg # re electron radius 2.8179e-15 m # a0 Bohr's radius 5.2918e-11 m # R0 solar radius 6.9599e+08 m # k2 IAU grav. const^2 0.000295912 AU3/d2/S0 # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_map(self, *args, **kwargs)
def maprec(self, *args, **kwargs): """ maprec(self, v = string("all")) -> record
Summary create record containing list of known unit names and constants
Description
maprec returns a record with the known mapping of units and constants. It has a single argument, which can be a coded string (no-case, minimax match): egin{description} \item[all] all of the following units (not constants): also the default \item[Prefix] known decimal prefixes \item[SI] known SI units \item[Customary] a set of customary units known to programs \item[User] units defined by the user nd{description}
Input Parameters: v type of information to list - coded string all
Example:
''' # print ' ---- maprec Ex 1 ----' p = qa.maprec('pre') # list decimal prefixes print p['Prefix_G'] # G (giga) 1000000000 s = qa.maprec('SI') # list SI units print s['SI_Jy'] #Jy (jansky) 1e-26 kg.s-2 # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_maprec(self, *args, **kwargs)
def fits(self): """ fits(self) -> bool
Summary define some FITS units
Description
fits defines some unit names used in reading and writing FITS files.
Example:
''' # print ' ---- fits Ex 1 ----' print qa.fits() #True print qa.map('user') # == User ==== # BEAM (dimensionless beam) 1 _ # DAYS (day) 86400 s # DEG (degree) 0.0174532925199 rad # DEGREES (degree) 0.0174532925199 rad # HZ (hertz) 1 s-1 # JY (jansky) 1e-26 kg.s-2 # KELVIN (kelvin) 1 K # KELVINS (kelvin) 1 K # KM (km) 1000 m # M (meter) 1 m # METERS (meter) 1 m # PASCAL (pascal) 1 m-1.kg.s-2 # PIXEL (dimensionless pixel) 1 _ # S (second) 1 s # SEC (second) 1 s # SECONDS (second) 1 s # VOLTS (volt) 1 m2.kg.s-3.A-1 # YEAR (year) 31557600 s # YEARS (year) 31557600 s # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_fits(self)
def angle(self, *args, **kwargs): """ angle(self, v, prec = 0, form = std::vector< string >(1, ""), showform = False) -> std::vector<(std::string)>
Summary show an angle as a formatted string
Description
angle converts an angle quantity to a formatted string. The formatting information is a precision (0 is default, 6 includes +-ddd.mm.ss) and a string array of codes (no-case, minimax match): Codes include: egin{description} \item[clean] delete leading/trailing superfluous separators \item[no\_d] do not show degrees part \item[no\_dm] do not show degrees and minutes part \item[dig2] show only 2 digits of degrees in angle format \item[time] show as time (hh:mm:ss.ttt) rather than as angle nd{description} If a multi-dimensional value is given for the value $v$, the returned value is a string vector of a length equal to last dimension. Each string has a number of fields equal to the number of elements in all earlier dimensions. If the {m showform} is $T$, each vector element is surrounded by a pair of square brackets if there is more than one entry, and fields are separated by a ','.
Input Parameters: v angle quantity value to output prec number of digits shown 0 form formatting information in coded string array showform show square brackets and separating , false
Example:
''' # print ' ---- angle Ex 1 ----' tu = qa.quantity('5.7.12.345678') # define an angle print tu #{'value': 5.1200960216666669, 'unit': 'deg'} print qa.angle(tu) # default output #+005.07.12 print qa.angle(tu, prec=7) # 7 digits #+005.07.12.3 print qa.angle(tu, prec=4) # 4 digits #+005.07. print qa.angle(tu, form=['tim','no_d']) # as time, no hours shown #:20:29 # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_angle(self, *args, **kwargs)
def time(self, *args, **kwargs): """ time(self, v, prec = 0, form = std::vector< string >(1, ""), showform = False) -> std::vector<(std::string)>
Summary show a time (or date) as a formatted string
Description
time converts a time quantity to a formatted string. The formatting information is a precision (0 is default, 6 includes hh.mm.ss) and a string array of codes (no-case, minimax match): Codes include: egin{description} \item[clean] delete leading/trailing superfluous separators \item[no\_d] do not show hours part \item[no\_dm] do not show hours and minutes part \item[ymd] include a date as yyyy/mm/dd (date is by default not shown) \item[dmy] include a date as ddMMMyyyy (date is by default not shown) \item[mjd] include a date as Modified Julian Day (date is by default not shown) \item[fits] include a date and show time in FITS format: le from OS \item[angle] show in angle (dd.mm.ss.ttt) rather than time format \item[day] prefix day-of-week to output \item[local] show local time rather than UTC (add timezone offset) \item[no\_time] suppress printing of time part nd{description} If a multi-dimensional value is given for the value $v$, the returned value is a string vector of a length equal to last dimension. Each string has a number of fields equal to the number of elements in all earlier dimensions. If the {m showform} is $T$, each vector element is surrounded by a pair of square brackets if there is more than one entry, and fields are separated by a ','.
Input Parameters: v time quantity value to output prec number of digits shown 0 form formatting information in coded string array showform show square brackets and separating , false
Example:
''' # print ' ---- time Ex 1 ----' tu = qa.quantity('today') # a time print tu #{'value': 54175.708981504627, 'unit': 'd'} print qa.time(tu) # default format #17:00:56 print qa.time(tu,form='dmy') # show date #16-Mar-2007/17:00:56 print qa.time(tu,form=['ymd','day']) # and day #Fri-2007/03/16/17:00:56 print qa.time(tu,form='fits') # FITS format #2007-03-16T17:00:56 print qa.time(tu,form=['fits','local']) # local FITS format #2007-03-16T10:00:56-07:00 print qa.time(tu,form=['ymd','local']) # local time #2007/03/16/10:00:56 # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_time(self, *args, **kwargs)
def add(self, *args, **kwargs): """ add(self, v, a = initialize_variant("0")) -> record
Summary add quantities
Description
add adds two quantities
Input Parameters: v value a value 0
Example:
''' # print ' ---- add Ex 1 ----' print qa.add('5m', '2yd') #{'value': 6.8288000000000002, 'unit': 'm'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_add(self, *args, **kwargs)
def sub(self, *args, **kwargs): """ sub(self, v, a = initialize_variant("0")) -> record
Summary subtract quantities
Description
sub subtracts two quantities
Input Parameters: v value a value 0
Example:
''' # print ' ---- sub Ex 1 ----' print qa.sub('5m', '2yd') #{'value': 3.1712000000000002, 'unit': 'm'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_sub(self, *args, **kwargs)
def mul(self, *args, **kwargs): """ mul(self, v, a = initialize_variant("1")) -> record
Summary multiply quantities
Description
mul multiplies two quantities
Input Parameters: v value a value 1
Example:
''' # print ' ---- mul Ex 1 ----' print qa.mul('5m', '3s') #{'value': 15.0, 'unit': 'm.s'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_mul(self, *args, **kwargs)
def div(self, *args, **kwargs): """ div(self, v, a = initialize_variant("1")) -> record
Summary divides quantities
Description
div divides two quantities
Input Parameters: v value a value 1
Example:
''' # print ' ---- div Ex 1 ----' print qa.div('5m', '3s') #{'value': 1.6666666666666667, 'unit': 'm/(s)'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_div(self, *args, **kwargs)
def neg(self, *args, **kwargs): """ neg(self, v = initialize_variant("1")) -> record
Summary negate quantities
Description
neg negates a quantity
Input Parameters: v value 1
Example:
''' # print ' ---- neg Ex 1 ----' print qa.neg('5m') #{'value': -5.0, 'unit': 'm'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_neg(self, *args, **kwargs)
def norm(self, *args, **kwargs): """ norm(self, v, a = -0.5) -> record
Summary normalise angle
Description
norm normalise angles in interval of $2\pi$ radians. The default interval is from -0.5 to +0.5 of a full interval (i.e. from -180 to +180 degrees). The lower end of the interval can be set as a fraction of $2\pi$
Input Parameters: v angle quantity a lower interval boundary -0.5
Example:
''' # print ' ---- norm Ex 1 ----' print qa.norm('713deg') #default normalisation #{'value': -6.9999999999999716, 'unit': 'deg'} print qa.norm('713deg', -2.5) # normalise to interval -900 - -540 deg #{'value': -727.0, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_norm(self, *args, **kwargs)
def le(self, *args, **kwargs): """ le(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
le compares two quantities for less than or equal.
Input Parameters: v value a value 0
Example:
''' # print ' ---- le Ex 1 ----' print qa.le('5m', '2yd') #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_le(self, *args, **kwargs)
def lt(self, *args, **kwargs): """ lt(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
lt compares two quantities for less than.
Input Parameters: v value a value 0
Example:
''' # print ' ---- lt Ex 1 ----' print qa.lt('5m', '2yd') #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_lt(self, *args, **kwargs)
def eq(self, *args, **kwargs): """ eq(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
eq compares two quantities for equality.
Input Parameters: v value a value 0
Example:
''' # print ' ---- eq Ex 1 ----' print qa.eq('5m', '2yd') #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_eq(self, *args, **kwargs)
def ne(self, *args, **kwargs): """ ne(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
ne compares two quantities for non equality.
Input Parameters: v value a value 0
Example:
''' # print ' ---- ne Ex 1 ----' print qa.ne('5m', '2yd') #True # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_ne(self, *args, **kwargs)
def gt(self, *args, **kwargs): """ gt(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
gt compares two quantities for greater than.
Input Parameters: v value a value 0
Example:
''' # print ' ---- gt Ex 1 ----' print qa.gt('5m', '2yd') #True # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_gt(self, *args, **kwargs)
def ge(self, *args, **kwargs): """ ge(self, v, a = initialize_variant("0")) -> bool
Summary compare quantities
Description
ge compares two quantities for greater than or equal.
Input Parameters: v value a value 0
Example:
''' # print ' ---- ge Ex 1 ----' print qa.ge('5m', '2yd') #True # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_ge(self, *args, **kwargs)
def sin(self, *args, **kwargs): """ sin(self, v) -> record
Summary sine of quantity
Description
sin gives sine of angle quantity
Input Parameters: v angle quantity
Example:
''' # print ' ---- sin Ex 1 ----' print qa.sin('7deg') #{'value': 0.12186934340514748, 'unit': ''} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_sin(self, *args, **kwargs)
def cos(self, *args, **kwargs): """ cos(self, v) -> record
Summary cosine of quantity
Description
cos gives cosine of angle quantity
Input Parameters: v angle quantity
Example:
''' # print ' ---- cos Ex 1 ----' print qa.cos('7deg') #{'value': 0.99254615164132198, 'unit': ''} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_cos(self, *args, **kwargs)
def tan(self, *args, **kwargs): """ tan(self, v) -> record
Summary tangent of quantity
Description
tan gives tangent of angle quantity
Input Parameters: v angle quantity
Example:
''' # print ' ---- tan Ex 1 ----' print qa.tan('7deg') #{'value': 0.1227845609029046, 'unit': ''} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_tan(self, *args, **kwargs)
def asin(self, *args, **kwargs): """ asin(self, v) -> record
Summary arcsine of quantity
Description
asin gives arcsine of non-dimensioned quantity
Input Parameters: v non-dimensioned quantity
Example:
''' # print ' ---- asin Ex 1 ----' print qa.convert(qa.asin(qa.sin('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_asin(self, *args, **kwargs)
def acos(self, *args, **kwargs): """ acos(self, v) -> record
Summary arccosine of quantity
Description
acos gives arccosine of non-dimensioned quantity
Input Parameters: v non-dimensioned quantity
Example:
''' # print ' ---- acos Ex 1 ----' print qa.convert(qa.acos(qa.cos('7deg')), 'deg') #{'value': 7.0000000000000249, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_acos(self, *args, **kwargs)
def atan(self, *args, **kwargs): """ atan(self, v) -> record
Summary arctangent of quantity
Description
atan gives arctangent of non-dimensioned quantity
Input Parameters: v non-dimensioned quantity
Example:
''' # print ' ---- atan Ex 1 ----' print qa.convert(qa.atan(qa.tan('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_atan(self, *args, **kwargs)
def atan2(self, *args, **kwargs): """ atan2(self, v, a) -> record
Summary arctangent of two quantity
Description
atan gives arctangent of two non-dimensioned quantity
Input Parameters: v non-dimensioned quantity a non-dimensioned quantity
Example:
''' # print ' ---- atan2 Ex 1 ----' print qa.convert(qa.atan2(qa.sin('7deg'), qa.cos('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_atan2(self, *args, **kwargs)
def abs(self, *args, **kwargs): """ abs(self, v) -> record
Summary absolute value of quantity
Description
abs gives absolute value of quantity
Input Parameters: v value
Example:
''' # print ' ---- abs Ex 1 ----' print qa.abs('-5km/s') #{'value': 5.0, 'unit': 'km/s'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_abs(self, *args, **kwargs)
def ceil(self, *args, **kwargs): """ ceil(self, v) -> record
Summary ceil value of quantity
Description
ceil gives ceiling value of quantity
Input Parameters: v value
Example:
''' # print ' ---- ceil Ex 1 ----' print qa.ceil('5.1AU') #{'value': 6.0, 'unit': 'AU'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_ceil(self, *args, **kwargs)
def floor(self, *args, **kwargs): """ floor(self, v) -> record
Summary floor value of quantity
Description
floor gives flooring value of quantity
Input Parameters: v value
Example:
''' # print ' ---- floor Ex 1 ----' print qa.floor('-5.1AU') #{'value': -6.0, 'unit': 'AU'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_floor(self, *args, **kwargs)
def log(self, *args, **kwargs): """ log(self, v) -> record
Summary logarithm of quantity
Description
log gives natural logarithm of dimensionless quantity
Input Parameters: v dimensionless quantity
Example:
''' # print ' ---- log Ex 1 ----' print qa.log('2') #{'value': 0.69314718055994529, 'unit': ''} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_log(self, *args, **kwargs)
def log10(self, *args, **kwargs): """ log10(self, v) -> record
Summary logarithm of quantity
Description
log10 gives logarithm of dimensionless quantity
Input Parameters: v dimensionless quantity
Example:
''' # print ' ---- log10 Ex 1 ----' print qa.log10('2') #{'value': 0.3010299956639812, 'unit': ''} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_log10(self, *args, **kwargs)
def exp(self, *args, **kwargs): """ exp(self, v) -> record
Summary exponential of quantity
Description
exp gives exponential value of dimensionless quantity
Input Parameters: v dimensionless quantity
Example:
''' # print ' ---- exp Ex 1 ----' print qa.exp('2') #{'value': 7.3890560989306504, 'unit': ''} try: print qa.exp('2m') except Exception, e: print 'Caught an expected exception', e #Caught an expected exception Quantum::exp illegal unit type 'm' # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_exp(self, *args, **kwargs)
def sqrt(self, *args, **kwargs): """ sqrt(self, v) -> record
Summary square root of quantity
Description
sqrt gives square root of quantity with only even powered dimensions
Input Parameters: v dimensionless quantity
Example:
''' # print ' ---- sqrt Ex 1 ----' print qa.sqrt('2m2') #{'value': 1.4142135623730951, 'unit': 'm'} try: print qa.sqrt('2s') except Exception, e: print 'Caught an expected exception', e #Caught an expected exception UnitVal::UnitVal Illegal unit dimensions for root # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_sqrt(self, *args, **kwargs)
def compare(self, *args, **kwargs): """ compare(self, v, a) -> bool
Summary compare dimensionality of units
Description
compare compares the dimensionality of units of two qauntities
Input Parameters: v value a value
Example:
''' # print ' ---- compare Ex 1 ----' print qa.compare('5yd/a', '6m/s') # equal dimensions #True print qa.compare('5yd', '5s') # unequal dimensions #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_compare(self, *args, **kwargs)
def check(self, *args, **kwargs): """ check(self, v) -> bool
Summary check for proper unit string
Description
check checks if the argument has a properly defined unit string
Input Parameters: v value
Example:
''' # print ' ---- check Ex 1 ----' print qa.check('5AE/Jy.pc5/s') #True print qa.check('7MYs') #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_check(self, *args, **kwargs)
def checkfreq(self, *args, **kwargs): """ checkfreq(self, cm) -> bool
Summary check for proper frequency unit
Description
checkfreq checks if the argument has a properly defined frequency interpretable unit string
Input Parameters: cm value
Example:
''' # print ' ---- checkfreq Ex 1 ----' print qa.checkfreq('5GHz') #True print qa.checkfreq('5cm') #True print qa.checkfreq('5cm/s2') #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_checkfreq(self, *args, **kwargs)
def pow(self, *args, **kwargs): """ pow(self, v, a = 1) -> record
Summary raise quantity to power
Description
pow raises a quantity to an integer power
Input Parameters: v value a power 1
Example:
''' # print ' ---- pow Ex 1 ----' print qa.pow('7.2km/s', -3) #{'value': 0.0026791838134430724, 'unit': '(km/s)-3'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_pow(self, *args, **kwargs)
def constants(self, *args, **kwargs): """ constants(self, v = string("pi")) -> record
Summary get a constant
Description
constants gets a named constant quantity. Names (no-case, minimax) are:
pi 3.14.. 3.14159 ee 2.71.. 2.71828 c light vel. 2.99792e+08 m/s G grav. const 6.67259e-11 N.m2/kg2 h Planck const 6.62608e-34 J.s HI HI line 1420.41 MHz R gas const 8.31451 J/K/mol NA Avogadro number 6.02214e+23 mol-1 e electron charge 1.60218e-19 C mp proton mass 1.67262e-27 kg mp\_me mp/me 1836.15 mu0 permeability vac. 1.25664e-06 H/m eps0 permittivity vac. 1.60218e-19 C k Boltzmann const 1.38066e-23 J/K F Faraday const 96485.3 C/mol me electron mass 9.10939e-31 kg re electron radius 2.8179e-15 m a0 Bohr's radius 5.2918e-11 m R0 solar radius 6.9599e+08 m k2 IAU grav. const\^2 0.000295912 AU3/d2/S0
Input Parameters: v name pi
Example:
''' # print ' ---- constants Ex 1 ----' print qa.constants() #{'unit': '', 'value': 3.1415926535897931} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_constants(self, *args, **kwargs)
def isangle(self, *args, **kwargs): """ isangle(self, v) -> bool
Summary check if valid angle or time quantity
Description
isangle checks if the argument is a valid angle/time quantity.
Input Parameters: v angle/time quantity
Example:
''' # print ' ---- isangle Ex 1 ----' print qa.isangle(qa.constants('pi')) #False # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_isangle(self, *args, **kwargs)
def totime(self, *args, **kwargs): """ totime(self, v) -> record
Summary convert an angle (or a time) to a time
Description
totime converts an angle quantity (or a time) to a time quantity
Input Parameters: v angle/time quantity
Example:
''' # print ' ---- totime Ex 1 ----' print qa.totime('2d5m') #{'value': 0.0057870370370370376, 'unit': 'd'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_totime(self, *args, **kwargs)
def toangle(self, *args, **kwargs): """ toangle(self, v) -> record
Summary convert a time (or an angle) to an angle
Description
toangle converts a time quantity (or an angle) to an angle quantity
Input Parameters: v angle/time quantity
Example:
''' # print ' ---- toangle Ex 1 ----' print qa.toangle('5h30m12.6') #{'value': 82.552499999999995, 'unit': 'deg'} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_toangle(self, *args, **kwargs)
def splitdate(self, *args, **kwargs): """ splitdate(self, v) -> record
Summary split a date/time into a record
Description
splitdate splits a date/time quantity into a record with constituent fields like year, yearday, month etc. All fields will be integer (to enable use as index and easy personal formatting), with the exception of the {m s} field which is a double float. See the example for the fields returned.
Input Parameters: v angle/time quantity
Example:
''' # print ' ---- splitdate Ex 1 ----' print qa.splitdate('today')
#{'mjd': 54175.752367291658, 'week': 11, 'usec': 533999, 'hour': 18, # 'min': 3, 'yearday': 75, 'msec': 533, 'month': 3, 's': # 24.533999226987362, 'sec': 24, 'weekday': 5, 'year': 2007, 'monthday': # 16} print qa.splitdate('183.33333333deg') #{'mjd': 0.50925925925000004, 'week': 46, 'usec': 999999, 'hour': 12, # 'min': 13, 'yearday': 321, 'msec': 999, 'month': 11, 's': # 19.999999200003487, 'sec': 19, 'weekday': 3, 'year': 1858, # 'monthday': 17} # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_splitdate(self, *args, **kwargs)
def tos(self, *args, **kwargs): """ tos(self, v, prec = 9) -> string
Summary convert quantity to string
Description
tos converts a quantity to a string with the precision defined with the {m setformat('prec')} (which defaults to 9). If the optional {m prec} argument is set to an integer value greater than 1, that precision is used in the conversion
Input Parameters: v value prec convert precision of value 9
Example:
''' # print ' ---- tos Ex 1 ----' a = qa.quantity('2.56 yd/s') print a #{'value': 2.5600000000000001, 'unit': 'yd/s'} print qa.tos(a) #2.560000000yd/s a=qa.quantity(1./7, 'km/s') print qa.tos(a) #0.142857143km/s print qa.tos(a,2) #0.14km/s print qa.tos(a,20) #0.14285714285714284921km/s print qa.tos(a) #0.142857143km/s # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_tos(self, *args, **kwargs)
def type(self): """ type(self) -> string
Summary type of tool
Description
type will return the tool name.
Example:
''' # print ' ---- type Ex 1 ----' print qa.type() #quanta # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_type(self)
def done(self, kill = False): """ done(self, kill = False) -> bool
Summary Free resources used by tool. Current implementation ignores input parameter, does nothing and returns true
Description
Currently, this method is an NOP.
Input Parameters: kill force kill of the default tool (ignored) false
Example:
''' # print ' ---- done Ex 1 ----' print qa.done() #True print qa.done() #True print qa.done(kill=T) #True # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_done(self, kill)
def unit(self, *args, **kwargs): """ unit(self, v, unitname = string("")) -> record
Summary quantity from value v and unit string
Description
unit makes a quantity from a string, or from a value and a string. Note that unit is a synonym for quantity (see example there).
Input Parameters: v unitname
--------------------------------------------------------------------------------
""" return _quanta.quanta_unit(self, *args, **kwargs)
def isquantity(self, *args, **kwargs): """ isquantity(self, v) -> bool
Summary Check if quantity
Description
Checks if the operand is a correct quantity
Input Parameters: v value to be tested
Example:
''' # print ' ---- isQuantity Ex 1 ----' a = qa.quantity('5Jy') # make a quantity print a #{'value': 5.0, 'unit': 'Jy'} print qa.isquantity(a) # is it one? #True print qa.isquantity('5Jy') # and this string? #True # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_isquantity(self, *args, **kwargs)
def setformat(self, *args, **kwargs): """ setformat(self, t = string(""), v = string("F")) -> bool
Summary set format for output of numbers. (NOT IMPLEMENTED YET!)
Input Parameters: t type -coded string indicating which format parameter to set v format parameter value - numeric or coded string, depending on format type to be set F
--------------------------------------------------------------------------------
""" return _quanta.quanta_setformat(self, *args, **kwargs)
def getformat(self, *args, **kwargs): """ getformat(self, t = string("")) -> string
Summary get current output format (NOT IMPLEMENTED YET!)
Description
getformat returns the current format value set for the different format possibilities. See the setformat function for the different format type descriptions. The known types are: \ prec, aprec, tprec, long, lat, len, dtime, elev, auto, vel, freq, dop, unit.
Input Parameters: t type - coded string
Example:
''' # print ' ---- getformat Ex 1 ----' print qa.getformat('prec') #6 #setformat is NOT IMPLEMENTED YET! #qa.setformat('prec', 12) # set precision to 12 significant digits #T #print qa.getformat('prec') #12 print qa.getformat('long') #hms # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_getformat(self, *args, **kwargs)
def formxxx(self, *args, **kwargs): """ formxxx(self, v, format = string("dms"), prec = 2) -> string
Summary Format a quantity using given format, allowed are hms, dms, deg, rad, +deg.
Description
form.xxx (xxx can be lat, long, len, vel, freq, dtime, unit) will format the input into a string using the global format information set by setformat().
Input Parameters: v value to be converted format xxx can be hms, dms, deg, rad or +deg dms prec digits in fractional part of output string for dms,hms 2
Example:
''' # print ' ---- formxxx Ex 1 ----' #qa.setformat('freq','cm') #T #qa.formxxx('freq',qa.quantity('5GHz')) #form_xxx NOT IMPLEMENTED YET! #5.99584916 cm print 'Last example, exiting! ...' exit() # '''
--------------------------------------------------------------------------------
""" return _quanta.quanta_formxxx(self, *args, **kwargs)
quanta_swigregister = _quanta.quanta_swigregister quanta_swigregister(quanta)
# This file is compatible with both classic and new-style classes.
|