Ignore:
Timestamp:
08/05/10 14:40:38 (14 years ago)
Author:
Malte Marquarding
Message:

Ticket #193: the rcParamsverbose? flag is only used in standard asap cli mode. Otherwise log messages are always send to the logger and one needs to call asaplog.disable()/asaplog.enable() to controls this. I have also added the function name as the log origin.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapmath.py

    r1827 r1859  
    6767        if not isinstance(s,scantable):
    6868            msg = "Please give a list of scantables"
    69             if rcParams['verbose']:
    70                 #print msg
    71                 asaplog.push(msg)
    72                 print_log('ERROR')
    73                 return
    74             else:
    75                 raise TypeError(msg)
     69            raise TypeError(msg)
    7670    if scanav: scanav = "SCAN"
    7771    else: scanav = "NONE"
     
    9690        s = scantable(stm._new_average(alignedlst, compel, mask, weight.upper(), scanav))
    9791    s._add_history("average_time",varlist)
    98     print_log()
     92
    9993    return s
    10094
     95@print_log_dec
    10196def quotient(source, reference, preserve=True):
    10297    """
     
    119114    s = scantable(stm._quotient(source, reference, preserve))
    120115    s._add_history("quotient",varlist)
    121     print_log()
    122116    return s
    123117
     
    138132    s = scantable(stm._dototalpower(calon, caloff, tcalval))
    139133    s._add_history("dototalpower",varlist)
    140     print_log()
    141134    return s
    142135
     
    159152    s = scantable(stm._dosigref(sig, ref, smooth, tsysval, tauval))
    160153    s._add_history("dosigref",varlist)
    161     print_log()
    162154    return s
    163155
     
    190182##     if s is None:
    191183##         msg = "The input data appear to contain no position-switch mode data."
    192 ##         if rcParams['verbose']:
    193 ##             #print msg
    194 ##             asaplog.push(msg)
    195 ##             print_log('ERROR')
    196 ##             return
    197 ##         else:
    198 ##             raise TypeError(msg)
     184##         raise TypeError(msg)
    199185    s = scantab.copy()
    200186    from asap._asap import srctype
     
    205191    except Exception, e:
    206192        msg = "The input data appear to contain no position-switch mode data."
    207         if rcParams['verbose']:
    208             #print msg
    209             asaplog.push(msg)
    210             print_log('ERROR')
    211             return
    212         else:
    213             raise TypeError(msg)
     193        raise TypeError(msg)
    214194    s.set_selection()
    215195    sel.reset()
     
    217197    if ssub is None:
    218198        msg = "No data was found with given scan numbers!"
    219         if rcParams['verbose']:
    220             #print msg
    221             asaplog.push(msg)
    222             print_log('ERROR')
    223             return
    224         else:
    225             raise TypeError(msg)
     199        raise TypeError(msg)
    226200    #ssubon = ssub.get_scan('*calon')
    227201    #ssuboff = ssub.get_scan('*[^calon]')
     
    238212    if ssubon.nrow() != ssuboff.nrow():
    239213        msg = "mismatch in numbers of CAL on/off scans. Cannot calibrate. Check the scan numbers."
    240         if rcParams['verbose']:
    241             #print msg
    242             asaplog.push(msg)
    243             print_log('ERROR')
    244             return
    245         else:
    246             raise TypeError(msg)
     214        raise TypeError(msg)
    247215    cals = dototalpower(ssubon, ssuboff, tcalval)
    248216    #sig = cals.get_scan('*ps')
     
    260228    if sig.nscan() != ref.nscan():
    261229        msg = "mismatch in numbers of on/off scans. Cannot calibrate. Check the scan numbers."
    262         if rcParams['verbose']:
    263             #print msg
    264             asaplog.push(msg)
    265             print_log('ERROR')
    266             return
    267         else:
    268             raise TypeError(msg)
     230        raise TypeError(msg)
    269231
    270232    #for user supplied Tsys
     
    272234        if tauval<=0.0:
    273235            msg = "Need to supply a valid tau to use the supplied Tsys"
    274             if rcParams['verbose']:
    275                 #print msg
    276                 asaplog.push(msg)
    277                 print_log('ERROR')
    278                 return
    279             else:
    280                 raise TypeError(msg)
     236            raise TypeError(msg)
    281237        else:
    282238            sig.recalc_azel()
    283239            ref.recalc_azel()
    284240            #msg = "Use of user specified Tsys is not fully implemented yet."
    285             #if rcParams['verbose']:
    286             #    print msg
    287             #    return
    288             #else:
    289             #    raise TypeError(msg)
     241            #raise TypeError(msg)
    290242            # use get_elevation to get elevation and
    291243            # calculate a scaling factor using the formula
     
    442394    ###
    443395    ress._add_history("calps", varlist)
    444     print_log()
    445396    return ress
    446397
     
    469420##     if s is None:
    470421##         msg = "The input data appear to contain no Nod observing mode data."
    471 ##         if rcParams['verbose']:
    472 ##             #print msg
    473 ##             asaplog.push(msg)
    474 ##             print_log('ERROR')
    475 ##             return
    476 ##         else:
    477 ##             raise TypeError(msg)
     422##         raise TypeError(msg)
    478423    s = scantab.copy()
    479424    sel = selector()
     
    483428    except Exception, e:
    484429        msg = "The input data appear to contain no Nod observing mode data."
    485         if rcParams['verbose']:
    486             #print msg
    487             asaplog.push(msg)
    488             print_log('ERROR')
    489             return
    490         else:
    491             raise TypeError(msg)
     430        raise TypeError(msg)
    492431    sel.reset()
    493432    del sel
     
    511450        #if len(scannos)>2:
    512451        #    msg = "calnod can only process a pair of nod scans at time."
    513         #    if rcParams['verbose']:
    514         #        print msg
    515         #        return
    516         #    else:
    517         #        raise TypeError(msg)
     452        #    raise TypeError(msg)
    518453        #
    519454        #if len(scannos)==2:
     
    525460        if tauval<=0.0:
    526461            msg = "Need to supply a valid tau to use the supplied Tsys"
    527             if rcParams['verbose']:
    528                 #print msg
    529                 asaplog.push(msg)
    530                 print_log('ERROR')
    531                 return
    532             else:
    533                 raise TypeError(msg)
     462            raise TypeError(msg)
    534463        else:
    535464            scantab.recalc_azel()
     
    683612    ###
    684613    resspec._add_history("calnod",varlist)
    685     print_log()
    686614    return resspec
    687615
     
    716644#    if check is None:
    717645#        msg = "The input data appear to contain no Nod observing mode data."
    718 #        if rcParams['verbose']:
    719 #            print msg
    720 #            return
    721 #        else:
    722 #            raise TypeError(msg)
     646#        raise TypeError(msg)
    723647    s = scantab.get_scan(scannos)
    724648    del scantab
     
    891815    ###
    892816    resspec._add_history("calfs",varlist)
    893     print_log()
    894817    return resspec
    895818
     
    921844        if not isinstance(s,scantable):
    922845            msg = "Please give a list of scantables"
    923             if rcParams['verbose']:
    924                 #print msg
    925                 asaplog.push(msg)
    926                 print_log('ERROR')
    927                 return
    928             else:
    929                 raise TypeError(msg)
     846            raise TypeError(msg)
    930847    s = scantable(stm._merge(lst))
    931848    s._add_history("merge", varlist)
    932     print_log()
    933849    return s
    934850
     851@print_log_dec
    935852def calibrate( scantab, scannos=[], calmode='none', verify=None ):
    936853    """
     
    946863    if ( calmode == 'nod' ):
    947864        asaplog.push( 'Calibrating nod data.' )
    948         print_log()
    949865        scal = calnod( scantab, scannos=scannos, verify=verify )
    950866    elif ( calmode == 'quotient' ):
    951867        asaplog.push( 'Calibrating using quotient.' )
    952         print_log()
    953868        scal = scantab.auto_quotient( verify=verify )
    954869    elif ( calmode == 'ps' ):
    955870        asaplog.push( 'Calibrating %s position-switched data.' % antname )
    956         print_log()
    957871        if ( antname.find( 'APEX' ) != -1 ):
    958872            scal = apexcal( scantab, scannos, calmode, verify )
     
    963877    elif ( calmode == 'fs' or calmode == 'fsotf' ):
    964878        asaplog.push( 'Calibrating %s frequency-switched data.' % antname )
    965         print_log()
    966879        if ( antname.find( 'APEX' ) != -1 ):
    967880            scal = apexcal( scantab, scannos, calmode, verify )
     
    972885    elif ( calmode == 'otf' ):
    973886        asaplog.push( 'Calibrating %s On-The-Fly data.' % antname )
    974         print_log()
    975887        scal = almacal( scantab, scannos, calmode, verify )
    976888    else:
     
    1015927    return scal
    1016928
     929@print_log_dec
    1017930def splitant(filename, outprefix='',overwrite=False):
    1018931    """
     
    1032945    """
    1033946    # Import the table toolkit from CASA
    1034     try:
    1035        import casac
    1036     except ImportError:
    1037        if rcParams['verbose']:
    1038            #print "failed to load casa"
    1039            print_log()
    1040            asaplog.push("failed to load casa")
    1041            print_log('ERROR')
    1042        else: raise
    1043        return False
    1044     try:
    1045        tbtool = casac.homefinder.find_home_by_name('tableHome')
    1046        tb = tbtool.create()
    1047        tb2 = tbtool.create()
    1048     except:
    1049        if rcParams['verbose']:
    1050            #print "failed to load a table tool:\n", e
    1051            print_log()
    1052            asaplog.push("failed to load table tool")
    1053            print_log('ERROR')
    1054        else: raise
    1055        return False
     947
     948    import casac
     949    tbtool = casac.homefinder.find_home_by_name('tableHome')
     950    tb = tbtool.create()
     951    tb2 = tbtool.create()
    1056952    # Check the input filename
    1057953    if isinstance(filename, str):
     
    1061957        if not os.path.exists(filename):
    1062958            s = "File '%s' not found." % (filename)
    1063             if rcParams['verbose']:
    1064                 print_log()
    1065                 asaplog.push(s)
    1066                 print_log('ERROR')
    1067                 return
    1068959            raise IOError(s)
    1069960        # check if input file is MS
     
    1072963               or not os.path.exists(filename+'/table.f1'):
    1073964            s = "File '%s' is not a Measurement set." % (filename)
    1074             if rcParams['verbose']:
    1075                 print_log()
    1076                 asaplog.push(s)
    1077                 print_log('ERROR')
    1078                 return
    1079965            raise IOError(s)
    1080966    else:
    1081967        s = "The filename should be string. "
    1082         if rcParams['verbose']:
    1083             print_log()
    1084             asaplog.push(s)
    1085             print_log('ERROR')
    1086             return
    1087968        raise TypeError(s)
    1088969    # Check out put file name
     
    1110991    return outfiles
    1111992
     993@print_log_dec
    1112994def _array2dOp( scan, value, mode="ADD", tsys=False ):
    1113995    """
     
    11281010        del stm
    11291011    elif len( value ) != nrow:
    1130         asaplog.push( 'len(value) must be 1 or conform to scan.nrow()' )
    1131         print_log( 'ERROR' )
     1012        raise ValueError( 'len(value) must be 1 or conform to scan.nrow()' )
    11321013    else:
    11331014        from asap._asap import stmath
Note: See TracChangeset for help on using the changeset viewer.