Ignore:
Timestamp:
04/06/06 10:12:03 (18 years ago)
Author:
mar637
Message:

added function to convert between polarisation types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r984 r992  
    232232
    233233def unique(x):
     234    """
     235    Return the unique values in a list
     236    Parameters:
     237        x:      the list to reduce
     238    Examples:
     239        x = [1,2,3,3,4]
     240        print unique(x)
     241        [1,2,3,4]
     242    """
    234243    return dict([ (val, 1) for val in x]).keys()
     244
     245def list_files(path=".",suffix="rpf"):
     246    """
     247    Return a list files readable by asap, such as rpf, sdfits, mbf, asap
     248    Parameters:
     249        path:     The directory to list (default '.')
     250        suffix:   The file extension (default rpf)
     251    Example:
     252        files = list_files("data/","sdfits")
     253        print files
     254        ['data/2001-09-01_0332_P363.sdfits',
     255        'data/2003-04-04_131152_t0002.sdfits',
     256        'data/Sgr_86p262_best_SPC.sdfits']
     257    """
     258    import os
     259    if not os.path.isdir(path):
     260        return None
     261    valid = "rpf sdf sdfits mbf asap".split()
     262    if not suffix in valid:
     263        return None
     264    files = [os.path.expanduser(os.path.expandvars(path+"/"+f)) for f in os.listdir(path)]
     265    return filter(lambda x: x.endswith(suffix),files)
    235266
    236267# workaround for ipython, which redirects this if banner=0 in ipythonrc
     
    335366                              all polarisations will contain the
    336367                              averaged spectrum.
     368            convert_pol     - convert to a different polarisation type
    337369            auto_quotient   - return the on/off quotient with
    338370                              automatic detection of the on/off scans
     
    417449        print               - print details about a variable
    418450        list_scans          - list all scantables created bt the user
     451        list_files          - list all files readable by asap (default rpf)
    419452        del                 - delete the given variable from memory
    420453        range               - create a list of values, e.g.
Note: See TracChangeset for help on using the changeset viewer.