Esempio n. 1
0
    def setUp(self):
        # Create two data sets to play with
        x_0 = 2.0 * np.ones(25)
        dx_0 = 0.5 * np.ones(25)
        qx_0 = np.arange(25)
        qy_0 = np.arange(25)
        mask_0 = np.zeros(25)
        dqx_0 = np.arange(25) / 100
        dqy_0 = np.arange(25) / 100
        q_0 = np.sqrt(qx_0 * qx_0 + qy_0 * qy_0)
        self.data = Data2D(image=x_0,
                           err_image=dx_0,
                           qx_data=qx_0,
                           qy_data=qy_0,
                           q_data=q_0,
                           mask=mask_0,
                           dqx_data=dqx_0,
                           dqy_data=dqy_0)

        y = np.ones(25)
        dy = np.ones(25)
        qx = np.arange(25)
        qy = np.arange(25)
        mask = np.zeros(25)
        q = np.sqrt(qx * qx + qy * qy)
        self.data2 = Data2D(image=y,
                            err_image=dy,
                            qx_data=qx,
                            qy_data=qy,
                            q_data=q,
                            mask=mask)
Esempio n. 2
0
    def create_gui_data(self, data, path=None):
        """
        Receive data from loader and create a data to use for guiframe
        """

        if issubclass(Data2D, data.__class__):
            new_plot = Data2D(
                image=None, err_image=None
            )  # For now, isSesans for 2D data is always false
        else:
            new_plot = Data1D(x=[],
                              y=[],
                              dx=None,
                              dy=None,
                              lam=None,
                              dlam=None,
                              isSesans=data.isSesans)

        #elif data.meta_data['loader'] == 'SESANS':
        #    new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True)
        #else:
        #    new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check???

        new_plot.copy_from_datainfo(data)
        data.clone_without_data(clone=new_plot)
        #creating a name for data
        title = ""
        file_name = os.path.basename(
            path) if path is not None else data.filename
        if file_name:
            name = file_name
        elif data.run:
            name = data.run[0]
        else:
            name = "data"
        name = self.rename(name)
        #find title
        if data.title.strip():
            title = data.title
        if title.strip() == "":
            title = file_name

        if new_plot.filename.strip() == "":
            new_plot.filename = file_name

        new_plot.name = name
        new_plot.title = title
        ## allow to highlight data when plotted
        new_plot.interactive = True
        ## when 2 data have the same id override the 1 st plotted
        self.time_stamp += 1
        new_plot.id = str(name) + str(self.time_stamp)
        ##group_id specify on which panel to plot this data
        new_plot.group_id = str(name) + str(self.time_stamp)
        new_plot.is_data = True
        new_plot.path = path
        new_plot.list_group_id = []
        ##post data to plot
        # plot data
        return new_plot
Esempio n. 3
0
 def _on_add_mask(self, event):
     """
     Add new mask to old mask
     """
     if self.slicer is not None:
         data = Data2D()
         data = self.data
         self.slicer_mask = self.slicer.update()
         data.mask = self.data.mask & self.slicer_mask
         self._check_display_mask(data.mask, event)
Esempio n. 4
0
    def __init__(self,
                 parent=None,
                 base=None,
                 data=None,
                 dimension=1,
                 id=ID,
                 *args,
                 **kwds):
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        kwds["size"] = wx.Size(PANEL_SIZE * 1.5, PANEL_SIZE * 1.5)
        wx.Dialog.__init__(self, parent, id=id, *args, **kwds)

        if data is not None:
            # Font size
            kwds = []
            self.SetWindowVariant(variant=FONT_VARIANT)
            self.SetTitle("Plot " + data.name)
            self.parent = base
            self.data = data
            self.str = self.data.__str__()
            # # when 2 data have the same id override the 1 st plotted
            self.name = self.data.name
            self.dimension = dimension
            # Panel for 2D plot
            self.plotpanel = Maskplotpanel(self,
                                           -1,
                                           dimension,
                                           style=wx.TRANSPARENT_WINDOW)
            self.plotpanel._SetInitialSize()
            self.plotpanel.prevXtrans = "x"
            self.plotpanel.prevYtrans = "y"

            self.cmap = DEFAULT_CMAP
            # # Create Artist and bind it
            self.subplot = self.plotpanel.subplot
            self._setup_layout()
            if self.dimension == 1:
                self.newplot = Data1D(x=data.x,
                                      y=data.y,
                                      dx=data.dx,
                                      dy=data.dy)
                self.newplot.name = data.name
            else:
                self.newplot = Data2D(image=self.data.data)
                self.newplot.setValues(self.data)
                # Compute and get the image plot
            self.get_plot()
            # self.plotpanel.add_image(self.newplot)
            self.Centre()
            self.Layout()
Esempio n. 5
0
    def __init__(self,
                 parent=None,
                 base=None,
                 data=None,
                 id=-1,
                 *args,
                 **kwds):
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        kwds["size"] = wx.Size(_STATICBOX_WIDTH * 0.8, PANEL_SIZE)
        wx.Dialog.__init__(self, parent, id=id, *args, **kwds)

        if data is not None:
            # Font size
            kwds = []
            self.SetWindowVariant(variant=FONT_VARIANT)
            self.SetTitle("Mask Editor for " + data.name)
            self.parent = base
            self.data = data
            self.str = self.data.__str__()
            # # mask for 2D
            self.mask = data.mask
            self.default_mask = copy.deepcopy(data.mask)
            # # masked data from GUI
            self.slicer_mask = None
            self.slicer = None
            self.slicer_z = 5
            self.data.interactive = True
            # # when 2 data have the same id override the 1 st plotted
            self.name = self.data.name
            # Panel for 2D plot
            self.plotpanel = Maskplotpanel(self,
                                           -1,
                                           style=wx.TRANSPARENT_WINDOW)
            self.cmap = DEFAULT_CMAP
            # # Create Artist and bind it
            self.subplot = self.plotpanel.subplot
            self.connect = BindArtist(self.subplot.figure)
            self._setup_layout()
            self.newplot = Data2D(image=self.data.data)
            self.newplot.setValues(self.data)
            self.plotpanel.add_image(self.newplot)
            self._update_mask(self.mask)
            self.Centre()
            self.Layout()
            # bind evt_close to _draw in fitpage
            self.Bind(wx.EVT_CLOSE, self.OnClose)