Ejemplo n.º 1
0
  parser.add_option("-f","--force",dest="force",action="store_true",
                    help="overwrites output MS if it already exists");

  parser.set_defaults(ddid=-1,output="%(ms)s_spw%(ddid)d%(msext)s");

  (options,msname) = parser.parse_args();

  if len(msname) != 1 :
    parser.error("Incorrect number of arguments. Use '-h' for help.");
  
  # open input MS
  msname = msname[0];
  print "Reading input MS %s"%msname;
  if not tableexists(msname):
    parser.error("MS %s not found."%msname);
  ms = table(msname);
  # check DDID option
  num_ddids = table(ms.getkeyword("DATA_DESCRIPTION")).nrows();
  print "MS contains %d DATA_DESC_IDs"%num_ddids;
  if options.ddid < 0:
    ddids = range(num_ddids);
  elif options.ddid >= num_ddids:
    parser.error("DATA_DESC_ID %d is out of range"%options.ddid);
  else:
    ddids = [ options.ddid ];

  # setup outputs
  msname,msext = os.path.splitext(os.path.basename(os.path.normpath(msname)));

  for ddid in ddids:
    msout = options.output%dict(ms=msname,msext=msext,ddid=ddid);
Ejemplo n.º 2
0
      progress("Deleting existing copy of %s"%msout);
      tabledelete(msout);
    # copy first MS to output as-is
    progress("Copying %s to %s"%(msins[0],msout));
    tablecopy(msins[0],msout,deep=True);
    # when renumbering spectral windows, need to have an addImagingColumns() call
    # unfortunately, this wipes CORRECTED_DATA! I see no way around this (copynorows=True is no help,
    # as then it fails to copy subtables) apart from the ugly: copy first MS deeply,
    # add imaging columns, then re-copy columns
    if options.renumber_spws:
      addImagingColumns(msout);
    # otherwise, first MS is already copied, so remove it from list
    # (but reset OBSERVATION_ID)
    else:
      if options.renumber_obs:
        tab = table(msout,readonly=False);
        obs = tab.getcol("OBSERVATION_ID");
        obs[:] = obsid;
        obsid += 1;
        tab.putcol("OBSERVATION_ID",obs);
        tab.close();
      msins = msins[1:];

  # open output for writing
  tab0 = table(msout,readonly=False);

  # get the number of DDIDs and SPWIDs
  ddid_offsets = [0]*len(msins);
  if options.renumber_spws:
    ddid_tab0 = table(tab0.getkeyword("DATA_DESCRIPTION"),readonly=False);
    spw_tab0 = table(tab0.getkeyword("SPECTRAL_WINDOW"),readonly=False);
Ejemplo n.º 3
0
        "-f", "--force", dest="force", action="store_true", help="overwrites output MS if it already exists"
    )

    parser.set_defaults(ddid=-1, output="%(ms)s_spw%(ddid)d%(msext)s")

    (options, msname) = parser.parse_args()

    if len(msname) != 1:
        parser.error("Incorrect number of arguments. Use '-h' for help.")

    # open input MS
    msname = msname[0]
    print "Reading input MS %s" % msname
    if not tableexists(msname):
        parser.error("MS %s not found." % msname)
    ms = table(msname)
    # check DDID option
    num_ddids = table(ms.getkeyword("DATA_DESCRIPTION")).nrows()
    print "MS contains %d DATA_DESC_IDs" % num_ddids
    if options.ddid < 0:
        ddids = range(num_ddids)
    elif options.ddid >= num_ddids:
        parser.error("DATA_DESC_ID %d is out of range" % options.ddid)
    else:
        ddids = [options.ddid]

    # setup outputs
    msname, msext = os.path.splitext(os.path.basename(os.path.normpath(msname)))

    for ddid in ddids:
        msout = options.output % dict(ms=msname, msext=msext, ddid=ddid)
Ejemplo n.º 4
0
            progress("Deleting existing copy of %s" % msout)
            tabledelete(msout)
        # copy first MS to output as-is
        progress("Copying %s to %s" % (msins[0], msout))
        tablecopy(msins[0], msout, deep=True)
        # when renumbering spectral windows, need to have an addImagingColumns() call
        # unfortunately, this wipes CORRECTED_DATA! I see no way around this (copynorows=True is no help,
        # as then it fails to copy subtables) apart from the ugly: copy first MS deeply,
        # add imaging columns, then re-copy columns
        if options.renumber_spws:
            addImagingColumns(msout)
        # otherwise, first MS is already copied, so remove it from list
        # (but reset OBSERVATION_ID)
        else:
            if options.renumber_obs:
                tab = table(msout, readonly=False)
                obs = tab.getcol("OBSERVATION_ID")
                obs[:] = obsid
                obsid += 1
                tab.putcol("OBSERVATION_ID", obs)
                tab.close()
            msins = msins[1:]

    # open output for writing
    tab0 = table(msout, readonly=False)

    # get the number of DDIDs and SPWIDs
    ddid_offsets = [0] * len(msins)
    if options.renumber_spws:
        ddid_tab0 = table(tab0.getkeyword("DATA_DESCRIPTION"), readonly=False)
        spw_tab0 = table(tab0.getkeyword("SPECTRAL_WINDOW"), readonly=False)