Update for plotting function.

This commit is contained in:
gao 2022-08-09 15:37:34 +02:00
parent cb1c9637d2
commit 8760e48105
11 changed files with 580 additions and 142 deletions

96
.idea/workspace.xml generated
View File

@ -1,36 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Debug for calculating atom number.&#10;&#10;Add background subtraction function.&#10;&#10;Correct the pixel size of the camera"> <list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Update for plotting function.">
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/DataExtractorLyse.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetAnalysePanel.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/MainPlotPanel.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/PlottingData.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/PlottingPanel.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/Quick1DPlot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/Unknown.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetDataSelector.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetFakeColorPlot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetPlot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetQuick2DPlot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetQuickPlotGenerator.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetQuickWaterFlowPlot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/__init__.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/test_living_plot.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/__init__.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/AbsorptionImaging.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/lib/dylab/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/build/lib/dylab/AbsorptionImaging.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/Plotting/DataExtractorLyse.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/DataExtractorLyse.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/lib/dylab/DyTransition.py" beforeDir="false" afterPath="$PROJECT_DIR$/build/lib/dylab/DyTransition.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/Plotting/MainPlotPanel.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/MainPlotPanel.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/lib/dylab/Fitting.py" beforeDir="false" afterPath="$PROJECT_DIR$/build/lib/dylab/Fitting.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetDataSelector.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetDataSelector.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/AbsorptionImaging.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetFakeColorPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetFakeColorPlot.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/Camera.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Camera.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetPlot.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/DyTransition.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/DyTransition.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/Fitting.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Fitting.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/FittingFunction.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/FittingFunction.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/TransitionClass.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/TransitionClass.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dylab/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/setup.py" beforeDir="false" afterPath="$PROJECT_DIR$/setup.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test_absorption_imaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_absorption_imaging.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/test_absorption_imaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_absorption_imaging.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test_fitting.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_fitting.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/test_living_plot.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_living_plot.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -47,6 +29,14 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="ProjectId" id="2CCrwoItH5rBCZFtzaw6hxgrIjy" /> <component name="ProjectId" id="2CCrwoItH5rBCZFtzaw6hxgrIjy" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
@ -64,8 +54,8 @@
<recent name="D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\HelperClasses\Plotting" /> <recent name="D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\HelperClasses\Plotting" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.test_living_plot"> <component name="RunManager" selected="Python.test (1)">
<configuration name="Plotting" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="Plotting1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="dylab" /> <module name="dylab" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
@ -78,7 +68,29 @@
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/HelperClasses/Plotting.py" /> <option name="SCRIPT_NAME" value="D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\HelperClasses\Plotting1.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="test (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="dylab" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" /> <option name="EMULATE_TERMINAL" value="false" />
@ -155,9 +167,10 @@
</configuration> </configuration>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.test (1)" />
<item itemvalue="Python.test_living_plot" /> <item itemvalue="Python.test_living_plot" />
<item itemvalue="Python.test" /> <item itemvalue="Python.test" />
<item itemvalue="Python.Plotting" /> <item itemvalue="Python.Plotting1" />
<item itemvalue="Python.test_fitting" /> <item itemvalue="Python.test_fitting" />
</list> </list>
</recent_temporary> </recent_temporary>
@ -177,7 +190,7 @@
<workItem from="1658844297242" duration="39201000" /> <workItem from="1658844297242" duration="39201000" />
<workItem from="1659027245256" duration="8511000" /> <workItem from="1659027245256" duration="8511000" />
<workItem from="1659078820495" duration="69000" /> <workItem from="1659078820495" duration="69000" />
<workItem from="1659078901335" duration="36607000" /> <workItem from="1659078901335" duration="89130000" />
</task> </task>
<task id="LOCAL-00001" summary="First working version. Need introductions"> <task id="LOCAL-00001" summary="First working version. Need introductions">
<created>1658494877565</created> <created>1658494877565</created>
@ -200,7 +213,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1658822265357</updated> <updated>1658822265357</updated>
</task> </task>
<option name="localTasksCounter" value="4" /> <task id="LOCAL-00004" summary="Update for plotting function.">
<created>1659210654086</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1659210654086</updated>
</task>
<option name="localTasksCounter" value="5" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -222,7 +242,8 @@
<MESSAGE value="First working version. Need introductions" /> <MESSAGE value="First working version. Need introductions" />
<MESSAGE value="Debug for calculating atom number.&#10;&#10;Add selecting the effective area function in AbsorptionImaging.py.&#10;&#10;Optimaze plotting function." /> <MESSAGE value="Debug for calculating atom number.&#10;&#10;Add selecting the effective area function in AbsorptionImaging.py.&#10;&#10;Optimaze plotting function." />
<MESSAGE value="Debug for calculating atom number.&#10;&#10;Add background subtraction function.&#10;&#10;Correct the pixel size of the camera" /> <MESSAGE value="Debug for calculating atom number.&#10;&#10;Add background subtraction function.&#10;&#10;Correct the pixel size of the camera" />
<option name="LAST_COMMIT_MESSAGE" value="Debug for calculating atom number.&#10;&#10;Add background subtraction function.&#10;&#10;Correct the pixel size of the camera" /> <MESSAGE value="Update for plotting function." />
<option name="LAST_COMMIT_MESSAGE" value="Update for plotting function." />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
@ -247,6 +268,10 @@
<line>7</line> <line>7</line>
<option name="timeStamp" value="57" /> <option name="timeStamp" value="57" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/HelperClasses/Plotting1.py</url>
<option name="timeStamp" value="61" />
</line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
<breakpoint type="python-exception"> <breakpoint type="python-exception">
@ -259,6 +284,7 @@
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/dylab$test_living_plot.coverage" NAME="test_living_plot Coverage Results" MODIFIED="1659127460208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/dylab$test_living_plot.coverage" NAME="test_living_plot Coverage Results" MODIFIED="1659127460208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/dylab$test__1_.coverage" NAME="test (1) Coverage Results" MODIFIED="1659948939920" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/dylab$Plotting.coverage" NAME="Plotting Coverage Results" MODIFIED="1659081506380" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/HelperClasses" /> <SUITE FILE_PATH="coverage/dylab$Plotting.coverage" NAME="Plotting Coverage Results" MODIFIED="1659081506380" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/HelperClasses" />
<SUITE FILE_PATH="coverage/dylab$test_fitting.coverage" NAME="test_fitting Coverage Results" MODIFIED="1658416885056" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" /> <SUITE FILE_PATH="coverage/dylab$test_fitting.coverage" NAME="test_fitting Coverage Results" MODIFIED="1658416885056" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/dylab$test.coverage" NAME="test Coverage Results" MODIFIED="1659126746245" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/HelperClasses" /> <SUITE FILE_PATH="coverage/dylab$test.coverage" NAME="test Coverage Results" MODIFIED="1659126746245" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/HelperClasses" />

View File

@ -40,7 +40,8 @@ class absorption_imaging:
# Ideally, we should be able to access all the data by function data(path). # Ideally, we should be able to access all the data by function data(path).
# However it is still under development. Now we can not read a picture by using function data(path). # However it is still under development. Now we can not read a picture by using function data(path).
# We have to change to use function Run(path), which creat a class with the saved hdf5 file. # We have to change to use function Run(path), which creat a class with the saved hdf5 file.
self.data_handle = Run(data_path) if data_path is not None:
self.data_handle = Run(data_path)
# Path of the saving images # Path of the saving images
self.camera_orientation = camera_orientation self.camera_orientation = camera_orientation
@ -130,8 +131,8 @@ class absorption_imaging:
self.x_start = left_up_conner[0] self.x_start = left_up_conner[0]
self.x_end = right_down_conner[0] self.x_end = right_down_conner[0]
self.y_start = left_up_conner[1] self.y_end = left_up_conner[1]
self.y_end = right_down_conner[1] self.y_start = right_down_conner[1]
self.image_absorption_cut = self.image_absorption[self.y_start:self.y_end, self.x_start:self.x_end] self.image_absorption_cut = self.image_absorption[self.y_start:self.y_end, self.x_start:self.x_end]

View File

@ -92,14 +92,26 @@ class DataExtractor:
elif self.data_type == 'single': elif self.data_type == 'single':
try: try:
if len(self.data_path) == 1:
result = data_handle.get_globals(self.data_path[0], h5_file=h5_file)
else:
result = data_handle.get_result(self.data_path[0], self.data_path[1], result = data_handle.get_result(self.data_path[0], self.data_path[1],
h5_file=h5_file) h5_file=h5_file)
except: except:
result = None result = None
elif self.data_type == 'global':
try:
result = data_handle.get_globals(self.data_path[0], h5_file=h5_file)
result = result[self.data_path[1]]
except:
result = None
elif self.data_type == 'image':
try:
result = data_handle.get_image(self.data_path[0], self.data_path[1],
self.data_path[2], h5_file=h5_file)
result = np.array(result)
except:
result = None
return result return result
def update_local_data(self, h5_path, h5_file=None): def update_local_data(self, h5_path, h5_file=None):

View File

@ -6,7 +6,8 @@ from pyqtgraph.dockarea import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
from PyQt5.QtCore import * from PyQt5.QtCore import *
import lyse import lyse
from .WidgetDataSelector import ShotSelector from .WidgetDataSelector import WidgetDataSelector
from .WidgetAnalysePanel import WidgetAnalysePanel
class MainPlotPanel(QtGui.QMainWindow): class MainPlotPanel(QtGui.QMainWindow):
@ -25,19 +26,25 @@ class MainPlotPanel(QtGui.QMainWindow):
self.area = DockArea() self.area = DockArea()
self.setCentralWidget(self.area) self.setCentralWidget(self.area)
self.resize(1000, 500) self.resize(900, 500)
self.dshotselector = Dock("Shot selector") self.dshotselector = Dock("Shot selector")
self.shotselector = ShotSelector() self.shotselector = WidgetDataSelector()
self.dshotselector.setFixedSize(400, 150)
self.dshotselector.addWidget(self.shotselector) self.dshotselector.addWidget(self.shotselector)
self.area.addDock(self.dshotselector, 'bottom') self.area.addDock(self.dshotselector, 'left')
# self.qpg_dock = Dock("Quick Plot Generator") # self.qpg_dock = Dock("Quick Plot Generator")
# self.qpg_dock.addWidget(QuickPlotGenerator(self)) # self.qpg_dock.addWidget(QuickPlotGenerator(self))
# self.qpg_dock.setMinimumSize(self.qpg_dock.minimumSizeHint()) # self.qpg_dock.setMinimumSize(self.qpg_dock.minimumSizeHint())
# self.area.addDock(self.qpg_dock) # self.area.addDock(self.qpg_dock)
self.danalyse_panel = Dock("Analyse and Fitting")
self.analyse_panel = WidgetAnalysePanel()
self.danalyse_panel.addWidget(self.analyse_panel)
self.area.addDock(self.danalyse_panel, 'bottom')
self.show() self.show()
self.plots = {} self.plots = {}
@ -47,7 +54,7 @@ class MainPlotPanel(QtGui.QMainWindow):
self.df = lyse.data() self.df = lyse.data()
def add_plot_dock(self, plot_name, plot_widget, **kwargs): def add_plot_dock(self, plot_name, plot_widget, overlap=True, **kwargs):
if plot_name not in self.plots: if plot_name not in self.plots:
plot_widget.plot_name = plot_name plot_widget.plot_name = plot_name
@ -55,7 +62,9 @@ class MainPlotPanel(QtGui.QMainWindow):
dock.sigClosed.connect(self.remove_plot) dock.sigClosed.connect(self.remove_plot)
dock.addWidget(plot_widget) dock.addWidget(plot_widget)
if len(self.plots): if overlap and len(self.plots):
self.area.addDock(dock, 'above', relativeTo=self.area.docks[list(self.plots.keys())[-1]])
elif len(self.plots):
if len(self.plots) % self.n_rows == 2: if len(self.plots) % self.n_rows == 2:
position = 'right' position = 'right'
self.area.addDock(dock, position) self.area.addDock(dock, position)

View File

@ -0,0 +1,86 @@
import pyqtgraph as pg
from pyqtgraph import Qt
from pyqtgraph.Qt import QtCore, QtGui
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from .DataExtractorLyse import DataExtractorManager
class WidgetAnalysePanel(QSplitter):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.setOrientation(Qt.Vertical)
# Add title
self.title = QtGui.QLabel()
self.title.setAlignment(QtCore.Qt.AlignCenter)
self.title.setText('<h2>' + 'Analyse and Fitting' + ' <\h2>')
self.title.setFixedHeight(30)
self.addWidget(self.title)
self.bottom = QSplitter()
self.addWidget(self.bottom)
self.absorption_image = None
self.absorption_image_plot = None
self.absorption_image_atom_number = None
def update_absorption_imaging_atom_number(self):
x, y = self.absorption_image_plot.roi.pos()
x_span, y_span = self.absorption_image_plot.roi.size()
x = int(x)
y = int(y)
x_span = int(x_span)
y_span = int(y_span)
left_up_conner = (x, y + y_span)
right_down_conner = (x + x_span, y)
self.absorption_image.image_absorption = self.absorption_image_plot.data_image
self.absorption_image.select_effective_data(left_up_conner, right_down_conner)
self.absorption_image.get_atom_number(force_to_run=True)
self.absorption_image_atom_number.setText(str(self.absorption_image.atom_number))
def add_absorption_imaging(self, absorption_image, widget_fake_color_plot):
self.absorption_image = absorption_image
self.absorption_image_plot = widget_fake_color_plot
self.absorption_image.image_absorption = self.absorption_image_plot.data_image
self.absorption_image_plot.roi.sigRegionChanged.connect(self.update_absorption_imaging_atom_number)
self.absorption_image_plot.analyse_panel_update = self.update_absorption_imaging_atom_number
current_box = QSplitter()
current_box.setOrientation(Qt.Vertical)
title = QLabel('Absorption Imaging')
title.setAlignment(Qt.AlignCenter)
title.setFixedHeight(30)
current_box.addWidget(title)
atom_number_box = QSplitter()
atom_number_box.setOrientation(Qt.Horizontal)
atom_number_title = QLabel(' Atom Number: ')
atom_number_title.setAlignment(Qt.AlignCenter)
self.absorption_image_atom_number = QLineEdit()
self.absorption_image_atom_number.setText(str(absorption_image.atom_number))
self.absorption_image_atom_number.setReadOnly(True)
atom_number_title.setFixedHeight(30)
self.absorption_image_atom_number.setFixedHeight(30)
atom_number_box.addWidget(atom_number_title)
atom_number_box.addWidget(self.absorption_image_atom_number)
current_box.addWidget(atom_number_box)
next_box = QSplitter()
next_box.addWidget(current_box)
self.bottom.addWidget(next_box)
self.bottom = next_box

View File

@ -9,7 +9,7 @@ from sortedcontainers import SortedSet
# ShotSelector class for choosing which the hdf5 files are import for plotting # ShotSelector class for choosing which the hdf5 files are import for plotting
class ShotSelector(pg.LayoutWidget): class WidgetDataSelector(pg.LayoutWidget):
valueChanged = pyqtSignal() valueChanged = pyqtSignal()
selectionChanged = pyqtSignal() selectionChanged = pyqtSignal()

View File

@ -1,16 +1,19 @@
import pyqtgraph as pg
from pyqtgraph import Qt
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np import numpy as np
from PyQt5 import QtGui
from pyqtgraph.dockarea import * from PyQt5.QtGui import QDoubleValidator
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from .DataExtractorLyse import DataExtractorManager from .DataExtractorLyse import DataExtractorManager
# import DataExtractorLyse from .WidgetPlot import WidgetPlot
from .WidgetPlot import DataPlot
# import WidgetPlot import pyqtgraph as pg
from pyqtgraph import OrderedDict
from PyQt5.QtWidgets import QLabel, QLineEdit
from pyqtgraph import Qt
from pyqtgraph.Qt import QtCore
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtCore import QRegExp
from PIL import ImageColor from PIL import ImageColor
@ -27,44 +30,135 @@ color_palette_html = ['#1f77b4',
color_palette = [ImageColor.getcolor(color, "RGB") for color in color_palette_html] color_palette = [ImageColor.getcolor(color, "RGB") for color in color_palette_html]
Gradients = OrderedDict([
('bw', {'ticks': [(0.0, (0, 0, 0, 255)), (1, (255, 255, 255, 255))], 'mode': 'rgb'}),
('hot', {'ticks': [(0.3333, (185, 0, 0, 255)), (0.6666, (255, 220, 0,
255)), (1, (255, 255, 255, 255)), (0, (0, 0, 0, 255))],
'mode': 'rgb'}),
('jet0', {'ticks': [(1, (166, 0, 0, 255)),
(0.32247191011235954, (0, 255, 255, 255)),
(0.11348314606741573, (0, 68, 255, 255)),
(0.6797752808988764, (255, 255, 0, 255)),
(0.902247191011236, (255, 0, 0, 255)),
(0.5022471910112359, (0, 255, 0, 255)),
(0.0, (0, 0, 166, 255))],
'mode': 'rgb'}),
('jet', {'ticks': [(1, (128, 0, 0, 255)),
(0.878431372549020, (255, 0, 0, 255)),
(0.627450980392157, (255, 255, 0, 255)),
(0.376470588235294, (0, 255, 255, 255)),
(0.125490196078431, (0, 0, 255, 255)),
(0.0, (0, 0, 131, 255))],
'mode': 'rgb'}),
('summer', {'ticks': [(1, (255, 255, 0, 255)), (0.0, (0, 170, 127, 255))], 'mode': 'rgb'}),
('space', {'ticks': [(0.562, (75, 215, 227, 255)), (0.087, (255, 170, 0, 254)), (0.332, (0, 255, 0, 255)),
(0.77, (85, 0, 255, 255)), (0.0, (255, 0, 0, 255)), (1.0, (255, 0, 127, 255))],
'mode': 'rgb'}),
('winter', {'ticks': [(1, (0, 255, 127, 255)), (0.0, (0, 0, 255, 255))], 'mode': 'rgb'})
])
class FakeColorPlot(DataPlot):
def __init__(self, title, data_path=None, **kwargs): class WidgetFakeColorPlot(WidgetPlot):
def __init__(self, title, data_path=None, data_group=None, Isocurve=False, Roi=True, HistogramLUT=False, colorbarText=True, **kwargs):
super().__init__(title, **kwargs) super().__init__(title, **kwargs)
self.colorbarText = colorbarText
self.analyse_panel_update = None
# set data extractor # set data extractor
self.data_extractor_manager = DataExtractorManager(data_path) if data_group is None or data_group == 'results':
self.data_extractor_manager.add_data_extractor('data_img', 'array', data_path) self.data_extractor_manager = DataExtractorManager(data_path)
self.data_extractor_manager.add_data_extractor('x', 'array', (data_path[0], 'x')) self.data_extractor_manager.add_data_extractor('data_img', 'array', data_path)
self.data_extractor_manager.add_data_extractor('y', 'array', (data_path[0], 'y')) self.data_extractor_manager.add_data_extractor('x', 'array', (data_path[0], 'x'))
self.data_extractor_manager.add_data_extractor('warning', 'single', (data_path[0], 'warning')) self.data_extractor_manager.add_data_extractor('y', 'array', (data_path[0], 'y'))
self.data_extractor_manager.add_data_extractor('warning', 'single', (data_path[0], 'warning'))
else:
self.data_extractor_manager = DataExtractorManager(data_path)
self.data_extractor_manager.add_data_extractor('data_img', 'image', (data_group, data_path[0], data_path[1]))
self.data_image = None
self.setMinimumHeight(550) self.setMinimumHeight(550)
self.setMinimumWidth(550) self.setMinimumWidth(550)
if Roi is True:
# Add y-axis data slider
self.axsumy = self.plots.addPlot(title="")
self.axsumy.setFixedWidth(300)
self.sumy = self.axsumy.plot()
self.sumy_data = self.axsumy.plot(pen=pg.mkPen(style=QtCore.Qt.DashLine, color=color_palette[1]))
# Add imaging # Add imaging
self.img = pg.ImageItem()
self.aximg = self.plots.addPlot(title="") self.aximg = self.plots.addPlot(title="")
self.img = pg.ImageItem()
self.aximg.addItem(self.img) self.aximg.addItem(self.img)
# Isocurve draplotsg # fixe the y-axis
self.iso = pg.IsocurveItem(level=1000, pen=color_palette[2]) if Roi is True:
self.iso.setParentItem(self.img) self.axsumy.setYLink(self.aximg)
self.iso.setZValue(5)
# Contrast/color control # Contrast/color control
self.hist = pg.HistogramLUTItem() self.colorbar = None
self.hist.setImageItem(self.img) if HistogramLUT is True:
self.plots.addItem(self.hist) self.colorbar = pg.HistogramLUTItem()
self.colorbar.setImageItem(self.img)
self.colormap = Gradients['jet']
self.colorbar.gradient.restoreState(self.colormap)
self.plots.addItem(self.colorbar)
else:
colormap = pg.colormap.getFromMatplotlib('jet')
self.colorbar = pg.ColorBarItem(cmap=colormap, values=(0, 1))
self.colorbar.setImageItem(self.img, insert_in=self.aximg)
# Draggable line for setting isocurve level self.iso = None
self.isoLine = pg.InfiniteLine(angle=0, movable=True, pen=color_palette[2]) self.roi = None
self.hist.vb.addItem(self.isoLine)
self.hist.vb.setMouseEnabled(y=False) # makes user interaction a little easier if Isocurve is True:
self.isoLine.setValue(1000) # Isocurve draplotsg
self.isoLine.setZValue(1000) # bring iso line above contrast controls self.iso = pg.IsocurveItem(level=0, pen=color_palette[2])
self.isoLine.sigDragged.connect(self.updateIsocurve) self.iso.setParentItem(self.img)
self.iso.setZValue(5)
# Draggable line for setting isocurve level
self.isoLine = pg.InfiniteLine(angle=0, movable=True, pen=color_palette[2])
self.colorbar.vb.addItem(self.isoLine)
self.colorbar.vb.setMouseEnabled(y=False) # makes user interaction a little easier
self.isoLine.setValue(1000)
self.isoLine.setZValue(1000) # bring iso line above contrast controls
self.isoLine.sigDragged.connect(self.updateIsocurve)
self.plots.nextRow()
if Roi is True:
# Custom ROI for selecting an image region
self.roi = pg.ROI([500, 500], [300, 300], pen={'color': 'k', 'width': 4})
self.roi.addScaleHandle([1, 0], [0.5, 0.5])
self.roi.addScaleHandle([0, 1], [0.5, 0.5])
self.aximg.addItem(self.roi)
self.roi.setZValue(10) # make sure ROI is drawn above image
self.roi_ax = self.plots.addPlot()
self.roi_ax.setFixedHeight(300)
self.roi_ax.setFixedWidth(300)
self.roi_img = pg.ImageItem()
self.roi_ax.addItem(self.roi_img)
roi_colormap = pg.colormap.getFromMatplotlib('jet')
self.roi_img.setColorMap(roi_colormap)
self.roi.sigRegionChanged.connect(self.updateROI)
self.colorbar.sigLevelsChanged.connect(self.updateROI)
# Add x-axis data slider
self.axsumx = self.plots.addPlot()
self.axsumx.setFixedHeight(300)
self.axsumx.setXLink(self.aximg)
self.sumx = self.axsumx.plot()
self.sumx_data = self.axsumx.plot(pen=pg.mkPen(style=QtCore.Qt.DashLine, color=color_palette[1]))
# Monkey-patch the image to use our custom hover function. # Monkey-patch the image to use our custom hover function.
# This is generally discouraged (you should subclass ImageItem instead), # This is generally discouraged (you should subclass ImageItem instead),
@ -81,25 +175,169 @@ class FakeColorPlot(DataPlot):
self.cx = 0 self.cx = 0
self.cy = 0 self.cy = 0
self.data_image = None #Add text box for colorbar and ROI
self.colorbar_ROI_box = QSplitter()
self.colorbar_ROI_box.setOrientation(Qt.Horizontal)
if colorbarText is True:
# Add text box for colorbar
self.colorbar_box = QSplitter()
self.colorbar_box.setOrientation(Qt.Vertical)
self.colorbar_title = QLabel('Color Bar')
self.colorbar_title.setAlignment(Qt.AlignCenter)
self.colorbar_box_container = QSplitter()
self.colorbar_box_container.setOrientation(Qt.Horizontal)
self.colorbar_box_max_label = QLabel(' Max: ')
self.colorbar_box_max_label.setAlignment(Qt.AlignCenter)
self.colorbar_box_max_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.colorbar_box_max_line)
self.colorbar_box_max_line.setValidator(double_validator)
self.colorbar_box_max_line.setAlignment(Qt.AlignLeft)
self.colorbar_box_min_label = QLabel(' Min: ')
self.colorbar_box_min_label.setAlignment(Qt.AlignCenter)
self.colorbar_box_min_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.colorbar_box_min_line)
self.colorbar_box_min_line.setValidator(double_validator)
self.colorbar_box_min_line.setAlignment(Qt.AlignLeft)
self.colorbar_box_label = QSplitter()
self.colorbar_box_label.setOrientation(Qt.Vertical)
self.colorbar_box_line = QSplitter()
self.colorbar_box_line.setOrientation(Qt.Vertical)
self.colorbar_box_label.addWidget(self.colorbar_box_max_label)
self.colorbar_box_label.addWidget(self.colorbar_box_min_label)
self.colorbar_box_line.addWidget(self.colorbar_box_max_line)
self.colorbar_box_line.addWidget(self.colorbar_box_min_line)
self.colorbar_box_container.addWidget(self.colorbar_box_label)
self.colorbar_box_container.addWidget(self.colorbar_box_line)
self.colorbar_box.addWidget(self.colorbar_title)
self.colorbar_box.addWidget(self.colorbar_box_container)
self.colorbar_box_max_line.editingFinished.connect(self.update_colorbar_text)
self.colorbar_box_min_line.editingFinished.connect(self.update_colorbar_text)
if Roi is True:
#Add text box for ROI
self.roi_box = QSplitter()
self.roi_box.setOrientation(Qt.Vertical)
self.roi_box_title = QLabel('Region of Interest')
self.roi_box_title.setAlignment(Qt.AlignCenter)
self.roi_box_container = QSplitter()
self.roi_box_container.setOrientation(Qt.Horizontal)
self.roi_center_container = QSplitter()
self.roi_center_container.setOrientation(Qt.Horizontal)
self.roi_span_container = QSplitter()
self.roi_span_container.setOrientation(Qt.Horizontal)
self.roi_center_label = QSplitter()
self.roi_center_label.setOrientation(Qt.Vertical)
self.roi_center_line = QSplitter()
self.roi_center_line.setOrientation(Qt.Vertical)
self.roi_span_label = QSplitter()
self.roi_span_label.setOrientation(Qt.Vertical)
self.roi_span_line = QSplitter()
self.roi_span_line.setOrientation(Qt.Vertical)
self.roi_center_x_label = QLabel(' X: ')
self.roi_center_x_label.setAlignment(Qt.AlignCenter)
self.roi_center_x_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.roi_center_x_line)
self.roi_center_x_line.setValidator(double_validator)
self.roi_center_x_line.setAlignment(Qt.AlignLeft)
self.roi_center_y_label = QLabel(' Y: ')
self.roi_center_y_label.setAlignment(Qt.AlignCenter)
self.roi_center_y_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.roi_center_y_line)
self.roi_center_y_line.setValidator(double_validator)
self.roi_center_y_line.setAlignment(Qt.AlignLeft)
self.roi_span_x_label = QLabel(' X Span: ')
self.roi_span_x_label.setAlignment(Qt.AlignCenter)
self.roi_span_x_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.roi_span_x_line)
self.roi_span_x_line.setValidator(double_validator)
self.roi_span_x_line.setAlignment(Qt.AlignLeft)
self.roi_span_y_label = QLabel(' Y Span: ')
self.roi_span_y_label.setAlignment(Qt.AlignCenter)
self.roi_span_y_line = QLineEdit(self)
double_regex = QRegExp("^[-+0-9.]+$")
double_validator = QRegExpValidator(double_regex, self.roi_span_y_line)
self.roi_span_y_line.setValidator(double_validator)
self.roi_span_y_line.setAlignment(Qt.AlignLeft)
self.roi_center_label.addWidget(self.roi_center_x_label)
self.roi_center_label.addWidget(self.roi_center_y_label)
self.roi_center_line.addWidget(self.roi_center_x_line)
self.roi_center_line.addWidget(self.roi_center_y_line)
self.roi_span_label.addWidget(self.roi_span_x_label)
self.roi_span_label.addWidget(self.roi_span_y_label)
self.roi_span_line.addWidget(self.roi_span_x_line)
self.roi_span_line.addWidget(self.roi_span_y_line)
self.roi_center_container.addWidget(self.roi_center_label)
self.roi_center_container.addWidget(self.roi_center_line)
self.roi_span_container.addWidget(self.roi_span_label)
self.roi_span_container.addWidget(self.roi_span_line)
self.roi_box_container.addWidget(self.roi_center_container)
self.roi_box_container.addWidget(self.roi_span_container)
self.roi_box.addWidget(self.roi_box_title)
self.roi_box.addWidget(self.roi_box_container)
self.roi_center_x_line.editingFinished.connect(self.updateROI_text)
self.roi_center_y_line.editingFinished.connect(self.updateROI_text)
self.roi_span_x_line.editingFinished.connect(self.updateROI_text)
self.roi_span_y_line.editingFinished.connect(self.updateROI_text)
self.colorbar_ROI_box.addWidget(self.colorbar_box)
self.colorbar_ROI_box.addWidget(self.roi_box)
self.bottom.addWidget(self.colorbar_ROI_box)
def update(self, h5_path): def update(self, h5_path):
data = self.data_extractor_manager.get_data(h5_path) data = self.data_extractor_manager.get_data(h5_path)
data_img = data['data_img'] self.data_image = data['data_img']
x = data['x']
y = data['y'] try:
x = data['x']
y = data['y']
warning = data['warning']
except:
x = None
y = None
warning = None
if x is None: if x is None:
x = np.linspace(0, data_img.shape[0], data_img.shape[0]) x = np.linspace(0, self.data_image.shape[0], self.data_image.shape[0])
if y is None: if y is None:
y = np.linspace(0, data_img.shape[1], data_img.shape[1]) y = np.linspace(0, self.data_image.shape[1], self.data_image.shape[1])
warning = data['warning']
# update plots # update plots
self.img.setImage(data_img.T) if self.colorbarText is True:
self.iso.setData(data_img.T) self.img.setImage(self.data_image.T, autoLevels=False)
else:
self.img.setImage(self.data_image.T, autoLevels=True)
self.colorbar.setLevels((np.min(self.data_image), np.max(self.data_image)))
self.data_img = data_img if self.iso is not None:
self.iso.setData(self.data_image.T)
# set position and scale of image # set position and scale of image
newscalex = x[1] - x[0] newscalex = x[1] - x[0]
@ -117,12 +355,72 @@ class FakeColorPlot(DataPlot):
self.cx = x[0] self.cx = x[0]
self.cy = y[0] self.cy = y[0]
# update the region of interest
if self.roi is not None:
self.updateROI()
# update table and warning # update table and warning
self.update_warning(warning) self.update_warning(warning)
if self.analyse_panel_update is not None:
self.analyse_panel_update()
def updateIsocurve(self): def updateIsocurve(self):
self.iso.setLevel(self.isoLine.value()) self.iso.setLevel(self.isoLine.value())
def update_colorbar_text(self):
colorbar_max = self.colorbar_box_max_line.text()
colorbar_min = self.colorbar_box_min_line.text()
colorbar_max = float(colorbar_max)
colorbar_min = float(colorbar_min)
try:
self.colorbar.setLevels(min=colorbar_min, max=colorbar_max)
except:
self.colorbar.setLevels(low=colorbar_min, high=colorbar_max)
if self.roi is not None:
self.updateROI()
def updateROI(self):
selected = self.roi.getArrayRegion(self.data_image.T, self.img)
try:
levels = self.colorbar.getLevels()
except:
levels = self.colorbar.levels()
self.roi_img.setImage(selected, levels=levels)
colorbar_min, colorbar_max = levels
self.colorbar_box_max_line.setText(str(colorbar_max))
self.colorbar_box_min_line.setText(str(colorbar_min))
x_center, y_center = self.roi.pos()
x_span, y_span = self.roi.size()
x_center = x_center + x_span / 2
y_center = y_center + y_span / 2
self.roi_center_x_line.setText(str(x_center))
self.roi_center_y_line.setText(str(y_center))
self.roi_span_x_line.setText(str(x_span))
self.roi_span_y_line.setText(str(y_span))
roi_pos = self.roi.pos()
pos = int(selected.shape[0]/2)
x = np.linspace(roi_pos[1], roi_pos[1] + selected.shape[1], selected.shape[1])
self.sumy_data.setData(x=np.squeeze(selected[pos:pos+1, :]), y=x)
pos = int(selected.shape[1] / 2)
x = np.linspace(roi_pos[0], roi_pos[0] + selected.shape[0], selected.shape[0])
self.sumx_data.setData(x=x, y=np.squeeze(selected[:, pos:pos + 1]))
def updateROI_text(self):
x_center = float(self.roi_center_x_line.text())
y_center = float(self.roi_center_y_line.text())
x_span = float(self.roi_span_x_line.text())
y_span = float(self.roi_span_y_line.text())
x = x_center - x_span / 2
y = y_center - y_span / 2
self.roi.setPos((x, y))
self.roi.setSize((x_span, y_span))
def imageHoverEvent(self, event): def imageHoverEvent(self, event):
"""Show the position, pixel, and value under the mouse cursor. """Show the position, pixel, and value under the mouse cursor.
""" """
@ -131,9 +429,9 @@ class FakeColorPlot(DataPlot):
return return
pos = event.pos() pos = event.pos()
i, j = pos.y(), pos.x() i, j = pos.y(), pos.x()
i = int(np.clip(i, 0, self.data_img.shape[0] - 1)) i = int(np.clip(i, 0, self.data_image.shape[0] - 1))
j = int(np.clip(j, 0, self.data_img.shape[1] - 1)) j = int(np.clip(j, 0, self.data_image.shape[1] - 1))
val = self.data_img[i, j] val = self.data_image[i, j]
ppos = self.img.mapToParent(pos) ppos = self.img.mapToParent(pos)
x, y = ppos.x(), ppos.y() x, y = ppos.x(), ppos.y()
self.aximg.setTitle("pos: (%0.1f, %0.1f) value: %g" % (x, y, val)) self.aximg.setTitle("pos: (%0.1f, %0.1f) value: %g" % (x, y, val))

View File

@ -7,39 +7,35 @@ from PyQt5.QtCore import *
from .DataExtractorLyse import DataExtractorManager from .DataExtractorLyse import DataExtractorManager
class DataPlot(QSplitter): class WidgetPlot(QSplitter):
def __init__(self, title, **kwargs): def __init__(self, title, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
# Orientation of plot and title (and other information) # Orientation of plot and title (and other information)
self.setOrientation(Qt.Vertical) self.setOrientation(Qt.Vertical)
# Add plot
self.plots = pg.GraphicsLayoutWidget()
self.addWidget(self.plots)
# Claim bottom part (title)
self.bottom = QSplitter()
self.bottom.setOrientation(Qt.Horizontal)
self.addWidget(self.bottom)
# Add title # Add title
self.title = QtGui.QLabel() self.title = QtGui.QLabel()
self.title.setAlignment(QtCore.Qt.AlignCenter) self.title.setAlignment(QtCore.Qt.AlignCenter)
self.title.setText('<h2>' + title + ' <\h2>') self.title.setText('<h2>' + title + ' <\h2>')
self.desciption = pg.LayoutWidget() self.addWidget(self.title)
self.desciption.addWidget(self.title)
# Claim bottom part (title)
self.bottom = QSplitter()
self.bottom.setOrientation(Qt.Vertical)
self.addWidget(self.bottom)
# Add plot
self.plots = pg.GraphicsLayoutWidget()
self.bottom.addWidget(self.plots)
# Add warning information # Add warning information
self.desciption = pg.LayoutWidget()
self.warning = QtGui.QLabel() self.warning = QtGui.QLabel()
self.warning.setAlignment(QtCore.Qt.AlignCenter) self.warning.setAlignment(QtCore.Qt.AlignCenter)
self.desciption.nextRow() self.desciption.nextRow()
self.desciption.addWidget(self.warning) self.desciption.addWidget(self.warning)
self.bottom.addWidget(self.desciption) # self.bottom.addWidget(self.desciption)
# Add a table for fitting information
self.table = pg.TableWidget()
self.bottom.addWidget(self.table)
# Current hdf5 file path # Current hdf5 file path
self.h5_path_shown = None self.h5_path_shown = None

15
test.py
View File

@ -1,13 +1,2 @@
import lyse import pyqtgraph.examples
from pylab import * pyqtgraph.examples.run()
from lyse import *
run = Run(path)
imaging = 'absorption_imaging'
cam = 'absorption_imaging'
h5_paths = lyse.h5_paths()
print(run.globals_groups())
print(run.get_result_arrays(imaging, cam))

View File

@ -1,5 +1,5 @@
from lyse import * from lyse import *
from HelperClasses import DyTransition, Camera, AbsorptionImaging, Plotting from HelperClasses import DyTransition, Camera, AbsorptionImaging, Plotting1
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.style as mplstyle import matplotlib.style as mplstyle
@ -20,7 +20,7 @@ with AbsorptionImaging.absorption_imaging(path, 'MOT_3D_Camera', 'in_situ_absorp
print(absorption_image.atom_number) print(absorption_image.atom_number)
plotting = Plotting.plotting_absorption_imaging(absorption_image) plotting = Plotting1.plotting_absorption_imaging(absorption_image)
plotting.four_plots() plotting.four_plots()
# plotting.absorption_plots() # plotting.absorption_plots()

View File

@ -8,6 +8,7 @@ import lyse
import numpy as np import numpy as np
from HelperClasses.Plotting import WidgetFakeColorPlot, MainPlotPanel from HelperClasses.Plotting import WidgetFakeColorPlot, MainPlotPanel
from HelperClasses import DyTransition, Camera, AbsorptionImaging
import cProfile import cProfile
import pstats import pstats
@ -15,7 +16,7 @@ import pstats
profile = cProfile.Profile() profile = cProfile.Profile()
profile.enable() profile.enable()
fm = lyse.figure_manager figure_manager = lyse.figure_manager
h5_paths = lyse.h5_paths() h5_paths = lyse.h5_paths()
@ -26,32 +27,52 @@ else:
# If not, get the filepath of the last shot of the lyse DataFrame # If not, get the filepath of the last shot of the lyse DataFrame
h5_path = lyse.h5_paths().iloc[-1] h5_path = lyse.h5_paths().iloc[-1]
print(h5_path)
if len(h5_paths): if len(h5_paths):
last_globals = run = lyse.Run(h5_paths.iloc[-1]).get_globals() last_globals = run = lyse.Run(h5_paths.iloc[-1]).get_globals()
if not hasattr(fm, 'ap'): if not hasattr(figure_manager, 'ap'):
fm.ap = MainPlotPanel.MainPlotPanel(h5_paths) figure_manager.MainPlotPanel = MainPlotPanel.MainPlotPanel(h5_paths)
# Imaging Methods # Add absorption imaging
imagings = ['absorption_imaging'] plot_name = '3D-MOT Absorption Imaging - With Atoms'
if not plot_name in figure_manager.MainPlotPanel.plots:
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1', ('in_situ_absorption', 'atoms'),
data_group='MOT_3D_Camera',
Roi=False, colorbarText=False)
figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
cams = {'absorption_imaging': ['Cam_absorption']} plot_name = '3D-MOT Absorption Imaging - Without Atoms'
if not plot_name in figure_manager.MainPlotPanel.plots:
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1', ('in_situ_absorption', 'background'),
data_group='MOT_3D_Camera',
Roi=False, colorbarText=False)
figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
imaging = 'absorption_imaging' plot_name = '3D-MOT Absorption Imaging - Dark'
for cam in cams[imaging]: if not plot_name in figure_manager.MainPlotPanel.plots:
plot_name = imaging + ' ' + cam current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1', ('in_situ_absorption', 'dark'),
data_group='MOT_3D_Camera',
Roi=False, colorbarText=False)
figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
if not plot_name in fm.ap.plots: plot_name = '3D-MOT Absorption Imaging'
ip = WidgetFakeColorPlot.FakeColorPlot(plot_name, ('absorption_imaging', 'absorption_imaging')) if not plot_name in figure_manager.MainPlotPanel.plots:
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name, ('absorption_imaging', 'absorption_imaging'))
fm.ap.add_plot_dock(plot_name, ip) figure_manager.MainPlotPanel.add_plot_dock(plot_name, current_plotting)
fm.ap.update_h5_paths(h5_paths) absorption_imaging_transition = DyTransition.creat_Dy421()
fm.ap.refresh(h5_path) mot_3D_camera = Camera.c11440_36u(absorption_imaging_transition['wavelength'])
absorption_image = AbsorptionImaging.absorption_imaging(None, 'MOT_3D_Camera', 'in_situ_absorption',
absorption_imaging_transition, mot_3D_camera, 0, 0)
figure_manager.MainPlotPanel.analyse_panel.add_absorption_imaging(absorption_image, current_plotting)
figure_manager.MainPlotPanel.update_h5_paths(h5_paths)
figure_manager.MainPlotPanel.refresh(h5_path)
profile.disable() profile.disable()
ps = pstats.Stats(profile) ps = pstats.Stats(profile)
ps.sort_stats('cumtime') ps.sort_stats('cumtime')
ps.print_stats(10) ps.print_stats(10)