Ejemplo n.º 1
0
        description=\
        "Sets up tiled storage managers for the DATA, FLAG and BITFLAG columns of an MS, "+
        "and sets a fixed shape on the columns. This can speed up access to some MSs, e.g. "+
        "such as those produced by the uvfits2ms converter. "
    )
    parser.add_option("-f",
                      "--force",
                      action="store_true",
                      help="proceed non-interactively")

    (options, msnames) = parser.parse_args()

    if len(msnames) != 1:
        parser.error("MS name not supplied.")

    if not Owlcat.find_exec("addtiledmscol"):
        print "Can't find the 'addtiledmscol' utility, which is required by this script."
        print "You may need to install or build the MeqTrees package."
        sys.exit(1)

    msname = msnames[0]
    ms = table(msname, readonly=False)

    if not options.force:
        print """
  This script will reinitialize the DATA, FLAG and BITFLAG columns
  of the MS using a tiled storage manager and a fixed shape. It will attempt
  to preserve the data in these columns. The MODEL_DATA, CORRECTED_DATA and
  IMAGING_WEIGHT columns will be reset and their contents discarded. If this
  operation is interrupted, the MS may be left in a corrupted state, so
  please make sure you have a backup of the MS.
  from optparse import OptionParser
  parser = OptionParser(usage="""%prog: [options] MS""",
      description=\
      "Sets up tiled storage managers for the DATA, FLAG and BITFLAG columns of an MS, "+
      "and sets a fixed shape on the columns. This can speed up access to some MSs, e.g. "+
      "such as those produced by the uvfits2ms converter. "
  );
  parser.add_option("-f","--force",action="store_true",
                    help="proceed non-interactively");

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

  if len(msnames) != 1:
    parser.error("MS name not supplied.");
    
  if not Owlcat.find_exec("addtiledmscol"):
    print "Can't find the 'addtiledmscol' utility, which is required by this script."
    print "You may need to install or build the MeqTrees package.";
    sys.exit(1);

  msname = msnames[0];
  ms = table(msname,readonly=False);

  if not options.force:
    print """
  This script will reinitialize the DATA, FLAG and BITFLAG columns
  of the MS using a tiled storage manager and a fixed shape. It will attempt
  to preserve the data in these columns. The MODEL_DATA, CORRECTED_DATA and
  IMAGING_WEIGHT columns will be reset and their contents discarded. If this
  operation is interrupted, the MS may be left in a corrupted state, so
  please make sure you have a backup of the MS.
Ejemplo n.º 3
0
def get_ms ():
  global ms;
  global msname;
  if not ms:
    ms = Owlcat.table(msname);
  return ms;
Ejemplo n.º 4
0
    import numpy
    import numpy.ma
    import Owlcat.Flagger
    from Owlcat.Flagger import Flagger

    # now, skip most of the actions below if we're in statonly mode and exporting
    if not (statonly and options.export):
        # create flagger object
        flagger = Flagger(msname, verbose=options.verbose, timestamps=options.timestamps, chunksize=options.chunk_size)

        #
        # -l/--list: list MS info
        #
        if options.list:
            ms = get_ms()
            ants = Owlcat.table(ms.getkeyword('ANTENNA')).getcol('NAME')
            ddid_tab = Owlcat.table(ms.getkeyword('DATA_DESCRIPTION'))
            spwids = ddid_tab.getcol('SPECTRAL_WINDOW_ID')
            polids = ddid_tab.getcol('POLARIZATION_ID')
            corrs = Owlcat.table(ms.getkeyword('POLARIZATION')).getcol('CORR_TYPE')
            spw_tab = Owlcat.table(ms.getkeyword('SPECTRAL_WINDOW'))
            ref_freq = spw_tab.getcol('REF_FREQUENCY')
            nchan = spw_tab.getcol('NUM_CHAN')
            fields = Owlcat.table(ms.getkeyword('FIELD')).getcol('NAME')

            print("===> MS is %s" % msname)
            print("  %d antennas: %s" % (len(ants), " ".join(ants)))
            print("  %d DATA_DESC_ID(s): " % len(spwids))
            for i, (spw, pol) in enumerate(zip(spwids, polids)):
                print("    %d: %.3f MHz, %d chans x %d correlations" % (
                i, ref_freq[spw] * 1e-6, nchan[spw], len(corrs[pol, :])))
Ejemplo n.º 5
0
        if len([opt for opt in allopt if opt == what]) > 1:
            parser.error("Conflicting --page/--stack/--average options for '%s'.")

    # get figsize
    try:
        w, h = list(map(int, options.figsize.split('x', 1)))
        figsize = (w * 10, h * 10)
    except:
        parser.error("Invalid --size setting '%s'" % options.figsize)

    # get MS name
    if not args:
        parser.error("MS not specified. Use '-h' for help.")
    msname = args[0]
    print("===> Attaching to MS %s" % msname)
    ms = Owlcat.table(msname)

    # get flagmask, use a Flagger for this
    import Owlcat.Flagger
    from Owlcat.Flagger import Flagger

    if options.flagmask == "0":
        flagmask = 0
        print("===> Flagmask 0, ignoring all flags")
    elif options.flagmask is not None:
        flagger = Flagger(msname)
        flagmask = flagger.lookup_flagmask(options.flagmask)
        flagger.close()
        flagger = None
        print("===> Flagmask is %s (you specified '%s')" % (Flagger.flagmaskstr(flagmask), options.flagmask))
        if not flagmask & Flagger.LEGACY:
Ejemplo n.º 6
0
    from Owlcat.Flagger import Flagger

    # now, skip most of the actions below if we're in statonly mode and exporting
    if not (statonly and options.export):
        # create flagger object
        flagger = Flagger(msname,
                          verbose=options.verbose,
                          timestamps=options.timestamps,
                          chunksize=options.chunk_size)

        #
        # -l/--list: list MS info
        #
        if options.list:
            ms = get_ms()
            ants = Owlcat.table(ms.getkeyword('ANTENNA')).getcol('NAME')
            ddid_tab = Owlcat.table(ms.getkeyword('DATA_DESCRIPTION'))
            spwids = ddid_tab.getcol('SPECTRAL_WINDOW_ID')
            polids = ddid_tab.getcol('POLARIZATION_ID')
            corrs = Owlcat.table(
                ms.getkeyword('POLARIZATION')).getcol('CORR_TYPE')
            spw_tab = Owlcat.table(ms.getkeyword('SPECTRAL_WINDOW'))
            ref_freq = spw_tab.getcol('REF_FREQUENCY')
            nchan = spw_tab.getcol('NUM_CHAN')
            fields = Owlcat.table(ms.getkeyword('FIELD')).getcol('NAME')

            print "===> MS is %s" % msname
            print "  %d antennas: %s" % (len(ants), " ".join(ants))
            print "  %d DATA_DESC_ID(s): " % len(spwids)
            for i, (spw, pol) in enumerate(zip(spwids, polids)):
                print "    %d: %.3f MHz, %d chans x %d correlations" % (
Ejemplo n.º 7
0
        if len([opt for opt in allopt if opt == what]) > 1:
            parser.error("Conflicting --page/--stack/--average options for '%s'.")

    # get figsize
    try:
        w, h = map(int, options.figsize.split("x", 1))
        figsize = (w * 10, h * 10)
    except:
        parser.error("Invalid --size setting '%s'" % options.figsize)

    # get MS name
    if not args:
        parser.error("MS not specified. Use '-h' for help.")
    msname = args[0]
    print "===> Attaching to MS %s" % msname
    ms = Owlcat.table(msname)

    # get flagmask, use a Flagger for this
    import Owlcat.Flagger
    from Owlcat.Flagger import Flagger

    if options.flagmask == "0":
        flagmask = 0
        print "===> Flagmask 0, ignoring all flags"
    elif options.flagmask is not None:
        flagger = Flagger(msname)
        flagmask = flagger.lookup_flagmask(options.flagmask)
        flagger.close()
        flagger = None
        print "===> Flagmask is %s (you specified '%s')" % (Flagger.flagmaskstr(flagmask), options.flagmask)
        if not flagmask & Flagger.LEGACY:
Ejemplo n.º 8
0
def get_ms():
    global ms
    global msname
    if not ms:
        ms = Owlcat.table(msname)
    return ms
Ejemplo n.º 9
0
            parser.error(
                "Conflicting --page/--stack/--average options for '%s'.")

    # get figsize
    try:
        w, h = map(int, options.figsize.split('x', 1))
        figsize = (w * 10, h * 10)
    except:
        parser.error("Invalid --size setting '%s'" % options.figsize)

    # get MS name
    if not args:
        parser.error("MS not specified. Use '-h' for help.")
    msname = args[0]
    print "===> Attaching to MS %s" % msname
    ms = Owlcat.table(msname)

    # get flagmask, use a Flagger for this
    import Owlcat.Flagger
    from Owlcat.Flagger import Flagger
    if options.flagmask == "0":
        flagmask = 0
        print "===> Flagmask 0, ignoring all flags"
    elif options.flagmask is not None:
        flagger = Flagger(msname)
        flagmask = flagger.lookup_flagmask(options.flagmask)
        flagger.close()
        flagger = None
        print "===> Flagmask is %s (you specified '%s')" % (
            Flagger.flagmaskstr(flagmask), options.flagmask)
        if not flagmask & Flagger.LEGACY: