cell=cell, mode=mode, nchan=nchan, width=width, start=start,
          threshold=threshold, field=field, phasecenter=phasecenter, spw=spw,
          imagermode=imagermode, multiscale=multiscale, outframe=outframe,
          veltype=veltype, minpb=0.3, weighting=weighting, robust=robust,
          restfreq=restfreq, usescratch=usescratch,
          interpolation=interpolation, pbcor=True)

if contsub:
    # Check that the concatenated MS exists
    if not os.path.exists(concat_ms):
        raise IOError("Concatenated MS does not exist in the given directory.")

    if os.path.exists(contsub_ms) and delete_old:
        rmtables(contsub_ms)

    uvcontsub(vis=concat_ms, fitspw=fitspw, excludechans=excludechans,
              fitorder=0, want_cont=False)

if dirty_cube:
    # Check that the contsub MS exists
    if not os.path.exists(contsub_ms):
        raise IOError("Contsub MS does not exist in the given directory.")

    if not os.path.exists(dirty_image_direc):
        os.mkdir(dirty_image_direc)

    out_image = os.path.join(dirty_image_direc,
                             line_name + "_" + project_name + "_dirty")
                             # line_name + "_" + project_name + "_dirty_noM33_3_equaltime")

    rmtables(out_image + ".*")
Beispiel #2
0
            # (there may be several cont.dats - we're just grabbing the first)
            path = os.path.split(vis[0])[0]

            contfile = os.path.join(path, '../calibration/cont.dat')

            cont_freq_selection = parse_contdotdat(contfile)

            for vv in vis:
                if not os.path.exists(vv + ".contsub"):
                    new_freq_selection = freq_selection_overlap(
                        vv, cont_freq_selection)
                    uvcontsub(
                        vis=vv,
                        fitspw=new_freq_selection,
                        excludechans=False,  # fit the regions in fitspw
                        combine=
                        'spw',  # redundant since we're working on single spw's
                        solint='int',
                        fitorder=1,
                        want_cont=False)

            if not os.path.exists(lineimagename + ".contsub.image"):
                tclean(vis=[vv + ".contsub" for vv in vis],
                       imagename=lineimagename + ".contsub",
                       field=[field.encode()] * len(vis),
                       specmode='cube',
                       outframe='LSRK',
                       veltype='radio',
                       niter=2000,
                       threshold=threshold,
                       usemask='auto-multithresh',
                          intent='OBSERVE_TARGET#ON_SOURCE',
                          datacolumn='CORRECTED',
                          keepflags=True)

                # Now continuum subtract with the line-free channels

                linefree_chan = linefree_chans[line_name]

                if len(linefree_chan) == 0:
                    print("No line free channels found for {0} {1}".format(
                        prefix, line_name))

                linefree_str = ["{0}~{1}".format(*ch) for ch in linefree_chan]
                if len(linefree_chans) > 1:
                    linefree_str = ";".join(linefree_str)
                else:
                    linefree_str = linefree_str[0]

                # Add SPW 0 for the split MS
                linefree_str = "0:{0}".format(linefree_str)

                contsubvis_name = "{0}.contsub".format(outputvis_name)

                if os.path.exists(contsubvis_name):
                    print("Found contsub MS for {0} {1}".format(
                        prefix, line_name))
                else:
                    uvcontsub(vis=outputvis_name,
                              fitspw=linefree_str,
                              fitorder=0)
Beispiel #4
0
                        frqs = {
                            spw: ms.cvelfreqs(spwids=[spw], outframe='LSRK')
                            for spw in spws
                        }
                    ms.close()

                    # calculate the line channels from the contdatfile (which is in LSRK)
                    # and the frequency arrays
                    linechannels = contchannels_to_linechannels(
                        cont_freq_selection, frqs)

                    uvcontsub(
                        vis=concatvis,
                        fitspw=linechannels,
                        excludechans=True,  # fit the non-line channels
                        combine=
                        'none',  # DO NOT combine spws for continuum ID (since that implies combining 7m <-> 12m)
                        solint='int',  # fit each integration (may be noisy?)
                        fitorder=1,
                        want_cont=False)

                # if do_contsub, we want to use the contsub'd MS
                concatvis = concatvis + contsub_suffix

            # check that autocorrs are flagged out
            if 'concat' in concatvis:
                flagsum = flagdata(vis=concatvis,
                                   mode='summary',
                                   uvrange='0~1m')
                if 'flagged' in flagsum and flagsum['flagged'] != flagsum[
                        'total']:
 #
 # My own diagnostic plots
 #
 # Copyfile not finished
 everythings_diagnostic_plots(msname=msname, plot_spw=8)
 #
 # uvcontsub
 #
 msforsplit = msname
 dataforsplit = 'corrected'
 spwsplit = '8'
 if contsub:
     everythings_log("Start uvcontsub")
     uvcontsub(vis=msname,
               fitspw='8:1024~3072',
               excludechans=True,
               want_cont=False,
               fitorder=1,
               spw='8')
     msforsplit = msname + '.contsub'
     dataforsplit = 'data'
     spwsplit = ''
 #
 # Split
 #
 everythings_log("Start final split")
 mssplit = msname + '.split'
 split(vis=msforsplit,
       outputvis=mssplit,
       spw=spwsplit,
       intent='*TARGET*',
       width=4,