Upload files to "/"

This commit is contained in:
2026-09-30 15:20:31 +00:00
parent cc67401de9
commit 38c09a4272
4 changed files with 350 additions and 97 deletions
+20 -4
View File
@@ -94,7 +94,7 @@ NOTES ON THE MATLAB -> PYTHON TRANSLATION
numpy.heaviside(x, 0.5).
"""
__version__ = "2.5"
__version__ = "2.6"
import time
import datetime
@@ -187,6 +187,15 @@ MODE_BEAM_DEFLECTION = "beam_deflection"
MODE_PUMP_PROBE = "pump_probe"
MODES = (MODE_BEAM_DEFLECTION, MODE_PUMP_PROBE)
# Run modes, independent of the measurement mode above. Fitting is the
# program's original behaviour: a measured scan is imported and the
# calculation compared against it. Simulation imports nothing and
# computes the signal from the parameters alone, over a delay range
# entered by hand rather than taken from a file.
RUN_MODE_FITTING = "fitting"
RUN_MODE_SIMULATION = "simulation"
RUN_MODES = (RUN_MODE_FITTING, RUN_MODE_SIMULATION)
def mechanism_allowed(name: str, mode: str) -> bool:
"""Whether a mechanism may occupy a slot in the given mode. Pump
@@ -332,6 +341,8 @@ class BDFresnelParams:
# --- measurement mode (see set_mode) ---
mode: str = MODE_BEAM_DEFLECTION
# --- run mode: fit an imported scan, or simulate without one ---
run_mode: str = RUN_MODE_FITTING
# Beam-deflection settings put aside while in pump-probe mode, and
# restored on switching back: the x_0 that pump probe forces to 0,
# and the mechanism slots as they were before the non-absorptive
@@ -1157,10 +1168,13 @@ def calc_beam_params(p: BDFresnelParams) -> BDFresnelParams:
# inputs_valid.m (nested function inside BD_Fresnel_GUI.m)
# =============================================================================
def inputs_valid(p: BDFresnelParams) -> bool:
def inputs_valid(p: BDFresnelParams, require_data: bool = True) -> bool:
"""Direct port of inputs_valid.m: whether the Fit button should be
enabled. Requires physically sensible beam/material parameters AND
that data has actually been imported."""
that data has actually been imported.
require_data=False drops the last condition, for Simulation mode,
which computes the signal without importing anything."""
return bool(
p.E_p > 0
and p.tau_p_FWHM > 0
@@ -1177,7 +1191,7 @@ def inputs_valid(p: BDFresnelParams) -> bool:
and p.alpha_p >= 0
and p.d > 0
and p.l > 0
and p.data_imported
and (p.data_imported or not require_data)
)
@@ -1229,6 +1243,8 @@ def apply_mode_constraints(p: BDFresnelParams) -> None:
settings file cannot put the program in an inconsistent state."""
if p.mode not in MODES:
p.mode = MODE_BEAM_DEFLECTION
if p.run_mode not in RUN_MODES:
p.run_mode = RUN_MODE_FITTING
if p.mode == MODE_PUMP_PROBE:
p.x_0 = 0.0
for i, m in enumerate(p.mech):