ism3d.uvhelper package

Submodules

ism3d.uvhelper.cli module

ism3d.uvhelper.cli.casatools_repack()[source]

Usage:

casatools_repack casatools-6.1.0.79-cp36-cp36m-macosx_10_15_x86_64.whl cp38 casatools_repack casatools-6.1.0.79-cp36-cp36m-macosx_10_15_x86_64.whl cp37m or cli.py casatools-6.1.0.79-cp36-cp36m-macosx_10_15_x86_64.whl cp38

ism3d.uvhelper.ft module

ism3d.uvhelper.ft.advise_header(uv, center, chanfreq, chanwidth, sortbyfreq=False, antsize=None)[source]
create a header template for discreating cloudlet model before uv sampling

using accroding to UV sampling and primary beam FOV uv.shape (nrecord,2) in units of meter chanfreq quantity frequency array center this could be phasecenter or somewhere near your target antsize=12*u.m

f_max: determines the UV grid size, or set a image cell-size upper limit

a valeu of >=2 would be a safe choice (set a upper limit of cellsize)

f_min: set the UV cell-size upper limit, or a lower limit of image FOV.

a value of >=3 would be translated into a FOV lager than >=3 of interfeormetry sensitive scale ***set a lower limit of imsize

PB: primary beam size, help set a lower limit of FOV

however, in terms of imaging quality metric, this is not crucial ***set a lower limit of imsize

The rule of thumbs are:
  • make sure f_max and f_min are good enought that all spatial frequency information is presented in

the reference models * the FOV is large enough to covert the object. * keep the cube size within the memory limit

# note: if dxy is too large, uvsampling will involve extrapolation which is not stable. # if nxy is too small, uvsampling should be okay as long as you believe no stucture-amp is above that scale. # interplate is more or less stable.

ism3d.uvhelper.ft.advise_imsize(u, v, pb=0, f_min=5.0, f_max=2.0, even=True)[source]

Compute the recommended image size given the (u, v) locations. Typical call signature:

nxy, dxy = advise_imsize(u, v, PB=0, f_min=5., f_max=2.5, verbose=False)
Parameters
  • u (array_like, float) – u coordinate of the visibility points where the FT has to be sampled. units: wavelength

  • v (array_like, float) – v coordinate of the visibility points where the FT has to be sampled. The length of v must be equal to the length of u. units: wavelength

  • PB (float, optional) – Primary beam of the antenna, e.g. 1.22*wavelength/Diameter for an idealized antenna with uniform illumination. units: rad

  • f_min (float) – Size of the field of view covered by the (u, v) plane grid w.r.t. the field of view covered by the image. Recommended to be larger than 3 for better results. units: pure number

  • f_max (float) – Nyquist rate: numerical factor that ensures the Nyquist criterion is satisfied when sampling the synthetic visibilities at the specified (u, v) locations. Must be larger than 2. The maximum (u, v)-distance covered is f_max times the maximum (u, v)-distance of the observed visibilities. units: pure number

  • verbose (bool, optional) – If True, prints information on the criteria to be fulfilled by nxy and dxy.

Returns

  • nxy (int) – Size of the image along x and y direction. units: pixel

  • dxy (float) – Returned only if not provided in input. Size of the image cell, assumed equal and uniform in both x and y direction. units: cm

ism3d.uvhelper.ft.invert_ft(uu=None, vv=None, wv=None, vis=None, wt=None, flag=None, uvdata=None, cell=None, imsize=None, header=None, bychannel=True, sortbyfreq=False)[source]

use nufft to create dirty cube from visibility uu: in meter (vector, nrecord vv: in meter (vector, nrecord) wv: in meter (vector, nchannel) psize: Quality wt: apply wt when doing invert (essentialy nature weighting)

only works when bychannle=true

bychannel: False ignore the wavelength changing effect on uvw

True: uu/vv will be calculated channel by channel

sortbyfreq: make sure the output cube is increasing by frequency (even chanel-freq is decreasing)

this make it easy to compare with the tclean results whihc is always mono-increasing in freq

output (nx,ny,nz)

note: should not include flagged records

uvdata or uu,vv,wv,vs,wt,flag header or cell,imsize

if vis and uvdata are both specified, vis>uvdata (useful for the PSF case) if vis is one D, it will be broadcasted to 2D

ism3d.uvhelper.ft.make_psf(**kwargs)[source]

ism3d.uvhelper.imager module

ism3d.uvhelper.imager.copyimages(imagename='', outname='')[source]

copy a imaging product set if imagename==outname, it will do nothing

ism3d.uvhelper.imager.exportimages(imagenames, velocity=False, optical=False, overwrite=True, stokeslast=True, dropstokes=False, dropmask=False, droptable=False, exclude_list=[], compress=False)[source]

a wrap function to export tclean products into FITS exclude_list include any ext_list element you don’t want process

ism3d.uvhelper.imager.ext_list()[source]

tclean output file extenstion list

ism3d.uvhelper.imager.invert(vis='', imagename='', datacolumn='data', antenna='', weighting='briggs', robust=1.0, npixels=0, cell=0.04, imsize=[128, 128], phasecenter='', specmode='cube', start='', width='', nchan=- 1, perchanweightdensity=True, restoringbeam='', onlydm=False, pbmask=0, pblimit=0, exclude_list=['residual', 'residual.tt0', 'residual.tt1', 'sumwt', 'sumwt.tt0', 'sumwt.tt1', 'sumwt.tt2', 'model', 'model.tt0', 'model.tt1'], **kwargs)[source]

Generate a compact dirty image from a MS dataset as a quick imaging snapshot;

Note about the default setting:

  • restoringbeam=’’ to preserve the original dirty beam shape: if “common” then additional undesired convolution will happen

  • Another faster way to do this would be using the toolkits: imager.open(‘3C273XC1.MS’) imager.defineimage(nx=256, ny=256, cellx=’0.7arcsec’, celly=’0.7arcsec’) imager.image(type=’corrected’, image=’3C273XC1.dirty’) imager.close() But it may be difficult to write a function to cover all setting already in casatasks.tclean()

note:

apperantly tclean(start=’’,width=’’,nchan-1) will not follow the actual spw-channel arrangeent: it will sort channel by frequency forst and then start the sequence. That means even when negative channel width will still get frequency-increasing cube:

for such case, width=-1,nchanel=240,start=239 will get a cube following the channel-frequency arrangment.

ism3d.uvhelper.imager.xclean(vis='', imagename='', spw='', field='', datacolumn='data', imsize=[128, 128], cell='0.04arcsec', phasecenter='', pblimit=- 0.1, stokes='I', outframe='LSRK', start='', width='', nchan=- 1, interpolation='linear', perchanweightdensity=True, deconvolver='mtmfs', specmode='mfs', scales=[], weighting='briggs', robust=1.0, threshold='0.0Jy', niter=10000, nsigma=0.0, restoringbeam='', usemask='pb', pbmask=0.2, mask='', uselast=False, runexport=True)[source]

A imaging/clean workflow function which wrap around tclean/exports, helping you make customized better imaging products

note:

ism3d.uvhelper.ms module

ism3d.uvhelper.ms.checkchflag(vis)[source]

check flag consistancy across channels it’s able to handle ms with multiple spw/pol.

note: miriad/invert slop=1,zero could include

partionally flagged records into imaging We can run xutils.unchflag() and zero-out such data to implement a similar treatment: http://www.atnf.csiro.au/computing/software/miriad/userguide/node145.html

ism3d.uvhelper.ms.flagbywt(vis, datacolumn='data', fitspw='')[source]

doesn’t really work yet (see statwt.py) performe the following procedures:

  1. save current flagging

  2. use statwt to recalculate weight

  3. flag weightoutlier

ism3d.uvhelper.ms.flagchan()[source]

flagged the channel if the data from contributing rows are partially flagged this is <unchflag> in the CASA 5 xutils

ism3d.uvhelper.ms.flagrow(vis)[source]

flagged the entire row if it’s partially flagged use this with cautions and you’re removing potentially large amount of rows

ism3d.uvhelper.ms.getcommonfreqs(vis_list, spw_list, edge_list=None, frame='LSRK', chanbin=2)[source]

edge_list: for each vis, we exclude some edge channels for evluation as they might be flagged in pipeline chanbin: the channel width will be chanbin*max(chanwidth among vis_list) output freqgrid will be covered by all vis_list fgrid: freqeuncy grid df: frequency resolution

ism3d.uvhelper.ms.getfreqs(vis, frame='LSRK', spwids=[0], edge=0)[source]

get the frequency sampling grid of one SPW in a MS, in a specified frame edge is for original grid

ism3d.uvhelper.ms.logger = <Logger ism3d.uvhelper.ms (DEBUG)>
about taql:

https://casacore.github.io/casacore-notes/199.html

ref:

C-contiguous order (last index varies the fastest FORTRAN-contiguous order in memory (first index varies the fastest)

Type

ref

ism3d.uvhelper.ms.read_ms(vis='', polaverage=True, flagdata=False, saveflag=True, includedata=True, usedouble=False, dataset=None, keyrule='basename')[source]
Note:

the different output sequence casacore.table.getcol(): nrecord x nchan x ncorr casatools.table.getcol(): ncorr x nchan x nrecord

flagdata: default=False

set flagged data value to np.nan, which may lead to troubles of calculating chisq2

saveflag: default=True

save flagging (bool) column, which is need to figure out channel-wise bad data

uvw in units of meters

includedata=False

only read the MS “framework” from MS, not the actual dataset

dataset: a dataset container (list or dictionary) for the readout data

if it’s provieded, not return from the function. if it’s not provide, the readout data will be return as a dictionary.

keyrule: ‘number’: data_0, data_1, data_3

‘basename’: basename1, basename2, basename3 ‘abspath’: absolute name

note: we on purpose preserve the data shape to ensure write_ms will work properly

ism3d.uvhelper.ms.rmColumns(vis, column='')[source]

remove columns from MS (only handle one column currently) By default, the function will check the available column names without removing any column. e.g. column=’WEIGHT_SPECTRUM’

ism3d.uvhelper.ms.rmPointing(outvis, verbose=False)[source]

Empty the POINTING table

ism3d.uvhelper.ms.write_ms(vis, value, datacolumn='corrected', inputvis=None)[source]

attach new visibility data/model values into an MS

if the specified datacolumn doesn’t exist, it will be created on-the-fly.

note:

the input data shape is nrecord x nchan x ncorr following the rule in casacore.table.getcol(), which is reversed from casa6.casatools.table.getcol() (ncorr x nchan x nrecord) alternatively, ncrecord x nchan (stokes-I) is also fine and will be broadcasted to all correlations (assumed to be RR, LL, XX, or YY)

ism3d.uvhelper.plts module

ism3d.uvhelper.proc module

ism3d.uvhelper.proc.casa_version()[source]

show the CASA 6 tools/tasks version number

ism3d.uvhelper.proc.plotuv_freqtime_amp(vis='', spw=[''], xaxis='freq')[source]

vis=’calibrated_target.ms’,spw

ism3d.uvhelper.proc.rawSelect(name, correlation='RR,LL', keepflags=False, datacolumn='data')[source]

get rid of trunk rows to reduce the data size

ism3d.uvhelper.vis_utils module

Module contents

subpackage uvhelper