Source code for casatools.quanta

#
# stub class definition file for docstring parsing
#

[docs]class quanta: r""" quanta tool handles units and quantities """
[docs] def quanta(self): r""" Create a quanta tool on the specified host (or by default the host you are running on). """ pass
[docs] def convertfreq(self, v='1.0', outunit='Hz'): r""" convertfreq converts a frequency quantity to another unit. .. rubric:: Parameters - ``v (variant='1.0')`` - quantity to convert - ``outunit (string='Hz')`` - unit to convert to .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t convertfreq Ex 1 \t----" print qa.convertfreq('5GHz','cm') #{'value': 5.9958491599999997, 'unit': 'cm'} print qa.convertfreq('5cm','GHz') #{'value': 5.9958491599999997, 'unit': 'GHz'} # """ pass
[docs] def convertdop(self, v='0.0', outunit='km/s'): r""" convertfreq converts a velocity quantity to another unit. Units are either velocity or dimensionless. .. rubric:: Parameters - ``v (variant='0.0')`` - quantity to convert - ``outunit (string='km/s')`` - unit to convert to .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t convertdop Ex 1 \t----" print qa.convertdop('1','km/s') #{'value': 299792.45799999998, 'unit': 'km/s'} print qa.convertdop('10km/s','1') #{'value': 3.3356409519815205e-05, 'unit': '1'} # """ pass
[docs] def quantity(self, v='', unitname='', keepshape=False): r""" 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). The keepshape input parameter is only relevant if v is a multi-dimensional array. In this case, if True, the output value array will have the same shape as v. If False, a one-dimensional array is returned with length equal to the number of elements in v. The default value is False in order to preserve backward compatibility with previous versions. .. rubric:: Parameters - ``v (variant='')`` - quantity or numeric or string to convert to quantity - ``unitname (string='')`` - unit string if v numeric - ``keepshape (bool=False)`` - Only used if input parameter v is a multi-dimensional array. Output array will have the same shape as v. .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t quantity Ex 1 \t----" 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} """ pass
[docs] def getvalue(self, v=''): r""" getvalue returns the internal value of a quantity. It also can handle a 1-D array of quantities, but multi-dimensional arrays are not supported. .. rubric:: Parameters - ``v (variant='')`` - quantity .. rubric:: Returns ``doubleVec`` .. rubric:: Examples :: # print "\t----\t getvalue Ex 1 \t----" 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] # """ pass
[docs] def getunit(self, v=''): r""" getunit returns the internal unit string of a quantity. Note that 1-D arrays are supported, but multi-dimensional arrays are not. .. rubric:: Parameters - ``v (variant='')`` - quantity .. rubric:: Returns ``string`` .. rubric:: Examples :: # print "\t----\t getunit Ex 1 \t----" 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 # """ pass
[docs] def canonical(self, v='1.0'): r""" canonical (with alias canon) gets the canonical value of a quantity .. rubric:: Parameters - ``v (variant='1.0')`` - value to convert .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t canonical Ex 1 \t----" 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'} # """ pass
[docs] def canon(self, v=''): r""" canon gets the canonical value of a quantity .. rubric:: Parameters - ``v (variant='')`` - value to convert .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t canon Ex 1 \t----" 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'} # """ pass
[docs] def convert(self, v='', outunit=''): r""" convert converts a quantity to another unit. If no output unit given, conversion is to canonical units .. rubric:: Parameters - ``v (variant='')`` - quantity to convert - ``outunit (variant='')`` - unit to convert to .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t convert Ex 1 \t----" 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'} # """ pass
[docs] def define(self, name='', v='1'): r""" define defines the name and value of a user defined unit .. rubric:: Parameters - ``name (string='')`` - name of unit to define - ``v (variant='1')`` - quantity value of new unit .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t define Ex 1 \t----" 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'} # """ pass
[docs] def map(self, v='all'): r""" map lists the known mapping of units and constants. It has a single argument, which can be a coded string (no-case, minimax match): all all of the following units (not constants): also the default Prefix known decimal prefixes SI known SI units Customary a set of customary units known to programs User units defined by the user Constants known constants (note: only ’const’, ’Const’, ’constants’ and ’Constants’ recognised). .. rubric:: Parameters - ``v (string='all')`` - type of information to list - coded string .. rubric:: Returns ``string`` .. rubric:: Examples :: # print "\t----\t map Ex 1 \t----" 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 # """ pass
[docs] def maprec(self, v='all'): r""" 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): all all of the following units (not constants): also the default Prefix known decimal prefixes SI known SI units Customary a set of customary units known to programs User units defined by the user .. rubric:: Parameters - ``v (string='all')`` - type of information to list - coded string .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t maprec Ex 1 \t----" 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 # """ pass
[docs] def fits(self): r""" fits defines some unit names used in reading and writing FITS files. """ pass
[docs] def angle(self, v='', prec=0, form='', showform=False): r""" 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: clean delete leading/trailing superfluous separators no_d do not show degrees part no_dm do not show degrees and minutes part dig2 show only 2 digits of degrees in angle format time show as time (hh:mm:ss.ttt) rather than as angle If a multi-dimensional value is given for the value :math:`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 *showform* is :math:`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 ’,’. .. rubric:: Parameters - ``v (variant='')`` - angle quantity value to output - ``prec (int=0)`` - number of digits shown - ``form (stringVec='')`` - formatting information in coded string array - ``showform (bool=False)`` - show square brackets and separating , .. rubric:: Returns ``stringVec`` .. rubric:: Examples :: # print "\t----\t angle Ex 1 \t----" 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 # """ pass
[docs] def time(self, v='', prec=0, form='', showform=False): r""" 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: clean delete leading/trailing superfluous separators no_d do not show hours part no_dm do not show hours and minutes part ymd include a date as yyyy/mm/dd (date is by default not shown) dmy include a date as ddMMMyyyy (date is by default not shown) mjd include a date as Modified Julian Day (date is by default not shown) fits include a date and show time in FITS format: le from OS angle show in angle (dd.mm.ss.ttt) rather than time format day prefix day-of-week to output local show local time rather than UTC (add timezone offset) no_time suppress printing of time part If a multi-dimensional value is given for the value :math:`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 *showform* is :math:`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 ’,’. .. rubric:: Parameters - ``v (variant='')`` - time quantity value to output - ``prec (int=0)`` - number of digits shown - ``form (stringVec='')`` - formatting information in coded string array - ``showform (bool=False)`` - show square brackets and separating , .. rubric:: Returns ``stringVec`` .. rubric:: Examples :: # print "\t----\t time Ex 1 \t----" 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 # """ pass
[docs] def add(self, v='', a='0'): r""" add adds two quantities .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t add Ex 1 \t----" print qa.add('5m', '2yd') #{'value': 6.8288000000000002, 'unit': 'm'} # """ pass
[docs] def sub(self, v='', a='0'): r""" sub subtracts two quantities .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t sub Ex 1 \t----" print qa.sub('5m', '2yd') #{'value': 3.1712000000000002, 'unit': 'm'} # """ pass
[docs] def mul(self, v='', a='1'): r""" mul multiplies two quantities .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='1')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t mul Ex 1 \t----" print qa.mul('5m', '3s') #{'value': 15.0, 'unit': 'm.s'} # """ pass
[docs] def div(self, v='', a='1'): r""" div divides two quantities .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='1')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t div Ex 1 \t----" print qa.div('5m', '3s') #{'value': 1.6666666666666667, 'unit': 'm/(s)'} # """ pass
[docs] def neg(self, v='1'): r""" neg negates a quantity .. rubric:: Parameters - ``v (variant='1')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t neg Ex 1 \t----" print qa.neg('5m') #{'value': -5.0, 'unit': 'm'} # """ pass
[docs] def norm(self, v='', a=-0.5): r""" norm normalise angles in interval of :math:`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 :math:`2\pi` .. rubric:: Parameters - ``v (variant='')`` - angle quantity - ``a (double=-0.5)`` - lower interval boundary .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t norm Ex 1 \t----" 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'} # """ pass
[docs] def le(self, v='', a='0'): r""" le compares two quantities for less than or equal. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t le Ex 1 \t----" print qa.le('5m', '2yd') #False # """ pass
[docs] def lt(self, v='', a='0'): r""" lt compares two quantities for less than. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t lt Ex 1 \t----" print qa.lt('5m', '2yd') #False # """ pass
[docs] def eq(self, v='', a='0'): r""" eq compares two quantities for equality. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t eq Ex 1 \t----" print qa.eq('5m', '2yd') #False # """ pass
[docs] def ne(self, v='', a='0'): r""" ne compares two quantities for non equality. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t ne Ex 1 \t----" print qa.ne('5m', '2yd') #True # """ pass
[docs] def gt(self, v='', a='0'): r""" gt compares two quantities for greater than. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t gt Ex 1 \t----" print qa.gt('5m', '2yd') #True # """ pass
[docs] def ge(self, v='', a='0'): r""" ge compares two quantities for greater than or equal. .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='0')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t ge Ex 1 \t----" print qa.ge('5m', '2yd') #True # """ pass
[docs] def sin(self, v=''): r""" sin gives sine of angle quantity .. rubric:: Parameters - ``v (variant='')`` - angle quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t sin Ex 1 \t----" print qa.sin('7deg') #{'value': 0.12186934340514748, 'unit': ''} # """ pass
[docs] def cos(self, v=''): r""" cos gives cosine of angle quantity .. rubric:: Parameters - ``v (variant='')`` - angle quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t cos Ex 1 \t----" print qa.cos('7deg') #{'value': 0.99254615164132198, 'unit': ''} # """ pass
[docs] def tan(self, v=''): r""" tan gives tangent of angle quantity .. rubric:: Parameters - ``v (variant='')`` - angle quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t tan Ex 1 \t----" print qa.tan('7deg') #{'value': 0.1227845609029046, 'unit': ''} # """ pass
[docs] def asin(self, v=''): r""" asin gives arcsine of non-dimensioned quantity .. rubric:: Parameters - ``v (variant='')`` - non-dimensioned quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t asin Ex 1 \t----" print qa.convert(qa.asin(qa.sin('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # """ pass
[docs] def acos(self, v=''): r""" acos gives arccosine of non-dimensioned quantity .. rubric:: Parameters - ``v (variant='')`` - non-dimensioned quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t acos Ex 1 \t----" print qa.convert(qa.acos(qa.cos('7deg')), 'deg') #{'value': 7.0000000000000249, 'unit': 'deg'} # """ pass
[docs] def atan(self, v=''): r""" atan gives arctangent of non-dimensioned quantity .. rubric:: Parameters - ``v (variant='')`` - non-dimensioned quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t atan Ex 1 \t----" print qa.convert(qa.atan(qa.tan('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # """ pass
[docs] def atan2(self, v='', a=''): r""" atan gives arctangent of two non-dimensioned quantity .. rubric:: Parameters - ``v (variant='')`` - non-dimensioned quantity - ``a (variant='')`` - non-dimensioned quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t atan2 Ex 1 \t----" print qa.convert(qa.atan2(qa.sin('7deg'), qa.cos('7deg')), 'deg') #{'value': 7.0, 'unit': 'deg'} # """ pass
[docs] def abs(self, v=''): r""" abs gives absolute value of quantity .. rubric:: Parameters - ``v (variant='')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t abs Ex 1 \t----" print qa.abs('-5km/s') #{'value': 5.0, 'unit': 'km/s'} # """ pass
[docs] def ceil(self, v=''): r""" ceil gives ceiling value of quantity .. rubric:: Parameters - ``v (variant='')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t ceil Ex 1 \t----" print qa.ceil('5.1AU') #{'value': 6.0, 'unit': 'AU'} # """ pass
[docs] def floor(self, v=''): r""" floor gives flooring value of quantity .. rubric:: Parameters - ``v (variant='')`` - value .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t floor Ex 1 \t----" print qa.floor('-5.1AU') #{'value': -6.0, 'unit': 'AU'} # """ pass
[docs] def log(self, v=''): r""" log gives natural logarithm of dimensionless quantity .. rubric:: Parameters - ``v (variant='')`` - dimensionless quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t log Ex 1 \t----" print qa.log('2') #{'value': 0.69314718055994529, 'unit': ''} # """ pass
[docs] def log10(self, v=''): r""" log10 gives logarithm of dimensionless quantity .. rubric:: Parameters - ``v (variant='')`` - dimensionless quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t log10 Ex 1 \t----" print qa.log10('2') #{'value': 0.3010299956639812, 'unit': ''} # """ pass
[docs] def exp(self, v=''): r""" exp gives exponential value of dimensionless quantity .. rubric:: Parameters - ``v (variant='')`` - dimensionless quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t exp Ex 1 \t----" 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' # """ pass
[docs] def sqrt(self, v=''): r""" sqrt gives square root of quantity with only even powered dimensions .. rubric:: Parameters - ``v (variant='')`` - dimensionless quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t sqrt Ex 1 \t----" 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 # """ pass
[docs] def compare(self, v='', a=''): r""" compare compares the dimensionality of units of two qauntities .. rubric:: Parameters - ``v (variant='')`` - value - ``a (variant='')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t compare Ex 1 \t----" print qa.compare('5yd/a', '6m/s') # equal dimensions #True print qa.compare('5yd', '5s') # unequal dimensions #False # """ pass
[docs] def check(self, v=''): r""" check checks if the argument has a properly defined unit string .. rubric:: Parameters - ``v (string='')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t check Ex 1 \t----" print qa.check('5AE/Jy.pc5/s') #True print qa.check('7MYs') #False # """ pass
[docs] def checkfreq(self, cm=''): r""" checkfreq checks if the argument has a properly defined frequency interpretable unit string .. rubric:: Parameters - ``cm (variant='')`` - value .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t checkfreq Ex 1 \t----" print qa.checkfreq('5GHz') #True print qa.checkfreq('5cm') #True print qa.checkfreq('5cm/s2') #False # """ pass
[docs] def pow(self, v='', a=1): r""" pow raises a quantity to an integer power .. rubric:: Parameters - ``v (variant='')`` - value - ``a (int=1)`` - power .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t pow Ex 1 \t----" print qa.pow('7.2km/s', -3) #{'value': 0.0026791838134430724, 'unit': '(km/s)-3'} # """ pass
[docs] def constants(self, v='pi'): r""" 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. const2̂ 0.000295912 AU3/d2/S0 .. rubric:: Parameters - ``v (string='pi')`` - name .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t constants Ex 1 \t----" print qa.constants() #{'unit': '', 'value': 3.1415926535897931} # """ pass
[docs] def isangle(self, v=''): r""" isangle checks if the argument is a valid angle/time quantity. .. rubric:: Parameters - ``v (variant='')`` - angle/time quantity .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t isangle Ex 1 \t----" print qa.isangle(qa.constants('pi')) #False # """ pass
[docs] def totime(self, v=''): r""" totime converts an angle quantity (or a time) to a time quantity .. rubric:: Parameters - ``v (variant='')`` - angle/time quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t totime Ex 1 \t----" print qa.totime('2d5m') #{'value': 0.0057870370370370376, 'unit': 'd'} # """ pass
[docs] def toangle(self, v=''): r""" toangle converts a time quantity (or an angle) to an angle quantity .. rubric:: Parameters - ``v (variant='')`` - angle/time quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t toangle Ex 1 \t----" print qa.toangle('5h30m12.6') #{'value': 82.552499999999995, 'unit': 'deg'} # """ pass
[docs] def splitdate(self, v=''): r""" 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 *s* field which is a double float. See the example for the fields returned. .. rubric:: Parameters - ``v (variant='')`` - angle/time quantity .. rubric:: Returns ``record`` .. rubric:: Examples :: # print "\t----\t splitdate Ex 1 \t----" 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} # """ pass
[docs] def tos(self, v='', prec=9): r""" tos converts a quantity to a string with the precision defined with the *setformat(’prec’)* (which defaults to 9). If the optional *prec* argument is set to an integer value greater than 1, that precision is used in the conversion .. rubric:: Parameters - ``v (variant='')`` - value - ``prec (int=9)`` - convert precision of value .. rubric:: Returns ``string`` .. rubric:: Examples :: # print "\t----\t tos Ex 1 \t----" 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 # """ pass
[docs] def type(self): r""" type will return the tool name. """ pass
[docs] def done(self, kill=False): r""" Currently, this method is an NOP. .. rubric:: Parameters - ``kill (bool=False)`` - force kill of the default tool (ignored) .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t done Ex 1 \t----" print qa.done() #True print qa.done() #True print qa.done(kill=T) #True # """ pass
[docs] def unit(self, v='', unitname='', keepshape=False): r""" unit makes a quantity from a string, or from a value and a string. Note that unit is a synonym for quantity (see description and example there). .. rubric:: Parameters - ``v (variant='')`` - ``unitname (string='')`` - ``keepshape (bool=False)`` .. rubric:: Returns ``record`` """ pass
[docs] def isquantity(self, v=''): r""" Checks if the operand is a correct quantity .. rubric:: Parameters - ``v (variant='')`` - value to be tested .. rubric:: Returns ``bool`` .. rubric:: Examples :: # print "\t----\t isQuantity Ex 1 \t----" 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 # """ pass
[docs] def setformat(self, t='', v='F'): r""" set format for output of numbers. (NOT IMPLEMENTED YET!) .. rubric:: Parameters - ``t (string='')`` - type -coded string indicating which format parameter to set - ``v (string='F')`` - format parameter value - numeric or coded string, depending on format type to be set .. rubric:: Returns ``bool`` """ pass
[docs] def getformat(self, t=''): r""" 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. .. rubric:: Parameters - ``t (string='')`` - type - coded string .. rubric:: Returns ``string`` .. rubric:: Examples :: # print "\t----\t getformat Ex 1 \t----" 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 # """ pass
[docs] def formxxx(self, v='', format='dms', prec=2): r""" 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(). .. rubric:: Parameters - ``v (variant='')`` - value to be converted - ``format (string='dms')`` - xxx can be hms, dms, deg, rad or +deg - ``prec (int=2)`` - digits in fractional part of output string for dms,hms .. rubric:: Returns ``string`` .. rubric:: Examples :: # print "\t----\t formxxx Ex 1 \t----" #qa.setformat('freq','cm') #T #qa.formxxx('freq',qa.quantity('5GHz')) #form_xxx NOT IMPLEMENTED YET! #5.99584916 cm print "Last example, exiting! ..." exit() # """ pass