Exemplo n.º 1
0
    def onSave(self, event):
        if len(self.data) == 0:
            wx.MessageBox("Nothing to save yet!", "Save Last Scan", style=wx.OK)
            return

        dlg = wx.FileDialog(None, "Save Last Scan", os.getcwd(), "", "*.*", wx.SAVE)

        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetPath()

            # set new working directory
            directory = os.path.split(filename)
            if not os.path.isdir(filename):
                os.chdir(directory[0])

            # save averaged data
            cutils.saveFSRS(filename, self.data)

            # save intermediate steps
            if len(self.intdata) > 1:
                tmp = filename.split(".")
                if len(tmp) > 1:
                    basename = tmp[:-1].join()
                    ext = "." + tmp[-1]
                else:
                    basename = filename
                    ext = ""
                for i in range(len(self.intdata)):
                    cutils.saveFSRS("%s_%d%s" % (basename, i, ext), self.intdata[i])

        dlg.Destroy()
Exemplo n.º 2
0
    def onUpdate(self, val, grexc, step, set):

        # prepare data
        A, B, C = val
        mode = self.getPropertyByLabel("mode").getValue()
        if mode == 0:
            A = -np.log(A)
        elif mode == 1:
            A = -np.log10(A)

        # save data
        filename = cutils.formatFSRSFilename(mode, self.basename, step, set, grexc)
        cutils.saveFSRS(filename, [A, B, C])

        # update progress bar
        self.getPropertyByLabel("progress").setValue(next(self.progress_iterator))
        self.getPropertyByLabel("status").setValue("position %.0ffs, set %d/%d" % (step, set, self.Nsets))

        # plot in window
        if isinstance(self.plotWnd, wx.Frame):
            if self.plotInit:
                self.plotWnd.upperPlotCanvas.setLine(0, np.arange(len(A)), A)
                self.plotWnd.lowerPlotCanvas.setLine(0, np.arange(len(A)), B)
                self.plotWnd.lowerPlotCanvas.setLine(1, np.arange(len(A)), C)
            else:
                self.plotInit = True
                self.plotWnd.upperPlotCanvas.addLine(np.arange(len(A)), A)
                self.plotWnd.lowerPlotCanvas.addLine(np.arange(len(A)), B)
                self.plotWnd.lowerPlotCanvas.addLine(np.arange(len(A)), C)
        else:
            # user closed the plotWindow -> stop thread
            self.onStart()
Exemplo n.º 3
0
    def onStart(self, event=None):
        if self.running:
            module.Experiment.stop(self)

        else:
            if self.plotWnd is not None:
                self.plotWnd.Destroy()
            self.plotInit = False
            self.plotID = 0

            self.plotWnd = FSRSplot.PlotFrame(None, title=time.strftime("XC Scan"), size=(640, 640))
            self.plotWnd.plotCanvas.tightx = True
            self.plotWnd.plotCanvas.tighty = True
            self.plotWnd.Show()

            self.data = []
            self.points = []
            self.bg = []

            s_type = self.getPropertyByLabel("type").getValue()
            s_ccd = self.cameras[self.getPropertyByLabel("camera").getValue()]
            s_axis = self.axes[self.getPropertyByLabel("axis").getValue()]
            s_shutter = self.shutters[self.getPropertyByLabel("shutter").getValue()]
            s_frames = int(self.getPropertyByLabel("frames").getValue())

            self.points = cutils.prepareScanPoints(self)

            self.s_points_iterator = itertools.cycle(self.points)
            self.progress_iterator = itertools.cycle(np.arange(len(self.points) * 1 + 1) * 100 / (len(self.points) * 1))
            self.getPropertyByLabel("progress").setValue(next(self.progress_iterator))

            self.running = True

            module.Experiment.start(self, ScanThread, type=s_type, ccd=s_ccd, axis=s_axis, shutter=s_shutter, frames=s_frames, points=self.points, sets=1)
Exemplo n.º 4
0
    def onSave(self, event):
        if len(self.data) == 0:
            wx.MessageBox("Nothing to save yet!", "Save Last Scan", style=wx.OK)
            return

        dlg = wx.FileDialog(None, "Save Last Scan", os.getcwd(), "", "*.*", wx.SAVE)

        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetPath()

            # set new working directory
            directory = os.path.split(filename)
            if not os.path.isdir(filename):
                os.chdir(directory[0])

            cutils.saveFSRS(filename, self.data)

        dlg.Destroy()
Exemplo n.º 5
0
    def onStart(self, event=None):
        if self.running:
            module.Experiment.stop(self)
        else:
            if self.plotWnd is not None:
                self.plotWnd.Destroy()
            self.plotInit = False

            self.plotWnd = FSRSplot.DualPlotFrame(None, title=time.strftime("FSRS Scan"), size=(800, 600))
            self.plotWnd.upperPlotCanvas.tightx = True
            self.plotWnd.lowerPlotCanvas.tightx = True
            self.plotWnd.lowerPlotCanvas.setXLabel("Wavenumber (px)")
            self.plotWnd.lowerPlotCanvas.setYLabel("Counts")

            s_type = self.getPropertyByLabel("type").getValue()
            if s_type == 0:
                self.plotWnd.upperPlotCanvas.setYLabel("Gain")
            elif s_type == 1:
                self.plotWnd.upperPlotCanvas.setYLabel("OD")
            else:
                self.plotWnd.upperPlotCanvas.setYLabel("dT / T0")

            self.plotWnd.Show()

            s_ccd = self.cameras[self.getPropertyByLabel("camera").getValue()]
            s_axis = self.axes[self.getPropertyByLabel("axis").getValue()]
            s_shutter = self.shutters[self.getPropertyByLabel("shutter").getValue()]
            s_frames = int(self.getPropertyByLabel("frames").getValue())
            s_ref = self.inputs[self.getPropertyByLabel("take ref.").getValue() - 1] if self.getPropertyByLabel("take ref.").getValue() >= 1 else None

            s_points = cutils.prepareScanPoints(self)
            self.Nsteps = len(s_points) + 1
            s_sets = int(self.getPropertyByLabel("sets").getValue())
            self.Nsets = s_sets

            self.s_points_iterator = itertools.cycle(s_points)
            self.progress_iterator = itertools.cycle(np.linspace(0, 100, len(s_points) * s_sets).astype(int))
            self.getPropertyByLabel("progress").setValue(0)

            self.basename = os.path.join(self.getPropertyByLabel("path").getValue(), self.getPropertyByLabel("basename").getValue())

            # save a timepoints file
            np.savetxt(self.basename + "_timepoints.txt", np.sort(s_points))

            module.Experiment.start(self, ScanThread, type=s_type, ccd=s_ccd, axis=s_axis, shutter=s_shutter, frames=s_frames, points=s_points, sets=s_sets, reference=s_ref)
Exemplo n.º 6
0
    def __init__(self):
        module.Experiment.__init__(self)

        self.name = "FSRS Scan"

        # stores the camera module
        self.cameras = []
        self.axes = []
        self.shutters = []
        self.inputs = []

        # stores the plotting window stuff
        self.plotWnd = None
        self.plotInit = False

        # when creating the properties, you should create a start/stop button with the label "Start"
        prop = []
        prop.append({"label": "Camera", "type": "choice", "choices": [], "value": 0})
        prop.append({"label": "Type", "type": "choice", "choices": ["FSRS", "TA", "T/T0"], "value": 0})
        prop.append({"label": "# of Frames", "type": "spin", "value": 8000, "info": (2, 20000)})

        prop.append({"label": "Axis", "type": "choice", "choices": [], "value": 0})
        prop = cutils.appendStageParameters(prop)

        prop.append({"label": "Shutter", "type": "choice", "choices": [], "value": 0})
        prop.append({"label": "Take Ref.", "type": "choice", "choices": [], "value": 0})

        prop.append({"label": "# of Sets", "type": "spin", "value": 1, "info": (1, 1000)})
        prop.append({"label": "Basename", "type": "input", "value": ""})
        prop.append({"label": "Output Path", "type": "file", "value": os.getcwd(), "info": "path"})
        prop.append({"label": "Progress", "type": "progress", "value": 0})
        prop.append({"label": "Status", "type": "label", "value": ""})
        prop.append({"label": "Start", "type": "button", "value": "Scan", "event": "onStart"})

        # convert dictionary to properties object
        self.parsePropertiesDict(prop)

        self.data = np.array([])
        self.Nsteps = 0
        self.Nsets = 0
Exemplo n.º 7
0
    def __init__(self):
        module.Experiment.__init__(self)

        self.name = "DAQ Scan"

        self.daqs = []

        self.plotWnd = None
        self.plotID = -1

        self.data = []
        self.points = []

        # when creating the properties, you should create a start/stop button with the label "Start"
        prop = []
        prop.append({"label": "DAQ", "type": "choice", "choices": [], "value": 0})
        prop.append({"label": "Axis", "type": "choice", "choices": [], "value": 0})
        prop = cutils.appendStageParameters(prop)
        prop.append({"label": "Save Scan", "type": "button", "value": "Save", "event": "onSave"})
        prop.append({"label": "Progress", "type": "progress", "value": 0})
        prop.append({"label": "Start", "type": "button", "value": "Scan", "event": "onStart"})
        self.parsePropertiesDict(prop)
Exemplo n.º 8
0
    def onStart(self, event=None):
        if self.running:
            module.Experiment.stop(self)
        else:
            self.data = []
            self.points = []

            if self.plotWnd is not None:
                self.plotWnd.Destroy()
            self.plotID = -1

            self.plotWnd = FSRSplot.PlotFrame(None, title="DAQScan", size=(640, 480))
            self.plotWnd.Show()

            s_axis = self.axes[self.getPropertyByLabel("axis").getValue()]
            s_daq = self.daqs[self.getPropertyByLabel("daq").getValue()]
            self.points = cutils.prepareScanPoints(self)

            self.progress_iterator = itertools.cycle(np.arange(len(self.points) + 1) * 100 / (len(self.points)))
            self.getPropertyByLabel("progress").setValue(next(self.progress_iterator))

            module.Experiment.start(self, DAQScanThread, daq=s_daq, axis=s_axis, points=self.points)
Exemplo n.º 9
0
    def __init__(self):
        module.Experiment.__init__(self)

        self.name = "XC Scan"

        # stores the camera module
        self.cameras = []
        self.axes = []
        self.shutters = []

        # stores the 2d data, each column is a new timepoint
        self.data = []
        self.points = []
        self.bg = []

        # stores the plotting window stuff
        self.plotWnd = None
        self.plotInit = False
        self.plotID = 0
        self.running = False

        # when creating the properties, you should create a start/stop button with the label "Start"
        prop = []
        prop.append({"label": "Camera", "type": "choice", "choices": [], "value": 0})
        prop.append({"label": "Type", "type": "choice", "choices": ["FSRS", "TA", "T/T0", "Kerr"], "value": 3})
        prop.append({"label": "# of Frames", "type": "spin", "value": 100, "info": (2, 20000)})

        prop.append({"label": "Axis", "type": "choice", "choices": [], "value": 0})
        prop = cutils.appendStageParameters(prop, -300, 300, 20)
        prop.append({"label": "Shutter", "type": "choice", "choices": [], "value": 0})

        prop.append({"label": "Save Last", "type": "button", "value": "Save", "event": "onSave"})

        prop.append({"label": "Progress", "type": "progress", "value": 0})
        prop.append({"label": "Start", "type": "button", "value": "Scan", "event": "onStart"})
        prop.append({"label": "Fit", "type": "button", "value": "Fit", "event": "onFit"})
        self.parsePropertiesDict(prop)
        self.data = np.array([])
Exemplo n.º 10
0
 def onAxisRangeChange(self, event):
     cutils.onAxisRangeChange(self, event)