cubevis 1.0.0__py3-none-any.whl → 1.0.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. cubevis/__init__.py +12 -23
  2. cubevis/__js__/bokeh-3.6/cubevisjs.min.js +64 -0
  3. cubevis/__js__/{cubevisjs.min.js → bokeh-3.7/cubevisjs.min.js} +3 -3
  4. cubevis/__js__/bokeh-3.8/cubevisjs.min.js +64 -0
  5. cubevis/__js__/casalib.min.js +1 -1
  6. cubevis/__version__.py +1 -1
  7. cubevis/bokeh/__init__.py +16 -0
  8. cubevis/bokeh/annotations/_ev_poly_annotation.py +2 -1
  9. cubevis/bokeh/format/_wcs_ticks.py +6 -2
  10. cubevis/bokeh/models/__init__.py +1 -0
  11. cubevis/bokeh/models/_showable.py +352 -0
  12. cubevis/bokeh/models/_tip.py +2 -1
  13. cubevis/bokeh/models/_tip_button.py +2 -3
  14. cubevis/bokeh/sources/_data_pipe.py +6 -2
  15. cubevis/bokeh/sources/_image_data_source.py +6 -2
  16. cubevis/bokeh/sources/_image_pipe.py +4 -1
  17. cubevis/bokeh/sources/_spectra_data_source.py +6 -3
  18. cubevis/bokeh/sources/_updatable_data_source.py +6 -2
  19. cubevis/bokeh/state/__init__.py +4 -3
  20. cubevis/bokeh/state/_current.py +34 -0
  21. cubevis/bokeh/state/_initialize.py +282 -116
  22. cubevis/bokeh/state/_javascript.py +95 -21
  23. cubevis/bokeh/tools/_cbreset_tool.py +2 -1
  24. cubevis/bokeh/tools/_drag_tool.py +2 -1
  25. cubevis/bokeh/utils/__init__.py +0 -1
  26. cubevis/exe/_setting.py +1 -0
  27. cubevis/private/apps/__init__.py +4 -2
  28. cubevis/private/apps/_interactiveclean.mustache +6 -2
  29. cubevis/private/apps/_interactiveclean.py +6 -2
  30. cubevis/private/apps/_interactivecleannotebook.mustache +112 -0
  31. cubevis/private/apps/_interactivecleannotebook.py +1874 -0
  32. cubevis/private/casatasks/iclean.py +4 -0
  33. cubevis/toolbox/_app_context.py +5 -9
  34. cubevis/toolbox/_cube.py +6 -2
  35. cubevis/toolbox/_interactive_clean_ui.mustache +20 -31
  36. cubevis/toolbox/_interactive_clean_ui.py +20 -31
  37. cubevis/utils/__init__.py +183 -41
  38. cubevis/utils/_git.py +36 -0
  39. cubevis/utils/_jupyter.py +12 -0
  40. {cubevis-1.0.0.dist-info → cubevis-1.0.4.dist-info}/METADATA +3 -3
  41. {cubevis-1.0.0.dist-info → cubevis-1.0.4.dist-info}/RECORD +43 -39
  42. cubevis/__js__/bokeh-3.6.1.min.js +0 -728
  43. cubevis/__js__/bokeh-tables-3.6.1.min.js +0 -119
  44. cubevis/__js__/bokeh-widgets-3.6.1.min.js +0 -141
  45. {cubevis-1.0.0.dist-info → cubevis-1.0.4.dist-info}/WHEEL +0 -0
  46. {cubevis-1.0.0.dist-info → cubevis-1.0.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,1874 @@
1
+ ########################################################################
2
+ #
3
+ # Copyright (C) 2022,2023,2024,2025
4
+ # Associated Universities, Inc. Washington DC, USA.
5
+ #
6
+ # This script is free software; you can redistribute it and/or modify it
7
+ # under the terms of the GNU Library General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or (at your
9
+ # option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful, but WITHOUT
12
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14
+ # License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Library General Public License
17
+ # along with this library; if not, write to the Free Software Foundation,
18
+ # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19
+ #
20
+ # Correspondence concerning AIPS++ should be adressed as follows:
21
+ # Internet email: casa-feedback@nrao.edu.
22
+ # Postal address: AIPS++ Project Office
23
+ # National Radio Astronomy Observatory
24
+ # 520 Edgemont Road
25
+ # Charlottesville, VA 22903-2475 USA
26
+ #
27
+ ########################################################################
28
+ '''implementation of the ``InteractiveClean`` application for interactive control
29
+ of tclean'''
30
+
31
+ from pprint import pprint
32
+
33
+ import sys
34
+ from uuid import uuid4
35
+ from os.path import exists
36
+ from bokeh.plotting import show
37
+ from bokeh.io import output_notebook
38
+ from casatasks.private.imagerhelpers.input_parameters import ImagerParameters
39
+
40
+ from cubevis.bokeh.models import Showable
41
+ from cubevis.utils import find_pkg, load_pkg
42
+ from cubevis.toolbox import InteractiveCleanUI
43
+ from cubevis import exe
44
+
45
+ class InteractiveCleanNotebook:
46
+ r'''InteractiveCleanNotebook(...) implements interactive clean using Bokeh
47
+ tclean ---- Radio Interferometric Image Reconstruction
48
+
49
+ Form images from visibilities and reconstruct a sky model.
50
+ This task handles continuum images and spectral line cubes,
51
+ supports outlier fields, contains standard clean based algorithms
52
+ along with algorithms for multi-scale and wideband image
53
+ reconstruction, widefield imaging correcting for the w-term,
54
+ full primary-beam imaging and joint mosaic imaging (with
55
+ heterogeneous array support for ALMA).
56
+
57
+ --------- parameter descriptions ---------------------------------------------
58
+
59
+ vis Name(s) of input visibility file(s)
60
+ default: none;
61
+ example: vis='ngc5921.ms'
62
+ vis=['ngc5921a.ms','ngc5921b.ms']; multiple MSs
63
+ selectdata Enable data selection parameters.
64
+ field to image or mosaic. Use field id(s) or name(s).
65
+ ['go listobs' to obtain the list id's or names]
66
+ default: ''= all fields.
67
+ If field string is a non-negative integer, it is assumed to
68
+ be a field index, otherwise it is assumed to be a
69
+ field name.
70
+ field='0~2'; field ids 0,1,2.
71
+ field='0,4,5~7'; field ids 0,4,5,6,7.
72
+ field='3C286,3C295'; field names 3C286 and 3C295.
73
+ field = '3,4C\*'; field id 3, all names starting with 4C.
74
+ For multiple MS input, a list of field strings can be used:
75
+ field = ['0~2','0~4']; field ids 0-2 for the first MS and 0-4
76
+ for the second.
77
+ field = '0~2'; field ids 0-2 for all input MSs.
78
+ spw l window/channels.
79
+ NOTE: channels not selected here will contain all zeros if
80
+ selected by other subparameters.
81
+ default: ''=all spectral windows and channels.
82
+ spw='0~2,4'; spectral windows 0,1,2,4 (all channels).
83
+ spw='0:5~61'; spw 0, channels 5 to 61.
84
+ spw='<2'; spectral windows less than 2 (i.e. 0,1).
85
+ spw='0,10,3:3~45'; spw 0,10 all channels, and spw 3
86
+ channels 3 to 45.
87
+ spw='0~2:2~6'; spw 0,1,2 with channels 2 through 6 in each.
88
+ For multiple MS input, a list of spw strings can be used:
89
+ spw=['0','0~3']; spw ids 0 for the first MS and 0-3 for the second.
90
+ spw='0~3' spw ids 0-3 for all input MS.
91
+ spw='3:10~20;50~60' for multiple channel ranges within spw id 3.
92
+ spw='3:10~20;50~60,4:0~30' for different channel ranges for spw ids 3 and 4.
93
+ spw='0:0~10,1:20~30,2:1;2;3'; spw 0, channels 0-10,
94
+ spw 1, channels 20-30, and spw 2, channels, 1,2 and 3.
95
+ spw='1~4;6:15~48' for channels 15 through 48 for spw ids 1,2,3,4 and 6.
96
+ timerange Range of time to select from data
97
+
98
+ default: '' (all); examples,
99
+ timerange = 'YYYY/MM/DD/hh:mm:ss~YYYY/MM/DD/hh:mm:ss'
100
+ Note: if YYYY/MM/DD is missing date defaults to first
101
+ day in data set.
102
+ timerange='09:14:0~09:54:0' picks 40 min on first day.
103
+ timerange='25:00:00~27:30:00' picks 1 hr to 3 hr
104
+ 30min on NEXT day.
105
+ timerange='09:44:00' pick data within one integration
106
+ of time.
107
+ timerange='> 10:24:00' data after this time.
108
+ For multiple MS input, a list of timerange strings can be
109
+ used:
110
+ timerange=['09:14:0~09:54:0','> 10:24:00'].
111
+ timerange='09:14:0~09:54:0''; apply the same timerange for
112
+ all input MSs.
113
+ uvrange Select data within uvrange (default unit is meters)
114
+ default: '' (all); example:
115
+ uvrange='0~1000klambda'; uvrange from 0-1000 kilo-lambda.
116
+ uvrange='> 4klambda';uvranges greater than 4 kilo lambda.
117
+ For multiple MS input, a list of uvrange strings can be
118
+ used:
119
+ uvrange=['0~1000klambda','100~1000klamda'].
120
+ uvrange='0~1000klambda'; apply 0-1000 kilo-lambda for all
121
+ input MSs.
122
+ uvrange='0~1000'; apply 0-1000 meter for all input MSs.
123
+ antenna Select data based on antenna/baseline
124
+
125
+ default: '' (all)
126
+ If antenna string is a non-negative integer, it is
127
+ assumed to be an antenna index, otherwise, it is
128
+ considered an antenna name.
129
+ antenna='5\&6'; baseline between antenna index 5 and
130
+ index 6.
131
+ antenna='VA05\&VA06'; baseline between VLA antenna 5
132
+ and 6.
133
+ antenna='5\&6;7\&8'; baselines 5-6 and 7-8.
134
+ antenna='5'; all baselines with antenna index 5.
135
+ antenna='05'; all baselines with antenna number 05
136
+ (VLA old name).
137
+ antenna='5,6,9'; all baselines with antennas 5,6,9
138
+ index number.
139
+ For multiple MS input, a list of antenna strings can be
140
+ used:
141
+ antenna=['5','5\&6'];
142
+ antenna='5'; antenna index 5 for all input MSs.
143
+ antenna='!DV14'; use all antennas except DV14.
144
+ scan Scan number range
145
+
146
+ default: '' (all).
147
+ example: scan='1~5'.
148
+ For multiple MS input, a list of scan strings can be used:
149
+ scan=['0~100','10~200'].
150
+ scan='0~100; scan ids 0-100 for all input MSs.
151
+ observation Observation ID range
152
+ default: '' (all).
153
+ example: observation='1~5'.
154
+ intent Scan Intent(s)
155
+
156
+ default: '' (all).
157
+ example: intent='TARGET_SOURCE'.
158
+ example: intent='TARGET_SOURCE1,TARGET_SOURCE2'.
159
+ example: intent='TARGET_POINTING\*'.
160
+ datacolumn Data column to image (data or observed, corrected)
161
+ default:'corrected'
162
+ ( If 'corrected' does not exist, it will use 'data' instead )
163
+ imagename Pre-name of output images
164
+
165
+ example : imagename='try'
166
+
167
+ Output images will be (a subset of) :
168
+
169
+ try.psf - Point Spread Function (PSF).
170
+ try.residual - Residual image.
171
+ try.image - Restored image.
172
+ try.model - Model image (contains only flux components).
173
+ try.sumwt - Single pixel image containing sum-of-weights.
174
+ (for natural weighting, sensitivity=1/sqrt(sumwt)).
175
+ try.pb - Primary Beam (PB) model (values depend on the gridder used).
176
+
177
+ A-projection algorithms (gridder=mosaic,awproject, awp2) will
178
+ compute the following images too.
179
+
180
+ try.weight - FT of gridded weights or the
181
+ un-normalized sum of PB-square (for all pointings).
182
+ Here, PB = sqrt(weight) normalized to a maximum of 1.0.
183
+
184
+ For multi-term wideband imaging, all relevant images above will
185
+ have additional .tt0,.tt1, etc suffixes to indicate Taylor terms,
186
+ plus the following extra output images.
187
+ try.alpha - spectral index.
188
+ try.alpha.error - estimate of error on spectral index.
189
+ try.beta - spectral curvature (if nterms \> 2).
190
+
191
+ Tip : Include a directory name in 'imagename' for all
192
+ output images to be sent there instead of the
193
+ current working directory : imagename='mydir/try'.
194
+
195
+ Tip : Restarting an imaging run without changing 'imagename'
196
+ implies continuation from the existing model image on disk.
197
+ - If 'startmodel' was initially specified it needs to be set to ""
198
+ for the restart run (or tclean will exit with an error message).
199
+ - By default, the residual image and psf will be recomputed
200
+ but if no changes were made to relevant parameters between
201
+ the runs, set calcres=False, calcpsf=False to resume directly from
202
+ the minor cycle without the (unnecessary) first major cycle.
203
+ To automatically change 'imagename' with a numerical
204
+ increment, set restart=False (see tclean docs for 'restart').
205
+
206
+ Note : All imaging runs will by default produce restored images.
207
+ For a niter=0 run, this will be redundant and can optionally
208
+ be turned off via the 'restoration=T/F' parameter.
209
+ imsize Number of pixels
210
+ example:
211
+
212
+ imsize = [350,250].
213
+ imsize = 500 is equivalent to [500,500].
214
+
215
+ To take proper advantage of internal optimized FFT routines, the
216
+ number of pixels must be even and factorizable by 2,3,5 only.
217
+ To find the nearest optimal imsize to that desired by the user, please use the following tool method:
218
+
219
+ from casatools import synthesisutils
220
+ su = synthesisutils()
221
+ su.getOptimumSize(345)
222
+ Output : 360
223
+ cell Cell size
224
+ example: cell=['0.5arcsec,'0.5arcsec'] or
225
+ cell=['1arcmin', '1arcmin'].
226
+ cell = '1arcsec' is equivalent to ['1arcsec','1arcsec'].
227
+ phasecenter Phase center of the image (string or field id); if the phasecenter is the name known major solar system object ('MERCURY', 'VENUS', 'MARS', 'JUPITER', 'SATURN', 'URANUS', 'NEPTUNE', 'PLUTO', 'SUN', 'MOON') or is an ephemerides table then that source is tracked and the background sources get smeared. There is a special case, when phasecenter='TRACKFIELD', which will use the ephemerides or polynomial phasecenter in the FIELD table of the MS's as the source center to track.
228
+
229
+ Note : If unspecified, tclean will use the phase-center from the first data field of the MS (or list of MSs) selected for imaging.
230
+
231
+ example: phasecenter='6'.
232
+ phasecenter='J2000 19h30m00 -40d00m00'.
233
+ phasecenter='J2000 292.5deg -40.0deg'.
234
+ phasecenter='J2000 5.105rad -0.698rad'.
235
+ phasecenter='ICRS 13:05:27.2780 -049.28.04.458'.
236
+ phasecenter='myComet_ephem.tab'.
237
+ phasecenter='MOON'.
238
+ phasecenter='TRACKFIELD'.
239
+ stokes Stokes Planes to make
240
+ default='I'; example: stokes='IQUV';
241
+ Options: 'I','Q','U','V','IV','QU','IQ','UV','IQUV','RR','LL','XX','YY','RRLL','XXYY','pseudoI'
242
+
243
+ Note : Due to current internal code constraints, if any correlation pair
244
+ is flagged, by default, no data for that row in the MS will be used.
245
+ So, in an MS with XX,YY, if only YY is flagged, neither a
246
+ Stokes I image nor an XX image can be made from those data points.
247
+ In such a situation, please split out only the unflagged correlation into
248
+ a separate MS, or use the option 'pseudoI'.
249
+
250
+ Note : The 'pseudoI' option is a partial solution, allowing Stokes I imaging
251
+ when either of the parallel-hand correlations are unflagged.
252
+
253
+ The remaining constraints shall be removed (where logical) in a future release.
254
+ projection Coordinate projection
255
+ Examples : SIN, NCP.
256
+ A list of supported (but untested) projections can be found here :
257
+ http://casa.nrao.edu/active/docs/doxygen/html/classcasa_1_1Projection.html#a3d5f9ec787e4eabdce57ab5edaf7c0cd
258
+ startmodel Name of starting model image
259
+
260
+ The contents of the supplied starting model image will be
261
+ copied to the imagename.model before the run begins.
262
+
263
+ example : startmodel = 'singledish.im'.
264
+
265
+ For deconvolver='mtmfs', one image per Taylor term must be provided.
266
+ example : startmodel = ['try.model.tt0', 'try.model.tt1'].
267
+ startmodel = ['try.model.tt0'] will use a starting model only
268
+ for the zeroth order term.
269
+ startmodel = ['','try.model.tt1'] will use a starting model only
270
+ for the first order term.
271
+
272
+ This starting model can be of a different image shape and size from
273
+ what is currently being imaged. If so, an image regrid is first triggered
274
+ to resample the input image onto the target coordinate system.
275
+
276
+ A common usage is to set this parameter equal to a single dish image.
277
+
278
+ Negative components in the model image will be included as is.
279
+
280
+ Note : If an error occurs during image resampling/regridding,
281
+ please try using task imregrid to resample the starting model
282
+ image onto a CASA image with the target shape and
283
+ coordinate system before supplying it via startmodel.
284
+ specmode Spectral definition mode (mfs,cube,cubedata, cubesource, mvc)
285
+
286
+ specmode='mfs' : Continuum imaging with only one output image channel.
287
+ (mode='cont' can also be used here)
288
+
289
+ specmode='cube' : Spectral line imaging with one or more channels.
290
+ Parameters start, width,and nchan define the spectral
291
+ coordinate system and can be specified either in terms
292
+ of channel numbers, frequency or velocity in whatever
293
+ spectral frame is specified in 'outframe'.
294
+ All internal and output images are made with outframe as the
295
+ base spectral frame. However imaging code internally uses the fixed
296
+ spectral frame, LSRK for automatic internal software
297
+ Doppler correction, so that a spectral line observed over an
298
+ extended time range will line up appropriately.
299
+ Therefore the output images have additional spectral frame conversion
300
+ layer in LSRK on the top the base frame.
301
+
302
+
303
+
304
+
305
+ specmode='cubedata' : Spectral line imaging with one or more channels.
306
+ There is no internal software Doppler correction, so
307
+ a spectral line observed over an extended time range
308
+ may be smeared out in frequency. There is strictly
309
+ no valid spectral frame with which to associate with the
310
+ output images, thus the image spectral frame will
311
+ be labelled "Undefined".
312
+
313
+
314
+ specmode='cubesource': Spectral line imaging while
315
+ tracking moving source (near field or solar system
316
+ objects). The velocity of the source is accounted
317
+ and the frequency reported is in the source frame.
318
+ As there is no "SOURCE" frame defined in CASA,
319
+ the frame in the image will be labelled "REST" (but do note the
320
+ velocity of a given line reported may be different from the rest frame
321
+ velocity if the emission region is moving w.r.t the systemic
322
+ velocity frame of the source).
323
+
324
+ specmode='mvc' : Multiterm continuum imaging with cube major cycles.
325
+ This mode requires deconvolver='mtmfs' with nterms>1
326
+ and user-set choices of 'reffreq' and 'nchan'.
327
+
328
+ The output images and minor cycle are similar to specmode='mfs'
329
+ with deconvolver='mtmfs', but the major cycles are done in
330
+ cube mode (and require a setting of 'reffreq' and 'nchan').
331
+ By default, frequency-dependent primary beam correction is
332
+ applied to each channel, before being combined across frequency
333
+ to make the inputs to the 'mtmfs' deconvolver. This results in
334
+ implicit wideband pb-correction, with the deconvolver seeing only
335
+ the sky spectral structure.
336
+
337
+ Note : There is currently no option to turn off wideband pb correction
338
+ as part of the flat-sky normalization between the major and minor cycles.
339
+ Therefore, 'mvc' with the 'standard' and 'wproject' gridders will also apply
340
+ pblimits per channel, masking all regions outside of pblimit.
341
+ An option to retain sources outside the pblimit will be added in a future release.
342
+
343
+ Note : Below is some guidance for choosing 'nchan' and 'reffreq' :
344
+
345
+ The cube produced by the major cycle is used in a linear least square fits for Taylor
346
+ polynomials per pixel. Therefore, one only needs as many channels in the cube, as
347
+ required for an accurate polynomial fit for sources that have the strongest
348
+ spectral structure.
349
+
350
+ In general, 'nchan' needs to be greater than or equal to 'nterms', and the
351
+ frequency range selected by the data will be evenly split into nchan channels.
352
+ For a low-order polynomial fit, only a small number (around 10)
353
+ channels are typically needed (for VLA/ALMA bandwidth ratios).
354
+ 'nchan=-1' applies a heuristic that results in a default of 10 cube channels
355
+ for a 2:1 bandwidth ratio.
356
+
357
+ nchan = MAX( bandwidth/(0.1*startfreq) , nterms+1 )
358
+
359
+ Note: When running in parallel, the nchan selected may limit the speedup if it
360
+ is smaller than the number of processes used.
361
+
362
+ The 'reffreq' is the reference frequency used for the Taylor polynomial expansion.
363
+ By default, in specmode='mvc', reffreq is set to the middle of the selected
364
+ frequency range.
365
+ reffreq Reference frequency of the output image coordinate system.
366
+
367
+ Example : reffreq='1.5GHz' as a string with units.
368
+
369
+ By default, it is calculated as the middle of the selected frequency range.
370
+
371
+ For deconvolver='mtmfs' the Taylor expansion is also done about
372
+ this specified reference frequency.
373
+ nchan Number of channels in the output image.
374
+ For default (=-1), the number of channels will be automatically determined
375
+ based on data selected by 'spw' with 'start' and 'width'.
376
+ It is often easiest to leave nchan at the default value.
377
+ example: nchan=100
378
+ start First channel (e.g. start=3,start=\'1.1GHz\',start=\'15343km/s\')
379
+ of output cube images specified by data channel number (integer),
380
+ velocity (string with a unit), or frequency (string with a unit).
381
+ Default:''; The first channel is automatically determined based on
382
+ the 'spw' channel selection and 'width'.
383
+ channels in 'spw'.
384
+ Since the integer number in 'start' represents the data channel number,
385
+ when the channel number is used along with the spectral window id selection
386
+ in 'spw', 'start' specified as an integer should be carefully set otherwise
387
+ it may result in the blank image channels if the 'start' channel (i.e. absolute
388
+ channel number) is outside of the channel range specified in 'spw'.
389
+ In such a case, 'start' can be left as a default (='') to ensure
390
+ matching with the data spectral channel selection.
391
+ For specmode='cube', when velocity or frequency is used it is
392
+ interpreted with the frame defined in outframe. [The parameters of
393
+ the desired output cube can be estimated by using the 'transform'
394
+ functionality of 'plotms'].
395
+ examples: start='5.0km/s'; 1st channel, 5.0km/s in outframe.
396
+ start='22.3GHz'; 1st channel, 22.3GHz in outframe.
397
+ width Channel width (e.g. width=2,width=\'0.1MHz\',width=\'10km/s\') of output cube images
398
+ specified by data channel number (integer), velocity (string with a unit), or
399
+ or frequency (string with a unit).
400
+ Default:''; data channel width.
401
+ The sign of width defines the direction of the channels to be incremented.
402
+ For width specified in velocity or frequency with '-' in front gives image channels in
403
+ decreasing velocity or frequency, respectively.
404
+ For specmode='cube', when velocity or frequency is used it is interpreted with
405
+ the reference frame defined in outframe.
406
+ examples: width='2.0km/s'; results in channels with increasing velocity.
407
+ width='-2.0km/s'; results in channels with decreasing velocity.
408
+ width='40kHz'; results in channels with increasing frequency.
409
+ width=-2; results in channels averaged of 2 data channels incremented from
410
+ high to low channel numbers.
411
+ outframe Spectral reference frame in which to interpret \'start\' and \'width\'
412
+ Options: '','LSRK','LSRD','BARY','GEO','TOPO','GALACTO','LGROUP','CMB'
413
+ example: outframe='bary' for Barycentric frame.
414
+
415
+ REST -- Rest frequency.
416
+ LSRD -- Local Standard of Rest (J2000).
417
+ -- as the dynamical definition (IAU, [9,12,7] km/s in galactic coordinates).
418
+ LSRK -- LSR as a kinematical (radio) definition.
419
+ -- 20.0 km/s in direction ra,dec = [270,+30] deg (B1900.0).
420
+ BARY -- Barycentric (J2000).
421
+ GEO --- Geocentric.
422
+ TOPO -- Topocentric.
423
+ GALACTO -- Galacto centric (with rotation of 220 km/s in direction l,b = [90,0] deg.
424
+ LGROUP -- Local group velocity -- 308km/s towards l,b = [105,-7] deg (F. Ghigo).
425
+ CMB -- CMB velocity -- 369.5km/s towards l,b = [264.4, 48.4] deg (F. Ghigo).
426
+ DEFAULT = LSRK.
427
+ veltype Velocity type (radio, z, ratio, beta, gamma, optical)
428
+ For 'start' and/or 'width' specified in velocity, specifies the velocity definition
429
+ Options: 'radio','optical','z','beta','gamma','optical'
430
+ NOTE: the viewer always defaults to displaying the 'radio' frame,
431
+ but that can be changed in the position tracking pull down.
432
+
433
+ The different types (with F = f/f0, the frequency ratio), are:
434
+
435
+ Z = (-1 + 1/F).
436
+ RATIO = (F) \*.
437
+ RADIO = (1 - F).
438
+ OPTICAL == Z.
439
+ BETA = ((1 - F^2)/(1 + F^2)).
440
+ GAMMA = ((1 + F^2)/2F) \*.
441
+ RELATIVISTIC == BETA (== v/c).
442
+ DEFAULT == RADIO.
443
+ Note that the ones with an '\*' have no real interpretation
444
+ (although the calculation will proceed) if given as a velocity.
445
+ restfreq List of rest frequencies or a rest frequency in a string.
446
+ Specify rest frequency to use for output image.
447
+
448
+ Currently it uses the first rest frequency in the list for translation of
449
+ velocities. The list will be stored in the output images.
450
+ Default: []; look for the rest frequency stored in the MS, if not available,
451
+ use center frequency of the selected channels.
452
+ examples: restfreq=['1.42GHz'].
453
+ restfreq='1.42GHz'.
454
+ interpolation Spectral interpolation (nearest,linear,cubic)
455
+
456
+ Interpolation rules to use when binning data channels onto image channels
457
+ and evaluating visibility values at the centers of image channels.
458
+
459
+ Note : 'linear' and 'cubic' interpolation requires data points on both sides of
460
+ each image frequency. Errors are therefore possible at edge channels, or near
461
+ flagged data channels. When image channel width is much larger than the data
462
+ channel width there is nothing much to be gained using linear or cubic thus
463
+ not worth the extra computation involved.
464
+ perchanweightdensity When calculating weight density for Briggs
465
+ style weighting in a cube, this parameter
466
+ determines whether to calculate the weight
467
+ density for each channel independently
468
+ (the default, True)
469
+ or a common weight density for all of the selected
470
+ data. This parameter has no
471
+ meaning for continuum (specmode='mfs') imaging
472
+ or for natural and radial weighting schemes.
473
+ For cube imaging
474
+ perchanweightdensity=True is a recommended
475
+ option that provides more uniform
476
+ sensitivity per channel for cubes, but with
477
+ generally larger psfs than the
478
+ perchanweightdensity=False (prior behavior)
479
+ option. When using Briggs style weight with
480
+ perchanweightdensity=True, the imaging weight
481
+ density calculations use only the weights of
482
+ data that contribute specifically to that
483
+ channel. On the other hand, when
484
+ perchanweightdensity=False, the imaging
485
+ weight density calculations sum all of the
486
+ weights from all of the data channels
487
+ selected whose (u,v) falls in a given uv cell
488
+ on the weight density grid. Since the
489
+ aggregated weights, in any given uv cell,
490
+ will change depending on the number of
491
+ channels included when imaging, the psf
492
+ calculated for a given frequency channel will
493
+ also necessarily change, resulting in
494
+ variability in the psf for a given frequency
495
+ channel when perchanweightdensity=False. In
496
+ general, perchanweightdensity=False results
497
+ in smaller psfs for the same value of
498
+ robustness compared to
499
+ perchanweightdensity=True, but the rms noise
500
+ as a function of channel varies and increases
501
+ toward the edge channels;
502
+ perchanweightdensity=True provides more
503
+ uniform sensitivity per channel for
504
+ cubes. This may make it harder to find
505
+ estimates of continuum when
506
+ perchanweightdensity=False. If you intend to
507
+ image a large cube in many smaller subcubes
508
+ and subsequently concatenate, it is advisable
509
+ to use perchanweightdensity=True to avoid
510
+ surprisingly varying sensitivity and psfs
511
+ across the concatenated cube.
512
+ gridder Gridding options (standard, wproject, widefield, mosaic, awproject, awp2, awphpg)
513
+
514
+
515
+ The following options choose different gridding convolution
516
+ functions for the process of convolutional resampling of the measured
517
+ visibilities onto a regular uv-grid prior to an inverse FFT.
518
+ Model prediction (degridding) also uses these same functions.
519
+ Several wide-field effects can be accounted for via careful choices of
520
+ convolution functions. Gridding (degridding) runtime will rise in
521
+ proportion to the support size of these convolution functions (in uv-pixels).
522
+
523
+ standard : Prolate Spheroid with 7x7 uv pixel support size.
524
+
525
+ [ This mode can also be invoked using 'ft' or 'gridft' ]
526
+
527
+ wproject : W-Projection algorithm to correct for the widefield
528
+ non-coplanar baseline effect. [Cornwell et.al 2008]
529
+
530
+ wprojplanes is the number of distinct w-values at
531
+ which to compute and use different gridding convolution
532
+ functions (see help for wprojplanes).
533
+ Convolution function support size can range
534
+ from 5x5 to few 100 x few 100.
535
+
536
+ [ This mode can also be invoked using 'wprojectft' ]
537
+
538
+ widefield : Facetted imaging with or without W-Projection per facet.
539
+
540
+ A set of facets x facets subregions of the specified image
541
+ are gridded separately using their respective phase centers
542
+ (to minimize max W). Deconvolution is done on the joint
543
+ full size image, using a PSF from the first subregion.
544
+
545
+ wprojplanes=1 : standard prolate spheroid gridder per facet.
546
+ wprojplanes > 1 : W-Projection gridder per facet.
547
+ nfacets=1, wprojplanes > 1 : Pure W-Projection and no facetting.
548
+ nfacets=1, wprojplanes=1 : Same as standard,ft,gridft.
549
+
550
+ A combination of facetting and W-Projection is relevant only for
551
+ very large fields of view. (In our current version of tclean, this
552
+ combination runs only with parallel=False.
553
+
554
+ mosaic : A-Projection with azimuthally symmetric beams without
555
+ sidelobes, beam rotation or squint correction.
556
+ Gridding convolution functions per visibility are computed
557
+ from FTs of PB models per antenna.
558
+ This gridder can be run on single fields as well as mosaics.
559
+
560
+ VLA : PB polynomial fit model (Napier and Rots, 1982).
561
+ EVLA : PB polynomial fit model (Perley, 2015).
562
+ ALMA : Airy disks for a 10.7m dish (for 12m dishes) and
563
+ 6.25m dish (for 7m dishes) each with 0.75m
564
+ blockages (Hunter/Brogan 2011). Joint mosaic
565
+ imaging supports heterogeneous arrays for ALMA.
566
+
567
+ Typical gridding convolution function support sizes are
568
+ between 7 and 50 depending on the desired
569
+ accuracy (given by the uv cell size or image field of view).
570
+
571
+ [ This mode can also be invoked using 'mosaicft' or 'ftmosaic' ]
572
+
573
+ awproject : A-Projection with azimuthally asymmetric beams and
574
+ including beam rotation, squint correction,
575
+ conjugate frequency beams and W-projection.
576
+ [Bhatnagar et.al, 2008]
577
+
578
+ Gridding convolution functions are computed from
579
+ aperture illumination models per antenna and optionally
580
+ combined with W-Projection kernels and a prolate spheroid.
581
+ This gridder can be run on single fields as well as mosaics.
582
+
583
+ VLA : Uses ray traced model (VLA and EVLA) including feed
584
+ leg and subreflector shadows, off-axis feed location
585
+ (for beam squint and other polarization effects), and
586
+ a Gaussian fit for the feed beams (Brisken 2009)
587
+ ALMA : Similar ray-traced model as above (but the correctness
588
+ of its polarization properties remains un-verified).
589
+
590
+ Typical gridding convolution function support sizes are
591
+ between 7 and 50 depending on the desired
592
+ accuracy (given by the uv cell size or image field of view).
593
+ When combined with W-Projection they can be significantly larger.
594
+
595
+ [ This mode can also be invoked using 'awprojectft' ]
596
+
597
+
598
+ awp2 : A-Projection with azimuthally asymmetric beams and
599
+ including beam rotation, squint correction and W-projection.
600
+ [Bhatnagar et.al, 2008]
601
+
602
+ Gridding convolution functions are computed from
603
+ aperture illumination models (assuming similar antennas) and optionally
604
+ combined with W-Projection kernels.
605
+ This gridder can be run on single fields as well as mosaics.
606
+ The other sub-parameters that are of significance when using this gridder
607
+ are wprojplanes, computepastep, mosweight, usepointing, pblimit and normtype.
608
+
609
+ Only supports VLA : Uses ray traced model (VLA and EVLA) including feed
610
+ leg and subreflector shadows, off-axis feed location
611
+ (for beam squint and other polarization effects), and
612
+ a Gaussian fit for the feed beams (Ref: Brisken 2009)
613
+
614
+ For squint correction the value passed in computepastep has to be smaller than 180.
615
+ Anything larger awp2 will use an average of LL and RR beams. If computepastep=5, for
616
+ e.g., PB every 5 degrees, over the range of parallactic angle covered by the data, will be calculated
617
+ and the nearest beam to every integration will be used to correct for the squint between the L and R beams.
618
+
619
+ NOTE : For mtmfs with nterms >1 and using awp2 gridder, for accurate results always use specmode="mvc"
620
+ as awp2 with specmode="mfs" does not use conjugate beams to remove the spectral
621
+ index of the primary beam.
622
+
623
+ awphpg : Implementation of the high performance gridder (HPG; Pokorny, ngVLA Computing Memo #5).
624
+ For CASA 6.7.0 this mode is only available on the internal VLASS release of CASA.
625
+ It will be made available for general use in a future CASA release.
626
+
627
+
628
+ imagemosaic : (untested implementation).
629
+
630
+ Grid and iFT each pointing separately and combine the
631
+ images as a linear mosaic (weighted by a PB model) in
632
+ the image domain before a joint minor cycle.
633
+
634
+ VLA/ALMA PB models are same as for gridder='mosaicft'.
635
+
636
+ ------ Notes on PB models :
637
+
638
+ (1) Several different sources of PB models are used in the modes
639
+ listed above. This is partly for reasons of algorithmic flexibility
640
+ and partly due to the current lack of a common beam model
641
+ repository or consensus on what beam models are most appropriate.
642
+
643
+ (2) For ALMA and gridder='mosaic', ray-traced (TICRA) beams
644
+ are also available via the vpmanager tool.
645
+ For example, call the following before the tclean run.
646
+ vp.setpbimage(telescope="ALMA",
647
+ compleximage='/home/casa/data/trunk/alma/responses/ALMA_0_DV__0_0_360_0_45_90_348.5_373_373_GHz_ticra2007_VP.im',
648
+ antnames=['DV'+'%02d'%k for k in range(25)])
649
+ vp.saveastable('mypb.tab')
650
+ Then, supply vptable='mypb.tab' to tclean.
651
+ ( Currently this will work only for non-parallel runs )
652
+
653
+
654
+ ------ Note on PB masks :
655
+
656
+ In tclean, A-Projection gridders (mosaic, awproject, and awp2) produce a
657
+ .pb image and use the 'pblimit' subparameter to decide normalization
658
+ cutoffs and construct an internal T/F mask in the .pb and .image images.
659
+ However, this T/F mask cannot directly be used during deconvolution
660
+ (which needs a 1/0 mask). There are two options for making a pb based
661
+ deconvolution mask.
662
+ -- Run tclean with niter=0 to produce the .pb, construct a 1/0 image
663
+ with the desired threshold (using ia.open('newmask.im');
664
+ ia.calc('iif("xxx.pb">0.3,1.0,0.0)');ia.close() for example),
665
+ and supply it via the 'mask' parameter in a subsequent run
666
+ (with calcres=F and calcpsf=F to restart directly from the minor cycle).
667
+ -- Run tclean with usemask='pb' for it to automatically construct
668
+ a 1/0 mask from the internal T/F mask from .pb at a fixed 0.2 threshold.
669
+
670
+
671
+ ----- Making PBs for gridders other than mosaic, awproject, awp2
672
+
673
+ After the PSF generation, a PB is constructed using the same
674
+ models used in gridder='mosaic' but just evaluated in the image
675
+ domain without consideration to weights.
676
+ facets Number of facets on a side
677
+
678
+ A set of (facets x facets) subregions of the specified image
679
+ are gridded separately using their respective phase centers
680
+ (to minimize max W). Deconvolution is done on the joint
681
+ full size image, using a PSF from the first subregion/facet.
682
+
683
+ In our current version of tclean, facets>1 may be used only
684
+ with parallel=False.
685
+ psfphasecenter For mosaic use psf centered on this
686
+ optional direction. You may need to use
687
+ this if for example the mosaic does not
688
+ have any pointing in the center of the
689
+ image. Another reason; as the psf is
690
+ approximate for a mosaic, this may help
691
+ to deconvolve a non central bright source
692
+ well and quickly.
693
+
694
+ example:
695
+
696
+ psfphasecenter='6' #center psf on field 6.
697
+ psfphasecenter='J2000 19h30m00 -40d00m00'.
698
+ psfphasecenter='J2000 292.5deg -40.0deg'.
699
+ psfphasecenter='J2000 5.105rad -0.698rad'.
700
+ psfphasecenter='ICRS 13:05:27.2780 -049.28.04.458'.
701
+ wprojplanes Number of distinct w-values at which to compute and use different
702
+ gridding convolution functions for W-Projection
703
+
704
+ An appropriate value of wprojplanes depends on the presence/absence
705
+ of a bright source far from the phase center, the desired dynamic
706
+ range of an image in the presence of a bright far out source,
707
+ the maximum w-value in the measurements, and the desired trade off
708
+ between accuracy and computing cost.
709
+
710
+ As a (rough) guide, VLA L-Band D-config may require a
711
+ value of 128 for a source 30arcmin away from the phase
712
+ center. A-config may require 1024 or more. To converge to an
713
+ appropriate value, try starting with 128 and then increasing
714
+ it if artifacts persist. W-term artifacts (for the VLA) typically look
715
+ like arc-shaped smears in a synthesis image or a shift in source
716
+ position between images made at different times. These artifacts
717
+ are more pronounced the further the source is from the phase center.
718
+
719
+ There is no harm in simply always choosing a large value (say, 1024)
720
+ but there will be a significant performance cost to doing so, especially
721
+ for gridder='awproject' where it is combined with A-Projection.
722
+
723
+ wprojplanes=-1 is an option for gridder='widefield' or 'wproject'
724
+ in which the number of planes is automatically computed.
725
+ vptable vpmanager
726
+
727
+ vptable="" : Choose default beams for different telescopes.
728
+ ALMA : Airy disks.
729
+ EVLA : old VLA models.
730
+
731
+ Other primary beam models can be chosen via the vpmanager tool.
732
+
733
+ Step 1 : Set up the vpmanager tool and save its state in a table.
734
+
735
+ vp.setpbpoly(telescope='EVLA', coeff=[1.0, -1.529e-3, 8.69e-7, -1.88e-10])
736
+ vp.saveastable('myvp.tab')
737
+
738
+ Step 2 : Supply the name of that table in tclean.
739
+
740
+ tclean(....., vptable='myvp.tab',....)
741
+
742
+ Please see the documentation for the vpmanager for more details on how to
743
+ choose different beam models. Work is in progress to update the defaults
744
+ for EVLA and ALMA.
745
+
746
+ Note : AWProjection currently does not use this mechanism to choose
747
+ beam models. It instead uses ray-traced beams computed from
748
+ parameterized aperture illumination functions, which are not
749
+ available via the vpmanager. So, gridder='awproject' does not allow
750
+ the user to set this parameter.
751
+ mosweight When doing Brigg's style weighting (including uniform) to perform the weight density calculation for each field indepedently if True. If False the weight density is calculated from the average uv distribution of all the fields.
752
+ aterm Use aperture illumination functions during gridding.
753
+
754
+ This parameter turns on the A-term of the AW-Projection gridder.
755
+ Gridding convolution functions are constructed from aperture illumination
756
+ function models of each antenna.
757
+ psterm Include the Prolate Spheroidal (PS) funtion as the anti-aliasing
758
+ operator in the gridding convolution functions used for gridding.
759
+
760
+ Setting this parameter to true is necessary when aterm is set to
761
+ false. It can be set to false when aterm is set to true, though
762
+ with this setting effects of aliasing may be there in the image,
763
+ particularly near the edges.
764
+
765
+ When set to true, the .pb images will contain the fourier transform
766
+ of the of the PS funtion.
767
+
768
+ For more information on the functional
769
+ effects of the psterm, aterm and wprojplanes settings, see the
770
+ 'Wide-field Imaging' pages in CASA Docs (https://casadocs.readthedocs.io).
771
+ wbawp Use frequency dependent A-terms.
772
+ Scale aperture illumination functions appropriately with frequency
773
+ when gridding and combining data from multiple channels.
774
+ conjbeams Use conjugate frequency for wideband A-terms.
775
+
776
+ While gridding data from one frequency channel, choose a convolution
777
+ function from a 'conjugate' frequency such that the resulting baseline
778
+ primary beam is approximately constant across frequency. For a system in
779
+ which the primary beam scales with frequency, this step will eliminate
780
+ instrumental spectral structure from the measured data and leave only the
781
+ sky spectrum for the minor cycle to model and reconstruct [Bhatnagar et al., ApJ, 2013].
782
+
783
+ As a rough guideline for when this is relevant, a source at the half power
784
+ point of the PB at the center frequency will see an artificial spectral
785
+ index of -1.4 due to the frequency dependence of the PB [Sault and Wieringa, 1994].
786
+ If left uncorrected during gridding, this spectral structure must be modeled
787
+ in the minor cycle (using the mtmfs algorithm) to avoid dynamic range limits
788
+ (of a few hundred for a 2:1 bandwidth).
789
+ This works for specmode='mfs' and its value is ignored for cubes.
790
+ cfcache Convolution function cache directory name.
791
+
792
+ Name of a directory in which to store gridding convolution functions.
793
+ This cache is filled at the beginning of an imaging run. This step can be time
794
+ consuming but the cache can be reused across multiple imaging runs that
795
+ use the same image parameters (cell size, image size , spectral data
796
+ selections, wprojplanes, wbawp, psterm, aterm). The effect of the wbawp,
797
+ psterm and aterm settings is frozen-in in the cfcache. Using an existing cfcache
798
+ made with a different setting of these parameters will not reflect the current
799
+ settings.
800
+
801
+ In a parallel execution, the construction of the cfcache is also parallelized
802
+ and the time to compute scales close to linearly with the number of compute
803
+ cores used. With the re-computation of Convolution Functions (CF) due to PA
804
+ rotation turned-off (the computepastep parameter), the total number of in the
805
+ cfcache can be computed as [No. of wprojplanes x No. of selected spectral windows x 4]
806
+
807
+ By default, cfcache = imagename + '.cf'
808
+ usepointing The usepointing flag informs the gridder that it should utilize the pointing table
809
+ to use the correct direction in which the antenna is pointing with respect to the pointing phasecenter.
810
+ computepastep Parallactic angle interval after the AIFs are recomputed (deg).
811
+
812
+ This parameter controls the accuracy of the aperture illumination function
813
+ used with AProjection for alt-az mount dishes where the AIF rotates on the
814
+ sky as the synthesis image is built up. Once the PA in the data changes by
815
+ the given interval, AIFs are re-computed at the new PA.
816
+
817
+ A value of 360.0 deg (the default) implies no re-computation due to PA rotation.
818
+ AIFs are computed for the PA value of the first valid data received and used for
819
+ all of the data.
820
+
821
+ For gridder=awp2 a value of 180.0 deg or larger implies no squint correction will be
822
+ attempted i.e an average beam of the left hand and right hand polarization will be calculated
823
+ rotatepastep Parallactic angle interval after which the nearest AIF is rotated (deg)
824
+
825
+ Instead of recomputing the AIF for every timestep's parallactic angle,
826
+ the nearest existing AIF is used and rotated
827
+ after the PA changed by rotatepastep value.
828
+
829
+ A value of 360.0 deg (the default) disables rotation of the AIF.
830
+
831
+ For example, computepastep=360.0 and rotatepastep=5.0 will compute
832
+ the AIFs at only the starting parallactic angle and all other timesteps will
833
+ use a rotated version of that AIF at the nearest 5.0 degree point.
834
+ pointingoffsetsigdev Corrections for heterogenous and time-dependent pointing
835
+ offsets via AWProjection are controlled by this parameter.
836
+ It is a vector of 2 ints or doubles each of which is interpreted
837
+ in units of arcsec. Based on the first threshold, a clustering
838
+ algorithm is applied to entries from the POINTING subtable
839
+ of the MS to determine how distinct antenna groups for which
840
+ the pointing offset must be computed separately. The second
841
+ number controls how much a pointing change across time can
842
+ be ignored and after which an antenna rebinning is required.
843
+
844
+
845
+ Note : The default value of this parameter is [], due a programmatic constraint.
846
+ If run with this value, it will internally pick [600,600] and exercise the
847
+ option of using large tolerances (10arcmin) on both axes. Please choose
848
+ a setting explicitly for runs that need to use this parameter.
849
+
850
+ Note : This option is available only for gridder='awproject' and usepointing=True and
851
+ and has been validated primarily with VLASS on-the-fly mosaic data
852
+ where POINTING subtables have been modified after the data are recorded.
853
+
854
+
855
+ Examples of parameter usage :
856
+
857
+ [100.0,100.0] : Pointing offsets of 100 arcsec or less are considered
858
+ small enough to be ignored. Using large values for both
859
+ indicates a homogeneous array.
860
+
861
+
862
+ [10.0, 100.0] : Based on entries in the POINTING subtable, antennas
863
+ are grouped into clusters based on a 10arcsec bin size.
864
+ All antennas in a bin are given a pointing offset calculated
865
+ as the average of the offsets of all antennas in the bin.
866
+ On the time axis, offset changes upto 100 arcsec will be ignored.
867
+
868
+ [10.0,10.0] : Calculate separate pointing offsets for each antenna group
869
+ (with a 10 arcsec bin size). As a function of time, recalculate
870
+ the antenna binning if the POINTING table entries change by
871
+ more than 10 arcsec w.r.to the previously computed binning.
872
+
873
+ [1.0, 1.0] : Tight tolerances will imply a fully heterogenous situation where
874
+ each antenna gets its own pointing offset. Also, time-dependent
875
+ offset changes greater than 1 arcsec will trigger recomputes of
876
+ the phase gradients. This is the most general situation and is also
877
+ the most expensive option as it constructs and uses separate
878
+ phase gradients for all baselines and timesteps.
879
+
880
+ For VLASS 1.1 data with two kinds of pointing offsets, the recommended
881
+ setting is [ 30.0, 30.0 ].
882
+
883
+ For VLASS 1.2 data with only the time-dependent pointing offsets, the
884
+ recommended setting is [ 300.0, 30.0 ] to turn off the antenna grouping
885
+ but to retain the time dependent corrections required from one timestep
886
+ to the next.
887
+ pblimit PB gain level at which to cut off normalizations.
888
+
889
+ Divisions by .pb during normalizations have a cut off at a .pb gain
890
+ level given by pblimit. Outside this limit, image values are set to zero.
891
+ Additionally, by default, an internal T/F mask is applied to the .pb, .image and
892
+ .residual images to mask out (T) all invalid pixels outside the pblimit area.
893
+
894
+ Note : This internal T/F mask cannot be used as a deconvolution mask.
895
+ To do so, please follow the steps listed above in the Notes for the
896
+ 'gridder' parameter.
897
+
898
+ Note : To prevent the internal T/F mask from appearing in anything other
899
+ than the .pb and .image.pbcor images, 'pblimit' can be set to a
900
+ negative number.
901
+ The absolute value will still be used as a valid 'pblimit' for normalization
902
+ purposes. So, for example, pick pblimit=-0.1 (and not pblimit=-1).
903
+ A tclean restart using existing output images on disk that already
904
+ have this T/F mask in the .residual and .image but only pblimit set
905
+ to a negative value, will remove this mask after the next major cycle.
906
+
907
+ Note : An existing internal T/F mask may be removed from an image as
908
+ follows (without needing to re-run tclean itself).
909
+ ia.open('test.image');
910
+ ia.maskhandler(op='set', name='');
911
+ ia.done()
912
+ normtype Normalization type (flatnoise, flatsky, pbsquare).
913
+
914
+ Gridded (and FT'd) images represent the PB-weighted sky image.
915
+ Qualitatively it can be approximated as two instances of the PB
916
+ applied to the sky image (one naturally present in the data
917
+ and one introduced during gridding via the convolution functions).
918
+
919
+ xxx.weight : Weight image approximately equal to sum ( square ( pb ) )
920
+ xxx.pb : Primary beam calculated as sqrt ( xxx.weight )
921
+
922
+ normtype='flatnoise' : Divide the raw image by sqrt(.weight) so that
923
+ the input to the minor cycle represents the
924
+ product of the sky and PB. The noise is 'flat'
925
+ across the region covered by each PB.
926
+
927
+ normtype='flatsky' : Divide the raw image by .weight so that the input
928
+ to the minor cycle represents only the sky.
929
+ The noise is higher in the outer regions of the
930
+ primary beam where the sensitivity is low.
931
+
932
+ normtype='pbsquare' : No normalization after gridding and FFT.
933
+ The minor cycle sees the sky times pb square
934
+ deconvolver Name of minor cycle algorithm (hogbom,clark,multiscale,mtmfs,mem,clarkstokes,asp)
935
+
936
+ Each of the following algorithms operate on residual images and PSFs
937
+ from the gridder and produce output model and restored images.
938
+ Minor cycles stop and a major cycle is triggered when cyclethreshold
939
+ or cycleniter are reached. For all methods, components are picked from
940
+ the entire extent of the image or (if specified) within a mask.
941
+
942
+ hogbom : An adapted version of Hogbom Clean [Hogbom, 1974].
943
+ - Find the location of the peak residual.
944
+ - Add this delta function component to the model image.
945
+ - Subtract a scaled and shifted PSF of the same size as the image
946
+ from regions of the residual image where the two overlap.
947
+ - Repeat.
948
+
949
+ clark : An adapted version of Clark Clean [Clark, 1980].
950
+ - Find the location of max(I^2+Q^2+U^2+V^2).
951
+ - Add delta functions to each stokes plane of the model image.
952
+ - Subtract a scaled and shifted PSF within a small patch size
953
+ from regions of the residual image where the two overlap.
954
+ - After several iterations trigger a Clark major cycle to subtract
955
+ components from the visibility domain, but without de-gridding.
956
+ - Repeat.
957
+
958
+ ( Note : 'clark' maps to imagermode='' in the old clean task.
959
+ 'clark_exp' is another implementation that maps to
960
+ imagermode='mosaic' or 'csclean' in the old clean task
961
+ but the behavior is not identical. For now, please
962
+ use deconvolver='hogbom' if you encounter problems. )
963
+
964
+ clarkstokes : Clark Clean operating separately per Stokes plane.
965
+
966
+ (Note : 'clarkstokes_exp' is an alternate version. See above.)
967
+
968
+ multiscale : MultiScale Clean [Cornwell, 2008].
969
+ - Smooth the residual image to multiple scale sizes.
970
+ - Find the location and scale at which the peak occurs.
971
+ - Add this multiscale component to the model image.
972
+ - Subtract a scaled,smoothed,shifted PSF (within a small
973
+ patch size per scale) from all residual images.
974
+ - Repeat from step 2.
975
+
976
+ mtmfs : Multi-term (Multi Scale) Multi-Frequency Synthesis [Rau and Cornwell, 2011].
977
+ - Smooth each Taylor residual image to multiple scale sizes.
978
+ - Solve a NTxNT system of equations per scale size to compute
979
+ Taylor coefficients for components at all locations.
980
+ - Compute gradient chi-square and pick the Taylor coefficients
981
+ and scale size at the location with maximum reduction in
982
+ chi-square.
983
+ - Add multi-scale components to each Taylor-coefficient
984
+ model image.
985
+ - Subtract scaled,smoothed,shifted PSF (within a small patch size
986
+ per scale) from all smoothed Taylor residual images.
987
+ - Repeat from step 2.
988
+
989
+
990
+ mem : Maximum Entropy Method [Cornwell and Evans, 1985].
991
+ - Iteratively solve for values at all individual pixels via the
992
+ MEM method. It minimizes an objective function of
993
+ chi-square plus entropy (here, a measure of difference
994
+ between the current model and a flat prior model).
995
+
996
+ (Note : This MEM implementation is not very robust.
997
+ Improvements will be made in the future.)
998
+
999
+ asp : Adaptive Scale Pixel algorithm [Bhatnagar and Cornwell, 2004].
1000
+ - Define a set of initial scales defined as 0, W, 2W 4W and 8W.
1001
+ where W is a 2D Gaussian fitting width to the PSF.
1002
+ - Smooth the residual image by a Gaussian beam at initial scales.
1003
+ - Search for the global peak (F) among these smoothed residual images.
1004
+ - form an active Aspen set: amplitude(F), amplitude location(x,y).
1005
+ - Optimize the Aspen set by minimizing the objective function RI-Aspen*PSF,
1006
+ where RI is the residual image and * is the convulition operation.
1007
+ - Compute the model image and update the residual image
1008
+ - Repeat from step 2
1009
+ scales List of scale sizes (in pixels) for multi-scale and mtmfs algorithms.
1010
+ --> scales=[0,6,20]
1011
+ This set of scale sizes should represent the sizes
1012
+ (diameters in units of number of pixels)
1013
+ of dominant features in the image being reconstructed.
1014
+
1015
+ The smallest scale size is recommended to be 0 (point source),
1016
+ the second being the size of the synthesized beam and the third being 3-5
1017
+ times the synthesized beam, etc. For example, if the synthesized
1018
+ beam is 10" FWHM and cell=2",try scales = [0,5,15].
1019
+
1020
+ For numerical stability, the largest scale must be
1021
+ smaller than the image (or mask) size and smaller than or
1022
+ comparable to the scale corresponding to the lowest measured
1023
+ spatial frequency (as a scale size much larger than what the
1024
+ instrument is sensitive to is unconstrained by the data making
1025
+ it harder to recover from errors during the minor cycle).
1026
+ nterms Number of Taylor coefficients in the spectral model.
1027
+
1028
+ - nterms=1 : Assume flat spectrum source.
1029
+ - nterms=2 : Spectrum is a straight line with a slope.
1030
+ - nterms=N : A polynomial of order N-1.
1031
+
1032
+ From a Taylor expansion of the expression of a power law, the
1033
+ spectral index is derived as alpha = taylorcoeff_1 / taylorcoeff_0.
1034
+
1035
+ Spectral curvature is similarly derived when possible.
1036
+
1037
+ The optimal number of Taylor terms depends on the available
1038
+ signal to noise ratio, bandwidth ratio, and spectral shape of the
1039
+ source as seen by the telescope (sky spectrum x PB spectrum).
1040
+
1041
+ nterms=2 is a good starting point for wideband EVLA imaging
1042
+ and the lower frequency bands of ALMA (when fractional bandwidth
1043
+ is greater than 10%) and if there is at least one bright source for
1044
+ which a dynamic range of greater than few 100 is desired.
1045
+
1046
+ Spectral artifacts for the VLA often look like spokes radiating out from
1047
+ a bright source (i.e. in the image made with standard mfs imaging).
1048
+ If increasing the number of terms does not eliminate these artifacts,
1049
+ check the data for inadequate bandpass calibration. If the source is away
1050
+ from the pointing center, consider including wide-field corrections too.
1051
+
1052
+ (Note : In addition to output Taylor coefficient images .tt0,.tt1,etc
1053
+ images of spectral index (.alpha), an estimate of error on
1054
+ spectral index (.alpha.error) and spectral curvature (.beta,
1055
+ if nterms is greater than 2) are produced.
1056
+ - These alpha, alpha.error and beta images contain
1057
+ internal T/F masks based on a threshold computed
1058
+ as peakresidual/10. Additional masking based on
1059
+ .alpha/.alpha.error may be desirable.
1060
+ - .alpha.error is a purely empirical estimate derived
1061
+ from the propagation of error during the division of
1062
+ two noisy numbers (alpha = xx.tt1/xx.tt0) where the
1063
+ 'error' on tt1 and tt0 are simply the values picked from
1064
+ the corresponding residual images. The absolute value
1065
+ of the error is not always accurate and it is best to interpret
1066
+ the errors across the image only in a relative sense.
1067
+ smallscalebias A numerical control to bias the scales when using multi-scale or mtmfs algorithms.
1068
+ The peak from each scale's smoothed residual is
1069
+ multiplied by ( 1 - smallscalebias \* scale/maxscale )
1070
+ to increase or decrease the amplitude relative to other scales,
1071
+ before the scale with the largest peak is chosen.
1072
+ Smallscalebias can be varied between -1.0 and 1.0.
1073
+ A score of 0.0 gives all scales equal weight (default).
1074
+ A score larger than 0.0 will bias the solution towards smaller scales.
1075
+ A score smaller than 0.0 will bias the solution towards larger scales.
1076
+ The effect of smallscalebias is more pronounced when using multi-scale relative to mtmfs.
1077
+ fusedthreshold ring Hogbom Clean (number in units of Jy).
1078
+
1079
+ fusedthreshold = 0.0001 : 0.1 mJy.
1080
+
1081
+ This is a subparameter of the Asp Clean deconvolver. When peak residual
1082
+ is lower than the threshold, Asp Clean is "switched to Hogbom Clean" (i.e. only use the 0 scale for cleaning) for
1083
+ the following number of iterations until it switches back to Asp Clean.
1084
+
1085
+ NumberIterationsInHogbom = 50 + 2 * (exp(0.05 * NthHogbom) - 1)
1086
+
1087
+ , where NthHogbom is the number of times Hogbom Clean has been triggered.
1088
+
1089
+ When the Asp Clean detects it is approaching convergence, it uses only the 0 scale for the following number of iterations for better computational efficiency.
1090
+
1091
+ NumberIterationsInHogbom = 500 + 2 * (exp(0.05 * NthHogbom) - 1)
1092
+
1093
+ Set 'fusedthreshold = -1' to make the Asp Clean deconvolver never "switch" to Hogbom Clean.
1094
+ largestscale xels) allowed for the initial guess for the Asp Clean deconvolver.
1095
+
1096
+ largestscale = 100
1097
+
1098
+ The default initial scale sizes used by Asp Clean is [0, w, 2w, 4w, 8w],
1099
+ where `w` is the PSF width. The default `largestscale` is -1 which indicates
1100
+ users accept these initial scales. If `largestscale` is set, the initial scales
1101
+ would be [0, w, ... up to the `largestscale`]. This is only an initial guess,
1102
+ and actual fitted scale sizes may evolve from these initial values.
1103
+
1104
+ It is recommended not to set `largestscale` unless Asp Clean picks a large
1105
+ scale that has no constraints from the data (the UV hole issue).
1106
+ restoration e.
1107
+
1108
+ Construct a restored image : imagename.image by convolving the model
1109
+ image with a clean beam and adding the residual image to the result.
1110
+ If a restoringbeam is specified, the residual image is also
1111
+ smoothed to that target resolution before adding it in.
1112
+
1113
+ If a .model does not exist, it will make an empty one and create
1114
+ the restored image from the residuals ( with additional smoothing if needed ).
1115
+ With algorithm='mtmfs', this will construct Taylor coefficient maps from
1116
+ the residuals and compute .alpha and .alpha.error.
1117
+ restoringbeam ize to use.
1118
+
1119
+ - restoringbeam='' or [''].
1120
+ A Gaussian fitted to the PSF main lobe (separately per image plane).
1121
+
1122
+ - restoringbeam='10.0arcsec'.
1123
+ Use a circular Gaussian of this width for all planes.
1124
+
1125
+ - restoringbeam=['8.0arcsec','10.0arcsec','45deg'].
1126
+ Use this elliptical Gaussian for all planes.
1127
+
1128
+ - restoringbeam='common'.
1129
+ Automatically estimate a common beam shape/size appropriate for
1130
+ all planes. This option can be used when the beam shape is different as a function of frequency, and will smooth all planes to a single beam, defined by the largest beam in the cube.
1131
+
1132
+ Note : For any restoring beam different from the native resolution
1133
+ the model image is convolved with the beam and added to
1134
+ residuals that have been convolved to the same target resolution.
1135
+ pbcor the output restored image.
1136
+
1137
+ A new image with extension .image.pbcor will be created from
1138
+ the evaluation of .image / .pb for all pixels above the specified pblimit.
1139
+
1140
+ Note : Stand-alone PB-correction can be triggered by re-running
1141
+ tclean with the appropriate imagename and with
1142
+ niter=0, calcpsf=False, calcres=False, pbcor=True, vptable='vp.tab'
1143
+ ( where vp.tab is the name of the vpmanager file;
1144
+ see the inline help for the 'vptable' parameter ). Alternatively, task impbcor can be used for primary beam correction using the .image and .pb files.
1145
+
1146
+ Note : For deconvolver='mtmfs', pbcor will divide each Taylor term image by the .tt0 average PB.
1147
+ For all gridders, this calculation is accurate for small fractional bandwidths.
1148
+
1149
+ For large fractional bandwidths, please use one of the following options.
1150
+
1151
+ (a) For single pointings, run the tclean task with specmode='mfs', deconvolver='mtmfs',
1152
+ and gridder='standard' with pbcor=True or False.
1153
+ If a PB-corrected spectral index is required,
1154
+ please use the widebandpbcor task to apply multi-tern PB-correction.
1155
+
1156
+ (b) For mosaics, run tclean task with specmode='mfs', deconvolver='mtmfs',
1157
+ and gridder='awproject' , wbawp=True, conjbeams=True, with pbcor=True.
1158
+ This option applies wideband PB correction as part of the gridding step and
1159
+ pbcor=True will be accurate because the spectral index map will already
1160
+ be PB-corrected.
1161
+
1162
+ (c) For mosaics, run tclean with specmode='mvc', deconvolver='mtmfs',
1163
+ and gridder='mosaic' or 'awp2' with pbcor=True.
1164
+ This option applies wideband PB-correction to channelized residual images
1165
+ prior to the minor cycle and pbcor=True will be accurate because the spectral
1166
+ index map will already be PB-corrected.
1167
+
1168
+ Note : Frequency-dependent PB corrections are typically required for full-band imaging with the VLA.
1169
+ Wideband PB corrections are required when the amplitude of the
1170
+ brightest source is known accurately enough to be sensitive
1171
+ to the difference in the PB gain between the upper and lower
1172
+ end of the band at its location. As a guideline, the artificial spectral
1173
+ index due to the PB is -1.4 at the 0.5 gain level and less than -0.2
1174
+ at the 0.9 gain level at the middle frequency )
1175
+ outlierfile Name of outlier-field image definitions.
1176
+
1177
+ A text file containing sets of parameter=value pairs,
1178
+ one set per outlier field.
1179
+
1180
+ Example : outlierfile='outs.txt'
1181
+
1182
+ Contents of outs.txt :
1183
+
1184
+ imagename=tst1
1185
+ nchan=1
1186
+ imsize=[80,80]
1187
+ cell=[8.0arcsec,8.0arcsec]
1188
+ phasecenter=J2000 19:58:40.895 +40.55.58.543
1189
+ mask=circle[[40pix,40pix],10pix]
1190
+
1191
+ imagename=tst2
1192
+ nchan=1
1193
+ imsize=[100,100]
1194
+ cell=[8.0arcsec,8.0arcsec]
1195
+ phasecenter=J2000 19:58:40.895 +40.56.00.000
1196
+ mask=circle[[60pix,60pix],20pix]
1197
+
1198
+ The following parameters are currently allowed to be different between
1199
+ the main field and the outlier fields (i.e. they will be recognized if found
1200
+ in the outlier text file). If a parameter is not listed, the value is picked from
1201
+ what is defined in the main task input.
1202
+
1203
+ imagename, imsize, cell, phasecenter, startmodel, mask
1204
+ specmode, nchan, start, width, nterms, reffreq,
1205
+ gridder, deconvolver, wprojplanes.
1206
+
1207
+ Note : 'specmode' is an option, so combinations of mfs and cube
1208
+ for different image fields, for example, are supported.
1209
+ 'deconvolver' and 'gridder' are also options that allow different
1210
+ imaging or deconvolution algorithm per image field.
1211
+
1212
+ For example, multiscale with wprojection and 16 w-term planes
1213
+ on the main field and mtmfs with nterms=3 and wprojection
1214
+ with 64 planes on a bright outlier source for which the frequency
1215
+ dependence of the primary beam produces a strong effect that
1216
+ must be modeled. The traditional alternative to this approach is
1217
+ to first image the outlier, subtract it out of the data (uvsub) and
1218
+ then image the main field.
1219
+ weighting Weighting scheme (natural,uniform,briggs,superuniform,radial, briggsabs, briggsbwtaper).
1220
+
1221
+ During gridding of the dirty or residual image, each visibility value is
1222
+ multiplied by a weight before it is accumulated on the uv-grid.
1223
+ The PSF's uv-grid is generated by gridding only the weights (weightgrid).
1224
+
1225
+ weighting='natural' : Gridding weights are identical to the data weights
1226
+ from the MS. For visibilities with similar data weights,
1227
+ the weightgrid will follow the sample density
1228
+ pattern on the uv-plane. This weighting scheme
1229
+ provides the maximum imaging sensitivity at the
1230
+ expense of a PSF with possibly wider main lobes and high sidelobes.
1231
+ It is most appropriate for detection experiments
1232
+ where sensitivity is most important.
1233
+
1234
+ weighting='uniform' : Gridding weights per visibility data point are the
1235
+ original data weights divided by the total weight of
1236
+ all data points that map to the same uv grid cell :
1237
+ ' data_weight / total_wt_per_cell '.
1238
+
1239
+ The weightgrid is as close to flat as possible resulting
1240
+ in a PSF with a narrow main lobe and suppressed
1241
+ sidelobes. However, since heavily sampled areas of
1242
+ the uv-plane get down-weighted, the imaging
1243
+ sensitivity is not as high as with natural weighting.
1244
+ It is most appropriate for imaging experiments where
1245
+ a well behaved PSF can help the reconstruction.
1246
+
1247
+ weighting='briggs' : Gridding weights per visibility data point are given by
1248
+ 'data_weight / ( A \* total_wt_per_cell + B ) ' where
1249
+ A and B vary according to the 'robust' parameter.
1250
+
1251
+ robust = -2.0 maps to A=1,B=0 or uniform weighting.
1252
+ robust = +2.0 maps to natural weighting.
1253
+ (robust=0.5 is equivalent to robust=0.0 in AIPS IMAGR.)
1254
+
1255
+ Robust/Briggs weighting generates a PSF that can
1256
+ vary smoothly between 'natural' and 'uniform' and
1257
+ allow customized trade-offs between PSF shape and
1258
+ imaging sensitivity.
1259
+ weighting='briggsabs' : Experimental option.
1260
+ Same as Briggs except the formula is different A=
1261
+ robust\*robust and B is dependent on the
1262
+ noise per visibility estimated. Giving noise='0Jy'
1263
+ is a not a reasonable option.
1264
+ In this mode (or formula) robust values
1265
+ from -2.0 to 0.0 only make sense (2.0 and
1266
+ -2.0 will get the same weighting)
1267
+
1268
+ weighting='superuniform' : This is similar to uniform weighting except that
1269
+ the total_wt_per_cell is replaced by the
1270
+ total_wt_within_NxN_cells around the uv cell of
1271
+ interest. N=7 is the default (when the
1272
+ parameter 'npixels' is set to 0 with 'superuniform')
1273
+
1274
+ This method tends to give a PSF with inner
1275
+ sidelobes that are suppressed as in uniform
1276
+ weighting but with far-out sidelobes closer to
1277
+ natural weighting. The peak sensitivity is also
1278
+ closer to natural weighting.
1279
+
1280
+ weighting='radial' : Gridding weights are given by ' data_weight \* uvdistance '
1281
+ This method approximately minimizes rms sidelobes
1282
+ for an east-west synthesis array.
1283
+
1284
+ weighting='briggsbwtaper' : A modified version of Briggs weighting for cubes where an inverse uv taper,
1285
+ which is proportional to the fractional bandwidth of the entire cube,
1286
+ is applied per channel. The objective is to modify cube (perchanweightdensity = True)
1287
+ imaging weights to have a similar density to that of the continuum imaging weights.
1288
+ This is currently an experimental weighting scheme being developed for ALMA.
1289
+
1290
+ For more details on weighting please see Chapter3
1291
+ of Dan Briggs' thesis (http://www.aoc.nrao.edu/dissertations/dbriggs)
1292
+ robust Robustness parameter for Briggs weighting.
1293
+
1294
+ robust = -2.0 maps to uniform weighting.
1295
+ robust = +2.0 maps to natural weighting.
1296
+ (robust=0.5 is equivalent to robust=0.0 in AIPS IMAGR.)
1297
+ noise noise parameter for briggs abs mode weighting
1298
+ npixels Number of pixels to determine uv-cell size for super-uniform weighting
1299
+ (0 defaults to -/+ 3 pixels).
1300
+
1301
+ npixels -- uv-box used for weight calculation
1302
+ a box going from -npixel/2 to +npixel/2 on each side
1303
+ around a point is used to calculate weight density.
1304
+
1305
+ npixels=2 goes from -1 to +1 and covers 3 pixels on a side.
1306
+
1307
+ npixels=0 implies a single pixel, which does not make sense for
1308
+ superuniform weighting. Therefore, for 'superuniform'
1309
+ weighting, if npixels=0 it will be forced to 6 (or a box
1310
+ of -3pixels to +3pixels) to cover 7 pixels on a side.
1311
+ uvtaper uv-taper on outer baselines in uv-plane.
1312
+
1313
+ Apply a Gaussian taper in addition to the weighting scheme specified
1314
+ via the 'weighting' parameter. Higher spatial frequencies are weighted
1315
+ down relative to lower spatial frequencies to suppress artifacts
1316
+ arising from poorly sampled areas of the uv-plane. It is equivalent to
1317
+ smoothing the PSF obtained by other weighting schemes and can be
1318
+ specified either as the HWHM of a Gaussian in uv-space (eg. units of lambda)
1319
+ or as the FWHM of a Gaussian in the image domain (eg. angular units like arcsec).
1320
+
1321
+ uvtaper = [bmaj, bmin, bpa].
1322
+
1323
+ Note : FWHM_uv_lambda = (4 log2) / ( pi * FWHM_lm_radians ).
1324
+
1325
+ A FWHM_lm of 100.000 arcsec maps to a HWHM_uv of 910.18 lambda.
1326
+ A FWHM_lm of 1 arcsec maps to a HWHM_uv of 91 klambda.
1327
+
1328
+ default: uvtaper=[]; no Gaussian taper applied.
1329
+ example: uvtaper=['5klambda'] circular taper of HWHM=5 kilo-lambda.
1330
+ uvtaper=['5klambda','3klambda','45.0deg'] uv-domain HWHM.
1331
+ uvtaper=['50arcsec','30arcsec','30.0deg'] : image domain FWHM.
1332
+ uvtaper=['10arcsec'] : image domain FWHM.
1333
+ uvtaper=['300.0'] default units are lambda in aperture plane.
1334
+ niter Maximum number of iterations.
1335
+
1336
+ A stopping criterion based on total iteration count.
1337
+ Currently the parameter type is defined as an integer therefore the integer value
1338
+ larger than 2147483647 will not be set properly as it causes an overflow.
1339
+
1340
+ Iterations are typically defined as the selecting one flux component
1341
+ and partially subtracting it out from the residual image.
1342
+
1343
+ niter=0 : Do only the initial major cycle (make dirty image, psf, pb, etc).
1344
+
1345
+ niter larger than zero : Run major and minor cycles.
1346
+
1347
+ Note : Global stopping criteria vs major-cycle triggers.
1348
+
1349
+ In addition to global stopping criteria, the following rules are
1350
+ used to determine when to terminate a set of minor cycle iterations
1351
+ and trigger major cycles [derived from Cotton-Schwab Clean, 1984].
1352
+
1353
+ 'cycleniter' : controls the maximum number of iterations per image
1354
+ plane before triggering a major cycle.
1355
+ 'cyclethreshold' : Automatically computed threshold related to the
1356
+ max sidelobe level of the PSF and peak residual.
1357
+ Divergence, detected as an increase of 10% in peak residual from the
1358
+ minimum so far (during minor cycle iterations).
1359
+
1360
+ The first criterion to be satisfied takes precedence.
1361
+
1362
+ Note : Iteration counts for cubes or multi-field images :
1363
+ For images with multiple planes (or image fields) on which the
1364
+ deconvolver operates in sequence, iterations are counted across
1365
+ all planes (or image fields). The iteration count is compared with
1366
+ 'niter' only after all channels/planes/fields have completed their
1367
+ minor cycles and exited either due to 'cycleniter' or 'cyclethreshold'.
1368
+ Therefore, the actual number of iterations reported in the logger
1369
+ can sometimes be larger than the user specified value in 'niter'.
1370
+ For example, with niter=100, cycleniter=20,nchan=10,threshold=0,
1371
+ a total of 200 iterations will be done in the first set of minor cycles
1372
+ before the total is compared with niter=100 and it exits.
1373
+
1374
+ Note : Additional global stopping criteria include:
1375
+ - no change in peak residual across two major cycles.
1376
+ - a 50% or more increase in peak residual across one major cycle.
1377
+ gain Loop gain.
1378
+
1379
+ Fraction of the source flux to subtract out of the residual image
1380
+ for the CLEAN algorithm and its variants.
1381
+
1382
+ A low value (0.2 or less) is recommended when the sky brightness
1383
+ distribution is not well represented by the basis functions used by
1384
+ the chosen deconvolution algorithm. A higher value can be tried when
1385
+ there is a good match between the true sky brightness structure and
1386
+ the basis function shapes. For example, for extended emission,
1387
+ multiscale clean with an appropriate set of scale sizes will tolerate
1388
+ a higher loop gain than Clark clean.
1389
+ threshold Stopping threshold (number in units of Jy, or string).
1390
+
1391
+ A global stopping threshold that the peak residual (within clean mask)
1392
+ across all image planes is compared to.
1393
+
1394
+ threshold = 0.005 : 5mJy
1395
+ threshold = '5.0mJy'
1396
+
1397
+ Note : A 'cyclethreshold' is internally computed and used as a major cycle
1398
+ trigger. It is related to what fraction of the PSF can be reliably
1399
+ used during minor cycle updates of the residual image. By default
1400
+ the minor cycle iterations terminate once the peak residual reaches
1401
+ the first sidelobe level of the brightest source.
1402
+
1403
+ 'cyclethreshold' is computed as follows using the settings in
1404
+ parameters 'cyclefactor','minpsffraction','maxpsffraction','threshold' :
1405
+
1406
+ psf_fraction = max_psf_sidelobe_level \* 'cyclefactor'
1407
+ psf_fraction = max(psf_fraction, 'minpsffraction');
1408
+ psf_fraction = min(psf_fraction, 'maxpsffraction');
1409
+ cyclethreshold = peak_residual \* psf_fraction
1410
+ cyclethreshold = max( cyclethreshold, 'threshold' )
1411
+
1412
+ If nsigma is set (>0.0), the N-sigma threshold is calculated (see
1413
+ the description under nsigma), then cyclethreshold is further modified as,
1414
+
1415
+ cyclethreshold = max( cyclethreshold, nsgima_threshold ).
1416
+
1417
+
1418
+ 'cyclethreshold' is made visible and editable only in the
1419
+ interactive GUI when tclean is run with interactive=True.
1420
+ nsigma Multiplicative factor for rms-based threshold stopping.
1421
+
1422
+ N-sigma threshold is calculated as nsigma \* rms value per image plane determined
1423
+ from a robust statistics. For nsigma > 0.0, in a minor cycle, a maximum of the two values,
1424
+ the N-sigma threshold and cyclethreshold, is used to trigger a major cycle
1425
+ (see also the descreption under 'threshold').
1426
+ Set nsigma=0.0 to preserve the previous tclean behavior without this feature.
1427
+ The top level parameter, fastnoise is relevant for the rms noise calculation which is used
1428
+ to determine the threshold.
1429
+
1430
+ The parameter 'nsigma' may be an int, float, or a double.
1431
+ cycleniter Maximum number of minor-cycle iterations (per plane) before triggering
1432
+ a major cycle.
1433
+
1434
+ For example, for a single plane image, if niter=100 and cycleniter=20,
1435
+ there will be 5 major cycles after the initial one (assuming there is no
1436
+ threshold based stopping criterion). At each major cycle boundary, if
1437
+ the number of iterations left over (to reach niter) is less than cycleniter,
1438
+ it is set to the difference.
1439
+
1440
+ Note : cycleniter applies per image plane, even if cycleniter x nplanes
1441
+ gives a total number of iterations greater than 'niter'. This is to
1442
+ preserve consistency across image planes within one set of minor
1443
+ cycle iterations.
1444
+ cyclefactor Scaling on PSF sidelobe level to compute the minor-cycle stopping threshold.
1445
+
1446
+ Please refer to the Note under the documentation for 'threshold' that
1447
+ discussed the calculation of 'cyclethreshold'.
1448
+
1449
+ cyclefactor=1.0 results in a cyclethreshold at the first sidelobe level of
1450
+ the brightest source in the residual image before the minor cycle starts.
1451
+
1452
+ cyclefactor=0.5 allows the minor cycle to go deeper.
1453
+ cyclefactor=2.0 triggers a major cycle sooner.
1454
+ minpsffraction PSF fraction that marks the max depth of cleaning in the minor cycle.
1455
+
1456
+ Please refer to the Note under the documentation for 'threshold' that
1457
+ discussed the calculation of 'cyclethreshold'.
1458
+
1459
+ For example, minpsffraction=0.5 will stop cleaning at half the height of
1460
+ the peak residual and trigger a major cycle earlier.
1461
+ maxpsffraction PSF fraction that marks the minimum depth of cleaning in the minor cycle.
1462
+
1463
+ Please refer to the Note under the documentation for 'threshold' that
1464
+ discussed the calculation of 'cyclethreshold'.
1465
+
1466
+ For example, maxpsffraction=0.8 will ensure that at least the top 20
1467
+ percent of the source will be subtracted out in the minor cycle even if
1468
+ the first PSF sidelobe is at the 0.9 level (an extreme example), or if the
1469
+ cyclefactor is set too high for anything to get cleaned.
1470
+ nmajor The nmajor parameter limits the number of minor and major cycle sets
1471
+ that tclean executes. It is defined as the number of major cycles after the
1472
+ initial set of minor cycle iterations. In other words, the count of nmajor does
1473
+ not include the initial residual calculation that occurs when calcres=True.
1474
+
1475
+ A setting of nmajor=-1 implies no limit (default -1).
1476
+ A setting of nmajor=0 implies nothing other than the initial residual calculation
1477
+ A setting of nmajor>0 imples that nmajor sets of minor and major cycles will
1478
+ be done in addition to the initial residual calculation.
1479
+
1480
+ If the major cycle limit is reached, stopcode 9 will be returned. Other stopping
1481
+ criteria (such as threshold) could cause tclean to stop in fewer than this
1482
+ number of major cycles. If tclean reaches another stopping criteria, first
1483
+ or at the same time as nmajor, then that stopcode will be returned instead.
1484
+
1485
+ Note however that major cycle ids in the log messages as well as in the return
1486
+ dictionary do begin with 1 for the initial residual calculation, when it exists.
1487
+
1488
+ Example 1 : A tclean run with 'nmajor=5' and 'calcres=True' will iterate for
1489
+ 5 major cycles (not counting the initial residual calculation). But, the return
1490
+ dictionary will show 'nmajordone:6'. If 'calcres=False', then the return
1491
+ dictionary will show 'nmajordone:5'.
1492
+
1493
+ Example 2 : For both the following cases, there will be a printout in the logs
1494
+ "Running Major Cycle 1" and the return value will include "nmajordone: 1",
1495
+ however there is a difference in the purpose of the major cycle and the
1496
+ number of minor cycles executed:
1497
+ Case 1; nmajor=0, calcres=True: The major cycle done is for the creation
1498
+ of the residual, and no minor cycles are executed.
1499
+ Case 2; nmajor=1, calcres=False: The major cycle is done as part of the
1500
+ major/minor cycle loop, and 1 minor cycle will be executed.
1501
+ usemask Type of mask(s) to be used for deconvolution.
1502
+
1503
+ user: (default) mask image(s) or user specified region file(s) or string CRTF expression(s).
1504
+ subparameters: mask, pbmask.
1505
+ pb: primary beam mask.
1506
+ subparameter: pbmask.
1507
+
1508
+ Example: usemask="pb", pbmask=0.2.
1509
+ Construct a mask at the 0.2 pb gain level.
1510
+ (Currently, this option will work only with
1511
+
1512
+ gridders that produce .pb (i.e. mosaic, awp2 and awproject)
1513
+ or if an externally produced .pb image exists on disk)
1514
+
1515
+
1516
+ auto-multithresh : auto-masking by multiple thresholds for deconvolution.
1517
+ subparameters : sidelobethreshold, noisethreshold, lownoisethreshold, negativethrehsold, smoothfactor,
1518
+ minbeamfrac, cutthreshold, pbmask, growiterations, dogrowprune, minpercentchange, verbose.
1519
+ Additional top level parameter relevant to auto-multithresh: fastnoise.
1520
+
1521
+ if pbmask is >0.0, the region outside the specified pb gain level is excluded from
1522
+ image statistics in determination of the threshold.
1523
+
1524
+
1525
+
1526
+
1527
+ Note: By default the intermediate mask generated by automask at each deconvolution cycle
1528
+ is over-written in the next cycle but one can save them by setting
1529
+ the environment variable, SAVE_ALL_AUTOMASKS="true".
1530
+ (e.g. in the CASA prompt, os.environ['SAVE_ALL_AUTOMASKS']="true" )
1531
+ The saved CASA mask image name will be imagename.mask.autothresh#, where
1532
+ # is the iteration cycle number.
1533
+ mask Mask (a list of image name(s) or region file(s) or region string(s).
1534
+
1535
+
1536
+ The name of a CASA image or region file or region string that specifies
1537
+ a 1/0 mask to be used for deconvolution. Only locations with value 1 will
1538
+ be considered for the centers of flux components in the minor cycle.
1539
+ If regions specified fall completely outside of the image, tclean will throw an error.
1540
+
1541
+ Manual mask options/examples :
1542
+
1543
+ mask='xxx.mask' : Use this CASA image named xxx.mask and containing
1544
+ ones and zeros as the mask.
1545
+ If the mask is only different in spatial coordinates from what is being made
1546
+ it will be resampled to the target coordinate system before being used.
1547
+ The mask has to have the same shape in velocity and Stokes planes
1548
+ as the output image. Exceptions are single velocity and/or single
1549
+ Stokes plane masks. They will be expanded to cover all velocity and/or
1550
+ Stokes planes of the output cube.
1551
+
1552
+ [ Note : If an error occurs during image resampling or
1553
+ if the expected mask does not appear, please try
1554
+ using tasks 'imregrid' or 'makemask' to resample
1555
+ the mask image onto a CASA image with the target
1556
+ shape and coordinates and supply it via the 'mask'
1557
+ parameter. ]
1558
+
1559
+
1560
+ mask='xxx.crtf' : A text file with region strings and the following on the first line
1561
+ ( #CRTFv0 CASA Region Text Format version 0 )
1562
+ This is the format of a file created via the viewer's region
1563
+ tool when saved in CASA region file format.
1564
+
1565
+ mask='circle[[40pix,40pix],10pix]' : A CASA region string.
1566
+
1567
+ mask=['xxx.mask','xxx.crtf', 'circle[[40pix,40pix],10pix]'] : a list of masks.
1568
+
1569
+
1570
+
1571
+
1572
+
1573
+ Note : Mask images for deconvolution must contain 1 or 0 in each pixel.
1574
+ Such a mask is different from an internal T/F mask that can be
1575
+ held within each CASA image. These two types of masks are not
1576
+ automatically interchangeable, so please use the makemask task
1577
+ to copy between them if you need to construct a 1/0 based mask
1578
+ from a T/F one.
1579
+
1580
+ Note : Work is in progress to generate more flexible masking options and
1581
+ enable more controls.
1582
+ pbmask Sub-parameter for usemask: primary beam mask.
1583
+
1584
+ Examples : pbmask=0.0 (default, no pb mask).
1585
+ pbmask=0.2 (construct a mask at the 0.2 pb gain level).
1586
+ sidelobethreshold Sub-parameter for "auto-multithresh": mask threshold based on sidelobe levels: sidelobethreshold \* max_sidelobe_level \* peak residual.
1587
+ noisethreshold Sub-parameter for "auto-multithresh": mask threshold based on the noise level: noisethreshold \* rms + location (=median).
1588
+
1589
+ The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD.
1590
+ lownoisethreshold Sub-parameter for "auto-multithresh": mask threshold to grow previously masked regions via binary dilation: lownoisethreshold \* rms in residual image + location (=median).
1591
+
1592
+ The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD.
1593
+ negativethreshold Sub-parameter for "auto-multithresh": mask threshold for negative features: -1.0* negativethreshold \* rms + location(=median).
1594
+
1595
+ The rms is calculated from the median absolute deviation (MAD), with rms = 1.4826\*MAD.
1596
+ smoothfactor Sub-parameter for "auto-multithresh": smoothing factor in a unit of the beam.
1597
+ minbeamfrac Sub-parameter for "auto-multithresh": minimum beam fraction in size to prune masks smaller than mimbeamfrac \* beam
1598
+ <=0.0 : No pruning
1599
+ cutthreshold Sub-parameter for "auto-multithresh": threshold to cut the smoothed mask to create a final mask: cutthreshold \* peak of the smoothed mask.
1600
+ growiterations Sub-parameter for "auto-multithresh": Maximum number of iterations to perform using binary dilation for growing the mask.
1601
+ dogrowprune Experimental sub-parameter for "auto-multithresh": Do pruning on the grow mask.
1602
+ minpercentchange If the change in the mask size in a particular channel is less than minpercentchange, stop masking that channel in subsequent cycles. This check is only applied when noise based threshold is used and when the previous clean major cycle had a cyclethreshold value equal to the clean threshold. Values equal to -1.0 (or any value less than 0.0) will turn off this check (the default). Automask will still stop masking if the current channel mask is an empty mask and the noise threshold was used to determine the mask.
1603
+ verbose he summary of automasking at the end of each automasking process
1604
+ is printed in the logger. Following information per channel will be listed in the summary.
1605
+
1606
+ chan: channel number.
1607
+ masking?: F - stop updating automask for the subsequent iteration cycles.
1608
+ RMS: robust rms noise.
1609
+ peak: peak in residual image.
1610
+ thresh_type: type of threshold used (noise or sidelobe).
1611
+ thresh_value: the value of threshold used.
1612
+ N_reg: number of the automask regions.
1613
+ N_pruned: number of the automask regions removed by pruning.
1614
+ N_grow: number of the grow mask regions.
1615
+ N_grow_pruned: number of the grow mask regions removed by pruning.
1616
+ N_neg_pix: number of pixels for negative mask regions.
1617
+
1618
+ Note that for a large cube, extra logging may slow down the process.
1619
+ fastnoise Only relevant when automask (user='multi-autothresh') and/or n-sigma stopping threshold (nsigma>0.0) are/is used. If it is set to True, a simpler but faster noise calucation is used.
1620
+ In this case, the threshold values are determined based on classic statistics (using all
1621
+ unmasked pixels for the calculations).
1622
+
1623
+ If it is set to False, the new noise calculation
1624
+ method is used based on pre-existing mask.
1625
+
1626
+ Case 1: no exiting mask.
1627
+ Calculate image statistics using Chauvenet algorithm.
1628
+
1629
+ Case 2: there is an existing mask.
1630
+ Calculate image statistics by classical method on the region
1631
+ outside the mask and inside the primary beam mask.
1632
+
1633
+ In all cases above RMS noise is calculated from the median absolute deviation (MAD).
1634
+ restart images (and start from an existing model image)
1635
+ or automatically increment the image name and make a new image set.
1636
+
1637
+ True : Re-use existing images. If imagename.model exists the subsequent
1638
+ run will start from this model (i.e. predicting it using current gridder
1639
+ settings and starting from the residual image). Care must be taken
1640
+ when combining this option with startmodel. Currently, only one or
1641
+ the other can be used.
1642
+
1643
+ startmodel='', imagename.model exists :
1644
+ - Start from imagename.model.
1645
+ startmodel='xxx', imagename.model does not exist :
1646
+ - Start from startmodel.
1647
+ startmodel='xxx', imagename.model exists :
1648
+ - Exit with an error message requesting the user to pick
1649
+ only one model. This situation can arise when doing one
1650
+ run with startmodel='xxx' to produce an output
1651
+ imagename.model that includes the content of startmodel,
1652
+ and wanting to restart a second run to continue deconvolution.
1653
+ Startmodel should be set to '' before continuing.
1654
+
1655
+ If any change in the shape or coordinate system of the image is
1656
+ desired during the restart, please change the image name and
1657
+ use the startmodel (and mask) parameter(s) so that the old model
1658
+ (and mask) can be regridded to the new coordinate system before starting.
1659
+
1660
+ False : A convenience feature to increment imagename with '_1', '_2',
1661
+ etc as suffixes so that all runs of tclean are fresh starts (without
1662
+ having to change the imagename parameter or delete images).
1663
+
1664
+ This mode will search the current directory for all existing
1665
+ imagename extensions, pick the maximum, and adds 1.
1666
+ For imagename='try' it will make try.psf, try_2.psf, try_3.psf, etc.
1667
+
1668
+ This also works if you specify a directory name in the path :
1669
+ imagename='outdir/try'. If './outdir' does not exist, it will create it.
1670
+ Then it will search for existing filenames inside that directory.
1671
+
1672
+ If outlier fields are specified, the incrementing happens for each
1673
+ of them (since each has its own 'imagename'). The counters are
1674
+ synchronized across imagefields, to make it easier to match up sets
1675
+ of output images. It adds 1 to the 'max id' from all outlier names
1676
+ on disk. So, if you do two runs with only the main field
1677
+ (imagename='try'), and in the third run you add an outlier with
1678
+ imagename='outtry', you will get the following image names
1679
+ for the third run : 'try_3' and 'outtry_3' even though
1680
+ 'outry' and 'outtry_2' have not been used.
1681
+ savemodel Options to save model visibilities (none, virtual, modelcolumn).
1682
+
1683
+ Often, model visibilities must be created and saved in the MS
1684
+ to be later used for self-calibration (or to just plot and view them).
1685
+
1686
+ none : Do not save any model visibilities in the MS. The MS is opened
1687
+ in readonly mode.
1688
+
1689
+ Model visibilities can be predicted in a separate step by
1690
+ restarting tclean with niter=0,savemodel=virtual or modelcolumn
1691
+ and not changing any image names so that it finds the .model on
1692
+ disk (or by changing imagename and setting startmodel to the
1693
+ original imagename).
1694
+
1695
+ virtual : In the last major cycle, save the image model and state of the
1696
+ gridder used during imaging within the SOURCE subtable of the
1697
+ MS. Images required for de-gridding will also be stored internally.
1698
+ All future references to model visibilities will activate the
1699
+ (de)gridder to compute them on-the-fly. This mode is useful
1700
+ when the dataset is large enough that an additional model data
1701
+ column on disk may be too much extra disk I/O, when the
1702
+ gridder is simple enough that on-the-fly recomputing of the
1703
+ model visibilities is quicker than disk I/O.
1704
+ For e.g. that gridder='awproject' and 'awp2' does not support virtual model.
1705
+
1706
+ modelcolumn : In the last major cycle, save predicted model visibilities
1707
+ in the MODEL_DATA column of the MS. This mode is useful when
1708
+ the de-gridding cost to produce the model visibilities is higher
1709
+ than the I/O required to read the model visibilities from disk.
1710
+ This mode is currently required for gridder='awproject' and 'awp2'.
1711
+ This mode is also required for the ability to later pull out
1712
+ model visibilities from the MS into a python array for custom
1713
+ processing.
1714
+
1715
+ Note 1 : The imagename.model image on disk will always be constructed
1716
+ if the minor cycle runs. This savemodel parameter applies only to
1717
+ model visibilities created by de-gridding the model image.
1718
+
1719
+ Note 2 : It is possible for an MS to have both a virtual model
1720
+ as well as a model_data column, but under normal operation,
1721
+ the last used mode will get triggered. Use the delmod task to
1722
+ clear out existing models from an MS if confusion arises.
1723
+ Note 3: when parallel=True, use savemodel='none'; Other options are not yet ready
1724
+ for use in parallel. If model visibilities need to be saved (virtual or modelcolumn):
1725
+ please run tclean in serial mode with niter=0; after the parallel run
1726
+ calcres Calculate initial residual image.
1727
+
1728
+ This parameter controls what the first major cycle does.
1729
+
1730
+ calcres=False with niter greater than 0 will assume that
1731
+ a .residual image already exists and that the minor cycle can
1732
+ begin without recomputing it.
1733
+
1734
+ calcres=False with niter=0 implies that only the PSF will be made
1735
+ and no data will be gridded.
1736
+
1737
+ calcres=True requires that calcpsf=True or that the .psf and .sumwt
1738
+ images already exist on disk (for normalization purposes).
1739
+
1740
+ Usage example : For large runs (or a pipeline scripts) it may be
1741
+ useful to first run tclean with niter=0 to create
1742
+ an initial .residual to look at and perhaps make
1743
+ a custom mask for. Imaging can be resumed
1744
+ without recomputing it.
1745
+ calcpsf Calculate PSF
1746
+
1747
+ This parameter controls what the first major cycle does.
1748
+
1749
+ calcpsf=False will assume that a .psf image already exists
1750
+ and that the minor cycle can begin without recomputing it.
1751
+ psfcutoff When the .psf image is created a 2 dimensional Gaussian is fit to the main lobe of the PSF.
1752
+ Which pixels in the PSF are fitted is determined by psfcutoff.
1753
+ The default value of psfcutoff is 0.35 and can varied from 0.01 to 0.99.
1754
+ Fitting algorithm:
1755
+ - A region of 41 x 41 pixels around the peak of the PSF is compared against the psfcutoff.
1756
+ Sidelobes are ignored by radially searching from the PSF peak.
1757
+ - Calculate the bottom left corner (blc) and top right corner (trc) from the points. Expand blc and trc with a number of pixels (5).
1758
+ - Create a new sub-matrix from blc and trc.
1759
+ - Interpolate matrix to a target number of points (3001) using CUBIC spline.
1760
+ - All the non-sidelobe points, in the interpolated matrix, that are above the psfcutoff are used to fit a Gaussian.
1761
+ A Levenberg-Marquardt algorithm is used.
1762
+ - If the fitting fails the algorithm is repeated with the psfcutoff decreased (psfcutoff=psfcutoff/1.5).
1763
+ A message in the log will apear if the fitting fails along with the new value of psfcutoff.
1764
+ This will be done up to 50 times if fitting fails.
1765
+ This Gaussian beam is defined by a major axis, minor axis, and position angle.
1766
+ During the restoration process, this Gaussian beam is used as the Clean beam.
1767
+ Varying psfcutoff might be useful for producing a better fit for highly non-Gaussian PSFs, however, the resulting fits should be carefully checked.
1768
+ This parameter should rarely be changed.
1769
+
1770
+ (This is not the support size for clark clean.)
1771
+ parallel Run major cycles in parallel.
1772
+
1773
+ Parallel tclean will run only if casa has already been started using mpirun.
1774
+ Please refer to external resources on high performance computing for details on how to start this on your system.
1775
+
1776
+ Example : mpirun -n 3 -xterm 0 `which casa`
1777
+
1778
+ Continuum Imaging :
1779
+ - Data are partitioned (in time) into NProc pieces.
1780
+ - Gridding/iFT is done separately per partition.
1781
+ - Images (and weights) are gathered and then normalized.
1782
+ - One non-parallel minor cycle is run.
1783
+ - Model image is scattered to all processes.
1784
+ - Major cycle is done in parallel per partition.
1785
+
1786
+ Cube Imaging :
1787
+ - Data and Image coordinates are partitioned (in freq) into NProc pieces.
1788
+ - Each partition is processed independently (major and minor cycles).
1789
+ - All processes are synchronized at major cycle boundaries for convergence checks.
1790
+ - At the end, cubes from all partitions are concatenated along the spectral axis.
1791
+
1792
+ Note 1 : Iteration control for cube imaging is independent per partition.
1793
+ - There is currently no communication between them to synchronize
1794
+ information such as peak residual and cyclethreshold. Therefore,
1795
+ different chunks may trigger major cycles at different levels.
1796
+ (Proper synchronization of iteration control is work in progress.)
1797
+ RETURNS void
1798
+
1799
+ --------- examples -----------------------------------------------------------
1800
+
1801
+
1802
+
1803
+ For more information, see the task pages of tclean in CASA Docs:
1804
+
1805
+ https://casadocs.readthedocs.io
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+ '''
1812
+
1813
+ def __init__( self, vis, imagename, selectdata=True, field='', spw='', timerange='', uvrange='', antenna='', scan='', observation='', intent='', datacolumn='corrected', imsize=[ int(100) ], cell=[ ], phasecenter='', stokes='I', projection='SIN', startmodel='', specmode='mfs', reffreq='', nchan=int(-1), start='', width='', outframe='LSRK', veltype='radio', restfreq=[ ], interpolation='linear', perchanweightdensity=True, gridder='standard', facets=int(1), psfphasecenter='', wprojplanes=int(1), vptable='', mosweight=True, aterm=True, psterm=False, wbawp=True, conjbeams=False, cfcache='', usepointing=False, computepastep=float(360.0), rotatepastep=float(360.0), pointingoffsetsigdev=[ ], pblimit=float(0.2), normtype='flatnoise', deconvolver='hogbom', scales=[ ], nterms=int(2), smallscalebias=float(0.0), fusedthreshold=float(0.0), largestscale=int(-1), restoration=True, restoringbeam=[ ], pbcor=False, outlierfile='', weighting='natural', robust=float(0.5), noise='1.0Jy', npixels=int(0), uvtaper=[ '' ], niter=int(0), gain=float(0.1), threshold=float(0.0), nsigma=float(0.0), cycleniter=int(-1), cyclefactor=float(1.0), minpsffraction=float(0.05), maxpsffraction=float(0.8), nmajor=int(-1), usemask='user', mask='', pbmask=float(0.0), sidelobethreshold=float(3.0), noisethreshold=float(5.0), lownoisethreshold=float(1.5), negativethreshold=float(0.0), smoothfactor=float(1.0), minbeamfrac=float(0.3), cutthreshold=float(0.01), growiterations=int(75), dogrowprune=True, minpercentchange=float(-1.0), verbose=False, fastnoise=True, restart=True, savemodel='none', calcres=True, calcpsf=True, psfcutoff=float(0.35), parallel=False, iclean_backend="PROD" ):
1814
+ ###
1815
+ ### iclean_backend can be used to select alternate backends for interactive clean. This could be used
1816
+ ### to enable a backend with extended features or it could be used to select a stub backend designed
1817
+ ### for testing
1818
+ ###
1819
+ mod_specs = None
1820
+ self._gclean_module = None
1821
+ if iclean_backend == 'PROD':
1822
+ mod_specs = find_pkg( "casatasks.private.imagerhelpers._gclean" )
1823
+ else:
1824
+ mod_specs = find_pkg( f"_gclean_{iclean_backend}" )
1825
+
1826
+ if mod_specs:
1827
+ self._gclean_module = load_pkg(mod_specs[0])
1828
+ else:
1829
+ raise ImportError(f"Could not locate {iclean_backend} kind of iclean backend")
1830
+
1831
+ self._args = {'vis': vis, 'selectdata': selectdata, 'field': field, 'spw': spw, 'timerange': timerange, 'uvrange': uvrange, 'antenna': antenna, 'scan': scan, 'observation': observation, 'intent': intent, 'datacolumn': datacolumn, 'imagename': imagename, 'imsize': imsize, 'cell': cell, 'phasecenter': phasecenter, 'stokes': stokes, 'projection': projection, 'startmodel': startmodel, 'specmode': specmode, 'reffreq': reffreq, 'nchan': nchan, 'start': start, 'width': width, 'outframe': outframe, 'veltype': veltype, 'restfreq': restfreq, 'interpolation': interpolation, 'perchanweightdensity': perchanweightdensity, 'gridder': gridder, 'facets': facets, 'psfphasecenter': psfphasecenter, 'wprojplanes': wprojplanes, 'vptable': vptable, 'mosweight': mosweight, 'aterm': aterm, 'psterm': psterm, 'wbawp': wbawp, 'conjbeams': conjbeams, 'cfcache': cfcache, 'usepointing': usepointing, 'computepastep': computepastep, 'rotatepastep': rotatepastep, 'pointingoffsetsigdev': pointingoffsetsigdev, 'pblimit': pblimit, 'normtype': normtype, 'deconvolver': deconvolver, 'scales': scales, 'nterms': nterms, 'smallscalebias': smallscalebias, 'fusedthreshold': fusedthreshold, 'largestscale': largestscale, 'restoration': restoration, 'restoringbeam': restoringbeam, 'pbcor': pbcor, 'outlierfile': outlierfile, 'weighting': weighting, 'robust': robust, 'noise': noise, 'npixels': npixels, 'uvtaper': uvtaper, 'niter': niter, 'gain': gain, 'threshold': threshold, 'nsigma': nsigma, 'cycleniter': cycleniter, 'cyclefactor': cyclefactor, 'minpsffraction': minpsffraction, 'maxpsffraction': maxpsffraction, 'nmajor': nmajor, 'usemask': usemask, 'mask': mask, 'pbmask': pbmask, 'sidelobethreshold': sidelobethreshold, 'noisethreshold': noisethreshold, 'lownoisethreshold': lownoisethreshold, 'negativethreshold': negativethreshold, 'smoothfactor': smoothfactor, 'minbeamfrac': minbeamfrac, 'cutthreshold': cutthreshold, 'growiterations': growiterations, 'dogrowprune': dogrowprune, 'minpercentchange': minpercentchange, 'verbose': verbose, 'fastnoise': fastnoise, 'restart': restart, 'savemodel': savemodel, 'calcres': calcres, 'calcpsf': calcpsf, 'psfcutoff': psfcutoff, 'parallel': parallel}
1832
+ self._gclean = self._gclean_module.gclean( **self._args )
1833
+ self._gclean_paths = self._gclean.image_products( )
1834
+ #self._residual_path = self._residual_path(self._clean['gclean'],imid)
1835
+ #self._mask_path = self._mask_path(self._clean['gclean'],imid)
1836
+
1837
+ self._future = None
1838
+ self._ui = InteractiveCleanUI(self._gclean, self._args)
1839
+
1840
+ def get_future(self):
1841
+ if self._future is None:
1842
+ raise RuntimeError( "interactive clean app has not been launched yet" )
1843
+ return self._future
1844
+
1845
+ def __call__( self ):
1846
+ '''Display GUI and process events until the user stops the application.
1847
+
1848
+ Example:
1849
+ Create ``iclean`` object and display::
1850
+
1851
+ print( "Result: %s" %
1852
+ iclean( vis='refim_point_withline.ms', imagename='test', imsize=512,
1853
+ cell='12.0arcsec', specmode='cube',
1854
+ interpolation='nearest', ... )( ) )
1855
+ '''
1856
+ ###
1857
+ ### Output notebook is implied.
1858
+ ###
1859
+ from bokeh.io.state import curstate
1860
+ state = curstate()
1861
+ if not state.notebook:
1862
+ from bokeh.io import output_notebook
1863
+ output_notebook( )
1864
+
1865
+ self._id = uuid4( )
1866
+ context = exe.Context( exe.Mode.THREAD )
1867
+ bokeh_ui, exec_task = self._ui( context, self._id )
1868
+
1869
+ def startup( ):
1870
+ self._future = context.execute( exec_task, self._id )
1871
+
1872
+ ### name is used in summary output of the Showable
1873
+ showed = Showable(bokeh_ui, startup, self.get_future, name="iclean-jpy")
1874
+ return showed