예제 #1
0
 def gui(self, **kwargs ):
     if self._gui is None:
         self.init_data()
         bin_colors = self.get_bin_colors("gist_rainbow") # self.get_bin_colors("jet",True)
         ptcolors = [ [1.0, 1.0, 1.0, 1.0], ] + bin_colors + LabelsManager.instance().colors[::-1]
         ptsizes = [1]*(self._n_point_bins+1) + [8]*LabelsManager.instance().nLabels
         self._gui = view( point_sets = self.point_sets, point_set_sizes=ptsizes, point_set_colors=ptcolors, background=[0,0,0] )
         self._gui.layout = { 'width': 'auto', 'flex': '1 1 auto' }
     return self._gui
예제 #2
0
 def color_by_value( self, D: np.ndarray, base = 12.0 ):
     DM = ma.masked_invalid(D)
     v1 = DM.max()/5.0; v0 = 0.016*v1
     N_log_bins = self._n_point_bins-1
     print(f" binned_points: v1 = {v1}, v0 = {v0}, base = {base}, D.shape = {DM.shape}")
     dmin, dmax = math.log(v0,base), math.log(v1,base)
     lspace: np.ndarray = np.logspace( dmin, dmax, N_log_bins )
     print(f"     ---> dmin = {dmin}, dmax = {dmax}, lspace = {lspace}")
     self._binned_points[0] = self._embedding[DM <= lspace[0]]
     print( f" binned_points[0]: size = {self._binned_points[0].shape[0]}, bin = (< {lspace[0]})")
     for iC in range(0,N_log_bins-1):
         mask: np.ndarray =  ( DM > lspace[iC] ) & ( DM <= lspace[iC+1] )
         self._binned_points[iC+1] = self._embedding[ mask ]
         print( f" binned_points[{iC+1}]: size = {self._binned_points[iC].shape[0]}, bin = [{lspace[iC]},{lspace[iC+1]}]")
     self._binned_points[-1] = self._embedding[ DM >  lspace[-1] ]
     print(f" binned_points[{self._n_point_bins-1}]: size = {self._binned_points[-1].shape[0]}, bin = (> {lspace[-1]})")
     LabelsManager.instance().addAction( "color", "points" )
     self.update_plot()
예제 #3
0
 def __init__(self, **kwargs):
     super(PointCloudManager, self).__init__(**kwargs)
     self._gui: Viewer = None
     self._n_point_bins = 27
     self._embedding: np.ndarray = None
     self._marker_points: List[np.ndarray] = [ self.empty_pointset for ic in range( LabelsManager.instance().nLabels ) ]
     self._marker_pids: List[np.ndarray] = [ self.empty_pids for ic in range( LabelsManager.instance().nLabels ) ]
     self._binned_points: List[np.ndarray] = [self.empty_pointset for ic in range(self._n_point_bins)]
     self._points: np.ndarray = self.empty_pointset
예제 #4
0
 def _createTableTabs(self) -> ipw.Tab:
     wTab = ipw.Tab()
     self._tables.append(self._createTable(0))
     wTab.set_title(0, 'Catalog')
     for iC, ctitle in enumerate(LabelsManager.instance().labels[1:], 1):
         self._tables.append(self._createTable(iC))
         wTab.set_title(iC, ctitle)
     wTab.children = self._tables
     return wTab
예제 #5
0
 def undo_action(self):
     from astrolab.model.labels import Action
     action: Action = LabelsManager.instance().popAction()
     if action is not None:
         if action.type == "mark":
             self.clear_pids(action.cid, action.pids)
         elif action.type == "color":
             self.pcm.clear_bins()
     self.pcm.update_plot()
예제 #6
0
    def mark_points(self, pids: np.ndarray, cid: int = -1, update=False):
        from astrolab.gui.control import ActionsPanel
        from astrolab.model.labels import LabelsManager
        lmgr = LabelsManager.instance()
        icid: int = cid if cid > 0 else lmgr.current_cid
        self._marker_pids[icid] = np.unique( np.append( self._marker_pids[icid], pids ) )
        marked_points: np.ndarray = self._embedding[ self._marker_pids[icid], : ]
#        print( f"  ***** POINTS- mark_points[{icid}], #pids = {len(pids)}, #points = {marked_points.shape[0]}")
        self._marker_points[ 0 ] = self.empty_pointset
        self._marker_points[ icid ] = marked_points # np.concatenate(  [ self._marker_points[ icid ], marked_points ] )
        lmgr.addAction( "mark", "points", pids, icid )
        if update: self.update_plot()
        return lmgr.current_cid
예제 #7
0
    def mark_points(self, pids: np.ndarray, cid: int = -1, update=False):
        from astrolab.model.labels import LabelsManager
        print( f"PointCloudManager.mark_points: pids = {pids}, cid = {cid}")
        self.initialize_markers()
        lmgr = LabelsManager.instance()
        icid: int = cid if cid > 0 else lmgr.current_cid
        self.clear_pids( pids )
        self.clear_points(0)
        self._marker_pids[icid] = np.append( self._marker_pids[icid], pids )
        marked_points: np.ndarray = self._embedding[ self._marker_pids[icid], : ]
#        print( f"  ***** POINTS- mark_points[{icid}], #pids = {len(pids)}, #points = {marked_points.shape[0]}")
        self._marker_points[ icid ] = marked_points # np.concatenate(  [ self._marker_points[ icid ], marked_points ] )
        lmgr.addAction( "mark", "points", pids, icid )
        if update: self.update_plot()
        return lmgr.current_cid
예제 #8
0
 def _createGui(self, **kwargs) -> ipw.Box:
     from astrolab.model.labels import LabelsManager
     for task in ["embed", "mark", "spread", "distance", "undo", "clear"]:
         button = ipw.Button(description=task)
         button.layout = ipw.Layout(width='auto', flex="1 0 auto")
         button.on_click(partial(self.on_button_click, task))
         self._buttons[task] = button
     buttonBox = ipw.HBox(list(self._buttons.values()))
     buttonBox.layout = ipw.Layout(width="100%")
     classes: ipw.DOMWidget = LabelsManager.instance().gui()
     gui = ipw.VBox([buttonBox, classes],
                    layout=ipw.Layout(width="100%",
                                      flex='1 0 180px',
                                      border='2px solid firebrick'))
     return gui
예제 #9
0
 def initialize_markers(self):
     if self._marker_points is None:
         nLabels = LabelsManager.instance().nLabels
         self._marker_points: List[np.ndarray] = [ self.empty_pointset for ic in range( nLabels ) ]
         self._marker_pids: List[np.ndarray] = [ self.empty_pids for ic in range( nLabels ) ]