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)
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)
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)
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)
def main(): sh.init(libwise.get_version(), USAGE) args = sh.get_args(min_nargs=1) img = imgutils.guess_and_open(args[0]) editor = PolyRegionEditor.PolyRegionEditor(img, current_folder=os.path.dirname(img.file)) if len(args) >= 2: poly_region = imgutils.PolyRegion.from_file(args[1], img.get_coordinate_system()) editor.load_poly_region(poly_region) editor.start()
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)
def main(): sh.init(libwise.get_version(), USAGE) start_date = get_date(sh.get_opt_value('start-date', 's'), 'start-date') end_date = get_date(sh.get_opt_value('end-date', 'e'), 'end-date') filter_dates = [get_date(k, 'filter-date') for k in sh.get_opt_value('filter-date', 'f', multiple=True)] output_filename = sh.get_opt_value('output', 'o', default='files') args = sh.get_args(min_nargs=1) files = imgutils.fast_sorted_fits(args, start_date=start_date, end_date=end_date, filter_dates=filter_dates) print "Outputing %s files in '%s'" % (len(files), output_filename) with open(output_filename, 'w') as f: f.write("\n".join(files) + "\n")
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
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)
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) 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)
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)
''' Created on Jun 11, 2012 @author: fmertens ''' import libwise import glob from setuptools import setup, find_packages setup( name = 'libwise', version = '%s' % libwise.get_version(), description = 'Various utilities for the WISE package', url = 'https://github.com/flomertens/libwise', author = 'Florent Mertens', author_email = '*****@*****.**', license='GPL2', include_package_data=True, packages=find_packages(), scripts=glob.glob('scripts/*') )