コード例 #1
0
def aocal_ratio(sol_numerator, sol_denominator, outpath):
    """Take the ratio of two sets of gains that are stored in the 
    mwareduce solution file format. The result is placed in a new
    file compatible with applysolutions. 

    Args:
        sol_numerator (str): Path to the gains that will act as the numerator
        sol_denominator (str): Path to the gains that will as the denominator
        outpath (str): The output path of the new solution file to create
    """
    ao_num = fromfile(sol_numerator)
    ao_den = fromfile(sol_denominator)

    ao_ratio = ao_num / ao_den

    mask = np.isfinite(ao_ratio)
    ao_ratio[~mask] = np.nan

    ao_ratio.tofile(outpath)
コード例 #2
0
def check_solutions(aofile, threshold=THRESHOLD, *args, **kwargs):
    """Inspects the ao-calibrate solutions file to evaluate its reliability

    Args:
        aofile (str): aocal solutions file to inspect
    
    Keyword Args:
        threshold (float): The threshold, between 0 to 1, where too many solutions are flagged before the file becomes invalid (default: 0.25)

    Returns:
        bool: a valid of invalid aosolutions file
    """
    threshold = threshold / 100 if threshold > 1 else threshold
    if not os.path.exists(aofile):
        return False

    ao_results = fromfile(aofile)
    ao_flagged = np.sum(np.isnan(ao_results)) / np.prod(ao_results.shape)

    if ao_flagged > threshold:
        return False

    return True
コード例 #3
0
                      action="store_true",
                      default=False,
                      dest="rms",
                      help="Plot rms histogram as well as del_phi")
    # TO ADD: LOG HISTOGRAMS OPTION
    #    parser.add_option("--output", default=None, dest="output", help="output names [default: OBSID_histogram.png and OBSID_phasemap.png")
    #    parser.add_option("--marker", default=',', dest="marker", type="string", help="matplotlib marker [default: %default]")
    #    parser.add_option("--markersize", default=2, dest="markersize", type="int", help="matplotlib markersize [default: %default]")
    options, args = parser.parse_args()

    if len(args) != 1:
        parser.error("incorrect number of arguments")

    filename = args[0]
    if os.path.exists(filename):
        ao = aocal.fromfile(filename)
    else:
        print(filename + " does not exist!")
        sys.exit(1)

    obsid = filename[0:10]
    diffs = np.array(diff(ao, options.metafits, options.refant))

    # Flatten array and delete NaNs for histogram
    median, peak, std = histo_diffs(
        diffs[np.logical_not(np.isnan(diffs))].flatten(), obsid)
    csv_out(obsid, median, peak, std)

    if options.metafits is not None:
        if os.path.exists(options.metafits):
            # Plotting on a single frequency, single pol on map because it's impossible otherwise
コード例 #4
0
    dest="preserve_xterms",
    help="preserve cross-terms (default is to set them all to 0+0j)")
opts, args = parser.parse_args()

if len(args) != 3:
    parser.error("incorrect number of arguments")
infilename = args[0]
outfilename = args[1]
refant = int(args[2])

if opts.verbose == 1:
    logging.basicConfig(level=logging.INFO)
elif opts.verbose > 1:
    logging.basicConfig(level=logging.DEBUG)

ao = fromfile(infilename)

ref_phasor = (ao[0, refant, ...] / np.abs(ao[0, refant, ...]))[np.newaxis,
                                                               np.newaxis, ...]
if opts.incremental:
    logging.warn("incremental solution untested!")
    ao = ao / (ao * ref_phasor)
else:
    ao = ao / ref_phasor

if not opts.preserve_xterms:
    ao[0, :, :, 1] = np.zeros(ao.shape[1:3], dtype=np.complex128)
    ao[0, :, :, 2] = np.zeros(ao.shape[1:3], dtype=np.complex128)

ao.tofile(outfilename)
コード例 #5
0
                      dest="amp_max",
                      type="float",
                      help="Maximum of y axis of amplitude plots")
    parser.add_option("--marker",
                      default=',',
                      dest="marker",
                      type="string",
                      help="matplotlib marker [default: %default]")
    parser.add_option("--markersize",
                      default=2,
                      dest="markersize",
                      type="int",
                      help="matplotlib markersize [default: %default]")
    opts, args = parser.parse_args()

    if len(args) != 1:
        parser.error("incorrect number of arguments")

    ao = aocal.fromfile(args[0])
    plot(ao,
         os.path.splitext(args[0])[0] + opts.suffix,
         opts.refant,
         plot_title=opts.plot_title,
         outdir=opts.outdir,
         format=opts.format,
         amp_max=opts.amp_max,
         marker=opts.marker,
         markersize=opts.markersize,
         verbose=opts.verbose,
         metafits=opts.metafits)