source: trunk/python/ipysupport.py @ 2499

Last change on this file since 2499 was 2499, checked in by Malte Marquarding, 12 years ago

use ipython >=0.11

File size: 12.6 KB
Line 
1import sys
2import inspect
3
4from asap.parameters import rcParams
5from asap.scantable import scantable
6
7
8# workaround for ipython, which redirects this if banner=0 in ipythonrc
9#sys.stdout = sys.__stdout__
10#sys.stderr = sys.__stderr__
11
12def version():
13    print  "ASAP %s(%s)"% (__version__, __date__)
14
15def list_scans(t = scantable):
16    print "The user created scantables are: ",
17    globs=inspect.currentframe().f_back.f_locals.copy()
18    out = [ k for k,v in globs.iteritems() \
19                 if isinstance(v, scantable) and not k.startswith("_") ]
20    print out
21    return out
22
23def commands():
24    x = """\
25[The scan container]
26    scantable           - a container for integrations/scans
27                          (can open asap/rpfits/sdfits and ms files)
28        copy            - returns a copy of a scan
29        get_scan        - gets a specific scan out of a scantable
30                          (by name or number)
31        drop_scan       - drops a specific scan out of a scantable
32                          (by number)
33        set_selection   - set a new subselection of the data
34        get_selection   - get the current selection object
35        summary         - print info about the scantable contents
36        stats           - get specified statistic of the spectra in
37                          the scantable
38        stddev          - get the standard deviation of the spectra
39                          in the scantable
40        get_tsys        - get the TSys
41        get_time        - get the timestamps of the integrations
42        get_inttime     - get the integration time
43        get_sourcename  - get the source names of the scans
44        get_azimuth     - get the azimuth of the scans
45        get_elevation   - get the elevation of the scans
46        get_parangle    - get the parallactic angle of the scans
47        get_coordinate  - get the spectral coordinate for the given row,
48                          which can be used for coordinate conversions
49        get_weather     - get the weather condition parameters
50        get_unit        - get the current unit
51        set_unit        - set the abcissa unit to be used from this
52                          point on
53        get_abcissa     - get the abcissa values and name for a given
54                          row (time)
55        get_column_names - get the names of the columns in the scantable
56                           for use with selector.set_query
57        set_freqframe   - set the frame info for the Spectral Axis
58                          (e.g. 'LSRK')
59        set_doppler     - set the doppler to be used from this point on
60        set_dirframe    - set the frame for the direction on the sky
61        set_instrument  - set the instrument name
62        set_feedtype    - set the feed type
63        get_fluxunit    - get the brightness flux unit
64        set_fluxunit    - set the brightness flux unit
65        set_sourcetype  - set the type of the source - source or reference
66        create_mask     - return an mask in the current unit
67                          for the given region. The specified regions
68                          are NOT masked
69        get_restfreqs   - get the current list of rest frequencies
70        set_restfreqs   - set a list of rest frequencies
71        shift_refpix    - shift the reference pixel of the IFs
72        set_spectrum    - overwrite the spectrum for a given row
73        get_spectrum    - retrieve the spectrum for a given
74        get_mask        - retrieve the mask for a given
75        flag            - flag selected channels in the data
76        lag_flag        - flag specified frequency in the data
77        save            - save the scantable to disk as either 'ASAP',
78                          'SDFITS' or 'ASCII'
79        nbeam,nif,nchan,npol - the number of beams/IFs/Pols/Chans
80        nscan           - the number of scans in the scantable
81        nrow            - the number of spectra in the scantable
82        history         - print the history of the scantable
83        get_fit         - get a fit which has been stored witnh the data
84        average_time    - return the (weighted) time average of a scan
85                          or a list of scans
86        average_pol     - average the polarisations together.
87        average_beam    - average the beams together.
88        convert_pol     - convert to a different polarisation type
89        auto_quotient   - return the on/off quotient with
90                          automatic detection of the on/off scans (closest
91                          in time off is selected)
92        mx_quotient     - Form a quotient using MX data (off beams)
93        scale, *, /     - return a scan scaled by a given factor
94        add, +          - return a scan with given value added
95        sub, -          - return a scan with given value subtracted
96        bin             - return a scan with binned channels
97        resample        - return a scan with resampled channels
98        smooth          - return the spectrally smoothed scan
99        poly_baseline   - fit a polynomial baseline to all Beams/IFs/Pols
100        auto_poly_baseline - automatically fit a polynomial baseline
101        recalc_azel     - recalculate azimuth and elevation based on
102                          the pointing
103        gain_el         - apply gain-elevation correction
104        opacity         - apply opacity correction
105        convert_flux    - convert to and from Jy and Kelvin brightness
106                          units
107        freq_align      - align spectra in frequency frame
108        invert_phase    - Invert the phase of the cross-correlation
109        swap_linears    - Swap XX and YY (or RR LL)
110        rotate_xyphase  - rotate XY phase of cross correlation
111        rotate_linpolphase - rotate the phase of the complex
112                             polarization O=Q+iU correlation
113        freq_switch     - perform frequency switching on the data
114        stats           - Determine the specified statistic, e.g. 'min'
115                          'max', 'rms' etc.
116        stddev          - Determine the standard deviation of the current
117                          beam/if/pol
118        get_row_selector - get the selection object for a specified row
119                           number
120 [Selection]
121     selector              - a selection object to set a subset of a scantable
122        set_scans          - set (a list of) scans by index
123        set_cycles         - set (a list of) cycles by index
124        set_beams          - set (a list of) beamss by index
125        set_ifs            - set (a list of) ifs by index
126        set_polarisations  - set (a list of) polarisations by name
127                             or by index
128        set_names          - set a selection by name (wildcards allowed)
129        set_tsys           - set a selection by tsys thresholds
130        set_query          - set a selection by SQL-like query, e.g. BEAMNO==1
131        ( also  get_ functions for all these )
132        reset              - unset all selections
133        +                  - merge two selections
134
135 [Math] Mainly functions which operate on more than one scantable
136
137        average_time    - return the (weighted) time average
138                          of a list of scans
139        quotient        - return the on/off quotient
140        simple_math     - simple mathematical operations on two scantables,
141                          'add', 'sub', 'mul', 'div'
142        quotient        - build quotient of the given on and off scans
143                          (matched pairs and 1 off - n on are valid)
144        merge           - merge a list of scantables
145
146 [Line Catalog]
147    linecatalog              - a linecatalog wrapper, taking an ASCII or
148                               internal format table
149        summary              - print a summary of the current selection
150        set_name             - select a subset by name pattern, e.g. '*OH*'
151        set_strength_limits  - select a subset by line strength limits
152        set_frequency_limits - select a subset by frequency limits
153        reset                - unset all selections
154        save                 - save the current subset to a table (internal
155                               format)
156        get_row              - get the name and frequency from a specific
157                               row in the table
158 [Fitting]
159    fitter
160        auto_fit        - return a scan where the function is
161                          applied to all Beams/IFs/Pols.
162        commit          - return a new scan where the fits have been
163                          commited.
164        fit             - execute the actual fitting process
165        store_fit       - store the fit parameters in the data (scantable)
166        get_chi2        - get the Chi^2
167        set_scan        - set the scantable to be fit
168        set_function    - set the fitting function
169        set_parameters  - set the parameters for the function(s), and
170                          set if they should be held fixed during fitting
171        set_gauss_parameters - same as above but specialised for individual
172                               gaussian components
173        get_parameters  - get the fitted parameters
174        plot            - plot the resulting fit and/or components and
175                          residual
176[Plotter]
177    asapplotter         - a plotter for asap, default plotter is
178                          called 'plotter'
179        plot            - plot a scantable
180        plot_lines      - plot a linecatalog overlay
181        plotazel        - plot azimuth and elevation versus time
182        plotpointing    - plot telescope pointings
183        save            - save the plot to a file ('png' ,'ps' or 'eps')
184        set_mode        - set the state of the plotter, i.e.
185                          what is to be plotted 'colour stacked'
186                          and what 'panelled'
187        set_selection   - only plot a selected part of the data
188        set_range       - set a 'zoom' window [xmin,xmax,ymin,ymax]
189        set_legend      - specify user labels for the legend indeces
190        set_title       - specify user labels for the panel indeces
191        set_abcissa     - specify a user label for the abcissa
192        set_ordinate    - specify a user label for the ordinate
193        set_layout      - specify the multi-panel layout (rows,cols)
194        set_colors      - specify a set of colours to use
195        set_linestyles  - specify a set of linestyles to use if only
196                          using one color
197        set_font        - set general font properties, e.g. 'family'
198        set_histogram   - plot in historam style
199        set_mask        - set a plotting mask for a specific polarization
200        text            - draw text annotations either in data or relative
201                          coordinates
202        arrow           - draw arrow annotations either in data or relative
203                          coordinates
204        axhline,axvline - draw horizontal/vertical lines
205        axhspan,axvspan - draw horizontal/vertical regions
206        annotate        - draw an arrow with label
207        create_mask     - create a scnatble mask interactively
208
209    xyplotter           - matplotlib/pylab plotting functions
210
211[General]
212    commands            - this command
213    print               - print details about a variable
214    list_scans          - list all scantables created by the user
215    list_files          - list all files readable by asap (default rpf)
216    del                 - delete the given variable from memory
217    range               - create a list of values, e.g.
218                          range(3) = [0,1,2], range(2,5) = [2,3,4]
219    help                - print help for one of the listed functions
220    execfile            - execute an asap script, e.g. execfile('myscript')
221    list_rcparameters   - print out a list of possible values to be
222                          put into $HOME/.asaprc
223    rc                  - set rc parameters from within asap
224    mask_and,mask_or,
225    mask_not            - boolean operations on masks created with
226                          scantable.create_mask
227    skydip              - gain opacity values from a sky dip observation
228    opacity_model       - compute opacities fro given frequencies based on
229                          atmospheric model
230
231Note:
232    How to use this with help:
233                                     # function 'summary'
234    [xxx] is just a category
235    Every 'sub-level' in this list should be replaces by a '.' Period when
236    using help
237    Example:
238        ASAP> help scantable # to get info on ths scantable
239        ASAP> help scantable.summary # to get help on the scantable's
240        ASAP> help average_time
241
242        """
243    if rcParams['verbose']:
244        try:
245            from IPython.genutils import page as pager
246        except ImportError:
247            from pydoc import pager
248        pager(x)
249    else:
250        print x
251    return
Note: See TracBrowser for help on using the repository browser.