source: branches/casa-release-4_3/python/ipysupport.py@ 3010

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

introduce 'reshape' method; this includes a fix to c++ for the upper boundary assertion

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 reshape - cut out channel range
100 poly_baseline - fit a polynomial baseline to all Beams/IFs/Pols
101 auto_poly_baseline - automatically fit a polynomial baseline
102 recalc_azel - recalculate azimuth and elevation based on
103 the pointing
104 gain_el - apply gain-elevation correction
105 opacity - apply opacity correction
106 convert_flux - convert to and from Jy and Kelvin brightness
107 units
108 freq_align - align spectra in frequency frame
109 invert_phase - Invert the phase of the cross-correlation
110 swap_linears - Swap XX and YY (or RR LL)
111 rotate_xyphase - rotate XY phase of cross correlation
112 rotate_linpolphase - rotate the phase of the complex
113 polarization O=Q+iU correlation
114 freq_switch - perform frequency switching on the data
115 stats - Determine the specified statistic, e.g. 'min'
116 'max', 'rms' etc.
117 stddev - Determine the standard deviation of the current
118 beam/if/pol
119 get_row_selector - get the selection object for a specified row
120 number
121 [Selection]
122 selector - a selection object to set a subset of a scantable
123 set_scans - set (a list of) scans by index
124 set_cycles - set (a list of) cycles by index
125 set_beams - set (a list of) beamss by index
126 set_ifs - set (a list of) ifs by index
127 set_polarisations - set (a list of) polarisations by name
128 or by index
129 set_names - set a selection by name (wildcards allowed)
130 set_tsys - set a selection by tsys thresholds
131 set_query - set a selection by SQL-like query, e.g. BEAMNO==1
132 ( also get_ functions for all these )
133 reset - unset all selections
134 + - merge two selections
135
136 [Math] Mainly functions which operate on more than one scantable
137
138 average_time - return the (weighted) time average
139 of a list of scans
140 quotient - return the on/off quotient
141 simple_math - simple mathematical operations on two scantables,
142 'add', 'sub', 'mul', 'div'
143 quotient - build quotient of the given on and off scans
144 (matched pairs and 1 off - n on are valid)
145 merge - merge a list of scantables
146
147 [Line Catalog]
148 linecatalog - a linecatalog wrapper, taking an ASCII or
149 internal format table
150 summary - print a summary of the current selection
151 set_name - select a subset by name pattern, e.g. '*OH*'
152 set_strength_limits - select a subset by line strength limits
153 set_frequency_limits - select a subset by frequency limits
154 reset - unset all selections
155 save - save the current subset to a table (internal
156 format)
157 get_row - get the name and frequency from a specific
158 row in the table
159 [Fitting]
160 fitter
161 auto_fit - return a scan where the function is
162 applied to all Beams/IFs/Pols.
163 commit - return a new scan where the fits have been
164 commited.
165 fit - execute the actual fitting process
166 store_fit - store the fit parameters in the data (scantable)
167 get_chi2 - get the Chi^2
168 set_scan - set the scantable to be fit
169 set_function - set the fitting function
170 set_parameters - set the parameters for the function(s), and
171 set if they should be held fixed during fitting
172 set_gauss_parameters - same as above but specialised for individual
173 gaussian components
174 get_parameters - get the fitted parameters
175 plot - plot the resulting fit and/or components and
176 residual
177[Plotter]
178 asapplotter - a plotter for asap, default plotter is
179 called 'plotter'
180 plot - plot a scantable
181 plot_lines - plot a linecatalog overlay
182 plotazel - plot azimuth and elevation versus time
183 plotpointing - plot telescope pointings
184 save - save the plot to a file ('png' ,'ps' or 'eps')
185 set_mode - set the state of the plotter, i.e.
186 what is to be plotted 'colour stacked'
187 and what 'panelled'
188 set_selection - only plot a selected part of the data
189 set_range - set a 'zoom' window [xmin,xmax,ymin,ymax]
190 set_legend - specify user labels for the legend indeces
191 set_title - specify user labels for the panel indeces
192 set_abcissa - specify a user label for the abcissa
193 set_ordinate - specify a user label for the ordinate
194 set_layout - specify the multi-panel layout (rows,cols)
195 set_colors - specify a set of colours to use
196 set_linestyles - specify a set of linestyles to use if only
197 using one color
198 set_font - set general font properties, e.g. 'family'
199 set_histogram - plot in historam style
200 set_mask - set a plotting mask for a specific polarization
201 text - draw text annotations either in data or relative
202 coordinates
203 arrow - draw arrow annotations either in data or relative
204 coordinates
205 axhline,axvline - draw horizontal/vertical lines
206 axhspan,axvspan - draw horizontal/vertical regions
207 annotate - draw an arrow with label
208 create_mask - create a scnatble mask interactively
209
210 xyplotter - matplotlib/pylab plotting functions
211
212[General]
213 commands - this command
214 print - print details about a variable
215 list_scans - list all scantables created by the user
216 list_files - list all files readable by asap (default rpf)
217 del - delete the given variable from memory
218 range - create a list of values, e.g.
219 range(3) = [0,1,2], range(2,5) = [2,3,4]
220 help - print help for one of the listed functions
221 execfile - execute an asap script, e.g. execfile('myscript')
222 list_rcparameters - print out a list of possible values to be
223 put into $HOME/.asaprc
224 rc - set rc parameters from within asap
225 mask_and,mask_or,
226 mask_not - boolean operations on masks created with
227 scantable.create_mask
228 skydip - gain opacity values from a sky dip observation
229 opacity_model - compute opacities fro given frequencies based on
230 atmospheric model
231
232Note:
233 How to use this with help:
234 # function 'summary'
235 [xxx] is just a category
236 Every 'sub-level' in this list should be replaces by a '.' Period when
237 using help
238 Example:
239 ASAP> help scantable # to get info on ths scantable
240 ASAP> help scantable.summary # to get help on the scantable's
241 ASAP> help average_time
242
243 """
244 if rcParams['verbose']:
245 try:
246 from IPython.genutils import page as pager
247 except ImportError:
248 from pydoc import pager
249 pager(x)
250 else:
251 print x
252 return
Note: See TracBrowser for help on using the repository browser.