Exemplo n.º 1
0
def display_frame_coords(data, coords, window, vectors=None, ref=None, outlines=None,
                         **kws):
    
    from grafico.imagine import ImageDisplay #FITSCubeDisplay,
    from obstools.aps import ApertureCollection

    fig, ax = plt.subplots()
    imd = ImageDisplay(ax, data)
    imd.connect()

    aps = ApertureCollection(coords=coords[:,::-1], radii=7, 
                             ec='darkorange', lw=1, ls='--',
                             **kws)
    aps.axadd(ax)
    aps.annotate(color='orangered', size='small')
    
    if window:
        from matplotlib.patches import Rectangle
        from matplotlib.collections import PatchCollection
        
        llc = coords[:,::-1] - window/2
        patches = [Rectangle(coo-window/2, window, window) for coo in llc] 
        rcol = PatchCollection(patches, edgecolor='r', facecolor='none',
                               lw=1, linestyle=':')
        ax.add_collection(rcol)
        
    
    if outlines is not None:
        from matplotlib.colors import to_rgba
        overlay = np.empty(data.shape+(4,))
        overlay[...] = to_rgba('0.8', 0)
        overlay[...,-1][~outlines.mask] = 1
        ax.hold(True)
        ax.imshow(overlay)
    
    if vectors is not None:
        if ref is None:
            'cannot plot vectors without reference star'
        Y, X = coords[ref]
        V, U = vectors.T
        ax.quiver(X, Y, U, V, color='r', scale_units='xy', scale=1, alpha=0.6)

    return fig
Exemplo n.º 2
0
class ImageCubeDisplayA(ImageCubeDisplay):
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    aperture_properties = dict(ec='m', lw=1, animated=True, picker=False,
                               widths=7.5, heights=7.5)
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def __init__(self, ax, data, ap_data_dict={}, **kwargs):
        '''with Apertures
        ap_data_dict is dict keyed on aperture aperture_properties, values of which
        are either array-like sequence of values indeces corresponing to frame number, 
        or callables that generate values.
        '''
        CubeDisplayBase.__init__(self, ax, data, **kwargs)
        
        #create apertures if coordinates provided
        self.aps = None
        self.ap_data = ap_data_dict
        if self.ap_data:
            from obstools.aps import ApertureCollection
            #add apertures to axes.  will not display yet as coordinates not set
            props = ImageCubeDisplayA.aperture_properties
            self.aps = ApertureCollection(**props)
            
            self.aps.axadd(ax)
            
            #TODO: check data
            
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    def set_frame(self, i, draw=True):
        
        super().set_frame(i, False)
        needs_drawing = self._needs_drawing()
        
        if self.aps is not None:
            for attr, item in self.ap_data.items():
                if isinstance(item, Callable):
                    vals = item(i)
                else:
                    vals = item[i]
                    
                setattr(self.aps, attr, vals)
            needs_drawing.append(self.aps)
        
        self.draw_blit(needs_drawing)
Exemplo n.º 3
0
 def __init__(self, ax, data, ap_data_dict={}, **kwargs):
     '''with Apertures
     ap_data_dict is dict keyed on aperture aperture_properties, values of which
     are either array-like sequence of values indeces corresponing to frame number, 
     or callables that generate values.
     '''
     CubeDisplayBase.__init__(self, ax, data, **kwargs)
     
     #create apertures if coordinates provided
     self.aps = None
     self.ap_data = ap_data_dict
     if self.ap_data:
         from obstools.aps import ApertureCollection
         #add apertures to axes.  will not display yet as coordinates not set
         props = ImageCubeDisplayA.aperture_properties
         self.aps = ApertureCollection(**props)
         
         self.aps.axadd(ax)