Ignore:
Timestamp:
02/28/05 15:28:33 (19 years ago)
Author:
mar637
Message:

*Moved most asapmath functions to scantable member functions. Only ones taking more than one scantable as input remain.

  • added asap._is_sequence_or_number to check input args
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r510 r513  
    55import os,sys
    66
    7 def validate_bool(b):
     7def _validate_bool(b):
    88    'Convert b to a boolean or raise'
    99    bl = b.lower()
     
    1313        raise ValueError('Could not convert "%s" to boolean' % b)
    1414
    15 def validate_int(s):
     15def _validate_int(s):
    1616    'convert s to int or raise'
    1717    try: return int(s)
     
    1919        raise ValueError('Could not convert "%s" to int' % s)
    2020
    21 def asap_fname():
     21def _asap_fname():
    2222    """
    2323    Return the path to the rc file
     
    5151defaultParams = {
    5252    # general
    53     'verbose'             : [True, validate_bool],
    54     'useplotter'          : [True, validate_bool],
    55     'insitu'              : [False, validate_bool],
     53    'verbose'             : [True, _validate_bool],
     54    'useplotter'          : [True, _validate_bool],
     55    'insitu'              : [False, _validate_bool],
    5656   
    5757    # plotting
     
    6161    # scantable
    6262    'scantable.save'      : ['ASAP', str],
    63     'scantable.autoaverage'      : [True, validate_bool],
     63    'scantable.autoaverage'      : [True, _validate_bool],
    6464    'scantable.freqframe' : ['LSRK', str],  #default frequency frame
    65     'scantable.allaxes'   : [True, validate_bool],  # apply action to all axes
    66     'scantable.plotter'   : [True, validate_bool], # use internal plotter
    67     'scantable.verbosesummary'   : [False, validate_bool]
     65    'scantable.allaxes'   : [True, _validate_bool],  # apply action to all axes
     66    'scantable.plotter'   : [True, _validate_bool], # use internal plotter
     67    'scantable.verbosesummary'   : [False, _validate_bool]
    6868
    6969    # fitter
     
    115115    'Return the default params updated from the values in the rc file'
    116116   
    117     fname = asap_fname()
     117    fname = _asap_fname()
    118118   
    119119    if fname is None or not os.path.exists(fname):
     
    199199    rcParams.update(rcParamsDefault)
    200200
     201
     202def _is_sequence_or_number(param, ptype=int):
     203    if isinstance(param,tuple) or isinstance(param,list):
     204        out = True
     205        for p in param:
     206            out &= isinstance(p,ptype)
     207        return out
     208    elif isinstance(param, ptype):
     209        return True
     210    return False
     211
    201212from asapfitter import *
    202213from asapreader import reader
     
    221232
    222233__date__ = '$Date$'
    223 __version__  = '0.2'
     234__version__  = '0.9'
    224235
    225236def list_scans(t = scantable):
     
    253264            get_time        - get the timestamps of the integrations
    254265            get_unit        - get the currnt unit
    255             set_unit        - set the abcissa unit to be used from this point on
     266            set_unit        - set the abcissa unit to be used from this
     267                              point on
    256268            get_abcissa     - get the abcissa values and name for a given
    257269                              row (time)
     
    273285            nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
    274286            history         - print the history of the scantable
    275     [Math]
    276         average_time       - return the (weighted) time average of a scan
    277                              or a list of scans
    278         average_pol         - average the polarisations together.
     287
     288            average_time    - return the (weighted) time average of a scan
     289                              or a list of scans
     290            average_pol     - average the polarisations together.
    279291                              The dimension won't be reduced and
    280292                              all polarisations will contain the
    281293                              averaged spectrum.
    282         quotient            - return the on/off quotient
    283         simple_math         - simple mathematical operations on two scantables,
     294            quotient        - return the on/off quotient
     295            scale           - return a scan scaled by a given factor
     296            add             - return a scan with given value added
     297            bin             - return a scan with binned channels
     298            resample        - return a scan with resampled channels
     299            smooth          - return the spectrally smoothed scan
     300            poly_baseline   - fit a polynomial baseline to all Beams/IFs/Pols
     301            gain_el         - apply gain-elevation correction
     302            opacity         - apply opacity correction
     303            convert_flux    - convert to and from Jy and Kelvin brightness
     304                              units
     305            freq_align      - align spectra in frequency frame
     306            rotate_xyphase  - rotate XY phase of cross correlation
     307            rotate_linpolphase - rotate the phase of the complex
     308                                 polarization O=Q+iU correlation
     309     [Math] Mainly functions which operate on more than one scantable
     310
     311            average_time    - return the (weighted) time average
     312                              of a list of scans
     313            quotient        - return the on/off quotient
     314            simple_math     - simple mathematical operations on two scantables,
    284315                              'add', 'sub', 'mul', 'div'
    285         scale               - return a scan scaled by a given factor
    286         add                 - return a scan with given value added
    287         bin                 - return a scan with binned channels
    288         resample            - return a scan with resampled channels
    289         smooth              - return the spectrally smoothed scan
    290         poly_baseline       - fit a polynomial baseline to all Beams/IFs/Pols
    291         auto_poly_baseline  - automatically fit a polynomial baseline
    292         gain_el             - apply gain-elevation correction
    293         opacity             - apply opacity correction
    294         convert_flux        - convert to and from Jy and Kelvin brightness
    295                               units
    296         freq_align          - align spectra in frequency frame
    297         rotate_xyphase      - rotate XY phase of cross correlation
    298 
     316     [Fitting]
    299317        fitter
    300318            auto_fit        - return a scan where the function is
     
    308326            set_parameters  - set the parameters for the function(s), and
    309327                              set if they should be held fixed during fitting
     328            set_gauss_parameters - same as above but specialised for individual
     329                                   gaussian components
    310330            get_parameters  - get the fitted parameters
     331            plot            - plot the resulting fit and/or components and
     332                              residual
    311333    [Plotter]
    312334        asapplotter         - a plotter for asap, default plotter is
Note: See TracChangeset for help on using the changeset viewer.