Update for 1D living plot, but exist a huge bug

This commit is contained in:
gao 2022-08-09 17:48:22 +02:00
parent 8760e48105
commit 98fd4f3ded
10 changed files with 120 additions and 39 deletions

25
.idea/workspace.xml generated
View File

@ -2,15 +2,14 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Update for plotting function."> <list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Update for plotting function.">
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetAnalysePanel.py" afterDir="false" /> <change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/Widget1DLivingPlot.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$/HelperClasses/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/AbsorptionImaging.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/HelperClasses/AbsorptionImaging.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/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$/HelperClasses/Plotting/DataExtractorLyse.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/DataExtractorLyse.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$/HelperClasses/Plotting/MainPlotPanel.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/MainPlotPanel.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$/HelperClasses/Plotting/WidgetAnalysePanel.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetAnalysePanel.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$/HelperClasses/Plotting/WidgetFakeColorPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetFakeColorPlot.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$/HelperClasses/Plotting/WidgetQuickWaterFlowPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetQuickWaterFallPlot.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test.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_living_plot.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_living_plot.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/test_living_plot.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_living_plot.py" afterDir="false" />
</list> </list>
@ -190,7 +189,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="89130000" /> <workItem from="1659078901335" duration="96964000" />
</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>
@ -220,7 +219,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1659210654086</updated> <updated>1659210654086</updated>
</task> </task>
<option name="localTasksCounter" value="5" /> <task id="LOCAL-00005" summary="Update for plotting function.">
<created>1660052254656</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1660052254656</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -272,6 +278,11 @@
<url>file://$PROJECT_DIR$/HelperClasses/Plotting1.py</url> <url>file://$PROJECT_DIR$/HelperClasses/Plotting1.py</url>
<option name="timeStamp" value="61" /> <option name="timeStamp" value="61" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/../../../analysis_plot_panel/src/analysis_plot_panel/analysis_plot_panel_lyse_routine.py</url>
<line>6</line>
<option name="timeStamp" value="62" />
</line-breakpoint>
</breakpoints> </breakpoints>
<default-breakpoints> <default-breakpoints>
<breakpoint type="python-exception"> <breakpoint type="python-exception">
@ -284,7 +295,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$test__1_.coverage" NAME="test (1) Coverage Results" MODIFIED="1660054001747" 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

@ -127,12 +127,12 @@ class absorption_imaging:
# select the effective data in an rectangle area defined by coordinates of two conner # select the effective data in an rectangle area defined by coordinates of two conner
# The select region will be presented as a red box in the plotting # The select region will be presented as a red box in the plotting
def select_effective_data(self, left_up_conner, right_down_conner): def select_effective_data(self, center, span):
self.x_start = left_up_conner[0] self.x_start = int(center[0] - span[0] / 2)
self.x_end = right_down_conner[0] self.x_end = int(center[0] + span[0] / 2)
self.y_end = left_up_conner[1] self.y_end = int(center[1] + span[1] / 2)
self.y_start = right_down_conner[1] self.y_start = int(center[1] - span[1] / 2)
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

@ -23,7 +23,7 @@ class DataExtractorManager:
def __init__(self, data_path=None): def __init__(self, data_path=None):
self.data_extractors = {} self.data_extractors = {}
self.h5_file = None # self.h5_file = None
self.data_path = data_path self.data_path = data_path
self.local_data_changed = False self.local_data_changed = False

View File

@ -45,7 +45,8 @@ class MainPlotPanel(QtGui.QMainWindow):
self.danalyse_panel.addWidget(self.analyse_panel) self.danalyse_panel.addWidget(self.analyse_panel)
self.area.addDock(self.danalyse_panel, 'bottom') self.area.addDock(self.danalyse_panel, 'bottom')
self.show() self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.showMaximized()
self.plots = {} self.plots = {}

View File

@ -0,0 +1,76 @@
import numpy as np
from .DataExtractorLyse import DataExtractorManager
from .WidgetPlot 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
class Widget1DLivingPlot(WidgetPlot):
def __init__(self, title, x_data_path=None, y_data_path=None, x_in_results=False, y_in_results=False, **kwargs):
super().__init__(title, **kwargs)
# set data extractor
if x_data_path is not None:
self.x_data_extractor_manager = DataExtractorManager(x_data_path)
self.x_data_extractor_manager.add_data_extractor('warning', 'single', (x_data_path[0], 'warning'))
if x_in_results:
self.x_data_extractor_manager.add_data_extractor('x', 'single', x_data_path)
else:
self.x_data_extractor_manager.add_data_extractor('x', 'global', x_data_path)
else:
self.x_data_extractor_manager = None
self.y_data_extractor_manager = DataExtractorManager(y_data_path)
self.y_data_extractor_manager.add_data_extractor('warning', 'single', (y_data_path[0], 'warning'))
if y_in_results:
self.y_data_extractor_manager.add_data_extractor('y', 'single', y_data_path)
else:
self.y_data_extractor_manager.add_data_extractor('y', 'global', y_data_path)
self.aximg = self.plots.addPlot(title="")
self.img = pg.PlotCurveItem()
self.aximg.setClipToView(True)
self.aximg.setDownsampling(mode='peak')
self.aximg.addItem(self.img)
self.x = np.empty(100)
self.y = np.empty(100)
self.current_data_length = 0
def update(self, h5_path):
if self.current_data_length >= self.x.shape[0]:
tmp = self.x
self.x = np.empty(self.x.shape[0] * 2)
self.x[:tmp.shape[0]] = tmp
tmp = self.y
self.y = np.empty(self.y.shape[0] * 2)
self.y[:tmp.shape[0]] = tmp
if self.x_data_extractor_manager is not None:
x_data = self.x_data_extractor_manager.get_data(h5_path)
self.x[self.current_data_length] = x_data['x']
else:
self.x[self.current_data_length] = self.current_data_length
y_data = self.y_data_extractor_manager.get_data(h5_path)
self.y[self.current_data_length] = y_data['y']
print(y_data['y'])
self.img.setData(x=self.x[:self.current_data_length], y=self.y[:self.current_data_length])
self.current_data_length = self.current_data_length + 1

View File

@ -37,12 +37,9 @@ class WidgetAnalysePanel(QSplitter):
x_span = int(x_span) x_span = int(x_span)
y_span = int(y_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.image_absorption = self.absorption_image_plot.data_image
self.absorption_image.select_effective_data(left_up_conner, right_down_conner) self.absorption_image.select_effective_data((x, y), (x_span, y_span))
self.absorption_image.get_atom_number(force_to_run=True) self.absorption_image.get_atom_number(force_to_run=True)

View File

@ -1,6 +1,4 @@
import numpy as np import numpy as np
from PyQt5 import QtGui
from PyQt5.QtGui import QDoubleValidator
from .DataExtractorLyse import DataExtractorManager from .DataExtractorLyse import DataExtractorManager
from .WidgetPlot import WidgetPlot from .WidgetPlot import WidgetPlot

View File

@ -1,26 +1,16 @@
from lyse import * from lyse import *
from HelperClasses import DyTransition, Camera, AbsorptionImaging, Plotting1 from HelperClasses import DyTransition, Camera, AbsorptionImaging
import matplotlib.pyplot as plt
import matplotlib.style as mplstyle
import matplotlib
matplotlib.use("qt5agg")
mplstyle.use('fast')
absorption_imaging_transition = DyTransition.creat_Dy421() absorption_imaging_transition = DyTransition.creat_Dy421()
mot_3D_camera = Camera.c11440_36u(absorption_imaging_transition['wavelength']) mot_3D_camera = Camera.c11440_36u(absorption_imaging_transition['wavelength'])
with AbsorptionImaging.absorption_imaging(path, 'MOT_3D_Camera', 'in_situ_absorption', with AbsorptionImaging.absorption_imaging(path, 'MOT_3D_Camera', 'in_situ_absorption',
absorption_imaging_transition, mot_3D_camera, 0, 0) as absorption_image: absorption_imaging_transition, mot_3D_camera, 0, 0) as absorption_image:
# Please selecte the effective area here
absorption_image.select_effective_data((800, 500), (1000, 700)) # The first tuple is the center position (x,y)
# The second tuple is the span in x and y direction (x_span, y_span)
absorption_image.select_effective_data((900, 600), (200, 200))
absorption_image.get_atom_number() absorption_image.get_atom_number()
print(absorption_image.atom_number) # print(absorption_image.atom_number)
plotting = Plotting1.plotting_absorption_imaging(absorption_image)
plotting.four_plots()
# plotting.absorption_plots()

View File

@ -7,7 +7,7 @@ Created on Thu Mar 11 14:58:18 2021
import lyse import lyse
import numpy as np import numpy as np
from HelperClasses.Plotting import WidgetFakeColorPlot, MainPlotPanel from HelperClasses.Plotting import WidgetFakeColorPlot, MainPlotPanel, Widget1DLivingPlot
from HelperClasses import DyTransition, Camera, AbsorptionImaging from HelperClasses import DyTransition, Camera, AbsorptionImaging
import cProfile import cProfile
@ -55,6 +55,7 @@ if not plot_name in figure_manager.MainPlotPanel.plots:
Roi=False, colorbarText=False) Roi=False, colorbarText=False)
figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting) figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
# Add plotting for absorption imaging
plot_name = '3D-MOT Absorption Imaging' plot_name = '3D-MOT Absorption Imaging'
if not plot_name in figure_manager.MainPlotPanel.plots: if not plot_name in figure_manager.MainPlotPanel.plots:
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name, ('absorption_imaging', 'absorption_imaging')) current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name, ('absorption_imaging', 'absorption_imaging'))
@ -67,8 +68,15 @@ if not plot_name in figure_manager.MainPlotPanel.plots:
absorption_imaging_transition, mot_3D_camera, 0, 0) absorption_imaging_transition, mot_3D_camera, 0, 0)
figure_manager.MainPlotPanel.analyse_panel.add_absorption_imaging(absorption_image, current_plotting) figure_manager.MainPlotPanel.analyse_panel.add_absorption_imaging(absorption_image, current_plotting)
figure_manager.MainPlotPanel.update_h5_paths(h5_paths) # Add realtime plotting for atom number
figure_manager.MainPlotPanel.refresh(h5_path) # plot_name = '3D-MOT Atom Number'
# if not plot_name in figure_manager.MainPlotPanel.plots:
# current_plotting = Widget1DLivingPlot.Widget1DLivingPlot(plot_name, y_data_path=('absorption_imaging', 'atom_number'), y_in_results=True)
#
# figure_manager.MainPlotPanel.add_plot_dock(plot_name, 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)