Changeset 1612 for branches/alma/python
- Timestamp:
- 08/05/09 17:48:43 (15 years ago)
- Location:
- branches/alma/python
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/__init__.py
r1605 r1612 212 212 tup = line.split(':',1) 213 213 if len(tup) !=2: 214 print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname)) 214 #print ('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname)) 215 casalog.post('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname), 'WARN') 215 216 continue 216 217 … … 218 219 key = key.strip() 219 220 if not defaultParams.has_key(key): 220 print ('Bad key "%s" on line %d in %s' % (key, cnt, fname)) 221 #print ('Bad key "%s" on line %d in %s' % (key, cnt, fname)) 222 casalog.post('Bad key "%s" on line %d in %s' % (key, cnt, fname), 'WARN') 221 223 continue 222 224 … … 228 230 try: cval = converter(val) # try to convert to proper type or raise 229 231 except ValueError, msg: 230 print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg)) 232 #print ('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg)) 233 casalog.post('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg), 'WARN') 231 234 continue 232 235 else: … … 343 346 344 347 # Logging 348 from taskinit import * 345 349 from asap._asap import Log as _asaplog 346 350 global asaplog … … 353 357 def print_log(): 354 358 log = asaplog.pop() 355 if len(log) and rcParams['verbose']: print log 359 #if len(log) and rcParams['verbose']: print log 360 if len(log) and rcParams['verbose']: casalog.post( log ) 356 361 return 357 362 … … 389 394 del gui 390 395 except ImportError: 391 print "Matplotlib not installed. No plotting available" 396 #print "Matplotlib not installed. No plotting available" 397 casalog.post( "Matplotlib not installed. No plotting available", 'WARN' ) 392 398 393 399 __date__ = '$Date$'.split()[1] -
branches/alma/python/asapfitter.py
r1603 r1612 4 4 from asap import _n_bools 5 5 from asap import mask_and 6 from taskinit import * 6 7 7 8 class fitter: … … 59 60 msg = "Please give a correct scan" 60 61 if rcParams['verbose']: 61 print msg 62 #print msg 63 casalog.post( msg, 'WARN' ) 62 64 return 63 65 else: … … 105 107 msg = "Invalid function type." 106 108 if rcParams['verbose']: 107 print msg 109 #print msg 110 casalog.post( msg, 'WARN' ) 108 111 return 109 112 else: … … 134 137 msg = "Fitter not yet initialised. Please set data & fit function" 135 138 if rcParams['verbose']: 136 print msg 139 #print msg 140 casalog.post( msg, 'WARN' ) 137 141 return 138 142 else: … … 170 174 except RuntimeError, msg: 171 175 if rcParams['verbose']: 172 print msg 176 #print msg 177 casalog.post( msg, 'WARN' ) 173 178 else: 174 179 raise … … 228 233 msg = "Please specify a fitting function first." 229 234 if rcParams['verbose']: 230 print msg 235 #print msg 236 casalog.post( msg, 'WARN' ) 231 237 return 232 238 else: … … 270 276 msg = "Function only operates on Gaussian components." 271 277 if rcParams['verbose']: 272 print msg 278 #print msg 279 casalog.post( msg, 'WARN' ) 273 280 return 274 281 else: … … 281 288 msg = "Please select a valid component." 282 289 if rcParams['verbose']: 283 print msg 290 #print msg 291 casalog.post( msg, 'WARN' ) 284 292 return 285 293 else: … … 322 330 msg = "Not yet fitted." 323 331 if rcParams['verbose']: 324 print msg 332 #print msg 333 casalog.post( msg, 'WARN' ) 325 334 return 326 335 else: … … 345 354 msg = "Not yet fitted." 346 355 if rcParams['verbose']: 347 print msg 356 #print msg 357 casalog.post( msg, 'WARN' ) 348 358 return 349 359 else: … … 375 385 fpars = self._format_pars(cpars, cfixed, errors and cerrs, area) 376 386 if rcParams['verbose']: 377 print fpars 387 #print fpars 388 casalog.post( fpars ) 378 389 return {'params':cpars, 'fixed':cfixed, 'formatted': fpars, 379 390 'errors':cerrs} … … 416 427 fixed = self.fitter.getfixedparameters() 417 428 if rcParams['verbose']: 418 print self._format_pars(pars,fixed,None) 429 #print self._format_pars(pars,fixed,None) 430 casalog.post( self._format_pars(pars,fixed,None) ) 419 431 return pars 420 432 … … 426 438 msg = "Not yet fitted." 427 439 if rcParams['verbose']: 428 print msg 440 #print msg 441 casalog.post( msg, 'WARN' ) 429 442 return 430 443 else: … … 439 452 msg = "Not yet fitted." 440 453 if rcParams['verbose']: 441 print msg 454 #print msg 455 casalog.post( msg, 'WARN' ) 442 456 return 443 457 else: … … 445 459 ch2 = self.fitter.getchi2() 446 460 if rcParams['verbose']: 447 print 'Chi^2 = %3.3f' % (ch2) 461 #print 'Chi^2 = %3.3f' % (ch2) 462 casalog.post( 'Chi^2 = %3.3f' % (ch2) ) 448 463 return ch2 449 464 … … 455 470 msg = "Not yet fitted." 456 471 if rcParams['verbose']: 457 print msg 472 #print msg 473 casalog.post( msg, 'WARN' ) 458 474 return 459 475 else: … … 468 484 msg = "Not yet fitted." 469 485 if rcParams['verbose']: 470 print msg 486 #print msg 487 casalog.post( msg, 'WARN' ) 471 488 return 472 489 else: … … 476 493 msg = "Not a scantable" 477 494 if rcParams['verbose']: 478 print msg 495 #print msg 496 casalog.post( msg, 'WARN' ) 479 497 return 480 498 else: … … 594 612 msg = "Data is not a scantable" 595 613 if rcParams['verbose']: 596 print msg 614 #print msg 615 casalog.post( msg, 'WARN' ) 597 616 return 598 617 else: -
branches/alma/python/asaplotbase.py
r1603 r1612 22 22 from matplotlib.transforms import blend_xy_sep_transform as blended_transform_factory 23 23 24 from taskinit import * 25 24 26 if int(matplotlib.__version__.split(".")[1]) < 87: 25 print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 27 #print "Warning: matplotlib version < 0.87. This might cause errors. Please upgrade." 28 casalog.post( "matplotlib version < 0.87. This might cause errors. Please upgrade.", 'WARN' ) 26 29 27 30 #class MyFormatter(OldScalarFormatter): … … 449 452 print 'Written file %s' % (fname) 450 453 except IOError, msg: 451 print 'Failed to save %s: Error msg was\n\n%s' % (fname, err) 454 #print 'Failed to save %s: Error msg was\n\n%s' % (fname, err) 455 casalog.post( 'Failed to save %s: Error msg was\n\n%s' % (fname, err), 'WARN' ) 452 456 return 453 457 else: 454 print "Invalid image type. Valid types are:" 455 print "'ps', 'eps', 'png'" 458 #print "Invalid image type. Valid types are:" 459 #print "'ps', 'eps', 'png'" 460 casalog.post( "Invalid image type. Valid types are:", 'WARN' ) 461 casalog.post( "'ps', 'eps', 'png'", 'WARN' ) 456 462 457 463 -
branches/alma/python/asapmath.py
r1446 r1612 3 3 from asap import print_log 4 4 from asap import selector 5 from taskinit import * 5 6 6 7 def average_time(*args, **kwargs): … … 66 67 msg = "Please give a list of scantables" 67 68 if rcParams['verbose']: 68 print msg 69 #print msg 70 casalog.post( msg, 'WARN' ) 69 71 return 70 72 else: … … 184 186 msg = "The input data appear to contain no position-switch mode data." 185 187 if rcParams['verbose']: 186 print msg 188 #print msg 189 casalog.post( msg, 'WARN' ) 187 190 return 188 191 else: … … 192 195 msg = "No data was found with given scan numbers!" 193 196 if rcParams['verbose']: 194 print msg 197 #print msg 198 casalog.post( msg, 'WARN' ) 195 199 return 196 200 else: … … 201 205 msg = "mismatch in numbers of CAL on/off scans. Cannot calibrate. Check the scan numbers." 202 206 if rcParams['verbose']: 203 print msg 207 #print msg 208 casalog.post( msg, 'WARN' ) 204 209 return 205 210 else: … … 211 216 msg = "mismatch in numbers of on/off scans. Cannot calibrate. Check the scan numbers." 212 217 if rcParams['verbose']: 213 print msg 218 #print msg 219 casalog.post( msg, 'WARN' ) 214 220 return 215 221 else: … … 221 227 msg = "Need to supply a valid tau to use the supplied Tsys" 222 228 if rcParams['verbose']: 223 print msg 229 #print msg 230 casalog.post( msg, 'WARN' ) 224 231 return 225 232 else: … … 267 274 msg = "The input data appear to contain no Nod observing mode data." 268 275 if rcParams['verbose']: 269 print msg 276 #print msg 277 casalog.post( msg, 'WARN' ) 270 278 return 271 279 else: … … 304 312 msg = "Need to supply a valid tau to use the supplied Tsys" 305 313 if rcParams['verbose']: 306 print msg 314 #print msg 315 casalog.post( msg, 'WARN' ) 307 316 return 308 317 else: … … 369 378 as well as the data 370 379 """ 371 print "simple_math is deprecated use +=/* instead." 380 #print "simple_math is deprecated use +=/* instead." 381 casalog.post( "simple_math is deprecated use +=/* instead.", 'WARN' ) 372 382 373 383 def merge(*args): … … 398 408 msg = "Please give a list of scantables" 399 409 if rcParams['verbose']: 400 print msg 410 #print msg 411 casalog.post( msg, 'WARN' ) 401 412 return 402 413 else: -
branches/alma/python/asapplotter.py
r1562 r1612 1 1 from asap import rcParams, print_log, selector 2 from taskinit import * 2 3 import matplotlib.axes 3 4 import re … … 74 75 msg = "Input is not a scantable" 75 76 if rcParams['verbose']: 76 print msg 77 #print msg 78 casalog.post( msg, 'WARN' ) 77 79 return 78 80 raise TypeError(msg) … … 169 171 not self.set_stacking(stacking): 170 172 if rcParams['verbose']: 171 print msg 173 #print msg 174 casalog.post( msg, 'WARN' ) 172 175 return 173 176 else: … … 522 525 msg = "Can only set mask after a first call to plot()" 523 526 if rcParams['verbose']: 524 print msg 527 #print msg 528 casalog.post( msg, 'WARN' ) 525 529 return 526 530 else: … … 888 892 msg = "Input is not a scantable" 889 893 if rcParams['verbose']: 890 print msg 894 #print msg 895 casalog.post( msg, 'WARN' ) 891 896 return 892 897 raise TypeError(msg) -
branches/alma/python/linecatalog.py
r1603 r1612 9 9 from asap import rcParams 10 10 import os 11 from taskinit import * 11 12 12 13 class linecatalog(lcbase): … … 30 31 msg = "File '%s' not found" % fpath 31 32 if rcParams['verbose']: 32 print msg 33 #print msg 34 casalog.post( msg, 'WARN' ) 33 35 return 34 36 else: … … 97 99 msg = "File %s exists." % name 98 100 if rcParams['verbose']: 99 print msg 101 #print msg 102 casalog.post( msg, 'WARN' ) 100 103 return 101 104 else: -
branches/alma/python/scantable.py
r1603 r1612 6 6 from asap import linecatalog 7 7 from asap import _n_bools, mask_not, mask_and, mask_or 8 from taskinit import * 8 9 9 10 class scantable(Scantable): … … 55 56 if rcParams['verbose']: 56 57 asaplog.push(s) 57 print asaplog.pop().strip() 58 #print asaplog.pop().strip() 59 print_log() 58 60 return 59 61 raise IOError(s) … … 72 74 "asap table." % (filename) 73 75 if rcParams['verbose']: 74 print msg 76 #print msg 77 casalog.post( msg, 'WARN' ) 75 78 return 76 79 else: … … 120 123 msg = "File %s exists." % name 121 124 if rcParams['verbose']: 122 print msg 125 #print msg 126 casalog.post( msg, 'WARN' ) 123 127 return 124 128 else: … … 159 163 if not _is_valid(scanid): 160 164 if rcParams['verbose']: 161 print "Please specify a scanno to drop from the scantable" 165 #print "Please specify a scanno to drop from the scantable" 166 casalog.post( "Please specify a scanno to drop from the scantable", 'WARN' ) 162 167 return 163 168 else: … … 171 176 except ValueError: 172 177 if rcParams['verbose']: 173 print "Couldn't find any match." 178 #print "Couldn't find any match." 179 casalog.post( "Couldn't find any match.", 'WARN' ) 174 180 return 175 181 else: raise … … 184 190 except RuntimeError: 185 191 if rcParams['verbose']: 186 print "Couldn't find any match." 192 #print "Couldn't find any match." 193 casalog.post( "Couldn't find any match.", 'WARN' ) 187 194 else: 188 195 raise … … 209 216 if scanid is None: 210 217 if rcParams['verbose']: 211 print "Please specify a scan no or name to " \ 212 "retrieve from the scantable" 218 #print "Please specify a scan no or name to " \ 219 # "retrieve from the scantable" 220 casalog.post( "Please specify a scan no or name to retrieve from the scantable", 'WARN' ) 213 221 return 214 222 else: … … 239 247 msg = "Illegal scanid type, use 'int' or 'list' if ints." 240 248 if rcParams['verbose']: 241 print msg 249 #print msg 250 casalog.post( msg, 'WARN' ) 242 251 else: 243 252 raise TypeError(msg) 244 253 except RuntimeError: 245 if rcParams['verbose']: print "Couldn't find any match." 254 if rcParams['verbose']: 255 #print "Couldn't find any match." 256 casalog.post( "Couldn't find any match.", 'WARN' ) 246 257 else: raise 247 258 … … 272 283 msg = "Illegal file name '%s'." % (filename) 273 284 if rcParams['verbose']: 274 print msg 285 #print msg 286 casalog.post( msg, 'WARN' ) 275 287 else: 276 288 raise IOError(msg) … … 430 442 431 443 if rcParams['verbose']: 432 print "--------------------------------------------------" 433 print " ", stat, statunit 434 print "--------------------------------------------------" 435 print out 444 tmpfile='/tmp/tmp_casapy_asap_scantable_stats' 445 f=open(tmpfile,'w') 446 print >> f, "--------------------------------------------------" 447 print >> f, " ", stat, statunit 448 print >> f, "--------------------------------------------------" 449 print >> f, out 450 f.close() 451 f=open(tmpfile,'r') 452 x=f.readlines() 453 f.close() 454 for xx in x: 455 casalog.post( xx ) 436 456 #else: 437 457 #retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], … … 513 533 out += "--------------------------------------------------\n" 514 534 if rcParams['verbose']: 515 print "--------------------------------------------------" 516 print " %s" % (label) 517 print "--------------------------------------------------" 518 print out 535 #print "--------------------------------------------------" 536 #print " %s" % (label) 537 #print "--------------------------------------------------" 538 #print out 539 casalog.post( "--------------------------------------------------" ) 540 casalog.post( " %s" % (label) ) 541 casalog.post( "--------------------------------------------------" ) 542 casalog.post( out ) 519 543 # disabled because the vector seems more useful 520 544 #retval = {'axesnames': axesnames, 'axes': axes, 'data': outvec} … … 703 727 msg = "Please specify a valid freq type. Valid types are:\n", valid 704 728 if rcParams['verbose']: 705 print msg 729 #print msg 730 casalog.post( msg, 'WARN' ) 706 731 else: 707 732 raise TypeError(msg) … … 722 747 except RuntimeError, msg: 723 748 if rcParams['verbose']: 724 print msg 749 #print msg 750 casalog.post( msg, 'WARN' ) 725 751 else: 726 752 raise … … 768 794 except RuntimeError, msg: 769 795 if rcParams['verbose']: 770 print msg 796 #print msg 797 casalog.post( msg, 'WARN' ) 771 798 return 772 799 else: raise … … 799 826 except RuntimeError, msg: 800 827 if rcParams['verbose']: 801 print msg 828 #print msg 829 casalog.post( msg, 'WARN' ) 802 830 return 803 831 else: raise … … 1118 1146 msg = "Illegal file name '%s'." % (filename) 1119 1147 if rcParams['verbose']: 1120 print msg 1148 #print msg 1149 casalog.post( msg, 'WARN' ) 1121 1150 else: 1122 1151 raise IOError(msg) … … 1176 1205 except RuntimeError, msg: 1177 1206 if rcParams['verbose']: 1178 print msg 1207 #print msg 1208 casalog.post( msg, 'WARN' ) 1179 1209 return 1180 1210 else: raise … … 1400 1430 except RuntimeError, msg: 1401 1431 if rcParams['verbose']: 1402 print msg 1432 #print msg 1433 casalog.post( msg, 'WARN' ) 1403 1434 return 1404 1435 else: … … 1477 1508 msg = "The fit failed, possibly because it didn't converge." 1478 1509 if rcParams['verbose']: 1479 print msg 1510 #print msg 1511 casalog.post( msg, 'WARN' ) 1480 1512 return 1481 1513 else: … … 1922 1954 fit = asapfit(self._getfit(row)) 1923 1955 if rcParams['verbose']: 1924 print fit 1956 #print fit 1957 casalog.post( '%s' %(fit) ) 1925 1958 return 1926 1959 else: … … 2029 2062 if rcParams['verbose']: 2030 2063 asaplog.push(msg) 2031 print asaplog.pop().strip() 2064 #print asaplog.pop().strip() 2065 casalog.post( asaplog.pop().strip(), 'WARN' ) 2032 2066 return 2033 2067 raise IOError(msg)
Note:
See TracChangeset
for help on using the changeset viewer.