Example #1
0
def main():
    sh.init(libwise.get_version(), USAGE)

    preprocess = not sh.get_opt_bool('no-crop', 'n')
    align = not sh.get_opt_bool('no-align', None)
    show_mask = sh.get_opt_bool('show-mask', 'm')

    region_files = sh.get_opt_value('reg-file', 'r', multiple=True)
    regions = []
    try:
        regions = [imgutils.Region(file) for file in region_files]
    except:
        print "Error: failed to read a region file"
        sh.usage(True)

    args = sh.get_args(min_nargs=1)

    config = actions.get_config(False)
    ctx = wise.AnalysisContext(config)
    actions.select_files(ctx, args)

    wise.tasks.view_all(ctx,
                        preprocess=preprocess,
                        show_regions=regions,
                        show_mask=show_mask,
                        align=align)
def main():
    sh.init(libwise.get_version(), USAGE)

    pa = sh.get_opt_bool('pa', 'p')
    fit = sh.get_opt_bool('fit', 'f')
    num = sh.get_opt_bool('num', 'n')
    min_link_size = sh.get_opt_value('min-link-size', 'm', default=2)
    sh.check(min_link_size, nputils.is_str_number, "min-link-size must be an integer")
    min_link_size = float(min_link_size)
    
    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Available scales: %s" % ctx.result.get_scales()
        sh.usage(True)

    fit_fct = None
    if fit:
        fit_fct = nputils.LinearFct
    fit_result = wise.tasks.plot_separation_from_core(ctx, scales=scales, num=num,
                        min_link_size=min_link_size, fit_fct=fit_fct, pa=pa)

    if fit:
        for link, fit_fct in fit_result.items():
            print "Fit result for link %s: %.2f +- %.2f mas / year" % (link.get_id(), fit_fct.a, fit_fct.ea)
Example #3
0
def main():
    sh.init(libwise.get_version(), USAGE)

    min_link_size = sh.get_opt_value('min-link-size', 'm', default=2)
    sh.check(min_link_size, nputils.is_str_number,
             "min-link-size must be an integer")
    min_link_size = float(min_link_size)

    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Available scales: %s" % ctx.result.get_scales(
        )
        sh.usage(True)

    wise.tasks.view_links(ctx, scales=scales, min_link_size=min_link_size)
Example #4
0
def get_date(date, option):
    if date is None:
        return None
    date = nputils.guess_date(date, ["%Y-%m-%d", "%Y_%m_%d"])
    if date is None:
        print "Error: invalid date format for the option %s" % option
        sh.usage(True)
    return date
Example #5
0
def get_date(date, option):
    if date is None:
        return None
    date = nputils.guess_date(date, ["%Y-%m-%d", "%Y_%m_%d"])
    if date is None:
        print "Error: invalid date format for the option %s" % option
        sh.usage(True)
    return date
Example #6
0
def main():
    sh.init(libwise.get_version(), USAGE)

    pa = sh.get_opt_bool('pa', 'p')
    fit = sh.get_opt_bool('fit', 'f')
    num = sh.get_opt_bool('num', 'n')
    min_link_size = sh.get_opt_value('min-link-size', 'm', default=2)
    sh.check(min_link_size, nputils.is_str_number,
             "min-link-size must be an integer")
    min_link_size = float(min_link_size)

    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Available scales: %s" % ctx.result.get_scales(
        )
        sh.usage(True)

    fit_fct = None
    if fit:
        fit_fct = nputils.LinearFct
    fit_result = wise.tasks.plot_separation_from_core(
        ctx,
        scales=scales,
        num=num,
        min_link_size=min_link_size,
        fit_fct=fit_fct,
        pa=pa)

    if fit:
        for link, fit_fct in fit_result.items():
            print "Fit result for link %s: %.2f +- %.2f mas / year" % (
                link.get_id(), fit_fct.a, fit_fct.ea)
Example #7
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Availables scales: %s" % ctx.result.get_scales()
        sh.usage(True)

    print "Plotting features from scales %s" % scales
    wise.tasks.view_all_features(ctx, scales)
Example #8
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Availables scales: %s" % ctx.result.get_scales(
        )
        sh.usage(True)

    print "Plotting features from scales %s" % scales
    wise.tasks.view_all_features(ctx, scales)
Example #9
0
def main():
    sh.init(libwise.get_version(), USAGE)

    preprocess = not sh.get_opt_bool('no-crop', 'n')
    align = not sh.get_opt_bool('no-align', None)
    show_mask = sh.get_opt_bool('show-mask', 'm')

    region_files = sh.get_opt_value('reg-file', 'r', multiple=True)
    regions = []
    try:
        regions = [imgutils.Region(file) for file in region_files]
    except:
        print "Error: failed to read a region file"
        sh.usage(True)

    args = sh.get_args(min_nargs=1)

    config = actions.get_config(False)
    ctx = wise.AnalysisContext(config)
    actions.select_files(ctx, args)

    wise.tasks.view_all(ctx, preprocess=preprocess, show_regions=regions, 
                        show_mask=show_mask, align=align)
Example #10
0
def main():
    sh.init(libwise.get_version(), USAGE)

    min_link_size = sh.get_opt_value('min-link-size', 'm', default=2)
    sh.check(min_link_size, nputils.is_str_number, "min-link-size must be an integer")
    min_link_size = float(min_link_size)
    
    args = sh.get_args(min_nargs=2)
    name = args[0]
    ctx = actions.load(name)

    if ctx is None:
        print "No results saved with name %s" % name
        sh.usage(True)

    scales = args[1]

    try:
        scales = nputils.str2floatlist(scales)
    except:
        print "Error: invalid scales. Available scales: %s" % ctx.result.get_scales()
        sh.usage(True)

    wise.tasks.view_links(ctx, scales=scales, min_link_size=min_link_size)
Example #11
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=0)

    config = actions.get_config(True)

    if len(args) == 0 or args[0] in ['get', 'show']:
        if len(args) < 2:
            print config.values()
        elif '.' in args[1]:
            section_name, option = args[1].split('.', 2)
            section = get_section(section_name, config)
            check_option(section, option)
            print '%s: %s' % (args[1], section.get(option, encode=True))
        else:
            section = get_section(args[1], config)
            print section.values()

    elif args[0] == 'set':
        for arg in args[1:]:
            if arg == 'matcher.delta_range_filter':
                delta_range_filter_handler(config)
                continue
            try:
                full_option, value = arg.split('=', 2)
                section_name, option = full_option.split('.', 2)
            except: 
                print "Error: setting option should be of the form SECTION.OPTION=VALUE\n"
                sh.usage(True)
            section = get_section(section_name, config)
            check_option(section, option)
            print "Setting %s to %s" % (full_option, value)
            section.set(option, value, decode=True)
        if len(args[1:]) > 0:
            config.to_file(actions.CONFIG_FILE)
            print "Configuration saved"

    elif args[0] == 'doc':
        if len(args) == 1:
            print config.doc()
        elif '.' in args[1]:
            section_name, option = args[1].split('.', 2)
            section = get_section(section_name, config)
            check_option(section, option)
            print "Documentation of %s: %s" % (args[1], section.get_doc(option))
        else:
            section = get_section(args[1], config)
            print section.doc()

    elif args[0] == 'restore':
        if len(args) != 2 or not os.path.isfile(args[1]):
            print "Error: an existing CONFIG_FILE is necessary\n"
            sh.usage(True)
        try:
            config.from_file(args[1])
            config.to_file(actions.CONFIG_FILE)
        except:
            print "Error: restoring configuration from %s failed\n" % args[1]
            raise
        print "Configuration restored from %s" % args[1]
    else:
        print "Error: Action not possible\n"
        sh.usage(True)
Example #12
0
def check_option(section, option):
    if not section.has(option):
        print "Error: option %s of %s does not exist\n" % (option, section.get_title())
        sh.usage(True)
Example #13
0
def get_section(section_name, config):
    if not section_name in ['data', 'finder', 'matcher']:
        print "Error: SECTION should be one of data, finder or matcher\n"
        sh.usage(True)
    return getattr(config, section_name)
Example #14
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=0)

    config = actions.get_config(True)

    if len(args) == 0 or args[0] in ['get', 'show']:
        if len(args) < 2:
            print config.values()
        elif '.' in args[1]:
            section_name, option = args[1].split('.', 2)
            section = get_section(section_name, config)
            check_option(section, option)
            print '%s: %s' % (args[1], section.get(option, encode=True))
        else:
            section = get_section(args[1], config)
            print section.values()

    elif args[0] == 'set':
        for arg in args[1:]:
            if arg == 'matcher.delta_range_filter':
                delta_range_filter_handler(config)
                continue
            try:
                full_option, value = arg.split('=', 2)
                section_name, option = full_option.split('.', 2)
            except:
                print "Error: setting option should be of the form SECTION.OPTION=VALUE\n"
                sh.usage(True)
            section = get_section(section_name, config)
            check_option(section, option)
            print "Setting %s to %s" % (full_option, value)
            section.set(option, value, decode=True)
        if len(args[1:]) > 0:
            config.to_file(actions.CONFIG_FILE)
            print "Configuration saved"

    elif args[0] == 'doc':
        if len(args) == 1:
            print config.doc()
        elif '.' in args[1]:
            section_name, option = args[1].split('.', 2)
            section = get_section(section_name, config)
            check_option(section, option)
            print "Documentation of %s: %s" % (args[1],
                                               section.get_doc(option))
        else:
            section = get_section(args[1], config)
            print section.doc()

    elif args[0] == 'restore':
        if len(args) != 2 or not os.path.isfile(args[1]):
            print "Error: an existing CONFIG_FILE is necessary\n"
            sh.usage(True)
        try:
            config.from_file(args[1])
            config.to_file(actions.CONFIG_FILE)
        except:
            print "Error: restoring configuration from %s failed\n" % args[1]
            raise
        print "Configuration restored from %s" % args[1]
    else:
        print "Error: Action not possible\n"
        sh.usage(True)
Example #15
0
def check_option(section, option):
    if not section.has(option):
        print "Error: option %s of %s does not exist\n" % (option,
                                                           section.get_title())
        sh.usage(True)
Example #16
0
def get_section(section_name, config):
    if not section_name in ['data', 'finder', 'matcher']:
        print "Error: SECTION should be one of data, finder or matcher\n"
        sh.usage(True)
    return getattr(config, section_name)