def mapallvis(uvo, uvc, so, mapdir, lines=[]): """ Similar to mapvis but doesn't do multiple frequency synthesis. The frequency axis is preserved so you can get spectra from the image. """ calibrator = 'cnt.usb' tall = 0.50 # remove continuum, its already been mapped lines.remove(calibrator) lines.remove('usb') for i, lin in enumerate(lines): vis = '{}/{}.{}.corrected.slfc'.format(uvc, so, lin) for src in [ '{}/{}.{}'.format(mapdir, so, lin), '{}/{}.{}.uncorrected'.format(mapdir, so, lin) ]: line = miriad.averageVelocityLine(vis, 2) for path in glob.glob('{}.full.*'.format(src)): if os.path.exists(path): shutil.rmtree(path) invertOptions = { 'vis': vis, 'stokes': 'i,v', 'beam': '{}.full.bm'.format(src), 'map': '{0}.i.full.mp,{0}.v.full.mp'.format(src), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double', 'sup': 0, } miriad.invert(invertOptions) for stk in ['i', 'v']: miriad.clean({ 'map': '{}.{}.full.mp'.format(src, stk), 'beam': '{}.full.bm'.format(src), 'out': '{}.{}.full.cc'.format(src, stk), 'niters': 3000, 'cutoff': tall }) miriad.restor({ 'map': '{}.{}.full.mp'.format(src, stk), 'beam': '{}.full.bm'.format(src), 'model': '{}.{}.full.cc'.format(src, stk), 'out': '{}.{}.full.cm'.format(src, stk), }) vis = '{}/{}.{}'.format(uvo, so, lin)
vis = 'UVDATA/{}.{}'.format(so, lab) src = 'MAPS/{}.{}'.format(so, lab) tall = rms * 3 # MAPS: for path in glob.glob('{}.*'.format(src)): if os.path.exists(path): if os.path.isdir(path): shutil.rmtree(path) else: os.remove(path) miriad.invert({ 'vis': vis, 'line': line, 'beam': '{}.bm'.format(src), 'map': '{0}.i.mp,{0}.q.mp,{0}.u.mp,{0}.v.mp'.format(src), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double', 'stokes': 'i,q,u,v', 'sup': 0 }) for stk in ['i', 'q', 'u', 'v']: miriad.clean({ 'map': '{}.{}.mp'.format(src, stk), 'beam': '{}.bm'.format(src), 'out': '{}.{}.cc'.format(src, stk), 'niters': 1000, 'cutoff': tall }) miriad.restor({
def mapvis(uvo, uvc, so, mapdir, lines=[], lineSelection=[]): """ Make a map from visibilities 1. Continuum Stokes I,V Uncorrected & Corrected data 2. Map All lines. Corrected 3. Map All lines. Uncorrected 4. Continuum LL and RR independently, for non-selfcal and selfcal cases """ calibrator = 'cnt.usb' if len(lines) != len(lineSelection): lineSelection = [None for l in lines] # 1. src = '{}/{}.cnt'.format(mapdir, so) tall = 0.03 for path in glob.glob('{}.*'.format(src)): if os.path.exists(path): shutil.rmtree(path) vis = '{}/{}.cnt.usb.corrected.slfc'.format(uvc, so) for src in [ '{}/{}.cnt'.format(mapdir, so), '{}/{}.cnt.uncorrected'.format(mapdir, so) ]: miriad.invert({ 'vis': vis, 'stokes': 'i,v', 'beam': '{}.bm'.format(src), 'map': '{0}.i.mp,{0}.v.mp'.format(src), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double,mfs', 'sup': 0 }) for stk in ['i', 'v']: miriad.clean({ 'map': '{}.{}.mp'.format(src, stk), 'beam': '{}.bm'.format(src), 'out': '{}.{}.cc'.format(src, stk), 'niters': 3000, 'cutoff': tall }) miriad.restor({ 'map': '{}.{}.mp'.format(src, stk), 'beam': '{}.bm'.format(src), 'model': '{}.{}.cc'.format(src, stk), 'out': '{}.{}.cm'.format(src, stk), }) vis = '{}/{}.cnt.usb'.format(uvo, so) # 2. Map corrected line data # 3. Map uncorrected line data with same paramenters as in 2 tall = 0.50 # remove continuum, its already been mapped lines.remove(calibrator) lines.remove('usb') for i, lin in enumerate(lines): vis = '{}/{}.{}.corrected.slfc'.format(uvc, so, lin) for src in [ '{}/{}.{}'.format(mapdir, so, lin), '{}/{}.{}.uncorrected'.format(mapdir, so, lin) ]: line = miriad.averageVelocityLine(vis, 2) for path in glob.glob('{}.*'.format(src)): if os.path.exists(path): shutil.rmtree(path) invertOptions = { 'vis': vis, 'stokes': 'i,v', 'beam': '{}.bm'.format(src), 'map': '{0}.i.mp,{0}.v.mp'.format(src), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double,mfs', 'sup': 0, } if lineSelection[i] is not None: invertOptions['line'] = lineSelection[i] miriad.invert(invertOptions) for stk in ['i', 'v']: miriad.clean({ 'map': '{}.{}.mp'.format(src, stk), 'beam': '{}.bm'.format(src), 'out': '{}.{}.cc'.format(src, stk), 'niters': 3000, 'cutoff': tall }) miriad.restor({ 'map': '{}.{}.mp'.format(src, stk), 'beam': '{}.bm'.format(src), 'model': '{}.{}.cc'.format(src, stk), 'out': '{}.{}.cm'.format(src, stk), }) vis = '{}/{}.{}'.format(uvo, so, lin) # 4. nopol is for selfcal case (this option is not used!) tall = 0.03 for stk in ['ll', 'rr']: src = '{}/{}.cnt.{}'.format(mapdir, so, stk) for path in glob.glob('{}.*'.format(src)): if os.path.exists(path): shutil.rmtree(path) for pol in ['nopol', 'nocal']: path = '{}.bm'.format(src) if os.path.exists(path): shutil.rmtree(path) miriad.invert({ 'vis': '{}/{}.cnt.usb.{}'.format(uvc, so, stk), 'beam': '{}.bm'.format(src), 'map': '{}.{}.mp'.format(src, pol), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double,mfs,{}'.format(pol), 'sup': 0 }) miriad.clean({ 'map': '{}.{}.mp'.format(src, pol), 'beam': '{}.bm'.format(src), 'out': '{}.{}.cc'.format(src, pol), 'niters': 3000, 'cutoff': tall }) miriad.restor({ 'map': '{}.{}.mp'.format(src, pol), 'beam': '{}.bm'.format(src), 'model': '{}.{}.cc'.format(src, pol), 'out': '{}.{}.cm'.format(src, pol), })
def mapallvis(uvo, uvc, so, mapdir, lines=[], lineSelection=[], selects=[]): """ Similar to mapvis but doesn't do multiple frequency synthesis. The frequency axis is preserved so you can get spectra from the image. """ from subprocess import CalledProcessError if len(lines) != len(lineSelection): lineSelection = [None for l in lines] if len(lines) != len(selects): selects = [None for l in lines] calibrator = 'cnt.usb' tall = 0.50 # remove continuum, its already been mapped lineSelection.pop(lines.index(calibrator)) lines.remove(calibrator) for i, lin in enumerate(lines): vis = '{}/{}.{}.corrected.slfc'.format(uvc, so, lin) for src in [ '{}/{}.{}'.format(mapdir, so, lin), '{}/{}.{}.uncorrected'.format(mapdir, so, lin) ]: for path in glob.glob('{}*.full.*'.format(src)): if os.path.exists(path): shutil.rmtree(path) invertOptions = { 'vis': vis, 'stokes': 'i,v', 'beam': '{}.full.bm'.format(src), 'map': '{0}.i.full.mp,{0}.v.full.mp'.format(src), 'imsize': 128, 'cell': 0.3, 'options': 'systemp,double', 'sup': 0, } if selects[i]: invertOptions['select'] = selects[i] try: miriad.invert(invertOptions) except CalledProcessError: print("### Retrying invert with line selection") line = miriad.averageVelocityLine(vis, 2) sel = lineSelection[i] if lineSelection[i] is not None else line invertOptions['line'] = sel miriad.invert(invertOptions) for stk in ['i', 'v']: miriad.clean({ 'map': '{}.{}.full.mp'.format(src, stk), 'beam': '{}.full.bm'.format(src), 'out': '{}.{}.full.cc'.format(src, stk), 'niters': 3000, 'cutoff': tall }) miriad.restor({ 'map': '{}.{}.full.mp'.format(src, stk), 'beam': '{}.full.bm'.format(src), 'model': '{}.{}.full.cc'.format(src, stk), 'out': '{}.{}.full.cm'.format(src, stk), }) vis = '{}/{}.{}'.format(uvo, so, lin)