Better gui with optinal info label
This commit is contained in:
@@ -78,6 +78,8 @@ class Config(BaseModel):
|
||||
|
||||
class LimitValues(NamedTuple):
|
||||
wl_zero_disp: float
|
||||
soliton_ion_limit:float
|
||||
soliton_sf_limit:float
|
||||
ion_lim: float
|
||||
sf_lim: float
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ def app(config_file: os.PathLike | None = None):
|
||||
|
||||
return LimitValues(
|
||||
wl_zero_disp,
|
||||
ion_limit,
|
||||
sf_limit,
|
||||
energy(t0, w0, beta2, n2, core_radius, ion_limit),
|
||||
energy(t0, w0, beta2, n2, core_radius, sf_limit),
|
||||
)
|
||||
@@ -130,19 +132,28 @@ def app(config_file: os.PathLike | None = None):
|
||||
@app.update
|
||||
def draw_energy_limit(core_diameter_um: float, pressure_mbar: float, t_fwhm_fs: float):
|
||||
lim = compute_max_energy(core_diameter_um, pressure_mbar, t_fwhm_fs)
|
||||
if lim.ion_lim > lim.sf_lim:
|
||||
power = lim.sf_lim * 1e3 * config.rep_rate
|
||||
app[0].set_line_name(
|
||||
"Capillary", f"Capillary, max energy = {power:.0f}mW (self-focusing)"
|
||||
)
|
||||
else:
|
||||
power = lim.ion_lim * 1e3 * config.rep_rate
|
||||
app[0].set_line_name(
|
||||
"Capillary", f"Capillary, max energy = {power:.0f}mW (ionization)"
|
||||
)
|
||||
|
||||
zdw = lim.wl_zero_disp * 1e9
|
||||
app[0].set_line_data("zdw", [zdw, zdw], [-3, 3])
|
||||
app[0].set_line_name("zdw", f"ZDW = {zdw:.0f}nm")
|
||||
|
||||
info_lines = [
|
||||
f"gas = {config.gas.title()}",
|
||||
f"rep rate = {config.rep_rate*1e-3}kHz",
|
||||
f"ZDW = {zdw:.0f}nm",
|
||||
]
|
||||
if lim.ion_lim > lim.sf_lim:
|
||||
power = lim.sf_lim * 1e3 * config.rep_rate
|
||||
info_lines += [
|
||||
f"max energy = {power:.0f}mW",
|
||||
f"N = {lim.soliton_sf_limit:.1f}",
|
||||
"limited by self-focusing",
|
||||
]
|
||||
else:
|
||||
power = lim.ion_lim * 1e3 * config.rep_rate
|
||||
info_lines += [
|
||||
f"max energy = {power:.0f}mW",
|
||||
f"N = {lim.soliton_sf_limit:.1f}",
|
||||
"limited by ionization",
|
||||
]
|
||||
app.info_label.setText("\n".join(info_lines))
|
||||
|
||||
config.save()
|
||||
|
||||
@@ -7,11 +7,11 @@ from functools import cache
|
||||
from types import MethodType
|
||||
from typing import Any, Callable, Iterable, Iterator, Optional, Type, Union, overload
|
||||
|
||||
from PySide6 import QtCore, QtWidgets, QtGui
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.dockarea import Dock, DockArea
|
||||
from pyqtgraph.graphicsItems.PlotDataItem import PlotDataItem
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
MPL_COLORS = [
|
||||
"#1f77b4",
|
||||
@@ -130,8 +130,9 @@ class SliderField(Field):
|
||||
self.value_changed.emit(new_value)
|
||||
|
||||
def field_changed(self):
|
||||
try:
|
||||
new_val = self.dtype(self.field.text())
|
||||
if new_val not in self.value_to_slider_map:
|
||||
except (ValueError, TypeError):
|
||||
self.update_label()
|
||||
return
|
||||
self.value = new_val
|
||||
@@ -349,7 +350,6 @@ class Plot:
|
||||
self.add_item(key, legend_item, line)
|
||||
|
||||
def set_lim(self, *, xlim=None, ylim=None):
|
||||
|
||||
x_auto = xlim is None
|
||||
y_auto = ylim is None
|
||||
if not x_auto:
|
||||
@@ -497,6 +497,7 @@ class PlotApp:
|
||||
params_layout: QtWidgets.QVBoxLayout
|
||||
central_widget: QtWidgets.QWidget
|
||||
params_widget: QtWidgets.QWidget
|
||||
info_label: QtWidgets.QLabel
|
||||
plots: dict[str, Plot]
|
||||
params: dict[str, Field]
|
||||
__cache_widget: Optional[CacheWidget] = None
|
||||
@@ -508,13 +509,32 @@ class PlotApp:
|
||||
self.window.resize(1200, 800)
|
||||
self.central_widget = QtWidgets.QWidget()
|
||||
self.params_widget = QtWidgets.QWidget()
|
||||
self.header_widget = QtWidgets.QWidget()
|
||||
self.info_label = QtWidgets.QLabel()
|
||||
self.window.setCentralWidget(self.central_widget)
|
||||
|
||||
self.central_layout = QtWidgets.QVBoxLayout()
|
||||
self.params_layout = QtWidgets.QVBoxLayout()
|
||||
self.header_layout = QtWidgets.QHBoxLayout()
|
||||
|
||||
_pl = QtWidgets.QSizePolicy.Policy.Preferred
|
||||
info_sp = QtWidgets.QSizePolicy(_pl, _pl)
|
||||
info_sp.setHorizontalStretch(1)
|
||||
params_sp = QtWidgets.QSizePolicy(_pl, _pl)
|
||||
params_sp.setHorizontalStretch(5)
|
||||
|
||||
self.central_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.central_widget.setLayout(self.central_layout)
|
||||
self.params_widget.setLayout(self.params_layout)
|
||||
self.central_layout.addWidget(self.params_widget, stretch=0)
|
||||
self.header_widget.setLayout(self.header_layout)
|
||||
|
||||
self.params_widget.setSizePolicy(params_sp)
|
||||
self.info_label.setSizePolicy(info_sp)
|
||||
|
||||
self.central_layout.addWidget(self.header_widget)
|
||||
self.header_layout.addWidget(self.info_label)
|
||||
self.header_layout.addWidget(self.params_widget, stretch=0)
|
||||
|
||||
self.dock_area = DockArea()
|
||||
self.plots = {}
|
||||
|
||||
@@ -718,5 +738,3 @@ class PlotApp:
|
||||
if key not in self.plots:
|
||||
self.plots[key] = Plot(key, self.dock_area)
|
||||
return self.plots[key]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user