예제 #1
0
파일: tasks.py 프로젝트: flomertens/wise
 def do_plot(fig, file):
     img = ctx.open_file(file)
     ax = fig.subplots()
     if align:
         ctx.align(img)
     if preprocess:
         ctx.pre_process(img)
     prj = ctx.get_projection(img)
     plotutils.imshow_image(ax, img, projection=prj, **kwargs)
     if not align:
         core_offset = ctx.get_core_offset()
         if core_offset is not None:
             x, y = core_offset.get(img.get_epoch())
             x, y = prj.s2p([x, y])
             # print core_offset, x, y
             ax.scatter(x, y, marker='*', s=40, c=plotutils.black)
     # if not preprocess:
     #     bg_mask = imgutils.Image(np.zeros_like(img.data, dtype=np.int8))
     #     bg = ctx.get_bg(bg_mask)
     #     if bg is not None and isinstance(bg, np.ndarray):
     #         bg.fill(1)
     if ctx.get_mask() is not None and show_mask is True:
         mask = ctx.get_mask()
         ctx.pre_process(mask)
         ax.contour(mask.data, [0.5])
     for region in show_regions:
         plotutils.plot_region(ax, region, prj, text=True)
예제 #2
0
파일: tasks.py 프로젝트: flomertens/wise
    def do_plot(fig):
        ax = fig.subplots()

        plotutils.imshow_image(ax, stack_img, projection=ctx.get_projection(stack_img), 
                               intensity_colorbar=intensity_colorbar, **kwargs)
        if ctx.get_mask() is not None and show_mask is True:
            ax.contour(ctx.get_mask().data, [0.5])
        for region in show_regions:
            plotutils.plot_region(ax, region, ctx.get_projection(stack_img), text=False, fill=True)
예제 #3
0
파일: tasks.py 프로젝트: flomertens/wise
    def do_plot(fig):
        ax_all = fig.subplots()

        plotutils.imshow_image(ax_all, ref_img, projection=projection, **img_kargs)

        if region_list is not None:
            for region, gdata in data.df.groupby('region'):
                features = wds.DatedFeaturesGroupScale(0, features=gdata.features.values)

                wiseutils.plot_features(ax_all, features, mode='com', c=region.get_color(), label=region.get_name())
                plotutils.plot_region(ax_all, region, projection=projection, text=False, 
                                      color=region.get_color(), fill=True)
        else:
            features = wds.DatedFeaturesGroupScale(0, features=data.df.features.values)
            wiseutils.plot_features(ax_all, features, mode='com')

        if legend:
            ax_all.legend(loc='best')
예제 #4
0
파일: tasks.py 프로젝트: flomertens/wise
def preview_detection_stack(ctx, stack_detection_name, count_threshold=0, ms_set=None, 
                            date_filter=None, show_regions=[]):
    ''' Plot detection in stack'''
    stack = plotutils.FigureStack()

    stack_img, img_snr, img_count = load_detection_stack_image(ctx, stack_detection_name, preprocess=True)

    img_snr.data[img_count.data < count_threshold] = 0
    img_count.data[img_count.data < count_threshold] = 0

    prj = ctx.get_projection(stack_img)

    fig, ax = stack.add_subplots("Stack image")
    plotutils.imshow_image(ax, stack_img, projection=prj)
    for region in show_regions:
        plotutils.plot_region(ax, region, prj, text=True)

    fig, ax1 = stack.add_subplots("Stack detection SNR")
    plotutils.imshow_image(ax1, img_snr, projection=prj, cmap=plotutils.get_cmap('jet'))
    for region in show_regions:
        plotutils.plot_region(ax1, region, prj, text=True)

    fig, ax2 = stack.add_subplots("Stack detection count")
    plotutils.imshow_image(ax2, img_count, projection=prj, cmap=plotutils.get_cmap('jet'))
    for region in show_regions:
        plotutils.plot_region(ax2, region, prj, text=True)

    if ms_set is not None:
        colorbar_setting = plotutils.ColorbarSetting(cmap='jet', ticks_locator=mdates.AutoDateLocator(),
                                                     ticks_formatter=mdates.DateFormatter('%m/%y'))

        def feature_filter(feature):
            if img_snr.data[tuple(feature.get_coord())] == 0:
                return False
            if date_filter is not None and not date_filter(feature.get_epoch()):
                return False
            return True

        ms_set = wds.MultiScaleImageSet.from_file(os.path.join(ctx.get_data_dir(), j),
                                                  feature_filter=feature_filter)
        plot_ms_set_map(ax1, None, ms_set, prj, colorbar_setting=colorbar_setting)
        plot_ms_set_map(ax2, None, ms_set, prj, colorbar_setting=colorbar_setting)

        add_features_tooltip(stack, ax1, ms_set.features_iter(), projection=prj, epoch=True, tol=1)
        add_features_tooltip(stack, ax2, ms_set.features_iter(), projection=prj, epoch=True, tol=1)

    stack.show()