示例#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)
示例#2
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=1)

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

    if len(ctx.files) == 0:
        sys.exit(0)

    wise.tasks.detection_all(ctx)

    str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)]
    check = lambda s: len(
        wise.tasks._get_scales(str2vector(s), ctx.result.get_scales())) > 0

    txt = "View scales (available: %s) (press enter to leave):" % ctx.result.get_scales(
    )

    while True:
        scales = sh.ask(txt, check_fct=check, default=[])
        if len(scales) == 0:
            break
        wise.tasks.view_wds(ctx, scales=str2vector(scales))

    save = sh.askbool("Save the result ?")

    if save:
        name = str(sh.ask("Name (default=result):", default='result'))
        wise.tasks.save(ctx, name)
示例#3
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=1)

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

    if len(ctx.files) == 0:
        sys.exit(0)

    wise.tasks.detection_all(ctx)

    str2vector = lambda s: [float(k) for k in re.findall("[-0-9.]+", s)]
    check = lambda s: len(wise.tasks._get_scales(str2vector(s), ctx.result.get_scales())) > 0

    txt ="View scales (available: %s) (press enter to leave):" % ctx.result.get_scales()

    while True:
        scales = sh.ask(txt, check_fct=check, default=[])
        if len(scales) == 0:
            break
        wise.tasks.view_wds(ctx, scales=str2vector(scales))

    save = sh.askbool("Save the result ?")
        
    if save:
        name = str(sh.ask("Name (default=result):", default='result'))
        wise.tasks.save(ctx, name)
示例#4
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=1)

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

    if len(ctx.files) == 0:
        sys.exit(0)

    wise.tasks.match_all(ctx)

    check = lambda s: nputils.is_str_number(s) and float(
        s) in ctx.result.get_scales()

    txt = "View scales (available: %s) (press enter to leave):" % ctx.result.get_scales(
    )

    while True:
        scale = float(sh.ask(txt, check_fct=check, default=0))
        if scale == 0:
            break
        wise.tasks.view_displacements(ctx, scale)

    save = sh.askbool("Save the result ?")

    if save:
        name = str(sh.ask("Name (default=result):", default='result'))
        wise.tasks.save(ctx, name)
示例#5
0
def main():
    sh.init(libwise.get_version(), USAGE)

    args = sh.get_args(min_nargs=1)

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

    if len(ctx.files) == 0:
        sys.exit(0)

    wise.tasks.match_all(ctx)

    check = lambda s: nputils.is_str_number(s) and float(s) in ctx.result.get_scales()

    txt ="View scales (available: %s) (press enter to leave):" % ctx.result.get_scales()

    while True:
        scale = float(sh.ask(txt, check_fct=check, default=0))
        if scale == 0:
            break
        wise.tasks.view_displacements(ctx, scale)

    save = sh.askbool("Save the result ?")
        
    if save:
        name = str(sh.ask("Name (default=result):", default='result'))
        wise.tasks.save(ctx, name)
示例#6
0
def main():
    sh.init(libwise.get_version(), USAGE)

    velocity = sh.get_opt_bool('velocity', 'V')

    args = sh.get_args(min_nargs=1)

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

    if velocity:
        wise.tasks.info_files_delta(ctx)
    else:
        wise.tasks.info_files(ctx)
示例#7
0
def main():
    sh.init(libwise.get_version(), USAGE)

    velocity = sh.get_opt_bool('velocity', 'V')

    args = sh.get_args(min_nargs=1)

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

    if velocity:
        wise.tasks.info_files_delta(ctx)
    else:
        wise.tasks.info_files(ctx)
示例#8
0
def main():
    sh.init(libwise.get_version(), USAGE)

    nsigma = float(sh.get_opt_value('nsigma', 'n', default=0))
    nsigma_connected = sh.get_opt_bool('nsigma_connected', 'c')
    output_filename = sh.get_opt_value('output', 'o', default='stack_img.fits')

    args = sh.get_args(min_nargs=1)

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

    stack_img = ctx.build_stack_image(preprocess=False, nsigma=nsigma, nsigma_connected=nsigma_connected)
    stack_img.save(output_filename)

    print "Stacked images save to %s" % output_filename
示例#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)
示例#10
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)
示例#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)