示例#1
0
def get_plot_data(data, x_name, y_name, z_expr):
    # fetch x
    try:
        x_col = data.getColumn(x_name)
    except xdp.ColumnNameError:
        util.fatal_error('invalid x-axis column name "%s"', repr(x_name)[1:-1])

    # fetch y
    try:
        y_col = data.getColumn(y_name)
    except xdp.ColumnNameError:
        util.fatal_error('invalid y-axis column name "%s"', repr(x_name)[1:-1])

    # evaluate the specified expression to get z
    z_col = data.evaluate(z_expr)

    return makeXYZ(x_col, y_col, z_col)
示例#2
0
def parse_arguments(args):
    USAGE = "%prog [OPTIONS...] FILE [ROI-NUMBER]"
    VERSION = "%prog " + frankenplot.__version__ + ", by Ken McIvor <*****@*****.**>"
    parser = optparse.OptionParser(usage=USAGE, version=VERSION)

    parser.add_option(
        "-i", action="callback", type="string", callback=legacy_i_callback, help=optparse.SUPPRESS_HELP, metavar="N"
    )

    parser.add_option(
        "-x",
        action="store",
        type="string",
        dest="xName",
        default=defaults.x_name,
        help='x-axis column name ("%s" is default)' % defaults.x_name,
        metavar="N",
    )

    parser.add_option(
        "-y",
        action="store",
        type="string",
        dest="yName",
        default=defaults.y_name,
        help='y-axis column name ("%s" is default)' % defaults.y_name,
        metavar="N",
    )

    parser.add_option(
        "-z",
        action="store",
        type="string",
        dest="zName",
        default=defaults.fluor_mode.z_name,
        help='z-axis column name ("%s" is default)' % defaults.fluor_mode.z_name,
        metavar="N",
    )

    # FIXME move to Edit -> Preferences
    parser.add_option("-n", action="store_false", dest="normalize", default=True, help="disable Io normalization")

    parser.add_option(
        "-m",
        action="store",
        dest="colormap",
        default=defaults.colormap,
        help=("color map (%s)" % ", ".join(defaults.colormaps)),
        metavar="C",
    )

    opts, args = parser.parse_args(args)
    if not 0 < len(args) < 3:
        parser.print_usage()
        sys.exit(1)

    # FIXME: most of this logic should be moved into f.data or f.gui
    fileName = args[0]
    roiNumber = 0
    if len(args) == 2:
        try:
            roiNumber = int(args[1])
        except ValueError:
            util.fatal_error('invalid ROI number "%s"', repr(args[1])[1:-1])

        if roiNumber < 0:
            util.fatal_error('invalid ROI number "%s"', repr(args[1])[1:-1])

    cm = opts.colormap.lower()
    if cm not in defaults.colormaps:
        fatal_error('invalid color map "%s"', opts.colormap)
    else:
        opts.colormap = cm

    return opts, (fileName, roiNumber)