NRAO Home > CASA > CASA Toolkit Reference Manual
quanta.tos - Function

1.5.1 convert quantity to string


Description

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

Arguments





Inputs

v

value

allowed:

any

Default:

variant

prec

convert precision of value

allowed:

int

Default:

9

Returns
string

Example

 
 
"""  
#  
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  
#  
"""  
 

__________________________________________________________________


More information about CASA may be found at the CASA web page

Copyright 2016 Associated Universities Inc., Washington, D.C.

This code is available under the terms of the GNU General Public Lincense


Home | Contact Us | Directories | Site Map | Help | Privacy Policy | Search