Coverage for /wheeldirectory/casa-6.7.0-12-py3.10.el8/lib/py/lib/python3.10/site-packages/casatools/__casac__/quanta.py: 54%

206 statements  

« prev     ^ index     » next       coverage.py v7.6.4, created at 2024-10-31 18:48 +0000

1# This file was automatically generated by SWIG (http://www.swig.org). 

2# Version 3.0.12 

3# 

4# Do not make changes to this file unless you know what you are doing--modify 

5# the SWIG interface file instead. 

6 

7from sys import version_info as _swig_python_version_info 

8if _swig_python_version_info >= (2, 7, 0): 

9 def swig_import_helper(): 

10 import importlib 

11 pkg = __name__.rpartition('.')[0] 

12 mname = '.'.join((pkg, '_quanta')).lstrip('.') 

13 try: 

14 return importlib.import_module(mname) 

15 except ImportError: 

16 return importlib.import_module('_quanta') 

17 _quanta = swig_import_helper() 

18 del swig_import_helper 

19elif _swig_python_version_info >= (2, 6, 0): 

20 def swig_import_helper(): 

21 from os.path import dirname 

22 import imp 

23 fp = None 

24 try: 

25 fp, pathname, description = imp.find_module('_quanta', [dirname(__file__)]) 

26 except ImportError: 

27 import _quanta 

28 return _quanta 

29 try: 

30 _mod = imp.load_module('_quanta', fp, pathname, description) 

31 finally: 

32 if fp is not None: 

33 fp.close() 

34 return _mod 

35 _quanta = swig_import_helper() 

36 del swig_import_helper 

37else: 

38 import _quanta 

39del _swig_python_version_info 

40 

41try: 

42 _swig_property = property 

43except NameError: 

44 pass # Python < 2.2 doesn't have 'property'. 

45 

46try: 

47 import builtins as __builtin__ 

48except ImportError: 

49 import __builtin__ 

50 

51def _swig_setattr_nondynamic(self, class_type, name, value, static=1): 

52 if (name == "thisown"): 

53 return self.this.own(value) 

54 if (name == "this"): 

55 if type(value).__name__ == 'SwigPyObject': 

56 self.__dict__[name] = value 

57 return 

58 method = class_type.__swig_setmethods__.get(name, None) 

59 if method: 

60 return method(self, value) 

61 if (not static): 

62 if _newclass: 

63 object.__setattr__(self, name, value) 

64 else: 

65 self.__dict__[name] = value 

66 else: 

67 raise AttributeError("You cannot add attributes to %s" % self) 

68 

69 

70def _swig_setattr(self, class_type, name, value): 

71 return _swig_setattr_nondynamic(self, class_type, name, value, 0) 

72 

73 

74def _swig_getattr(self, class_type, name): 

75 if (name == "thisown"): 

76 return self.this.own() 

77 method = class_type.__swig_getmethods__.get(name, None) 

78 if method: 

79 return method(self) 

80 raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name)) 

81 

82 

83def _swig_repr(self): 

84 try: 

85 strthis = "proxy of " + self.this.__repr__() 

86 except __builtin__.Exception: 

87 strthis = "" 

88 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 

89 

90try: 

91 _object = object 

92 _newclass = 1 

93except __builtin__.Exception: 

94 class _object: 

95 pass 

96 _newclass = 0 

97 

98class quanta(_object): 

99 """Proxy of C++ casac::quanta class.""" 

100 

101 __swig_setmethods__ = {} 

102 __setattr__ = lambda self, name, value: _swig_setattr(self, quanta, name, value) 

103 __swig_getmethods__ = {} 

104 __getattr__ = lambda self, name: _swig_getattr(self, quanta, name) 

105 __repr__ = _swig_repr 

106 

107 def __init__(self): 

108 """__init__(self) -> quanta""" 

109 this = _quanta.new_quanta() 

110 try: 

111 self.this.append(this) 

112 except __builtin__.Exception: 

113 self.this = this 

114 

115 def convertfreq(self, *args, **kwargs): 

116 """ 

117 convertfreq(self, _v, _outunit) -> record * 

118 

119 

120 

121 Summary: 

122 convert a frequency quantity to another unit 

123 

124 Description: 

125 

126 

127 convertfreq converts a frequency quantity to another unit. 

128 

129 Input Parameters: 

130 v quantity to convert 

131 outunit unit to convert to 

132 

133 Example: 

134 

135 

136 # 

137 print 't----t convertfreq Ex 1 t----' 

138 print qa.convertfreq('5GHz','cm') 

139 #{'value': 5.9958491599999997, 'unit': 'cm'} 

140 print qa.convertfreq('5cm','GHz') 

141 #{'value': 5.9958491599999997, 'unit': 'GHz'} 

142 # 

143 

144 

145 -------------------------------------------------------------------------------- 

146 

147 """ 

148 return _quanta.quanta_convertfreq(self, *args, **kwargs) 

149 

150 

151 def convertdop(self, *args, **kwargs): 

152 """ 

153 convertdop(self, _v, _outunit) -> record * 

154 

155 

156 

157 Summary: 

158 convert a doppler velocity quantity to another unit 

159 

160 Description: 

161 

162 

163 convertfreq converts a velocity quantity to another unit. Units are either 

164 velocity or dimensionless. 

165 

166 Input Parameters: 

167 v quantity to convert 

168 outunit unit to convert to 

169 

170 Example: 

171 

172 

173 # 

174 print 't----t convertdop Ex 1 t----' 

175 print qa.convertdop('1','km/s') 

176 #{'value': 299792.45799999998, 'unit': 'km/s'} 

177 print qa.convertdop('10km/s','1') 

178 #{'value': 3.3356409519815205e-05, 'unit': '1'} 

179 # 

180 

181 

182 -------------------------------------------------------------------------------- 

183 

184 """ 

185 return _quanta.quanta_convertdop(self, *args, **kwargs) 

186 

187 

188 def quantity(self, *args, **kwargs): 

189 """ 

190 quantity(self, _v, _unitname, _keepshape) -> record * 

191 

192 

193 

194 Summary: 

195 make a quantity from a string or from a numeric value and a unit string 

196 

197 Description: 

198 

199 

200 quantity makes a quantity from a string, or from a value and a 

201 string. Note that a function unit exists which is a synonym for 

202 quantity. If only a string is given, it can be a scalar string. 

203 The result will be a scalar quantity. 

204 

205 

206 If a numeric value and a unit string 

207 are given, the numeric value can be any numeric type, and can also be 

208 a vector of numeric values. print qa.map() to get a list of recognized units. 

209 'd' is usually days, but can be degrees (see example). 

210 

211 The keepshape input parameter is only relevant if v is a multi-dimensional array. 

212 In this case, if true, the output value array will have the same shape as v. If false, 

213 a one-dimensional array is returned with length equal to the number of elements in 

214 v. The default value is false in order to preserve backward compatibility with 

215 previous versions. 

216 

217 Input Parameters: 

218 v quantity or numeric or string to convert to quantity 

219 unitname unit string if v numeric 

220 keepshape Only used if input parameter v is a multi-dimensional array. Output array will have the same shape as v. 

221 

222 Example: 

223 

224 

225 # 

226 print 't----t quantity Ex 1 t----' 

227 tu = qa.quantity('1Jy')# make quantity 

228 print tu 

229 #{'value': 1.0, 'unit': 'Jy'} 

230 print qa.quantity(tu)# also accepts a quantity 

231 #{'value': 1.0, 'unit': 'Jy'} 

232 tu = qa.unit('1Jy')# make quantity with synonym 

233 print tu 

234 #{'value': 1.0, 'unit': 'Jy'} 

235 print qa.quantity(-1.3, 'Jy')# make quantity with separate value 

236 #{'value': -1.3, 'unit': 'Jy'} 

237 q1 = qa.quantity([8.57132661e+09, 1.71426532e+10], 'km/s') # Composite unit 

238 print q1 

239 #{'value': array([ 8.57132661e+09, 1.71426532e+10]), 'unit': 'km/s'} 

240 q = qa.quantity('5d'); print q 

241 #{'value': 5.0, 'unit': 'd'} # d = days 

242 q = qa.quantity('5 d'); print q 

243 #{'value': 5.0, 'unit': 'd'} # even if there's a space, as of 5/28/09 

244 q = qa.quantity('5d30m'); print q 

245 #{'value': 5.5, 'unit': 'deg'} # Unless followed by an m! 

246 qa.quantity('5d30s') # WRONG 

247 # {'unit': 'd30s', 'value': 5.0} # I told you... 

248 qa.quantity('5d0m30s') # OK 

249 # {'unit': 'deg', 'value': 5.0083333333333337} 

250 

251 

252 -------------------------------------------------------------------------------- 

253 

254 """ 

255 return _quanta.quanta_quantity(self, *args, **kwargs) 

256 

257 

258 def getvalue(self, *args, **kwargs): 

259 """ 

260 getvalue(self, _v) -> std::vector< double > 

261 

262 

263 

264 Summary: 

265 get the internal value of a quantity 

266 

267 Description: 

268 

269 

270 getvalue returns the internal value of a quantity. It also can handle a 1-D 

271 array of quantities, but multi-dimensional arrays are not supported. 

272 

273 Input Parameters: 

274 v quantity 

275 

276 Example: 

277 

278 

279 # 

280 print 't----t getvalue Ex 1 t----' 

281 tu = qa.quantity(-1.3, 'Jy') # make quantity 

282 print tu 

283 #{'value': -1.3, 'unit': 'Jy'} 

284 print qa.getvalue(tu) 

285 #-1.3 

286 print qa.getunit(tu) 

287 #Jy 

288 a = qa.quantity([3,5],'cm') 

289 print a 

290 #{'value': array([ 3., 5.]), 'unit': 'cm'} 

291 print qa.getvalue(a) 

292 #[3.0, 5.0] 

293 # 

294 

295 

296 -------------------------------------------------------------------------------- 

297 

298 """ 

299 return _quanta.quanta_getvalue(self, *args, **kwargs) 

300 

301 

302 def getunit(self, *args, **kwargs): 

303 """ 

304 getunit(self, _v) -> string 

305 

306 

307 

308 Summary: 

309 get the internal unit of a quantity 

310 

311 Description: 

312 

313 

314 getunit returns the internal unit string of a quantity. Note that 1-D arrays 

315 are supported, but multi-dimensional arrays are not. 

316 

317 Input Parameters: 

318 v quantity 

319 

320 Example: 

321 

322 

323 # 

324 print 't----t getunit Ex 1 t----' 

325 tu = qa.quantity(-1.3, 'Jy') # make quantity 

326 print tu 

327 #{'value': -1.3, 'unit': 'Jy'} 

328 print qa.getvalue(tu) 

329 #-1.3 

330 print qa.getunit(tu) 

331 #Jy 

332 # 

333 

334 

335 -------------------------------------------------------------------------------- 

336 

337 """ 

338 return _quanta.quanta_getunit(self, *args, **kwargs) 

339 

340 

341 def canonical(self, *args, **kwargs): 

342 """ 

343 canonical(self, _v) -> record * 

344 

345 

346 

347 Summary: 

348 get canonical value of quantity 

349 

350 Description: 

351 

352 

353 canonical (with alias canon) gets the canonical value of a quantity 

354 

355 Input Parameters: 

356 v value to convert 

357 

358 Example: 

359 

360 

361 # 

362 print 't----t canonical Ex 1 t----' 

363 print qa.canonical('1Jy')# canonical value of a string 

364 #{'value': 1e-26, 'unit': 'kg.s-2'} 

365 print qa.canon(qa.quantity('1Jy'))# canonical value of a unit 

366 #{'value': 1e-26, 'unit': 'kg.s-2'} 

367 # 

368 

369 

370 -------------------------------------------------------------------------------- 

371 

372 """ 

373 return _quanta.quanta_canonical(self, *args, **kwargs) 

374 

375 

376 def canon(self, *args, **kwargs): 

377 """ 

378 canon(self, _v) -> record * 

379 

380 

381 

382 Summary: 

383 get canonical value of quantity 

384 

385 Description: 

386 

387 

388 canon gets the canonical value of a quantity 

389 

390 Input Parameters: 

391 v value to convert 

392 

393 Example: 

394 

395 

396 # 

397 print 't----t canon Ex 1 t----' 

398 print qa.canon('1Jy') # canonical value of a string 

399 #{'value': 1e-26, 'unit': 'kg.s-2'} 

400 print qa.canonical(qa.quantity('1Jy'))# canonical value of a unit 

401 #{'value': 1e-26, 'unit': 'kg.s-2'} 

402 # 

403 

404 

405 -------------------------------------------------------------------------------- 

406 

407 """ 

408 return _quanta.quanta_canon(self, *args, **kwargs) 

409 

410 

411 def convert(self, *args, **kwargs): 

412 """ 

413 convert(self, _v, _outunit) -> record * 

414 

415 

416 

417 Summary: 

418 convert a quantity to another unit 

419 

420 Description: 

421 

422 

423 convert converts a quantity to another unit. If no output unit given, 

424 conversion is to canonical units 

425 

426 Input Parameters: 

427 v quantity to convert 

428 outunit unit to convert to 

429 

430 Example: 

431 

432 

433 # 

434 print 't----t convert Ex 1 t----' 

435 tu = qa.quantity('5Mm/s')# specify a quantity 

436 print tu 

437 #{'value': 5.0, 'unit': 'Mm/s'} 

438 print qa.convert(tu, 'pc/a')# convert it to parsec per year 

439 #{'value': 0.0051135608266237404, 'unit': 'pc/a'} 

440 print qa.convert(tu)# convert to canonical units 

441 #{'value': 5000000.0, 'unit': 'm.s-1'} 

442 # 

443 

444 

445 -------------------------------------------------------------------------------- 

446 

447 """ 

448 return _quanta.quanta_convert(self, *args, **kwargs) 

449 

450 

451 def define(self, *args, **kwargs): 

452 """ 

453 define(self, _name, _v) -> bool 

454 

455 

456 

457 Summary: 

458 define a new unit name 

459 

460 Description: 

461 

462 

463 define defines the name and value of a user defined unit 

464 

465 Input Parameters: 

466 name name of unit to define 

467 v quantity value of new unit 

468 

469 Example: 

470 

471 

472 # 

473 print 't----t define Ex 1 t----' 

474 print qa.define('JY','1Jy')# your misspelling 

475 #True 

476 print qa.define('VLAunit', '0.898 JY')# a special unit using it 

477 #True 

478 print qa.quantity('5 VLAunit') # check its use 

479 #{'value': 5.0, 'unit': 'VLAunit'} 

480 print qa.convert('5 VLAunit','Jy') 

481 #{'value': 4.4900000000000002, 'unit': 'Jy'} 

482 # 

483 

484 

485 -------------------------------------------------------------------------------- 

486 

487 """ 

488 return _quanta.quanta_define(self, *args, **kwargs) 

489 

490 

491 def map(self, *args, **kwargs): 

492 """ 

493 map(self, _v) -> string 

494 

495 

496 

497 Summary: 

498 list known unit names and constants 

499 

500 Description: 

501 

502 

503 map lists the known mapping of units and constants. It has a single argument, 

504 which can be a coded string (no-case, minimax match): 

505 begin{description} 

506 item[all] all of the following units (not constants): also the default 

507 item[Prefix] known decimal prefixes 

508 item[SI] known SI units 

509 item[Customary] a set of customary units known to programs 

510 item[User] units defined by the user 

511 item[Constants] known constants (note: only 'const', 'Const', 'constants' 

512 and 'Constants' recognised). 

513 end{description} 

514 

515 Input Parameters: 

516 v type of information to list - coded string 

517 

518 Example: 

519 

520 

521 # 

522 print 't----t map Ex 1 t----' 

523 print qa.map('pre')# list decimal prefixes 

524 # == Prefix ==== 20 ==== 

525 # E (exa) 1e+18 

526 # G (giga) 1000000000 

527 # M (mega) 1000000 

528 # P (peta) 1e+15 

529 # T (tera) 1e+12 

530 # Y (yotta) 1e+24 

531 # Z (zetta) 1e+21 

532 # a (atto) 1e-18 

533 # c (centi) 0.01 

534 # d (deci) 0.1 

535 # da (deka) 10 

536 # f (femto) 1e-15 

537 # h (hecto) 100 

538 # k (kilo) 1000 

539 # m (milli) 0.001 

540 # n (nano) 1e-09 

541 # p (pico) 1e-12 

542 # u (micro) 1e-06 

543 # y (yocto) 1e-24 

544 # z (zepto) 1e-21 

545 print qa.map('Constants')# list known constants 

546 # == Constants ==== 

547 # pi 3.14.. 3.14159 

548 # ee 2.71.. 2.71828 

549 # c light vel. 2.99792e+08 m/s 

550 # G grav. const 6.67259e-11 N.m2/kg2 

551 # h Planck const 6.62608e-34 J.s 

552 # HI HI line 1420.41 MHz 

553 # R gas const 8.31451 J/K/mol 

554 # NA Avogadro # 6.02214e+23 mol-1 

555 # e electron charge 1.60218e-19 C 

556 # mp proton mass 1.67262e-27 kg 

557 # mp_me mp/me 1836.15 

558 # mu0 permeability vac. 1.25664e-06 H/m 

559 # eps0 permittivity vac. 1.60218e-19 C 

560 # k Boltzmann const 1.38066e-23 J/K 

561 # F Faraday const 96485.3 C/mol 

562 # me electron mass 9.10939e-31 kg 

563 # re electron radius 2.8179e-15 m 

564 # a0 Bohr's radius 5.2918e-11 m 

565 # R0 solar radius 6.9599e+08 m 

566 # k2 IAU grav. const^2 0.000295912 AU3/d2/S0 

567 # 

568 

569 

570 -------------------------------------------------------------------------------- 

571 

572 """ 

573 return _quanta.quanta_map(self, *args, **kwargs) 

574 

575 

576 def maprec(self, *args, **kwargs): 

577 """ 

578 maprec(self, _v) -> record * 

579 

580 

581 

582 Summary: 

583 create record containing list of known unit names and constants 

584 

585 Description: 

586 

587 

588 maprec returns a record with the known mapping of units and constants. It has a single argument, 

589 which can be a coded string (no-case, minimax match): 

590 begin{description} 

591 item[all] all of the following units (not constants): also the default 

592 item[Prefix] known decimal prefixes 

593 item[SI] known SI units 

594 item[Customary] a set of customary units known to programs 

595 item[User] units defined by the user 

596 end{description} 

597 

598 Input Parameters: 

599 v type of information to list - coded string 

600 

601 Example: 

602 

603 

604 # 

605 print 't----t maprec Ex 1 t----' 

606 p = qa.maprec('pre')# list decimal prefixes 

607 print p['Prefix_G'] 

608 # G (giga) 1000000000 

609 s = qa.maprec('SI') # list SI units 

610 print s['SI_Jy'] 

611 #Jy (jansky) 1e-26 kg.s-2 

612 # 

613 

614 

615 -------------------------------------------------------------------------------- 

616 

617 """ 

618 return _quanta.quanta_maprec(self, *args, **kwargs) 

619 

620 

621 def fits(self): 

622 """ 

623 fits(self) -> bool 

624 

625 

626 

627 Summary: 

628 define some FITS units 

629 

630 Description: 

631 

632 

633 fits defines some unit names used in reading and writing FITS files. 

634 

635 Example: 

636 

637 

638 # 

639 print 't----t fits Ex 1 t----' 

640 print qa.fits() 

641 #True 

642 print qa.map('user') 

643 # == User ==== 

644 # BEAM (dimensionless beam) 1 _ 

645 # DAYS (day) 86400 s 

646 # DEG (degree) 0.0174532925199 rad 

647 # DEGREES (degree) 0.0174532925199 rad 

648 # HZ (hertz) 1 s-1 

649 # JY (jansky) 1e-26 kg.s-2 

650 # KELVIN (kelvin) 1 K 

651 # KELVINS (kelvin) 1 K 

652 # KM (km) 1000 m 

653 # M (meter) 1 m 

654 # METERS (meter) 1 m 

655 # PASCAL (pascal) 1 m-1.kg.s-2 

656 # PIXEL (dimensionless pixel) 1 _ 

657 # S (second) 1 s 

658 # SEC (second) 1 s 

659 # SECONDS (second) 1 s 

660 # VOLTS (volt) 1 m2.kg.s-3.A-1 

661 # YEAR (year) 31557600 s 

662 # YEARS (year) 31557600 s 

663 # 

664 

665 

666 -------------------------------------------------------------------------------- 

667 

668 """ 

669 return _quanta.quanta_fits(self) 

670 

671 

672 def angle(self, *args, **kwargs): 

673 """ 

674 angle(self, _v, _prec, _form, _showform) -> std::vector< std::string > 

675 

676 

677 

678 Summary: 

679 show an angle as a formatted string 

680 

681 Description: 

682 

683 

684 angle converts an angle quantity to a formatted string. The formatting 

685 information is a precision (0 is default, 6 includes +-ddd.mm.ss) and a 

686 string array of codes (no-case, minimax match): 

687 Codes include: 

688 begin{description} 

689 item[clean] delete leading/trailing superfluous separators 

690 item[no_d] do not show degrees part 

691 item[no_dm] do not show degrees and minutes part 

692 item[dig2] show only 2 digits of degrees in angle format 

693 item[time] show as time (hh:mm:ss.ttt) rather than as angle 

694 end{description} 

695 If a multi-dimensional value is given for the value $v$, the returned value 

696 is a string vector of a length equal to last dimension. Each string has a 

697 number of fields equal to the number of elements in all earlier 

698 dimensions. If the {em showform} is $T$, each vector element is surrounded 

699 by a pair of square brackets if there is more than one entry, and fields are 

700 separated by a ','. 

701 

702 Input Parameters: 

703 v angle quantity value to output 

704 prec number of digits shown 

705 form formatting information in coded string array 

706 showform show square brackets and separating , 

707 

708 Example: 

709 

710 

711 # 

712 print 't----t angle Ex 1 t----' 

713 tu = qa.quantity('5.7.12.345678')# define an angle 

714 print tu 

715 #{'value': 5.1200960216666669, 'unit': 'deg'} 

716 print qa.angle(tu) # default output 

717 #+005.07.12 

718 print qa.angle(tu, prec=7)# 7 digits 

719 #+005.07.12.3 

720 print qa.angle(tu, prec=4)# 4 digits 

721 #+005.07. 

722 print qa.angle(tu, form=['tim','no_d'])# as time, no hours shown 

723 #:20:29 

724 # 

725 

726 

727 -------------------------------------------------------------------------------- 

728 

729 """ 

730 return _quanta.quanta_angle(self, *args, **kwargs) 

731 

732 

733 def time(self, *args, **kwargs): 

734 """ 

735 time(self, _v, _prec, _form, _showform) -> std::vector< std::string > 

736 

737 

738 

739 Summary: 

740 show a time (or date) as a formatted string 

741 

742 Description: 

743 

744 

745 time converts a time quantity to a formatted string. The formatting 

746 information is a precision (0 is default, 6 includes hh.mm.ss) and a 

747 string array of codes (no-case, minimax match): 

748 Codes include: 

749 begin{description} 

750 item[clean] delete leading/trailing superfluous separators 

751 item[no_d] do not show hours part 

752 item[no_dm] do not show hours and minutes part 

753 item[ymd] include a date as yyyy/mm/dd (date is by default not shown) 

754 item[dmy] include a date as ddMMMyyyy (date is by default not shown) 

755 item[mjd] include a date as Modified Julian Day (date is by default not shown) 

756 item[fits] include a date and show time in FITS format: le from OS 

757 item[angle] show in angle (dd.mm.ss.ttt) rather than time format 

758 item[day] prefix day-of-week to output 

759 item[local] show local time rather than UTC (add timezone offset) 

760 item[no_time] suppress printing of time part 

761 end{description} 

762 If a multi-dimensional value is given for the value $v$, the returned value 

763 is a string vector of a length equal to last dimension. Each string has a 

764 number of fields equal to the number of elements in all earlier 

765 dimensions. If the {em showform} is $T$, each vector element is surrounded 

766 by a pair of square brackets if there is more than one entry, and fields are 

767 separated by a ','. 

768 

769 Input Parameters: 

770 v time quantity value to output 

771 prec number of digits shown 

772 form formatting information in coded string array 

773 showform show square brackets and separating , 

774 

775 Example: 

776 

777 

778 # 

779 print 't----t time Ex 1 t----' 

780 tu = qa.quantity('today')# a time 

781 print tu 

782 #{'value': 54175.708981504627, 'unit': 'd'} 

783 print qa.time(tu)# default format 

784 #17:00:56 

785 print qa.time(tu,form='dmy') # show date 

786 #16-Mar-2007/17:00:56 

787 print qa.time(tu,form=['ymd','day'])# and day 

788 #Fri-2007/03/16/17:00:56 

789 print qa.time(tu,form='fits') # FITS format 

790 #2007-03-16T17:00:56 

791 print qa.time(tu,form=['fits','local']) # local FITS format 

792 #2007-03-16T10:00:56-07:00 

793 print qa.time(tu,form=['ymd','local']) # local time 

794 #2007/03/16/10:00:56 

795 # 

796 

797 

798 -------------------------------------------------------------------------------- 

799 

800 """ 

801 return _quanta.quanta_time(self, *args, **kwargs) 

802 

803 

804 def add(self, *args, **kwargs): 

805 """ 

806 add(self, _v, _a) -> record * 

807 

808 

809 

810 Summary: 

811 add quantities 

812 

813 Description: 

814 

815 

816 add adds two quantities 

817 

818 Input Parameters: 

819 v value 

820 a value 

821 

822 Example: 

823 

824 

825 # 

826 print 't----t add Ex 1 t----' 

827 print qa.add('5m', '2yd') 

828 #{'value': 6.8288000000000002, 'unit': 'm'} 

829 # 

830 

831 

832 -------------------------------------------------------------------------------- 

833 

834 """ 

835 return _quanta.quanta_add(self, *args, **kwargs) 

836 

837 

838 def sub(self, *args, **kwargs): 

839 """ 

840 sub(self, _v, _a) -> record * 

841 

842 

843 

844 Summary: 

845 subtract quantities 

846 

847 Description: 

848 

849 

850 sub subtracts two quantities 

851 

852 Input Parameters: 

853 v value 

854 a value 

855 

856 Example: 

857 

858 

859 # 

860 print 't----t sub Ex 1 t----' 

861 print qa.sub('5m', '2yd') 

862 #{'value': 3.1712000000000002, 'unit': 'm'} 

863 # 

864 

865 

866 -------------------------------------------------------------------------------- 

867 

868 """ 

869 return _quanta.quanta_sub(self, *args, **kwargs) 

870 

871 

872 def mul(self, *args, **kwargs): 

873 """ 

874 mul(self, _v, _a) -> record * 

875 

876 

877 

878 Summary: 

879 multiply quantities 

880 

881 Description: 

882 

883 

884 mul multiplies two quantities 

885 

886 Input Parameters: 

887 v value 

888 a value 

889 

890 Example: 

891 

892 

893 # 

894 print 't----t mul Ex 1 t----' 

895 print qa.mul('5m', '3s') 

896 #{'value': 15.0, 'unit': 'm.s'} 

897 # 

898 

899 

900 -------------------------------------------------------------------------------- 

901 

902 """ 

903 return _quanta.quanta_mul(self, *args, **kwargs) 

904 

905 

906 def div(self, *args, **kwargs): 

907 """ 

908 div(self, _v, _a) -> record * 

909 

910 

911 

912 Summary: 

913 divides quantities 

914 

915 Description: 

916 

917 

918 div divides two quantities 

919 

920 Input Parameters: 

921 v value 

922 a value 

923 

924 Example: 

925 

926 

927 # 

928 print 't----t div Ex 1 t----' 

929 print qa.div('5m', '3s') 

930 #{'value': 1.6666666666666667, 'unit': 'm/(s)'} 

931 # 

932 

933 

934 -------------------------------------------------------------------------------- 

935 

936 """ 

937 return _quanta.quanta_div(self, *args, **kwargs) 

938 

939 

940 def neg(self, *args, **kwargs): 

941 """ 

942 neg(self, _v) -> record * 

943 

944 

945 

946 Summary: 

947 negate quantities 

948 

949 Description: 

950 

951 

952 neg negates a quantity 

953 

954 Input Parameters: 

955 v value 

956 

957 Example: 

958 

959 

960 # 

961 print 't----t neg Ex 1 t----' 

962 print qa.neg('5m') 

963 #{'value': -5.0, 'unit': 'm'} 

964 # 

965 

966 

967 -------------------------------------------------------------------------------- 

968 

969 """ 

970 return _quanta.quanta_neg(self, *args, **kwargs) 

971 

972 

973 def norm(self, *args, **kwargs): 

974 """ 

975 norm(self, _v, _a) -> record * 

976 

977 

978 

979 Summary: 

980 normalise angle 

981 

982 Description: 

983 

984 

985 norm normalise angles in interval of $2pi$ radians. The default interval is 

986 from -0.5 to +0.5 of a full interval (i.e. from -180 to +180 degrees). The 

987 lower end of the interval can be set as a fraction of $2pi$ 

988 

989 Input Parameters: 

990 v angle quantity 

991 a lower interval boundary 

992 

993 Example: 

994 

995 

996 # 

997 print 't----t norm Ex 1 t----' 

998 print qa.norm('713deg')#default normalisation 

999 #{'value': -6.9999999999999716, 'unit': 'deg'} 

1000 print qa.norm('713deg', -2.5) # normalise to interval -900 - -540 deg 

1001 #{'value': -727.0, 'unit': 'deg'} 

1002 # 

1003 

1004 

1005 -------------------------------------------------------------------------------- 

1006 

1007 """ 

1008 return _quanta.quanta_norm(self, *args, **kwargs) 

1009 

1010 

1011 def le(self, *args, **kwargs): 

1012 """ 

1013 le(self, _v, _a) -> bool 

1014 

1015 

1016 

1017 Summary: 

1018 compare quantities 

1019 

1020 Description: 

1021 

1022 

1023 le compares two quantities for less than or equal. 

1024 

1025 Input Parameters: 

1026 v value 

1027 a value 

1028 

1029 Example: 

1030 

1031 

1032 # 

1033 print 't----t le Ex 1 t----' 

1034 print qa.le('5m', '2yd') 

1035 #False 

1036 # 

1037 

1038 

1039 -------------------------------------------------------------------------------- 

1040 

1041 """ 

1042 return _quanta.quanta_le(self, *args, **kwargs) 

1043 

1044 

1045 def lt(self, *args, **kwargs): 

1046 """ 

1047 lt(self, _v, _a) -> bool 

1048 

1049 

1050 

1051 Summary: 

1052 compare quantities 

1053 

1054 Description: 

1055 

1056 

1057 lt compares two quantities for less than. 

1058 

1059 Input Parameters: 

1060 v value 

1061 a value 

1062 

1063 Example: 

1064 

1065 

1066 # 

1067 print 't----t lt Ex 1 t----' 

1068 print qa.lt('5m', '2yd') 

1069 #False 

1070 # 

1071 

1072 

1073 -------------------------------------------------------------------------------- 

1074 

1075 """ 

1076 return _quanta.quanta_lt(self, *args, **kwargs) 

1077 

1078 

1079 def eq(self, *args, **kwargs): 

1080 """ 

1081 eq(self, _v, _a) -> bool 

1082 

1083 

1084 

1085 Summary: 

1086 compare quantities 

1087 

1088 Description: 

1089 

1090 

1091 eq compares two quantities for equality. 

1092 

1093 Input Parameters: 

1094 v value 

1095 a value 

1096 

1097 Example: 

1098 

1099 

1100 # 

1101 print 't----t eq Ex 1 t----' 

1102 print qa.eq('5m', '2yd') 

1103 #False 

1104 # 

1105 

1106 

1107 -------------------------------------------------------------------------------- 

1108 

1109 """ 

1110 return _quanta.quanta_eq(self, *args, **kwargs) 

1111 

1112 

1113 def ne(self, *args, **kwargs): 

1114 """ 

1115 ne(self, _v, _a) -> bool 

1116 

1117 

1118 

1119 Summary: 

1120 compare quantities 

1121 

1122 Description: 

1123 

1124 

1125 ne compares two quantities for non equality. 

1126 

1127 Input Parameters: 

1128 v value 

1129 a value 

1130 

1131 Example: 

1132 

1133 

1134 # 

1135 print 't----t ne Ex 1 t----' 

1136 print qa.ne('5m', '2yd') 

1137 #True 

1138 # 

1139 

1140 

1141 -------------------------------------------------------------------------------- 

1142 

1143 """ 

1144 return _quanta.quanta_ne(self, *args, **kwargs) 

1145 

1146 

1147 def gt(self, *args, **kwargs): 

1148 """ 

1149 gt(self, _v, _a) -> bool 

1150 

1151 

1152 

1153 Summary: 

1154 compare quantities 

1155 

1156 Description: 

1157 

1158 

1159 gt compares two quantities for greater than. 

1160 

1161 Input Parameters: 

1162 v value 

1163 a value 

1164 

1165 Example: 

1166 

1167 

1168 # 

1169 print 't----t gt Ex 1 t----' 

1170 print qa.gt('5m', '2yd') 

1171 #True 

1172 # 

1173 

1174 

1175 -------------------------------------------------------------------------------- 

1176 

1177 """ 

1178 return _quanta.quanta_gt(self, *args, **kwargs) 

1179 

1180 

1181 def ge(self, *args, **kwargs): 

1182 """ 

1183 ge(self, _v, _a) -> bool 

1184 

1185 

1186 

1187 Summary: 

1188 compare quantities 

1189 

1190 Description: 

1191 

1192 

1193 ge compares two quantities for greater than or equal. 

1194 

1195 Input Parameters: 

1196 v value 

1197 a value 

1198 

1199 Example: 

1200 

1201 

1202 # 

1203 print 't----t ge Ex 1 t----' 

1204 print qa.ge('5m', '2yd') 

1205 #True 

1206 # 

1207 

1208 

1209 -------------------------------------------------------------------------------- 

1210 

1211 """ 

1212 return _quanta.quanta_ge(self, *args, **kwargs) 

1213 

1214 

1215 def sin(self, *args, **kwargs): 

1216 """ 

1217 sin(self, _v) -> record * 

1218 

1219 

1220 

1221 Summary: 

1222 sine of quantity 

1223 

1224 Description: 

1225 

1226 

1227 sin gives sine of angle quantity 

1228 

1229 Input Parameters: 

1230 v angle quantity 

1231 

1232 Example: 

1233 

1234 

1235 # 

1236 print 't----t sin Ex 1 t----' 

1237 print qa.sin('7deg') 

1238 #{'value': 0.12186934340514748, 'unit': ''} 

1239 # 

1240 

1241 

1242 -------------------------------------------------------------------------------- 

1243 

1244 """ 

1245 return _quanta.quanta_sin(self, *args, **kwargs) 

1246 

1247 

1248 def cos(self, *args, **kwargs): 

1249 """ 

1250 cos(self, _v) -> record * 

1251 

1252 

1253 

1254 Summary: 

1255 cosine of quantity 

1256 

1257 Description: 

1258 

1259 

1260 cos gives cosine of angle quantity 

1261 

1262 Input Parameters: 

1263 v angle quantity 

1264 

1265 Example: 

1266 

1267 

1268 # 

1269 print 't----t cos Ex 1 t----' 

1270 print qa.cos('7deg') 

1271 #{'value': 0.99254615164132198, 'unit': ''} 

1272 # 

1273 

1274 

1275 -------------------------------------------------------------------------------- 

1276 

1277 """ 

1278 return _quanta.quanta_cos(self, *args, **kwargs) 

1279 

1280 

1281 def tan(self, *args, **kwargs): 

1282 """ 

1283 tan(self, _v) -> record * 

1284 

1285 

1286 

1287 Summary: 

1288 tangent of quantity 

1289 

1290 Description: 

1291 

1292 

1293 tan gives tangent of angle quantity 

1294 

1295 Input Parameters: 

1296 v angle quantity 

1297 

1298 Example: 

1299 

1300 

1301 # 

1302 print 't----t tan Ex 1 t----' 

1303 print qa.tan('7deg') 

1304 #{'value': 0.1227845609029046, 'unit': ''} 

1305 # 

1306 

1307 

1308 -------------------------------------------------------------------------------- 

1309 

1310 """ 

1311 return _quanta.quanta_tan(self, *args, **kwargs) 

1312 

1313 

1314 def asin(self, *args, **kwargs): 

1315 """ 

1316 asin(self, _v) -> record * 

1317 

1318 

1319 

1320 Summary: 

1321 arcsine of quantity 

1322 

1323 Description: 

1324 

1325 

1326 asin gives arcsine of non-dimensioned quantity 

1327 

1328 Input Parameters: 

1329 v non-dimensioned quantity 

1330 

1331 Example: 

1332 

1333 

1334 # 

1335 print 't----t asin Ex 1 t----' 

1336 print qa.convert(qa.asin(qa.sin('7deg')), 'deg') 

1337 #{'value': 7.0, 'unit': 'deg'} 

1338 # 

1339 

1340 

1341 -------------------------------------------------------------------------------- 

1342 

1343 """ 

1344 return _quanta.quanta_asin(self, *args, **kwargs) 

1345 

1346 

1347 def acos(self, *args, **kwargs): 

1348 """ 

1349 acos(self, _v) -> record * 

1350 

1351 

1352 

1353 Summary: 

1354 arccosine of quantity 

1355 

1356 Description: 

1357 

1358 

1359 acos gives arccosine of non-dimensioned quantity 

1360 

1361 Input Parameters: 

1362 v non-dimensioned quantity 

1363 

1364 Example: 

1365 

1366 

1367 # 

1368 print 't----t acos Ex 1 t----' 

1369 print qa.convert(qa.acos(qa.cos('7deg')), 'deg') 

1370 #{'value': 7.0000000000000249, 'unit': 'deg'} 

1371 # 

1372 

1373 

1374 -------------------------------------------------------------------------------- 

1375 

1376 """ 

1377 return _quanta.quanta_acos(self, *args, **kwargs) 

1378 

1379 

1380 def atan(self, *args, **kwargs): 

1381 """ 

1382 atan(self, _v) -> record * 

1383 

1384 

1385 

1386 Summary: 

1387 arctangent of quantity 

1388 

1389 Description: 

1390 

1391 

1392 atan gives arctangent of non-dimensioned quantity 

1393 

1394 Input Parameters: 

1395 v non-dimensioned quantity 

1396 

1397 Example: 

1398 

1399 

1400 # 

1401 print 't----t atan Ex 1 t----' 

1402 print qa.convert(qa.atan(qa.tan('7deg')), 'deg') 

1403 #{'value': 7.0, 'unit': 'deg'} 

1404 # 

1405 

1406 

1407 -------------------------------------------------------------------------------- 

1408 

1409 """ 

1410 return _quanta.quanta_atan(self, *args, **kwargs) 

1411 

1412 

1413 def atan2(self, *args, **kwargs): 

1414 """ 

1415 atan2(self, _v, _a) -> record * 

1416 

1417 

1418 

1419 Summary: 

1420 arctangent of two quantity 

1421 

1422 Description: 

1423 

1424 

1425 atan gives arctangent of two non-dimensioned quantity 

1426 

1427 Input Parameters: 

1428 v non-dimensioned quantity 

1429 a non-dimensioned quantity 

1430 

1431 Example: 

1432 

1433 

1434 # 

1435 print 't----t atan2 Ex 1 t----' 

1436 print qa.convert(qa.atan2(qa.sin('7deg'), qa.cos('7deg')), 'deg') 

1437 #{'value': 7.0, 'unit': 'deg'} 

1438 # 

1439 

1440 

1441 -------------------------------------------------------------------------------- 

1442 

1443 """ 

1444 return _quanta.quanta_atan2(self, *args, **kwargs) 

1445 

1446 

1447 def abs(self, *args, **kwargs): 

1448 """ 

1449 abs(self, _v) -> record * 

1450 

1451 

1452 

1453 Summary: 

1454 absolute value of quantity 

1455 

1456 Description: 

1457 

1458 

1459 abs gives absolute value of quantity 

1460 

1461 Input Parameters: 

1462 v value 

1463 

1464 Example: 

1465 

1466 

1467 # 

1468 print 't----t abs Ex 1 t----' 

1469 print qa.abs('-5km/s') 

1470 #{'value': 5.0, 'unit': 'km/s'} 

1471 # 

1472 

1473 

1474 -------------------------------------------------------------------------------- 

1475 

1476 """ 

1477 return _quanta.quanta_abs(self, *args, **kwargs) 

1478 

1479 

1480 def ceil(self, *args, **kwargs): 

1481 """ 

1482 ceil(self, _v) -> record * 

1483 

1484 

1485 

1486 Summary: 

1487 ceil value of quantity 

1488 

1489 Description: 

1490 

1491 

1492 ceil gives ceiling value of quantity 

1493 

1494 Input Parameters: 

1495 v value 

1496 

1497 Example: 

1498 

1499 

1500 # 

1501 print 't----t ceil Ex 1 t----' 

1502 print qa.ceil('5.1AU') 

1503 #{'value': 6.0, 'unit': 'AU'} 

1504 # 

1505 

1506 

1507 -------------------------------------------------------------------------------- 

1508 

1509 """ 

1510 return _quanta.quanta_ceil(self, *args, **kwargs) 

1511 

1512 

1513 def floor(self, *args, **kwargs): 

1514 """ 

1515 floor(self, _v) -> record * 

1516 

1517 

1518 

1519 Summary: 

1520 floor value of quantity 

1521 

1522 Description: 

1523 

1524 

1525 floor gives flooring value of quantity 

1526 

1527 Input Parameters: 

1528 v value 

1529 

1530 Example: 

1531 

1532 

1533 # 

1534 print 't----t floor Ex 1 t----' 

1535 print qa.floor('-5.1AU') 

1536 #{'value': -6.0, 'unit': 'AU'} 

1537 # 

1538 

1539 

1540 -------------------------------------------------------------------------------- 

1541 

1542 """ 

1543 return _quanta.quanta_floor(self, *args, **kwargs) 

1544 

1545 

1546 def log(self, *args, **kwargs): 

1547 """ 

1548 log(self, _v) -> record * 

1549 

1550 

1551 

1552 Summary: 

1553 logarithm of quantity 

1554 

1555 Description: 

1556 

1557 

1558 log gives natural logarithm of dimensionless quantity 

1559 

1560 Input Parameters: 

1561 v dimensionless quantity 

1562 

1563 Example: 

1564 

1565 

1566 # 

1567 print 't----t log Ex 1 t----' 

1568 print qa.log('2') 

1569 #{'value': 0.69314718055994529, 'unit': ''} 

1570 # 

1571 

1572 

1573 -------------------------------------------------------------------------------- 

1574 

1575 """ 

1576 return _quanta.quanta_log(self, *args, **kwargs) 

1577 

1578 

1579 def log10(self, *args, **kwargs): 

1580 """ 

1581 log10(self, _v) -> record * 

1582 

1583 

1584 

1585 Summary: 

1586 logarithm of quantity 

1587 

1588 Description: 

1589 

1590 

1591 log10 gives logarithm of dimensionless quantity 

1592 

1593 Input Parameters: 

1594 v dimensionless quantity 

1595 

1596 Example: 

1597 

1598 

1599 # 

1600 print 't----t log10 Ex 1 t----' 

1601 print qa.log10('2') 

1602 #{'value': 0.3010299956639812, 'unit': ''} 

1603 # 

1604 

1605 

1606 -------------------------------------------------------------------------------- 

1607 

1608 """ 

1609 return _quanta.quanta_log10(self, *args, **kwargs) 

1610 

1611 

1612 def exp(self, *args, **kwargs): 

1613 """ 

1614 exp(self, _v) -> record * 

1615 

1616 

1617 

1618 Summary: 

1619 exponential of quantity 

1620 

1621 Description: 

1622 

1623 

1624 exp gives exponential value of dimensionless quantity 

1625 

1626 Input Parameters: 

1627 v dimensionless quantity 

1628 

1629 Example: 

1630 

1631 

1632 # 

1633 print 't----t exp Ex 1 t----' 

1634 print qa.exp('2') 

1635 #{'value': 7.3890560989306504, 'unit': ''} 

1636 try: 

1637 print qa.exp('2m') 

1638 except Exception, e: 

1639 print 'Caught an expected exception', e 

1640 #Caught an expected exception Quantum::exp illegal unit type 'm' 

1641 # 

1642 

1643 

1644 -------------------------------------------------------------------------------- 

1645 

1646 """ 

1647 return _quanta.quanta_exp(self, *args, **kwargs) 

1648 

1649 

1650 def sqrt(self, *args, **kwargs): 

1651 """ 

1652 sqrt(self, _v) -> record * 

1653 

1654 

1655 

1656 Summary: 

1657 square root of quantity 

1658 

1659 Description: 

1660 

1661 

1662 sqrt gives square root of quantity with only even powered dimensions 

1663 

1664 Input Parameters: 

1665 v dimensionless quantity 

1666 

1667 Example: 

1668 

1669 

1670 # 

1671 print 't----t sqrt Ex 1 t----' 

1672 print qa.sqrt('2m2') 

1673 #{'value': 1.4142135623730951, 'unit': 'm'} 

1674 try: 

1675 print qa.sqrt('2s') 

1676 except Exception, e: 

1677 print 'Caught an expected exception', e 

1678 #Caught an expected exception UnitVal::UnitVal Illegal unit dimensions for root 

1679 # 

1680 

1681 

1682 -------------------------------------------------------------------------------- 

1683 

1684 """ 

1685 return _quanta.quanta_sqrt(self, *args, **kwargs) 

1686 

1687 

1688 def compare(self, *args, **kwargs): 

1689 """ 

1690 compare(self, _v, _a) -> bool 

1691 

1692 

1693 

1694 Summary: 

1695 compare dimensionality of units 

1696 

1697 Description: 

1698 

1699 

1700 compare compares the dimensionality of units of two qauntities 

1701 

1702 Input Parameters: 

1703 v value 

1704 a value 

1705 

1706 Example: 

1707 

1708 

1709 # 

1710 print 't----t compare Ex 1 t----' 

1711 print qa.compare('5yd/a', '6m/s') # equal dimensions 

1712 #True 

1713 print qa.compare('5yd', '5s')# unequal dimensions 

1714 #False 

1715 # 

1716 

1717 

1718 -------------------------------------------------------------------------------- 

1719 

1720 """ 

1721 return _quanta.quanta_compare(self, *args, **kwargs) 

1722 

1723 

1724 def check(self, *args, **kwargs): 

1725 """ 

1726 check(self, _v) -> bool 

1727 

1728 

1729 

1730 Summary: 

1731 check for proper unit string 

1732 

1733 Description: 

1734 

1735 

1736 check checks if the argument has a properly defined unit string 

1737 

1738 Input Parameters: 

1739 v value 

1740 

1741 Example: 

1742 

1743 

1744 # 

1745 print 't----t check Ex 1 t----' 

1746 print qa.check('5AE/Jy.pc5/s') 

1747 #True 

1748 print qa.check('7MYs') 

1749 #False 

1750 # 

1751 

1752 

1753 -------------------------------------------------------------------------------- 

1754 

1755 """ 

1756 return _quanta.quanta_check(self, *args, **kwargs) 

1757 

1758 

1759 def checkfreq(self, *args, **kwargs): 

1760 """ 

1761 checkfreq(self, _cm) -> bool 

1762 

1763 

1764 

1765 Summary: 

1766 check for proper frequency unit 

1767 

1768 Description: 

1769 

1770 

1771 checkfreq checks if the argument has a properly defined frequency interpretable 

1772 unit string 

1773 

1774 Input Parameters: 

1775 cm value 

1776 

1777 Example: 

1778 

1779 

1780 # 

1781 print 't----t checkfreq Ex 1 t----' 

1782 print qa.checkfreq('5GHz') 

1783 #True 

1784 print qa.checkfreq('5cm') 

1785 #True 

1786 print qa.checkfreq('5cm/s2') 

1787 #False 

1788 # 

1789 

1790 

1791 -------------------------------------------------------------------------------- 

1792 

1793 """ 

1794 return _quanta.quanta_checkfreq(self, *args, **kwargs) 

1795 

1796 

1797 def pow(self, *args, **kwargs): 

1798 """ 

1799 pow(self, _v, _a) -> record * 

1800 

1801 

1802 

1803 Summary: 

1804 raise quantity to power 

1805 

1806 Description: 

1807 

1808 

1809 pow raises a quantity to an integer power 

1810 

1811 Input Parameters: 

1812 v value 

1813 a power 

1814 

1815 Example: 

1816 

1817 

1818 # 

1819 print 't----t pow Ex 1 t----' 

1820 print qa.pow('7.2km/s', -3) 

1821 #{'value': 0.0026791838134430724, 'unit': '(km/s)-3'} 

1822 # 

1823 

1824 

1825 -------------------------------------------------------------------------------- 

1826 

1827 """ 

1828 return _quanta.quanta_pow(self, *args, **kwargs) 

1829 

1830 

1831 def constants(self, *args, **kwargs): 

1832 """ 

1833 constants(self, _v) -> record * 

1834 

1835 

1836 

1837 Summary: 

1838 get a constant 

1839 

1840 Description: 

1841 

1842 

1843 constants gets a named constant quantity. Names (no-case, minimax) are: 

1844 

1845 pi 3.14.. 3.14159 

1846 ee 2.71.. 2.71828 

1847 c light vel. 2.99792e+08 m/s 

1848 G grav. const 6.67259e-11 N.m2/kg2 

1849 h Planck const 6.62608e-34 J.s 

1850 HI HI line 1420.41 MHz 

1851 R gas const 8.31451 J/K/mol 

1852 NA Avogadro number 6.02214e+23 mol-1 

1853 e electron charge 1.60218e-19 C 

1854 mp proton mass 1.67262e-27 kg 

1855 mp_me mp/me 1836.15 

1856 mu0 permeability vac. 1.25664e-06 H/m 

1857 eps0 permittivity vac. 1.60218e-19 C 

1858 k Boltzmann const 1.38066e-23 J/K 

1859 F Faraday const 96485.3 C/mol 

1860 me electron mass 9.10939e-31 kg 

1861 re electron radius 2.8179e-15 m 

1862 a0 Bohr's radius 5.2918e-11 m 

1863 R0 solar radius 6.9599e+08 m 

1864 k2 IAU grav. const^2 0.000295912 AU3/d2/S0 

1865 

1866 Input Parameters: 

1867 v name 

1868 

1869 Example: 

1870 

1871 

1872 # 

1873 print 't----t constants Ex 1 t----' 

1874 print qa.constants() 

1875 #{'unit': '', 'value': 3.1415926535897931} 

1876 # 

1877 

1878 

1879 -------------------------------------------------------------------------------- 

1880 

1881 """ 

1882 return _quanta.quanta_constants(self, *args, **kwargs) 

1883 

1884 

1885 def isangle(self, *args, **kwargs): 

1886 """ 

1887 isangle(self, _v) -> bool 

1888 

1889 

1890 

1891 Summary: 

1892 check if valid angle or time quantity 

1893 

1894 Description: 

1895 

1896 

1897 isangle checks if the argument is a valid angle/time quantity. 

1898 

1899 Input Parameters: 

1900 v angle/time quantity 

1901 

1902 Example: 

1903 

1904 

1905 # 

1906 print 't----t isangle Ex 1 t----' 

1907 print qa.isangle(qa.constants('pi')) 

1908 #False 

1909 # 

1910 

1911 

1912 -------------------------------------------------------------------------------- 

1913 

1914 """ 

1915 return _quanta.quanta_isangle(self, *args, **kwargs) 

1916 

1917 

1918 def totime(self, *args, **kwargs): 

1919 """ 

1920 totime(self, _v) -> record * 

1921 

1922 

1923 

1924 Summary: 

1925 convert an angle (or a time) to a time 

1926 

1927 Description: 

1928 

1929 

1930 totime converts an angle quantity (or a time) to a time quantity 

1931 

1932 Input Parameters: 

1933 v angle/time quantity 

1934 

1935 Example: 

1936 

1937 

1938 # 

1939 print 't----t totime Ex 1 t----' 

1940 print qa.totime('2d5m') 

1941 #{'value': 0.0057870370370370376, 'unit': 'd'} 

1942 # 

1943 

1944 

1945 -------------------------------------------------------------------------------- 

1946 

1947 """ 

1948 return _quanta.quanta_totime(self, *args, **kwargs) 

1949 

1950 

1951 def toangle(self, *args, **kwargs): 

1952 """ 

1953 toangle(self, _v) -> record * 

1954 

1955 

1956 

1957 Summary: 

1958 convert a time (or an angle) to an angle 

1959 

1960 Description: 

1961 

1962 

1963 toangle converts a time quantity (or an angle) to an angle quantity 

1964 

1965 Input Parameters: 

1966 v angle/time quantity 

1967 

1968 Example: 

1969 

1970 

1971 # 

1972 print 't----t toangle Ex 1 t----' 

1973 print qa.toangle('5h30m12.6') 

1974 #{'value': 82.552499999999995, 'unit': 'deg'} 

1975 # 

1976 

1977 

1978 -------------------------------------------------------------------------------- 

1979 

1980 """ 

1981 return _quanta.quanta_toangle(self, *args, **kwargs) 

1982 

1983 

1984 def splitdate(self, *args, **kwargs): 

1985 """ 

1986 splitdate(self, _v) -> record * 

1987 

1988 

1989 

1990 Summary: 

1991 split a date/time into a record 

1992 

1993 Description: 

1994 

1995 

1996 splitdate splits a date/time quantity into a record with constituent fields 

1997 like year, yearday, month etc. All fields will be integer (to enable use as 

1998 index and easy personal formatting), with the exception of the {em s} field 

1999 which is a double float. See the example for the fields returned. 

2000 

2001 Input Parameters: 

2002 v angle/time quantity 

2003 

2004 Example: 

2005 

2006 

2007 # 

2008 print 't----t splitdate Ex 1 t----' 

2009 print qa.splitdate('today') 

2010 

2011 #{'mjd': 54175.752367291658, 'week': 11, 'usec': 533999, 'hour': 18, 

2012 # 'min': 3, 'yearday': 75, 'msec': 533, 'month': 3, 's': 

2013 # 24.533999226987362, 'sec': 24, 'weekday': 5, 'year': 2007, 'monthday': 

2014 # 16} print qa.splitdate('183.33333333deg') 

2015 #{'mjd': 0.50925925925000004, 'week': 46, 'usec': 999999, 'hour': 12, 

2016 # 'min': 13, 'yearday': 321, 'msec': 999, 'month': 11, 's': 

2017 # 19.999999200003487, 'sec': 19, 'weekday': 3, 'year': 1858, 

2018 # 'monthday': 17} 

2019 # 

2020 

2021 

2022 -------------------------------------------------------------------------------- 

2023 

2024 """ 

2025 return _quanta.quanta_splitdate(self, *args, **kwargs) 

2026 

2027 

2028 def tos(self, *args, **kwargs): 

2029 """ 

2030 tos(self, _v, _prec) -> string 

2031 

2032 

2033 

2034 Summary: 

2035 convert quantity to string 

2036 

2037 Description: 

2038 

2039 

2040 tos converts a quantity to a string with the precision defined with 

2041 the {em setformat('prec')} (which defaults to 9). If the optional 

2042 {em prec} argument is set to an integer value greater than 1, that 

2043 precision is used in the conversion 

2044 

2045 Input Parameters: 

2046 v value 

2047 prec convert precision of value 

2048 

2049 Example: 

2050 

2051 

2052 # 

2053 print 't----t tos Ex 1 t----' 

2054 a = qa.quantity('2.56 yd/s') 

2055 print a 

2056 #{'value': 2.5600000000000001, 'unit': 'yd/s'} 

2057 print qa.tos(a) 

2058 #2.560000000yd/s 

2059 a=qa.quantity(1./7, 'km/s') 

2060 print qa.tos(a) 

2061 #0.142857143km/s 

2062 print qa.tos(a,2) 

2063 #0.14km/s 

2064 print qa.tos(a,20) 

2065 #0.14285714285714284921km/s 

2066 print qa.tos(a) 

2067 #0.142857143km/s 

2068 # 

2069 

2070 

2071 -------------------------------------------------------------------------------- 

2072 

2073 """ 

2074 return _quanta.quanta_tos(self, *args, **kwargs) 

2075 

2076 

2077 def type(self): 

2078 """ 

2079 type(self) -> string 

2080 

2081 

2082 

2083 Summary: 

2084 type of tool 

2085 

2086 Description: 

2087 

2088 

2089 type will return the tool name. 

2090 

2091 Example: 

2092 

2093 

2094 # 

2095 print 't----t type Ex 1 t----' 

2096 print qa.type() 

2097 #quanta 

2098 # 

2099 

2100 

2101 -------------------------------------------------------------------------------- 

2102 

2103 """ 

2104 return _quanta.quanta_type(self) 

2105 

2106 

2107 def done(self, *args, **kwargs): 

2108 """ 

2109 done(self, _kill) -> bool 

2110 

2111 

2112 

2113 Summary: 

2114 Free resources used by tool. Current implementation ignores input parameter, does nothing and returns true 

2115 

2116 Description: 

2117 

2118 

2119 Currently, this method is an NOP. 

2120 

2121 Input Parameters: 

2122 kill force kill of the default tool (ignored) 

2123 

2124 Example: 

2125 

2126 

2127 # 

2128 print 't----t done Ex 1 t----' 

2129 print qa.done() 

2130 #True 

2131 print qa.done() 

2132 #True 

2133 print qa.done(kill=T) 

2134 #True 

2135 # 

2136 

2137 

2138 -------------------------------------------------------------------------------- 

2139 

2140 """ 

2141 return _quanta.quanta_done(self, *args, **kwargs) 

2142 

2143 

2144 def unit(self, *args, **kwargs): 

2145 """ 

2146 unit(self, _v, _unitname, _keepshape) -> record * 

2147 

2148 

2149 

2150 Summary: 

2151 quantity from value v and unit string 

2152 

2153 Description: 

2154 

2155 

2156 unit makes a quantity from a string, or from a value and a string. 

2157 Note that unit is a synonym for quantity (see description and example there). 

2158 

2159 Input Parameters: 

2160 v  

2161 unitname  

2162 keepshape  

2163 

2164 -------------------------------------------------------------------------------- 

2165 

2166 """ 

2167 return _quanta.quanta_unit(self, *args, **kwargs) 

2168 

2169 

2170 def isquantity(self, *args, **kwargs): 

2171 """ 

2172 isquantity(self, _v) -> bool 

2173 

2174 

2175 

2176 Summary: 

2177 Check if quantity 

2178 

2179 Description: 

2180 

2181 

2182 Checks if the operand is a correct quantity 

2183 

2184 Input Parameters: 

2185 v value to be tested 

2186 

2187 Example: 

2188 

2189 

2190 # 

2191 print 't----t isQuantity Ex 1 t----' 

2192 a = qa.quantity('5Jy') # make a quantity 

2193 print a 

2194 #{'value': 5.0, 'unit': 'Jy'} 

2195 print qa.isquantity(a) # is it one? 

2196 #True 

2197 print qa.isquantity('5Jy') # and this string? 

2198 #True 

2199 # 

2200 

2201 

2202 -------------------------------------------------------------------------------- 

2203 

2204 """ 

2205 return _quanta.quanta_isquantity(self, *args, **kwargs) 

2206 

2207 

2208 def setformat(self, *args, **kwargs): 

2209 """ 

2210 setformat(self, _t, _v) -> bool 

2211 

2212 

2213 

2214 Summary: 

2215 set format for output of numbers. (NOT IMPLEMENTED YET!) 

2216 

2217 Input Parameters: 

2218 t type -coded string indicating which format parameter to set 

2219 v format parameter value - numeric or coded string, depending on format type to be set 

2220 

2221 -------------------------------------------------------------------------------- 

2222 

2223 """ 

2224 return _quanta.quanta_setformat(self, *args, **kwargs) 

2225 

2226 

2227 def getformat(self, *args, **kwargs): 

2228 """ 

2229 getformat(self, _t) -> string 

2230 

2231 

2232 

2233 Summary: 

2234 get current output format (NOT IMPLEMENTED YET!) 

2235 

2236 Description: 

2237 

2238 

2239 getformat returns the current format value set for the different 

2240 format possibilities. See the 

2241 setformat function for the 

2242 different format type descriptions. The known types are:  

2243 prec, aprec, tprec, long, lat, len, dtime, elev, auto, vel, freq, 

2244 dop, unit. 

2245 

2246 Input Parameters: 

2247 t type - coded string 

2248 

2249 Example: 

2250 

2251 

2252 # 

2253 print 't----t getformat Ex 1 t----' 

2254 print qa.getformat('prec') 

2255 #6 

2256 #setformat is NOT IMPLEMENTED YET! 

2257 #qa.setformat('prec', 12)# set precision to 12 significant digits 

2258 #T 

2259 #print qa.getformat('prec') 

2260 #12 

2261 print qa.getformat('long') 

2262 #hms 

2263 # 

2264 

2265 

2266 -------------------------------------------------------------------------------- 

2267 

2268 """ 

2269 return _quanta.quanta_getformat(self, *args, **kwargs) 

2270 

2271 

2272 def formxxx(self, *args, **kwargs): 

2273 """ 

2274 formxxx(self, _v, _format, _prec) -> string 

2275 

2276 

2277 

2278 Summary: 

2279 Format a quantity using given format, allowed are hms, dms, deg, rad, +deg.  

2280 

2281 Description: 

2282 

2283 

2284 form.xxx (xxx can be lat, long, len, vel, freq, dtime, unit) will format the 

2285 input into a string using the global format information set by setformat(). 

2286 

2287 Input Parameters: 

2288 v value to be converted 

2289 format xxx can be hms, dms, deg, rad or +deg  

2290 prec digits in fractional part of output string for dms,hms 

2291 

2292 Example: 

2293 

2294 

2295 # 

2296 print 't----t formxxx Ex 1 t----' 

2297 #qa.setformat('freq','cm') 

2298 #T 

2299 #qa.formxxx('freq',qa.quantity('5GHz')) 

2300 #form_xxx NOT IMPLEMENTED YET! 

2301 #5.99584916 cm 

2302 print 'Last example, exiting! ...' 

2303 exit() 

2304 # 

2305 

2306 

2307 -------------------------------------------------------------------------------- 

2308 

2309 """ 

2310 return _quanta.quanta_formxxx(self, *args, **kwargs) 

2311 

2312 __swig_destroy__ = _quanta.delete_quanta 

2313 __del__ = lambda self: None 

2314quanta_swigregister = _quanta.quanta_swigregister 

2315quanta_swigregister(quanta) 

2316 

2317# This file is compatible with both classic and new-style classes. 

2318 

2319