- Timestamp:
- 08/06/09 15:48:39 (15 years ago)
- Location:
- branches/alma/python
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/__init__.py
r1612 r1614 213 213 if len(tup) !=2: 214 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 asaplog.push('Illegal line #%d\n\t%s\n\tin file "%s"' % (cnt, line, fname)) 216 print_log('WARN') 216 217 continue 217 218 … … 220 221 if not defaultParams.has_key(key): 221 222 #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') 223 asaplog.push('Bad key "%s" on line %d in %s' % (key, cnt, fname)) 224 print_log('WARN') 223 225 continue 224 226 … … 231 233 except ValueError, msg: 232 234 #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') 235 asaplog.push('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' % (val, cnt, line, fname, msg)) 236 print_log('WARN') 234 237 continue 235 238 else: … … 355 358 asaplog.disable() 356 359 357 def print_log( ):360 def print_log(level='INFO'): 358 361 log = asaplog.pop() 359 362 #if len(log) and rcParams['verbose']: print log 360 if len(log) and rcParams['verbose']: casalog.post( log )363 if len(log) and rcParams['verbose']: casalog.post( log, priority=level ) 361 364 return 362 365 … … 395 398 except ImportError: 396 399 #print "Matplotlib not installed. No plotting available" 397 casalog.post( "Matplotlib not installed. No plotting available", 'WARN' ) 400 asaplog.post( "Matplotlib not installed. No plotting available") 401 print_log('WARN') 398 402 399 403 __date__ = '$Date$'.split()[1] -
branches/alma/python/asapfitter.py
r1612 r1614 4 4 from asap import _n_bools 5 5 from asap import mask_and 6 from taskinit import *6 from asap import asaplog 7 7 8 8 class fitter: … … 61 61 if rcParams['verbose']: 62 62 #print msg 63 casalog.post( msg, 'WARN' ) 63 asaplog.push(msg) 64 print_log('ERROR') 64 65 return 65 66 else: … … 108 109 if rcParams['verbose']: 109 110 #print msg 110 casalog.post( msg, 'WARN' ) 111 asaplog.push(msg) 112 print_log('ERROR') 111 113 return 112 114 else: … … 138 140 if rcParams['verbose']: 139 141 #print msg 140 casalog.post( msg, 'WARN' ) 142 asaplog.push(msg) 143 print_log('ERROR') 141 144 return 142 145 else: … … 175 178 if rcParams['verbose']: 176 179 #print msg 177 casalog.post( msg, 'WARN' ) 180 print_log() 181 asaplog.push(msg) 182 print_log('ERROR') 178 183 else: 179 184 raise … … 234 239 if rcParams['verbose']: 235 240 #print msg 236 casalog.post( msg, 'WARN' ) 241 asaplog.push(msg) 242 print_log('ERROR') 237 243 return 238 244 else: … … 277 283 if rcParams['verbose']: 278 284 #print msg 279 casalog.post( msg, 'WARN' ) 285 asaplog.push(msg) 286 print_log('ERROR') 280 287 return 281 288 else: … … 289 296 if rcParams['verbose']: 290 297 #print msg 291 casalog.post( msg, 'WARN' ) 298 asaplog.push(msg) 299 print_log('ERROR') 292 300 return 293 301 else: … … 331 339 if rcParams['verbose']: 332 340 #print msg 333 casalog.post( msg, 'WARN' ) 341 asaplog.push(msg) 342 print_log('ERROR') 334 343 return 335 344 else: … … 355 364 if rcParams['verbose']: 356 365 #print msg 357 casalog.post( msg, 'WARN' ) 366 asaplog.push(msg) 367 print_log('ERROR') 358 368 return 359 369 else: … … 386 396 if rcParams['verbose']: 387 397 #print fpars 388 casalog.post( fpars ) 398 asaplog.push(fpars) 399 print_log() 389 400 return {'params':cpars, 'fixed':cfixed, 'formatted': fpars, 390 401 'errors':cerrs} … … 428 439 if rcParams['verbose']: 429 440 #print self._format_pars(pars,fixed,None) 430 casalog.post( self._format_pars(pars,fixed,None) ) 441 asaplog.push(self._format_pars(pars,fixed,None)) 442 print_log() 431 443 return pars 432 444 … … 439 451 if rcParams['verbose']: 440 452 #print msg 441 casalog.post( msg, 'WARN' ) 453 asaplog.push(msg) 454 print_log('ERROR') 442 455 return 443 456 else: … … 453 466 if rcParams['verbose']: 454 467 #print msg 455 casalog.post( msg, 'WARN' ) 468 asaplog.push(msg) 469 print_log('ERROR') 456 470 return 457 471 else: … … 460 474 if rcParams['verbose']: 461 475 #print 'Chi^2 = %3.3f' % (ch2) 462 casalog.post( 'Chi^2 = %3.3f' % (ch2) ) 476 asaplog.push( 'Chi^2 = %3.3f' % (ch2) ) 477 print_log() 463 478 return ch2 464 479 … … 471 486 if rcParams['verbose']: 472 487 #print msg 473 casalog.post( msg, 'WARN' ) 488 asaplog.push(msg) 489 print_log('ERROR') 474 490 return 475 491 else: … … 485 501 if rcParams['verbose']: 486 502 #print msg 487 casalog.post( msg, 'WARN' ) 503 asaplog.push(msg) 504 print_log('ERROR') 488 505 return 489 506 else: … … 494 511 if rcParams['verbose']: 495 512 #print msg 496 casalog.post( msg, 'WARN' ) 513 asaplog.push(msg) 514 print_log('ERROR') 497 515 return 498 516 else: … … 613 631 if rcParams['verbose']: 614 632 #print msg 615 casalog.post( msg, 'WARN' ) 633 asaplog.push(msg) 634 print_log('ERROR') 616 635 return 617 636 else: -
branches/alma/python/asaplotbase.py
r1612 r1614 22 22 from matplotlib.transforms import blend_xy_sep_transform as blended_transform_factory 23 23 24 from taskinit import *24 from asap import asaplog 25 25 26 26 if int(matplotlib.__version__.split(".")[1]) < 87: 27 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' ) 28 asaplog.push( "matplotlib version < 0.87. This might cause errors. Please upgrade." ) 29 print_log( 'WARN' ) 29 30 30 31 #class MyFormatter(OldScalarFormatter): … … 453 454 except IOError, msg: 454 455 #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' ) 456 print_log() 457 asaplog.push('Failed to save %s: Error msg was\n\n%s' % (fname, msg)) 458 print_log( 'ERROR' ) 456 459 return 457 460 else: 458 461 #print "Invalid image type. Valid types are:" 459 462 #print "'ps', 'eps', 'png'" 460 casalog.post( "Invalid image type. Valid types are:", 'WARN' ) 461 casalog.post( "'ps', 'eps', 'png'", 'WARN' ) 463 asaplog.push( "Invalid image type. Valid types are:" ) 464 asaplog.push( "'ps', 'eps', 'png'" ) 465 print_log('WARN') 462 466 463 467 -
branches/alma/python/asapmath.py
r1612 r1614 3 3 from asap import print_log 4 4 from asap import selector 5 from taskinit import *5 from asap import asaplog 6 6 7 7 def average_time(*args, **kwargs): … … 68 68 if rcParams['verbose']: 69 69 #print msg 70 casalog.post( msg, 'WARN' ) 70 asaplog.push(msg) 71 print_log('ERROR') 71 72 return 72 73 else: … … 187 188 if rcParams['verbose']: 188 189 #print msg 189 casalog.post( msg, 'WARN' ) 190 asaplog.push(msg) 191 print_log('ERROR') 190 192 return 191 193 else: … … 196 198 if rcParams['verbose']: 197 199 #print msg 198 casalog.post( msg, 'WARN' ) 200 asaplog.push(msg) 201 print_log('ERROR') 199 202 return 200 203 else: … … 206 209 if rcParams['verbose']: 207 210 #print msg 208 casalog.post( msg, 'WARN' ) 211 asaplog.push(msg) 212 print_log('ERROR') 209 213 return 210 214 else: … … 217 221 if rcParams['verbose']: 218 222 #print msg 219 casalog.post( msg, 'WARN' ) 223 asaplog.push(msg) 224 print_log('ERROR') 220 225 return 221 226 else: … … 228 233 if rcParams['verbose']: 229 234 #print msg 230 casalog.post( msg, 'WARN' ) 235 asaplog.push(msg) 236 print_log('ERROR') 231 237 return 232 238 else: … … 275 281 if rcParams['verbose']: 276 282 #print msg 277 casalog.post( msg, 'WARN' ) 283 asaplog.push(msg) 284 print_log('ERROR') 278 285 return 279 286 else: … … 313 320 if rcParams['verbose']: 314 321 #print msg 315 casalog.post( msg, 'WARN' ) 322 asaplog.push(msg) 323 print_log('ERROR') 316 324 return 317 325 else: … … 379 387 """ 380 388 #print "simple_math is deprecated use +=/* instead." 381 casalog.post( "simple_math is deprecated use +=/* instead.", 'WARN' ) 389 asaplog.push( "simple_math is deprecated use +=/* instead." ) 390 print_log('WARN') 382 391 383 392 def merge(*args): … … 409 418 if rcParams['verbose']: 410 419 #print msg 411 casalog.post( msg, 'WARN' ) 420 asaplog.push(msg) 421 print_log('ERROR') 412 422 return 413 423 else: -
branches/alma/python/asapplotter.py
r1612 r1614 1 1 from asap import rcParams, print_log, selector 2 from taskinit import *2 from asap import asaplog 3 3 import matplotlib.axes 4 4 import re … … 76 76 if rcParams['verbose']: 77 77 #print msg 78 casalog.post( msg, 'WARN' ) 78 asaplog.push( msg ) 79 print_log( 'ERROR' ) 79 80 return 80 81 raise TypeError(msg) … … 172 173 if rcParams['verbose']: 173 174 #print msg 174 casalog.post( msg, 'WARN' ) 175 asaplog.push( msg ) 176 print_log( 'ERROR' ) 175 177 return 176 178 else: … … 526 528 if rcParams['verbose']: 527 529 #print msg 528 casalog.post( msg, 'WARN' ) 530 asaplog.push( msg ) 531 print_log( 'ERROR' ) 529 532 return 530 533 else: … … 617 620 "Selecting first %d selections..." % (maxn, maxn) 618 621 asaplog.push(msg) 619 print_log( )622 print_log('WARN') 620 623 n = min(n,maxpanel) 621 624 nstack = min(nstack,maxstack) … … 893 896 if rcParams['verbose']: 894 897 #print msg 895 casalog.post( msg, 'WARN' ) 898 asaplog.push( msg ) 899 print_log( 'ERROR' ) 896 900 return 897 901 raise TypeError(msg) -
branches/alma/python/linecatalog.py
r1612 r1614 8 8 from asap._asap import linecatalog as lcbase 9 9 from asap import rcParams 10 from asap import asaplog 10 11 import os 11 from taskinit import *12 12 13 13 class linecatalog(lcbase): … … 32 32 if rcParams['verbose']: 33 33 #print msg 34 casalog.post( msg, 'WARN' ) 34 asaplog.push( msg ) 35 print_log( 'ERROR' ) 35 36 return 36 37 else: … … 100 101 if rcParams['verbose']: 101 102 #print msg 102 casalog.post( msg, 'WARN' ) 103 asaplog.push( msg ) 104 print_log( 'ERROR' ) 103 105 return 104 106 else: -
branches/alma/python/scantable.py
r1613 r1614 6 6 from asap import linecatalog 7 7 from asap import _n_bools, mask_not, mask_and, mask_or 8 from taskinit import *9 8 10 9 class scantable(Scantable): … … 57 56 asaplog.push(s) 58 57 #print asaplog.pop().strip() 59 print_log( )58 print_log('ERROR') 60 59 return 61 60 raise IOError(s) … … 75 74 if rcParams['verbose']: 76 75 #print msg 77 casalog.post( msg, 'WARN' ) 76 asaplog.push( msg ) 77 print_log( 'ERROR' ) 78 78 return 79 79 else: … … 124 124 if rcParams['verbose']: 125 125 #print msg 126 casalog.post( msg, 'WARN' ) 126 asaplog.push( msg ) 127 print_log( 'ERROR' ) 127 128 return 128 129 else: … … 164 165 if rcParams['verbose']: 165 166 #print "Please specify a scanno to drop from the scantable" 166 casalog.post( "Please specify a scanno to drop from the scantable", 'WARN' ) 167 asaplog.push( 'Please specify a scanno to drop from the scantable' ) 168 print_log( 'ERROR' ) 167 169 return 168 170 else: … … 177 179 if rcParams['verbose']: 178 180 #print "Couldn't find any match." 179 casalog.post( "Couldn't find any match.", 'WARN' ) 181 print_log() 182 asaplog.push( "Couldn't find any match." ) 183 print_log( 'ERROR' ) 180 184 return 181 185 else: raise … … 191 195 if rcParams['verbose']: 192 196 #print "Couldn't find any match." 193 casalog.post( "Couldn't find any match.", 'WARN' ) 197 print_log() 198 asaplog.push( "Couldn't find any match." ) 199 print_log( 'ERROR' ) 194 200 else: 195 201 raise … … 218 224 #print "Please specify a scan no or name to " \ 219 225 # "retrieve from the scantable" 220 casalog.post( "Please specify a scan no or name to retrieve from the scantable", 'WARN' ) 226 asaplog.push( 'Please specify a scan no or name to retrieve from the scantable' ) 227 print_log( 'ERROR' ) 221 228 return 222 229 else: … … 248 255 if rcParams['verbose']: 249 256 #print msg 250 casalog.post( msg, 'WARN' ) 257 asaplog.push( msg ) 258 print_log( 'ERROR' ) 251 259 else: 252 260 raise TypeError(msg) … … 254 262 if rcParams['verbose']: 255 263 #print "Couldn't find any match." 256 casalog.post( "Couldn't find any match.", 'WARN' ) 264 print_log() 265 asaplog.push( "Couldn't find any match." ) 266 print_log( 'ERROR' ) 257 267 else: raise 258 268 … … 284 294 if rcParams['verbose']: 285 295 #print msg 286 casalog.post( msg, 'WARN' ) 296 asaplog.push( msg ) 297 print_log( 'ERROR' ) 287 298 else: 288 299 raise IOError(msg) … … 454 465 f.close() 455 466 for xx in x: 456 casalog.post( xx ) 467 asaplog.push( xx ) 468 print_log() 457 469 #else: 458 470 #retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'], … … 534 546 out += "--------------------------------------------------\n" 535 547 if rcParams['verbose']: 536 #print "--------------------------------------------------" 537 #print " %s" % (label) 538 #print "--------------------------------------------------" 539 #print out 540 casalog.post( "--------------------------------------------------" ) 541 casalog.post( " %s" % (label) ) 542 casalog.post( "--------------------------------------------------" ) 543 casalog.post( out ) 548 usr=os.environ['USER'] 549 tmpfile='/tmp/tmp_'+usr+'_casapy_asap_scantable_row_callback' 550 f=open(tmpfile,'w') 551 print >> f, "--------------------------------------------------" 552 print >> f, " %s" % (label) 553 print >> f, "--------------------------------------------------" 554 print >> f, out 555 f.close() 556 f=open(tmpfile,'r') 557 x=f.readlines() 558 f.close() 559 for xx in x: 560 asaplog.push( xx ) 561 print_log() 544 562 # disabled because the vector seems more useful 545 563 #retval = {'axesnames': axesnames, 'axes': axes, 'data': outvec} … … 729 747 if rcParams['verbose']: 730 748 #print msg 731 casalog.post( msg, 'WARN' ) 749 asaplog.push( msg ) 750 print_log( 'ERROR' ) 732 751 else: 733 752 raise TypeError(msg) … … 749 768 if rcParams['verbose']: 750 769 #print msg 751 casalog.post( msg, 'WARN' ) 770 print_log() 771 asaplog.push( msg ) 772 print_log( 'ERROR' ) 752 773 else: 753 774 raise … … 796 817 if rcParams['verbose']: 797 818 #print msg 798 casalog.post( msg, 'WARN' ) 819 print_log() 820 asaplog.push( msg ) 821 print_log( 'ERROR' ) 799 822 return 800 823 else: raise … … 828 851 if rcParams['verbose']: 829 852 #print msg 830 casalog.post( msg, 'WARN' ) 853 print_log() 854 asaplog.push( msg ) 855 print_log( 'ERROR' ) 831 856 return 832 857 else: raise … … 1148 1173 if rcParams['verbose']: 1149 1174 #print msg 1150 casalog.post( msg, 'WARN' ) 1175 asaplog.push( msg ) 1176 print_log( 'ERROR' ) 1151 1177 else: 1152 1178 raise IOError(msg) … … 1207 1233 if rcParams['verbose']: 1208 1234 #print msg 1209 casalog.post( msg, 'WARN' ) 1235 print_log() 1236 asaplog.push( msg ) 1237 print_log( 'ERROR' ) 1210 1238 return 1211 1239 else: raise … … 1432 1460 if rcParams['verbose']: 1433 1461 #print msg 1434 casalog.post( msg, 'WARN' ) 1462 print_log() 1463 asaplog.push( msg ) 1464 print_log( 'ERROR' ) 1435 1465 return 1436 1466 else: … … 1510 1540 if rcParams['verbose']: 1511 1541 #print msg 1512 casalog.post( msg, 'WARN' ) 1542 print_log() 1543 asaplog.push( msg ) 1544 print_log( 'ERROR' ) 1513 1545 return 1514 1546 else: … … 1956 1988 if rcParams['verbose']: 1957 1989 #print fit 1958 casalog.post( '%s' %(fit) ) 1990 asaplog.push( '%s' %(fit) ) 1991 print_log() 1959 1992 return 1960 1993 else: … … 2064 2097 asaplog.push(msg) 2065 2098 #print asaplog.pop().strip() 2066 casalog.post( asaplog.pop().strip(), 'WARN' )2099 print_log( 'ERROR' ) 2067 2100 return 2068 2101 raise IOError(msg)
Note:
See TracChangeset
for help on using the changeset viewer.