all_flagsets = set(flagger.flagsets.names()) # warn if any named flagsets were not found if remove_flagsets - all_flagsets: print("===> WARNING: flagset(s) %s not found, ignoring" % ",".join(remove_flagsets - all_flagsets)) # build flagmask of remaining flagsets retain = all_flagsets - remove_flagsets if not retain: # if names_not_found: # error("No such flagset(s): %s"%",".join(names_not_found)) print("===> WARNING: no flagsets to remove, exiting") sys.exit(0) flagmask = 0 for name in retain: flagmask |= flagger.flagsets.flagmask(name) print("===> removing flagset(s) %s" % ",".join(all_flagsets - retain)) print("===> and clearing flagmask %s" % Flagger.flagmaskstr(~flagmask)) if options.fill_legacy is not None: print("===> and filling FLAG/FLAG_ROW using flagmask %s" % Flagger.flagmaskstr(options.fill_legacy)) flagger.xflag(unflag=~flagmask, fill_legacy=options.fill_legacy) flagger.flagsets.remove_flagset(*list(all_flagsets - retain)) sys.exit(0) # parse subset options subset = parse_subset_options(options) if not subset: print("===> ended up with empty subset, exiting") sys.exit(0) # convert timeslots to reltime option, if specified if options.timeslots: from Owlcat import Parsing
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: print("===> NB: legacy FLAG/FLAG_ROW columns will be ignored with this flagmask") else: flagmask = Flagger.BITMASK_ALL | Flagger.LEGACY print("===> Using all flags") # parse slice specs try: freqslice = Parsing.parse_slice(options.freqslice) print("===> Channel selection is ", freqslice) except: parser.error("Invalid -L/--channels option. Start:end[:step] or start~end[:step] expected.") try: timeslice = Parsing.parse_slice(options.timeslice) print("===> Timeslot selection is ", timeslice)
all_flagsets = set(flagger.flagsets.names()) # warn if any named flagsets were not found if remove_flagsets - all_flagsets: print "===> WARNING: flagset(s) %s not found, ignoring"%",".join(remove_flagsets - all_flagsets) # build flagmask of remaining flagsets retain = all_flagsets-remove_flagsets if not retain: #if names_not_found: # error("No such flagset(s): %s"%",".join(names_not_found)); print "===> WARNING: no flagsets to remove, exiting" sys.exit(0) flagmask = 0 for name in retain: flagmask |= flagger.flagsets.flagmask(name) print "===> removing flagset(s) %s"%",".join(all_flagsets-retain); print "===> and clearing flagmask %s"%Flagger.flagmaskstr(~flagmask); if options.fill_legacy is not None: print "===> and filling FLAG/FLAG_ROW using flagmask %s"%Flagger.flagmaskstr(options.fill_legacy); flagger.xflag(unflag=~flagmask,fill_legacy=options.fill_legacy); flagger.flagsets.remove_flagset(*list(all_flagsets-retain)); sys.exit(0); # parse subset options subset = parse_subset_options(options); if not subset: print "===> ended up with empty subset, exiting"; sys.exit(0); # convert timeslots to reltime option, if specified if options.timeslots: from Owlcat import Parsing
if remove_flagsets - all_flagsets: print "===> WARNING: flagset(s) %s not found, ignoring" % ",".join( remove_flagsets - all_flagsets) # build flagmask of remaining flagsets retain = all_flagsets - remove_flagsets if not retain: #if names_not_found: # error("No such flagset(s): %s"%",".join(names_not_found)); print "===> WARNING: no flagsets to remove, exiting" sys.exit(0) flagmask = 0 for name in retain: flagmask |= flagger.flagsets.flagmask(name) print "===> removing flagset(s) %s" % ",".join(all_flagsets - retain) print "===> and clearing flagmask %s" % Flagger.flagmaskstr( ~flagmask) if options.fill_legacy is not None: print "===> and filling FLAG/FLAG_ROW using flagmask %s" % Flagger.flagmaskstr( options.fill_legacy) flagger.xflag(unflag=~flagmask, fill_legacy=options.fill_legacy) flagger.flagsets.remove_flagset(*list(all_flagsets - retain)) sys.exit(0) # parse subset options subset = parse_subset_options(options) if not subset: print "===> ended up with empty subset, exiting" sys.exit(0) # convert timeslots to reltime option, if specified if options.timeslots:
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: print "===> NB: legacy FLAG/FLAG_ROW columns will be ignored with this flagmask" else: flagmask = Flagger.BITMASK_ALL | Flagger.LEGACY print "===> Using all flags" # parse slice specs try: freqslice = Parsing.parse_slice(options.freqslice) print "===> Channel selection is ", freqslice except: parser.error( "Invalid -L/--channels option. Start:end[:step] or start~end[:step] expected." ) try: