def list_saved_results(ctx): '''List all saved results Parameters ---------- ctx : :class:`wise.project.AnalysisContext` .. _tags: task_general ''' ref_img = ctx.get_ref_image() projection = ctx.get_projection(stack_img) ext = '.set.dat' data = [] header = ["Name", "Number of epochs", "First epoch", "Last epoch", "Kinematic", "Scales"] for file in glob.glob(os.path.join(ctx.get_data_dir(), '*', '*' + ext)): name = os.path.basename(os.path.dirname(file)) if not os.path.basename(file) == name + ext: continue img_set = imgutils.ImageSet.from_file(file, projection) epochs = img_set.get_epochs() if isinstance(epochs[0], datetime.datetime): epochs = [epoch.strftime("%Y-%m-%d") for epoch in epochs] n = len(epochs) first, last = epochs[0], epochs[-1] link_builder_files = glob.glob(os.path.join(os.path.dirname(file), '*.ms.dfc.dat')) scales = [f.rsplit('_')[-1].split('.')[0] for f in link_builder_files] data.append([name, n, first, last, bool(len(scales)), ", ".join(scales)]) print nputils.format_table(data, header)
def info_files(ctx): '''Print List of selected files with information on beam and pixel scales Parameters ---------- ctx : :class:`wise.project.AnalysisContext` .. _tags: task_general ''' data_beam = [] header = ["File", "Date", "Shape", "Pixel scale", "Beam"] data_table = [] for file in ctx.files: img = ctx.open_file(file) beam = img.get_beam() date = img.get_epoch(str_format='%Y-%m-%d') k = ctx.get_projection(img).mean_pixel_scale() u = ctx.get_projection(img).get_unit() if isinstance(beam, imgutils.GaussianBeam): b = [k * beam.bmin, k * beam.bmaj, beam.bpa] # beam_str = "%.3f, %.3f, %.3f" % (b[0] * u, b[1] * u, b[2]) beam_str = "{0:.3f}, {1:.3f}, {2:.2f}".format(b[0] * u, b[1] * u, b[2]) data_beam.append([b[0], b[1], b[2]]) else: beam_str = str(beam) shape_str = "%sx%s" % img.data.shape data_table.append([os.path.basename(file), date, shape_str, "{0:.3f}".format(k * u), beam_str]) print nputils.format_table(data_table, header) print "Number of files: %s" % (len(ctx.files)) if len(data_beam) > 0: print "Mean beam: Bmin: %.3f, Bmaj: %.3f, Angle:%.2f" % tuple(np.mean(data_beam, axis=0))
def info_files_delta(ctx, delta_time_unit=u.day, angular_velocity_unit=u.mas / u.year, proper_velocity_unit=unit_c): '''Print List of selected pair of files with information on velocity resolution Parameters ---------- ctx : :class:`wise.project.AnalysisContext` delta_time_unit : :class:`astropy.units.Unit`, optional angular_velocity_unit : :class:`astropy.units.Unit`, optional proper_velocity_unit : :class:`astropy.units.Unit`, optional .. _tags: task_general ''' all_delta_time = [] all_velocity_c_px = [] all_velocity_px = [] data = [] header = ["Date 1", "Date 2", "Delta (%s)" % delta_time_unit, "Angular vel. res. (%s)" % angular_velocity_unit, "Proper vel. res. (%s)" % proper_velocity_unit] has_distance = ctx.config.data.object_distance or ctx.config.data.object_z for file1, file2 in nputils.pairwise(ctx.files): img1 = ctx.open_file(file1) img2 = ctx.open_file(file2) prj = ctx.get_projection(img1) date1 = img1.get_epoch(str_format='%Y-%m-%d') date2 = img2.get_epoch(str_format='%Y-%m-%d') if not isinstance(date1, datetime.date): print "Images have no date information" return delta_t = ((img2.get_epoch() - img1.get_epoch()).total_seconds() * u.second).to(delta_time_unit) all_delta_time.append(delta_t) velocity_px = prj.angular_velocity([0, 0], [0, 1], delta_t).to(angular_velocity_unit) all_velocity_px.append(velocity_px) if has_distance: velocity_c_px = prj.proper_velocity([0, 0], [0, 1], delta_t).to(proper_velocity_unit) all_velocity_c_px.append(velocity_c_px) if has_distance: data.append([date1, date2, delta_t.value, velocity_px.value, velocity_c_px.value]) else: data.append([date1, date2, delta_t.value, velocity_px.value, '-']) # print "{0} -> {1}: Delta time: {2}, Velocity resolution: {3:.3f}, {4:.3f}".format(*data) all_delta_time = nputils.quantities_to_array(all_delta_time) all_velocity_px = nputils.quantities_to_array(all_velocity_px) print nputils.format_table(data, header) print "Mean Delta time: %s +- %s" % (np.mean(all_delta_time), np.std(all_delta_time)) print "Mean Velocity resolution: %s +- %s" % (np.mean(all_velocity_px), np.std(all_velocity_px)) if has_distance: all_velocity_c_px = nputils.quantities_to_array(all_velocity_c_px) print "Mean Velocity resolution: %s +- %s" % (np.mean(all_velocity_c_px), np.std(all_velocity_c_px))
def list_tasks(): """Lists all WISE tasks """ data = [] header = ["Name", "Description"] for name, value in inspect.getmembers(sys.modules[__name__]): doc = inspect.getdoc(value) if inspect.isfunction(value) and doc is not None and not name.startswith('_'): data.append([name, doc.splitlines()[0]]) print nputils.format_table(data, header)