Changeset 489


Ignore:
Timestamp:
02/21/05 11:38:19 (20 years ago)
Author:
mar637
Message:
  • added history to all functions, which modify the data
Location:
trunk/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapmath.py

    r481 r489  
    3131    if kwargs.has_key('mask'):
    3232        mask = kwargs.get('mask')
     33    varlist = vars()
    3334    lst = tuple(args)
     35    del varlist["kwargs"]
     36    varlist["args"] = "%d scantables" % len(lst)
     37    # need special formatting her for history...
     38   
    3439    from asap._asap import average as _av
    3540    for s in lst:
     
    3742            print "Please give a list of scantables"
    3843            return
    39     return scantable(_av(lst, mask, scanAv, weight))
     44    s = scantable(_av(lst, mask, scanAv, weight))
     45    s._add_history("average_time",varlist)
     46    return s
    4047
    4148def quotient(source, reference, preserve=True):
     
    6976                       as well as the data
    7077    """
     78    varlist = vars()
    7179    if not isinstance(left,scantable) and not isinstance(right,scantable):
    7280        print "Please provide two scantables as input"
    7381        return
    7482    from asap._asap import b_operate as _bop
    75     return scantable(_bop(left, right, op, tsys))
     83    s = scantable(_bop(left, right, op, tsys))
     84    s._add_history("simple_math", varlist)
     85    return s
    7686
    7787def scale(scan, factor, insitu=None, allaxes=None, tsys=True):
     
    92102    if allaxes is None: allaxes = rcParams['scantable.allaxes']
    93103    if insitu is None: insitu = rcParams['insitu']
     104    varlist = vars()
    94105    if not insitu:
    95106        from asap._asap import scale as _scale
    96         return scantable(_scale(scan, factor, allaxes, tsys))
     107        s = scantable(_scale(scan, factor, allaxes, tsys))
     108        s._add_history("scale",varlist)
     109        return s
    97110    else:
    98111        from asap._asap import scale_insitu as _scale
    99112        _scale(scan, factor, allaxes, tsys)
     113        scan._add_history("scale",varlist)
    100114        return
    101115       
    102 
    103116def add(scan, offset, insitu=None, allaxes=None):
    104117    """
     
    124137        return
    125138       
    126 def convert_flux(scan, jyperk=None, eta=None, d=None, insitu=None, allaxes=None):
     139def convert_flux(scan, jyperk=None, eta=None, d=None, insitu=None,
     140                 allaxes=None):
    127141    """
    128142    Return a scan where all spectra are converted to either Jansky or Kelvin
     
    146160    if allaxes is None: allaxes = rcParams['scantable.allaxes']
    147161    if insitu is None: insitu = rcParams['insitu']
     162    varlist = vars()
    148163    if jyperk is None: jyperk = -1.0
    149164    if d is None: d = -1.0
     
    151166    if not insitu:
    152167        from asap._asap import convertflux as _convert
    153         return scantable(_convert(scan, d, eta, jyperk, allaxes))
     168        s = scantable(_convert(scan, d, eta, jyperk, allaxes))
     169        s._add_history("convert_flux", varlist)
     170        return s
    154171    else:
    155172        from asap._asap import convertflux_insitu as _convert
    156173        _convert(scan, d, eta, jyperk, allaxes)
     174        scan._add_history("convert_flux", varlist)
    157175        return
    158176
     
    200218    """
    201219    if allaxes is None: allaxes = rcParams['scantable.allaxes']
     220    if insitu is None: insitu = rcParams['insitu']
     221    varlist = vars()
    202222    if poly is None:
    203223       poly = ()
    204     if insitu is None: insitu = rcParams['insitu']
    205224    from os.path import expandvars
    206225    filename = expandvars(filename)
    207226    if not insitu:
    208227        from asap._asap import gainel as _gainEl
    209         return scantable(_gainEl(scan, poly, filename, method, allaxes))
     228        s = scantable(_gainEl(scan, poly, filename, method, allaxes))
     229        s._add_history("gain_el", varlist)
     230        return s
    210231    else:
    211232        from asap._asap import gainel_insitu as _gainEl
    212233        _gainEl(scan, poly, filename, method, allaxes)
     234        scan._add_history("gain_el", varlist)
    213235        return
    214236       
     
    229251                     The default is taken from .asaprc (False)
    230252    """
     253    if insitu is None: insitu = rcParams['insitu']
     254    varlist = vars()
    231255    if reftime is None: reftime = ''
    232     if insitu is None: insitu = rcParams['insitu']
    233256    perfreqid = not perif
    234257    if not insitu:
    235258        from asap._asap import freq_align as _align
    236         return scantable(_align(scan, reftime, method, perfreqid))
     259        s = scantable(_align(scan, reftime, method, perfreqid))
     260        s._add_history("freq_align", varlist)
     261        return s
    237262    else:
    238263        from asap._asap import freq_align_insitu as _align
    239264        _align(scan, reftime, method, perfreqid)
     265        scan._add_history("freq_align", varlist)
    240266        return
    241267       
     
    257283    if allaxes is None: allaxes = rcParams['scantable.allaxes']
    258284    if insitu is None: insitu = rcParams['insitu']
     285    varlist = vars()
    259286    if not insitu:
    260287        from asap._asap import opacity as _opacity
    261         return scantable(_opacity(scan, tau, allaxes))
     288        s = scantable(_opacity(scan, tau, allaxes))
     289        s._add_history("opacity", varlist)
     290        return s
    262291    else:
    263292        from asap._asap import opacity_insitu as _opacity
    264293        _opacity(scan, tau, allaxes)
     294        scan._add_history("opacity", varlist)
    265295        return
    266296       
     
    274304    """
    275305    if insitu is None: insitu = rcParams['insitu']
     306    varlist = vars()
    276307    if not insitu:
    277308        from asap._asap import bin as _bin
    278         return scantable(_bin(scan, width))
     309        s = scantable(_bin(scan, width))
     310        s._add_history("bin",varlist)
     311        return s
    279312    else:
    280313        from asap._asap import bin_insitu as _bin
    281314        _bin(scan, width)
     315        scan._add_history("bin",varlist)
    282316        return
    283317
     
    293327    """
    294328    if insitu is None: insitu = rcParams['insitu']
     329    varlist = vars()
    295330    if not insitu:
    296331        from asap._asap import resample as _resample
    297         return scantable(_resample(scan, method, width))
     332        s = scantable(_resample(scan, method, width))
     333        s._add_history("resample",varlist)
     334        return s
    298335    else:
    299336        from asap._asap import resample_insitu as _resample
    300337        _resample(scan, method, width)
     338        scan._add_history("resample",varlist)
    301339        return
    302340
     
    318356        polav = average_pols(myscan)
    319357    """
     358    if insitu is None: insitu = rcParams['insitu']
     359    varlist = vars()
     360
    320361    if mask is None:
    321362        mask = ()
    322     if insitu is None: insitu = rcParams['insitu']
    323363    if not insitu:
    324364        from asap._asap import averagepol as _avpol
    325         return scantable(_avpol(scan, mask, weight))
     365        s = scantable(_avpol(scan, mask, weight))
     366        s._add_history("average_pol",varlist)
     367        return s
    326368    else:
    327369        from asap._asap import averagepol_insitu as _avpol
    328370        _avpol(scan, mask, weight)
     371        scan._add_history("average_pol",varlist)
    329372        return
    330373   
     
    352395    if allaxes is None: allaxes = rcParams['scantable.allaxes']
    353396    if insitu is None: insitu = rcParams['insitu']
     397    varlist = vars()
    354398    if not insitu:
    355399        from asap._asap import smooth as _smooth
    356         return scantable(_smooth(scan,kernel,width,allaxes))
     400        s = scantable(_smooth(scan,kernel,width,allaxes))
     401        s._add_history("smooth", varlist)
     402        return s
    357403    else:
    358404        from asap._asap import smooth_insitu as _smooth
    359405        _smooth(scan,kernel,width,allaxes)
     406        scan._add_history("smooth", varlist)
    360407        return
    361408   
     
    375422        bscan = poly_baseline(scan, order=3)
    376423    """
     424    if insitu is None: insitu = rcParams['insitu']
     425    varlist = vars()
    377426    from asap.asapfitter import fitter
    378427    if mask is None:
     
    384433    f.set_function(poly=order)   
    385434    sf = f.auto_fit(insitu)
     435    sf._add_history("poly_baseline", varlist)
    386436    return sf
    387437
    388 def rotate_xyphase (scan, angle, allaxes=None):
     438def rotate_xyphase(scan, angle, allaxes=None):
    389439    """
    390440    Rotate the phase of the XY correlation.  This is always done in situ
     
    400450    """
    401451    if allaxes is None: allaxes = rcParams['scantable.allaxes']
     452    varlist = vars()
    402453    from asap._asap import rotate_xyphase as _rotate_xyphase
    403454    _rotate_xyphase(scan, angle, allaxes)
     455    s._add_history("rotate_xyphase", varlist)
    404456    return
    405 
  • trunk/python/scantable.py

    r484 r489  
    2727                         (input rpfits/sdfits/ms) or replaces the value
    2828                         in existing scantables
    29         """
     29        """       
     30        if average is None or type(average) is not bool:
     31            average = rcParams['scantable.autoaverage']           
     32
    3033        varlist = vars()
    3134        self._vb = rcParams['verbose']
    3235        self._p = None
    33        
    34         if average is None or type(average) is not bool:
    35             autoav = rcParams['scantable.autoaverage']           
    3636
    3737        if isinstance(filename,sdtable):
     
    6464                if unit is not None:
    6565                    tbl.set_fluxunit(unit)
    66                 if autoav:
    67                     from asap._asap import average
     66                if average:
     67                    from asap._asap import average as _av
    6868                    tmp = tuple([tbl])
    6969                    print 'Auto averaging integrations...'
    70                     tbl2 = average(tmp,(),True,'none')
     70                    tbl2 = _av(tmp,(),True,'none')
    7171                    sdtable.__init__(self,tbl2)
    7272                    del r,tbl
     
    8181        Parameters:
    8282            name:        the name of the outputfile. For format="FITS" this
    83                          is the directory file name into which all the files will
    84                          be written (default is 'asap_FITS')
     83                         is the directory file name into which all the files
     84                         will be written (default is 'asap_FITS')
    8585            format:      an optional file format. Default is ASAP.
    8686                         Allowed are - 'ASAP' (save as ASAP [aips++] Table),
     
    9090                                       'MS2' (saves as an aips++
    9191                                              MeasurementSet V2)
    92             stokes:      Convert to Stokes parameters.  Default is False.
     92            stokes:      Convert to Stokes parameters (only available
     93                         currently with FITS and ASCII formats.
     94                         Default is False.
    9395            overwrite:   If the file should be overwritten if it exists.
    9496                         The default False is to return with warning
     
    711713        print "-"*80
    712714        for h in hist:
    713             items = h.split("##")
    714             date = items[0]
    715             func = items[1]
    716             items = items[2:]
    717             print date           
    718             print "Function: %s\n  Parameters:" % (func)
    719             for i in items:
    720                 s = i.split("=")
    721                 print "   %s: %s" % (s[0],s[1])
    722             print "-"*80
     715            if h.startswith("---"):
     716                print h
     717            else:
     718                items = h.split("##")
     719                date = items[0]
     720                func = items[1]
     721                items = items[2:]
     722                print date           
     723                print "Function: %s\n  Parameters:" % (func)
     724                for i in items:
     725                    s = i.split("=")
     726                    print "   %s = %s" % (s[0],s[1])
     727                print "-"*80
    723728        return
    724729
Note: See TracChangeset for help on using the changeset viewer.