Finally, achieve the living plotting
This commit is contained in:
parent
98fd4f3ded
commit
ae037596dc
95
.idea/workspace.xml
generated
95
.idea/workspace.xml
generated
@ -1,16 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Update for plotting function.">
|
||||
<change afterPath="$PROJECT_DIR$/HelperClasses/Plotting/Widget1DLivingPlot.py" afterDir="false" />
|
||||
<list default="true" id="68ddce6f-baaa-4bac-af24-443b9be545bf" name="Changes" comment="Update for 1D living plot, but exist a huge bug">
|
||||
<change afterPath="$PROJECT_DIR$/living_plot_main.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/living_plot_starter.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/test_call.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/text2.py" 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/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/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/WidgetQuickWaterFlowPlot.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetQuickWaterFallPlot.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$/HelperClasses/Plotting/WidgetDataSelector.py" beforeDir="false" afterPath="$PROJECT_DIR$/HelperClasses/Plotting/WidgetDataSelector.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$/test.py" beforeDir="false" afterPath="$PROJECT_DIR$/test.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/test_living_plot.py" beforeDir="false" afterPath="$PROJECT_DIR$/test_living_plot.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
@ -53,8 +56,8 @@
|
||||
<recent name="D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\HelperClasses\Plotting" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager" selected="Python.test (1)">
|
||||
<configuration name="Plotting1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<component name="RunManager" selected="Python.test_call">
|
||||
<configuration name="living_plot_starter" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="dylab" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
@ -62,12 +65,12 @@
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/HelperClasses" />
|
||||
<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="D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\HelperClasses\Plotting1.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/living_plot_starter.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
@ -98,29 +101,7 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="test" 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$/HelperClasses" />
|
||||
<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$/HelperClasses/test.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_fitting" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<configuration name="test_call" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="dylab" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
@ -133,7 +114,7 @@
|
||||
<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_fitting.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test_call.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
@ -164,13 +145,35 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="text2" 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$/text2.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>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.test_call" />
|
||||
<item itemvalue="Python.test (1)" />
|
||||
<item itemvalue="Python.living_plot_starter" />
|
||||
<item itemvalue="Python.text2" />
|
||||
<item itemvalue="Python.test_living_plot" />
|
||||
<item itemvalue="Python.test" />
|
||||
<item itemvalue="Python.Plotting1" />
|
||||
<item itemvalue="Python.test_fitting" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@ -189,7 +192,8 @@
|
||||
<workItem from="1658844297242" duration="39201000" />
|
||||
<workItem from="1659027245256" duration="8511000" />
|
||||
<workItem from="1659078820495" duration="69000" />
|
||||
<workItem from="1659078901335" duration="96964000" />
|
||||
<workItem from="1659078901335" duration="106222000" />
|
||||
<workItem from="1660122062939" duration="19981000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="First working version. Need introductions">
|
||||
<created>1658494877565</created>
|
||||
@ -226,7 +230,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1660052254656</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="6" />
|
||||
<task id="LOCAL-00006" summary="Update for 1D living plot, but exist a huge bug">
|
||||
<created>1660060102676</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1660060102676</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -249,7 +260,8 @@
|
||||
<MESSAGE value="Debug for calculating atom number. Add selecting the effective area function in AbsorptionImaging.py. Optimaze plotting function." />
|
||||
<MESSAGE value="Debug for calculating atom number. Add background subtraction function. Correct the pixel size of the camera" />
|
||||
<MESSAGE value="Update for plotting function." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Update for plotting function." />
|
||||
<MESSAGE value="Update for 1D living plot, but exist a huge bug" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Update for 1D living plot, but exist a huge bug" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
@ -295,9 +307,12 @@
|
||||
</component>
|
||||
<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__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$test__1_.coverage" NAME="test (1) Coverage Results" MODIFIED="1660132502214" 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$test_call.coverage" NAME="test_call Coverage Results" MODIFIED="1660141050972" 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$living_plot_starter.coverage" NAME="living_plot_starter Coverage Results" MODIFIED="1660123156670" 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$text2.coverage" NAME="text2 Coverage Results" MODIFIED="1660064702499" 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" />
|
||||
</component>
|
||||
</project>
|
@ -117,9 +117,9 @@ class absorption_imaging:
|
||||
mean += np.average(image[0:int(image.shape[0] * y_fraction), 0:int(image.shape[1] * x_fraction)])
|
||||
mean += np.average(image[0:int(image.shape[0] * y_fraction),
|
||||
int(image.shape[1] - image.shape[1] * x_fraction):int(image.shape[1])])
|
||||
mean += np.average(image[int(image.shape[0] - image.shape[0] * y_fraction):int(image.shape[1]),
|
||||
mean += np.average(image[int(image.shape[0] - image.shape[0] * y_fraction):int(image.shape[0]),
|
||||
0:int(image.shape[1] * x_fraction)])
|
||||
mean += np.average(image[int(image.shape[0] - image.shape[0] * y_fraction):int(image.shape[1]),
|
||||
mean += np.average(image[int(image.shape[0] - image.shape[0] * y_fraction):int(image.shape[0]),
|
||||
int(image.shape[1] - image.shape[1] * x_fraction):int(image.shape[1])])
|
||||
mean = mean / 4
|
||||
|
||||
@ -137,6 +137,7 @@ class absorption_imaging:
|
||||
self.image_absorption_cut = self.image_absorption[self.y_start:self.y_end, self.x_start:self.x_end]
|
||||
|
||||
back_ground = self.corner_subtract(self.image_absorption_cut, 0.1, 0.1)
|
||||
|
||||
self.image_absorption_cut = self.image_absorption_cut - back_ground
|
||||
self.image_absorption_remove_background = self.image_absorption - back_ground
|
||||
|
||||
|
@ -23,11 +23,14 @@ class DataExtractorManager:
|
||||
def __init__(self, data_path=None):
|
||||
|
||||
self.data_extractors = {}
|
||||
# self.h5_file = None
|
||||
self.data_path = data_path
|
||||
self.local_data_changed = False
|
||||
|
||||
def update_local_data(self, h5_path):
|
||||
|
||||
h5_path = h5_path.replace('\n', '')
|
||||
h5_path = os.path.join(h5_path)
|
||||
|
||||
with h5py.File(h5_path, 'r') as h5_file:
|
||||
self.local_data_changed = False
|
||||
for key in self.data_extractors:
|
||||
@ -76,41 +79,15 @@ class DataExtractor:
|
||||
self.data_type = type
|
||||
self.data_label = label
|
||||
|
||||
def extract_data(self, h5_path, h5_file=None):
|
||||
def extract_data(self, h5_file):
|
||||
|
||||
result = None
|
||||
|
||||
data_handle = lyse.Run(h5_path, no_write=True)
|
||||
|
||||
if self.data_type == 'array':
|
||||
try:
|
||||
result = data_handle.get_result_array(self.data_path[0], self.data_path[1],
|
||||
h5_file=h5_file)
|
||||
result = np.array(result)
|
||||
except:
|
||||
result = None
|
||||
|
||||
elif self.data_type == 'single':
|
||||
try:
|
||||
result = data_handle.get_result(self.data_path[0], self.data_path[1],
|
||||
h5_file=h5_file)
|
||||
except:
|
||||
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
|
||||
try:
|
||||
result = h5_file[self.data_path][()]
|
||||
result = np.array(result)
|
||||
except:
|
||||
result = None
|
||||
|
||||
return result
|
||||
|
||||
@ -118,7 +95,7 @@ class DataExtractor:
|
||||
if h5_path in self.local_datas and self.local_mtimes[h5_path] == get_mtime(h5_path):
|
||||
self.local_data_changed = False
|
||||
elif self.load_to_ram:
|
||||
self.local_datas[h5_path] = self.extract_data(h5_path, h5_file=h5_file)
|
||||
self.local_datas[h5_path] = self.extract_data(h5_file)
|
||||
self.local_mtimes[h5_path] = get_mtime(h5_path)
|
||||
self.local_data_changed = True
|
||||
|
||||
@ -138,7 +115,7 @@ class DataExtractor:
|
||||
|
||||
def clean_memory(self, h5_paths):
|
||||
for key in list(self.local_datas):
|
||||
if key not in h5_paths.to_list():
|
||||
if key not in h5_paths.tolist():
|
||||
del self.local_datas[key]
|
||||
del self.local_mtimes[key]
|
||||
|
||||
|
@ -1,23 +1,38 @@
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
from pyqtgraph.dockarea import *
|
||||
from PyQt5.QtWidgets import *
|
||||
from PyQt5.QtCore import *
|
||||
import lyse
|
||||
from .WidgetDataSelector import WidgetDataSelector
|
||||
from .WidgetAnalysePanel import WidgetAnalysePanel
|
||||
|
||||
|
||||
def write_pid():
|
||||
with open("living_plot.ini", 'w') as pid_file:
|
||||
pid = os.getpid()
|
||||
pid_file.write(str(pid))
|
||||
|
||||
return pid
|
||||
|
||||
|
||||
def clean_pid():
|
||||
with open("living_plot.ini", 'w') as pid_file:
|
||||
pid_file.truncate(0)
|
||||
|
||||
|
||||
class MainPlotPanel(QtGui.QMainWindow):
|
||||
|
||||
def __init__(self, h5_paths, n_rows=3, **kwargs):
|
||||
|
||||
self.h5_paths = h5_paths
|
||||
|
||||
super().__init__(**kwargs)
|
||||
|
||||
write_pid()
|
||||
|
||||
self.h5_paths = np.array(h5_paths)
|
||||
|
||||
pg.mkQApp()
|
||||
|
||||
self.n_rows = n_rows
|
||||
@ -53,7 +68,9 @@ class MainPlotPanel(QtGui.QMainWindow):
|
||||
self.shotselector.valueChanged.connect(self.refresh)
|
||||
self.shotselector.selectionChanged.connect(self.refresh)
|
||||
|
||||
self.df = lyse.data()
|
||||
def closeEvent(self, event):
|
||||
clean_pid()
|
||||
event.accept()
|
||||
|
||||
def add_plot_dock(self, plot_name, plot_widget, overlap=True, **kwargs):
|
||||
if plot_name not in self.plots:
|
||||
@ -87,27 +104,30 @@ class MainPlotPanel(QtGui.QMainWindow):
|
||||
del self.plots[dock.title()]
|
||||
|
||||
def update_h5_paths(self, h5_paths):
|
||||
self.h5_paths = h5_paths
|
||||
self.h5_paths = np.array(h5_paths)
|
||||
|
||||
self.shotselector.update_nshots(len(h5_paths))
|
||||
|
||||
for plot_name in self.plots:
|
||||
self.plots[plot_name].data_extractor_manager.clean_memory(h5_paths)
|
||||
|
||||
def add_h5_path(self, h5_path):
|
||||
self.h5_paths = np.append(self.h5_paths, h5_path)
|
||||
|
||||
self.shotselector.update_nshots(len(self.h5_paths))
|
||||
|
||||
def refresh(self, h5_path=None):
|
||||
if len(self.h5_paths):
|
||||
|
||||
self.h5_paths_selected = self.h5_paths.iloc[self.shotselector.get_selected_indices()]
|
||||
self.h5_paths_selected = self.h5_paths[np.array(self.shotselector.get_selected_indices())]
|
||||
|
||||
if h5_path == None:
|
||||
i = self.shotselector.get_current_index()
|
||||
h5_path = self.h5_paths.iloc[i]
|
||||
h5_path = self.h5_paths[np.array(i)]
|
||||
|
||||
for plot_name in self.plots:
|
||||
self.plots[plot_name].data_extractor_manager.update_local_data(h5_path)
|
||||
|
||||
# self.data_extractor_manager.update_local_data(h5_path)
|
||||
|
||||
for plot_name, plot in self.plots.items():
|
||||
plot.update_from_h5(h5_path)
|
||||
else:
|
||||
|
@ -32,6 +32,9 @@ class WidgetAnalysePanel(QSplitter):
|
||||
x, y = self.absorption_image_plot.roi.pos()
|
||||
x_span, y_span = self.absorption_image_plot.roi.size()
|
||||
|
||||
x = x + x_span / 2
|
||||
y = y + y_span / 2
|
||||
|
||||
x = int(x)
|
||||
y = int(y)
|
||||
x_span = int(x_span)
|
||||
|
@ -128,4 +128,4 @@ class WidgetDataSelector(pg.LayoutWidget):
|
||||
return int(self.current_idx_le.text()) % self.nshots
|
||||
|
||||
def get_selected_indices(self):
|
||||
return (np.array(self.idx_selected),)
|
||||
return np.array(self.idx_selected)
|
@ -44,6 +44,7 @@ class WidgetPlot(QSplitter):
|
||||
self.data_extractor_manager = DataExtractorManager()
|
||||
|
||||
def update_from_h5(self, h5_path):
|
||||
h5_path = h5_path.replace('\n', '')
|
||||
if self.h5_path_shown != h5_path or self.data_extractor_manager.local_data_changed:
|
||||
self.h5_path_shown = h5_path
|
||||
self.update(h5_path)
|
||||
|
93
living_plot_class.py
Normal file
93
living_plot_class.py
Normal file
@ -0,0 +1,93 @@
|
||||
import lyse
|
||||
import numpy as np
|
||||
from PyQt5.QtCore import QTimer
|
||||
|
||||
from HelperClasses.Plotting import WidgetFakeColorPlot, MainPlotPanel, Widget1DLivingPlot
|
||||
from HelperClasses import DyTransition, Camera, AbsorptionImaging
|
||||
|
||||
import cProfile
|
||||
import pstats
|
||||
|
||||
|
||||
class FigureManager:
|
||||
def __init__(self):
|
||||
self.MainPlotPanel = None
|
||||
self.timer = None
|
||||
self.h5_paths = np.empty(0)
|
||||
|
||||
def refresh_h5_path(self):
|
||||
with open(r'D:\Jianshun Gao\Simulations\DyLab\publishedPackage\dylab\h5_file_path.ini', 'r') as h5_path_file:
|
||||
h5_path_new = np.array(h5_path_file.readlines())
|
||||
|
||||
if len(h5_path_new) == len(self.h5_paths) + 1:
|
||||
|
||||
if len(h5_path_new) == 1 or (h5_path_new[:len(h5_path_new) - 1] == self.h5_paths).any():
|
||||
|
||||
h5_path = h5_path_new[len(h5_path_new) - 1]
|
||||
self.MainPlotPanel.add_h5_path(h5_path)
|
||||
self.h5_paths = np.append(self.h5_paths, h5_path)
|
||||
self.MainPlotPanel.refresh(h5_path)
|
||||
|
||||
elif len(h5_path_new) == len(self.h5_paths):
|
||||
|
||||
if not (self.h5_paths == h5_path_new).any():
|
||||
|
||||
self.h5_paths = h5_path_new
|
||||
self.MainPlotPanel.update_h5_paths(h5_path_new)
|
||||
self.MainPlotPanel.refresh(h5_path_new[len(h5_path_new) - 1])
|
||||
|
||||
else:
|
||||
self.h5_paths = h5_path_new
|
||||
self.MainPlotPanel.update_h5_paths(h5_path_new)
|
||||
self.MainPlotPanel.refresh(h5_path_new[len(h5_path_new) - 1])
|
||||
|
||||
def start_living_plot(self, h5_paths):
|
||||
|
||||
self.MainPlotPanel = MainPlotPanel.MainPlotPanel(h5_paths)
|
||||
|
||||
plot_name = '3D-MOT Absorption Imaging - With Atoms'
|
||||
if not plot_name in self.MainPlotPanel.plots:
|
||||
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1',
|
||||
data_path=r"images/MOT_3D_Camera/in_situ_absorption/atoms",
|
||||
Roi=False, colorbarText=False)
|
||||
self.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
|
||||
|
||||
plot_name = '3D-MOT Absorption Imaging - Without Atoms'
|
||||
if not plot_name in self.MainPlotPanel.plots:
|
||||
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1',
|
||||
data_path=r"images/MOT_3D_Camera/in_situ_absorption/background",
|
||||
Roi=False, colorbarText=False)
|
||||
self.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
|
||||
|
||||
plot_name = '3D-MOT Absorption Imaging - Dark'
|
||||
if not plot_name in self.MainPlotPanel.plots:
|
||||
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name + '1',
|
||||
data_path=r"images/MOT_3D_Camera/in_situ_absorption/dark",
|
||||
Roi=False, colorbarText=False)
|
||||
self.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
|
||||
|
||||
plot_name = r'3D-MOT Absorption Imaging'
|
||||
if not plot_name in self.MainPlotPanel.plots:
|
||||
current_plotting = WidgetFakeColorPlot.WidgetFakeColorPlot(plot_name,
|
||||
data_path=r"results/absorption_imaging/absorption_imaging")
|
||||
|
||||
self.MainPlotPanel.add_plot_dock(plot_name, current_plotting)
|
||||
|
||||
absorption_imaging_transition = DyTransition.creat_Dy421()
|
||||
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)
|
||||
self.MainPlotPanel.analyse_panel.add_absorption_imaging(absorption_image, current_plotting)
|
||||
|
||||
# Add realtime plotting for atom number
|
||||
# plot_name = '3D-MOT Atom Number'
|
||||
# if not plot_name in self.MainPlotPanel.plots:
|
||||
# current_plotting = Widget1DLivingPlot.Widget1DLivingPlot(plot_name, y_data_path=('absorption_imaging', 'atom_number'), y_in_results=True)
|
||||
#
|
||||
# self.MainPlotPanel.add_plot_dock(plot_name, current_plotting)
|
||||
|
||||
self.timer = QTimer()
|
||||
self.timer.timeout.connect(self.refresh_h5_path)
|
||||
self.timer.start(1000)
|
||||
|
||||
return self
|
16
living_plot_main.py
Normal file
16
living_plot_main.py
Normal file
@ -0,0 +1,16 @@
|
||||
from living_plot_class import FigureManager
|
||||
import numpy as np
|
||||
|
||||
import sys
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
|
||||
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
h5_paths = np.empty(0)
|
||||
|
||||
figure_manager = FigureManager()
|
||||
|
||||
run = figure_manager.start_living_plot(h5_paths)
|
||||
|
||||
sys.exit(app.exec_())
|
31
living_plot_starter.py
Normal file
31
living_plot_starter.py
Normal file
@ -0,0 +1,31 @@
|
||||
import os
|
||||
import time
|
||||
|
||||
import lyse
|
||||
|
||||
|
||||
def get_pid():
|
||||
with open("living_plot.ini", 'r') as pid_file:
|
||||
pid_str = pid_file.readline()
|
||||
|
||||
return pid_str
|
||||
|
||||
|
||||
def call_living_plot():
|
||||
pid_str = get_pid()
|
||||
if pid_str == "":
|
||||
start_dire = r"living_plot_main.py"
|
||||
os.popen("python %s" % start_dire)
|
||||
|
||||
|
||||
def update_h5_path_file():
|
||||
h5_paths = lyse.h5_paths()
|
||||
|
||||
with open('h5_file_path.ini', 'w') as h5_path_file:
|
||||
h5_path_file.truncate(0)
|
||||
s = '\n'.join(h5_paths)
|
||||
h5_path_file.write(s)
|
||||
|
||||
update_h5_path_file()
|
||||
call_living_plot()
|
||||
|
13
test.py
13
test.py
@ -1,2 +1,11 @@
|
||||
import pyqtgraph.examples
|
||||
pyqtgraph.examples.run()
|
||||
# import pyqtgraph.examples
|
||||
# pyqtgraph.examples.run()
|
||||
|
||||
|
||||
import h5py
|
||||
|
||||
h5_path = r"C:/Users/Jianshun Gao/Desktop/2022-07-22_0037_MOT_3D_Imaging_4.h5"
|
||||
data_path = r"results/absorption_imaging/absorption_imaging"
|
||||
with h5py.File(h5_path, 'r') as h5_file:
|
||||
result = h5_file[data_path][()]
|
||||
print(result)
|
||||
|
@ -20,6 +20,8 @@ figure_manager = lyse.figure_manager
|
||||
|
||||
h5_paths = lyse.h5_paths()
|
||||
|
||||
print(h5_paths)
|
||||
|
||||
if lyse.spinning_top:
|
||||
# If so, use the filepath of the current shot
|
||||
h5_path = lyse.path
|
||||
@ -41,19 +43,19 @@ if not plot_name in figure_manager.MainPlotPanel.plots:
|
||||
Roi=False, colorbarText=False)
|
||||
figure_manager.MainPlotPanel.add_plot_dock(plot_name + '1', current_plotting)
|
||||
|
||||
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)
|
||||
|
||||
plot_name = '3D-MOT Absorption Imaging - Dark'
|
||||
if not plot_name in figure_manager.MainPlotPanel.plots:
|
||||
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)
|
||||
# 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)
|
||||
#
|
||||
# plot_name = '3D-MOT Absorption Imaging - Dark'
|
||||
# if not plot_name in figure_manager.MainPlotPanel.plots:
|
||||
# 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)
|
||||
|
||||
# Add plotting for absorption imaging
|
||||
plot_name = '3D-MOT Absorption Imaging'
|
||||
@ -74,9 +76,9 @@ 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)
|
||||
|
||||
figure_manager.MainPlotPanel.update_h5_paths(h5_paths)
|
||||
figure_manager.MainPlotPanel.refresh(h5_path)
|
||||
|
||||
profile.disable()
|
||||
ps = pstats.Stats(profile)
|
||||
|
Loading…
Reference in New Issue
Block a user