Compare commits
10
Commits
61dbd0452b
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49bc1dc644 | ||
|
|
520542ee1b | ||
|
|
1bc882e163 | ||
|
|
50d0d27464 | ||
|
|
45efc8239d | ||
|
|
d7ab1b823e | ||
|
|
98e95180cc | ||
|
|
38c09a4272 | ||
|
|
cc67401de9 | ||
|
|
6d7996ff30 |
+287
-5
@@ -4,7 +4,292 @@ All notable changes to BD Fresnel are documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||||
|
|
||||||
## [Unreleased]
|
## [3.0] - 2026-11-14
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Semi-analytical** algorithm, selectable from a third toggle in the
|
||||||
|
Operation mode box alongside **Fresnel propagation**:
|
||||||
|
- Instead of propagating the exit field to the detector by FFT, it
|
||||||
|
uses closed-form expressions for the power difference and total at
|
||||||
|
the detector, already integrated over the detector plane. Only an
|
||||||
|
integral over time at each delay remains.
|
||||||
|
- The time window runs +/- 5T about each delay, where T = tau_p/tau_e.
|
||||||
|
- Transmission is the energy total normalised to its value before the
|
||||||
|
pump arrives: the first delay point when fitting, and
|
||||||
|
min(-3 rho, -3) tau_e when simulating, so a thin sample with
|
||||||
|
rho -> 0 still normalises away from the peak.
|
||||||
|
- `X_num` and `X_max` are disabled in this mode: the expressions are
|
||||||
|
already integrated over space, so there is no spatial grid.
|
||||||
|
- Applies to both measurement modes. In pump probe the probe is
|
||||||
|
centred, x_0 = 0, so the deflection term vanishes identically and
|
||||||
|
the transmission alone is calculated.
|
||||||
|
- Both algorithms are kept so results can be compared. Switching
|
||||||
|
discards the current result, which belongs to the other method.
|
||||||
|
- The algorithm is saved with the other settings and recorded in the
|
||||||
|
parameter log.
|
||||||
|
- The absorptive term in the deflection expression carries a
|
||||||
|
PROVISIONAL coefficient, `SA_ABSORPTIVE_FACTOR`. As derived, that
|
||||||
|
term matched neither the sign nor the magnitude of the Fresnel
|
||||||
|
result: a purely absorptive mechanism disagreed by a factor of
|
||||||
|
about -69, with correlation exactly -1. Dividing by
|
||||||
|
D = d / (pi w_0_p^2 / lambda_p) = d / z_0_p accounts for the distance and
|
||||||
|
wavelength dependence exactly, and is independent of sample
|
||||||
|
thickness at constant alpha_2_exp*l; the remaining -1/(1 + 2W^2) was
|
||||||
|
measured against the Fresnel path rather than derived. With it the
|
||||||
|
two methods agree to 0.5% for mechanisms with a refractive part and
|
||||||
|
4.5% for purely absorptive ones. It is isolated in one function
|
||||||
|
pending a corrected derivation.
|
||||||
|
|
||||||
|
- The parameter log's `Calculated Parameters (pump)` section reports
|
||||||
|
`sigma_e`, the normalised pump linear absorption `alpha_e * L / 2`.
|
||||||
|
It sits next to `T_lin`, which restates it: with no pump two-photon
|
||||||
|
absorption `T_lin = (1 - R_p) exp(-2 sigma_e)`. Read from the
|
||||||
|
parameters rather than the result, so it is reported for either
|
||||||
|
algorithm.
|
||||||
|
|
||||||
|
- The `Other` panel and the parameter log's `Other` section both report
|
||||||
|
`eta (peak)` and `Gamma (peak)`, the largest nonlinear phase and
|
||||||
|
absorption exponent anywhere on the grid, from whichever algorithm
|
||||||
|
produced the result. These are the only readouts in those panels that
|
||||||
|
come from the result rather than from the parameters, since they are
|
||||||
|
peaks over the whole (T, T_d) grid and cannot be had without running
|
||||||
|
the calculation. They therefore show `--` until a Fit or Simulate
|
||||||
|
completes, and return to `--` whenever that result is discarded, so a
|
||||||
|
stale phase is never displayed beside freshly edited parameters.
|
||||||
|
`eta (peak)` is the yardstick for the semi-analytical algorithm's
|
||||||
|
validity: its `dP` is first order in the response while Fresnel
|
||||||
|
propagation keeps every order, so the two agree only while the phase
|
||||||
|
is small. On the 4-layer mechanisms the peak of `DeltaEoE` sits at
|
||||||
|
the same delay to within 0.0003 tau_e at `eta (peak)` = 0.14, but
|
||||||
|
0.0035 at 1.41, 0.077 at 5.6 and 0.36 at 14.1. Holding `eta (peak)`
|
||||||
|
fixed, the agreement is unaffected by sample thickness (0.05 to
|
||||||
|
2 mm), by walk-off (`rho` 0.04 to 1.7) and by pump absorption
|
||||||
|
(`sigma_e` 0 to 10), so this one number sets the regime. Both
|
||||||
|
algorithms report it to within 2e-5 of each other.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Both beams are now explicitly subscripted: the pump carries `_e`
|
||||||
|
(excitation) and the probe carries `_p`.** This restores the
|
||||||
|
convention the original MATLAB used, which the Python port had
|
||||||
|
partly inverted (`_p` for the pump) and partly dropped (no suffix
|
||||||
|
for the probe). No beam quantity is unsubscripted any more; the only
|
||||||
|
unsuffixed parameters left are the ones belonging to neither beam --
|
||||||
|
the sampling grid, the sample geometry (`l`, `d`, `shift`), the
|
||||||
|
relative offset `x_0`, and the walk-off `rho`.
|
||||||
|
|
||||||
|
| pump: was | now | | probe: was | now |
|
||||||
|
|-----|-----|-|-----|-----|
|
||||||
|
| `E_p` | `E_e` | | `tau_FWHM` | `tau_p_FWHM` |
|
||||||
|
| `tau_p_FWHM` | `tau_e_FWHM` | | `w_0` | `w_0_p` |
|
||||||
|
| `w_0p` | `w_0_e` | | `lambda_` | `lambda_p` |
|
||||||
|
| `lambda_p` | `lambda_e` | | `R` | `R_p` |
|
||||||
|
| `R_p` | `R_e` | | `alpha` | `alpha_p` |
|
||||||
|
| `alpha_p` | `alpha_e` | | `n` | `n_p` |
|
||||||
|
| `n_p` | `n_e` | | `dndl` | `dndl_p` |
|
||||||
|
| `dndl_p` | `dndl_e` | | `tau` | `tau_p` |
|
||||||
|
| `alpha_2d` | `alpha_2d_e` | | `ng` | `ng_p` |
|
||||||
|
| `tau_p` | `tau_e` | | `z_0` | `z_0_p` |
|
||||||
|
| `sigma_p` | `sigma_e` | | `Tlin` | `Tlin_p` |
|
||||||
|
| `I_0_p` | `I_0_e` | | | |
|
||||||
|
| `ng_p` | `ng_e` | | | |
|
||||||
|
| `z_0_p` | `z_0_e` | | | |
|
||||||
|
| `Tlin_p` | `Tlin_e` | | | |
|
||||||
|
| `sigma_p2` / `sigma_p20` | `sigma_e2` / `sigma_e20` | | | |
|
||||||
|
| `a_p_0`, `W_0_p`, `I_p_pulse` | `a_e_0`, `W_0_e`, `I_e_pulse` | | | |
|
||||||
|
|
||||||
|
Note that six probe names -- `tau_p_FWHM`, `lambda_p`, `R_p`,
|
||||||
|
`alpha_p`, `n_p`, `dndl_p` -- are spelled exactly like what were
|
||||||
|
**pump** names before this release. Reading an old log or settings
|
||||||
|
file alongside a new one needs care; see the settings note below for
|
||||||
|
how the program itself is protected.
|
||||||
|
|
||||||
|
The pump pass renamed 389 identifier occurrences textually; the
|
||||||
|
probe pass was done by rewriting 116 exact AST node positions
|
||||||
|
instead, because `n`, `R`, `alpha` and `tau` are overloaded in this
|
||||||
|
codebase (lambda parameters, the author's initials in the copyright
|
||||||
|
line, the semi-analytical formula's geometric `R`, a diagnostics
|
||||||
|
dict key) and no text pattern distinguishes them.
|
||||||
|
|
||||||
|
| was | now | | was | now |
|
||||||
|
|-----|-----|-|-----|-----|
|
||||||
|
| `E_p` | `E_e` | | `tau_p` | `tau_e` |
|
||||||
|
| `tau_p_FWHM` | `tau_e_FWHM` | | `sigma_p` | `sigma_e` |
|
||||||
|
| `w_0p` | `w_0_e` | | `I_0_p` | `I_0_e` |
|
||||||
|
| `lambda_p` | `lambda_e` | | `ng_p` | `ng_e` |
|
||||||
|
| `R_p` | `R_e` | | `z_0_p` | `z_0_e` |
|
||||||
|
| `alpha_p` | `alpha_e` | | `Tlin_p` | `Tlin_e` |
|
||||||
|
| `n_p` | `n_e` | | `sigma_p2` | `sigma_e2` |
|
||||||
|
| `dndl_p` | `dndl_e` | | `sigma_p20` | `sigma_e20` |
|
||||||
|
| `alpha_2d` | `alpha_2d_e` | | `a_p_0` | `a_e_0` |
|
||||||
|
|
||||||
|
`w_0p` gains the separating underscore it was missing, so the field
|
||||||
|
name finally matches the variable that held it (`w_0_p`) and its
|
||||||
|
siblings `z_0_e` and `I_0_e`. `alpha_2d_e` keeps the `d` for
|
||||||
|
degenerate.
|
||||||
|
|
||||||
|
- **The Electronic mechanism's parameters are renamed `alpha_2e` ->
|
||||||
|
`alpha_2el` and `n_2e` -> `n_2el`**, since their `e` meant
|
||||||
|
*electronic* and would otherwise collide with `_e` for excitation --
|
||||||
|
the pump's degenerate two-photon coefficient would have wanted the
|
||||||
|
name `alpha_2e`, which was taken. `_e` now means excitation and
|
||||||
|
nothing else.
|
||||||
|
|
||||||
|
- `BD_3_level_triplet`, `I_e_func` and `excite_prop` needed no
|
||||||
|
renaming at all: transliterated from the MATLAB, they already used
|
||||||
|
`_e` for the pump and `_p` for the probe, so `n_g_p`, `v_p` and
|
||||||
|
`I_p` inside them were correct all along. With both beams now
|
||||||
|
subscribed to that convention, the whole file reads against the
|
||||||
|
MATLAB without translation.
|
||||||
|
|
||||||
|
- **`last_settings.json` written by an earlier version is now refused
|
||||||
|
rather than misread.** Saved settings carry a `settings_schema`
|
||||||
|
stamp, and a file without the current one is rejected with a message
|
||||||
|
explaining why. This is not housekeeping: because six probe field
|
||||||
|
names are spelled exactly like former pump keys, loading an old file
|
||||||
|
by name alone would have installed the pump's wavelength, index,
|
||||||
|
reflectivity, absorption and dispersion as the *probe's* -- every
|
||||||
|
number plausible, every result wrong. Re-enter the parameters once
|
||||||
|
and they save in the new layout. Any other unrecognised key is still
|
||||||
|
dropped with a note on stderr.
|
||||||
|
|
||||||
|
- Log and panel labels follow their fields on both sides: `n_g_e`,
|
||||||
|
`sigma_e`, `T_lin_e`, `z_0_e`, `I_0_e` for the pump and `n_g_p`,
|
||||||
|
`T_lin_p`, `z_0_p` for the probe, with the beam parameters and
|
||||||
|
material blocks likewise. The GUI's pump calculated-parameters panel
|
||||||
|
also gains a `sigma_e` readout, which it had not displayed before.
|
||||||
|
|
||||||
|
- `T_lin_p` and `T_lin_e` are labelled `T_lin_p (transmission)` and
|
||||||
|
`T_lin_e (transmission)` in both the panel and the log, so the
|
||||||
|
quantity is named and not just abbreviated. The log's value column
|
||||||
|
moved from 25 to 29 to fit them, and the panel's label column from 20
|
||||||
|
to 23 characters -- which also squares up `z_0_p (Rayleigh range)`,
|
||||||
|
`z_0_e (Rayleigh range)` and `I_0_e (peak irradiance)`, all of which
|
||||||
|
had been overrunning the old 20 and pushing their own values out of
|
||||||
|
line.
|
||||||
|
|
||||||
|
- The rename is numerically inert: across 8 mechanism types x 2
|
||||||
|
algorithms x 3 pump-absorption configurations (49 cases, 3275
|
||||||
|
values), `DeltaEoE`, `T`, `Delta_n`, `eta_peak` and `Gamma_peak` are
|
||||||
|
bit-identical to the pre-rename code, and `pyflakes` reports zero
|
||||||
|
warnings before and after.
|
||||||
|
|
||||||
|
- Transmission y-axis tick labels are limited to three significant
|
||||||
|
digits, so "99.75" reads "99.8". The count is a floor rather than a
|
||||||
|
cap: a shallow scan spanning a few hundredths of a percent would
|
||||||
|
round every tick to "100", so digits are added only where that would
|
||||||
|
happen. The deflection axis is unaffected.
|
||||||
|
|
||||||
|
- The reference list in the README and the parameter log follows Optica
|
||||||
|
style: every author listed, initials first, abbreviated journal,
|
||||||
|
volume, full page range, year. Author lists and page ranges were
|
||||||
|
checked against the published papers.
|
||||||
|
- The duplicate supplementary-material citation is dropped, leaving two
|
||||||
|
references.
|
||||||
|
- The parameter log is written as UTF-8. The citations use typographic
|
||||||
|
quotes and an en dash, which the locale's encoding cannot always
|
||||||
|
represent.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The instantaneous (Electronic) response for a sample with both
|
||||||
|
walk-off and pump absorption is evaluated through the scaled
|
||||||
|
complementary error function `erfcx` instead of the form in
|
||||||
|
`BD_Fresnel_func_ni.m`. That form multiplied `exp(sigma_e^2/rho^2 +
|
||||||
|
2 sigma_e u/rho)` by a difference of error functions falling to zero,
|
||||||
|
so the product was lost to cancellation well before it overflowed:
|
||||||
|
at `rho = 0.4336` (l = 0.5 mm) it was already wrong over 8.6% of the
|
||||||
|
delay axis at `sigma_e = 2.5` (alpha_e = 100 cm^-1), **returning
|
||||||
|
exactly 0.0 with no NaN to signal it**, and returned NaN above
|
||||||
|
`sigma_e = 3`. The usable ceiling on `alpha_e` for an Electronic
|
||||||
|
mechanism at that thickness was therefore about 60 cm^-1, not the
|
||||||
|
~120 where NaN first appeared. The rearrangement is algebraic, with
|
||||||
|
every surviving exponent non-positive; it reproduces the original
|
||||||
|
evaluated at 600 decimal digits to 1e-16..3e-13 relative over
|
||||||
|
`sigma_e` = 0.25 to 10 and `u` = -3 to 18, both where the original
|
||||||
|
works and where it does not.
|
||||||
|
- Pump absorption is applied to non-instantaneous mechanisms when the
|
||||||
|
walk-off is exactly zero. Substituting `T1 = (T+T_d) - rho +
|
||||||
|
rho*zeta` shows the `rho != 0` branch to be a depth average over
|
||||||
|
`atten_fac`, whose `rho -> 0` limit is the response at one instant
|
||||||
|
times the *mean* of `atten_fac`; the original used the bare response.
|
||||||
|
The dropped factor is `(1 - exp(-2 sigma_e))/(2 sigma_e)` for linear
|
||||||
|
pump absorption, so the response was previously **independent of
|
||||||
|
`alpha_e` altogether** in this case -- identical at `alpha_e` = 0 and
|
||||||
|
200 cm^-1. It was 1.27x too large at `alpha_e` = 10 cm^-1 and
|
||||||
|
l = 0.5 mm, and 10x at 200 cm^-1. The two branches now agree to nine
|
||||||
|
digits across `rho = 0`. This affects only samples with `ng_p` exactly
|
||||||
|
equal to `ng_e` (for example no dispersion entered at either
|
||||||
|
wavelength) *and* non-zero pump absorption; with `alpha_e = alpha_2d_e
|
||||||
|
= 0` the mean is exactly 1 and results are bit-identical to before.
|
||||||
|
- Pump absorption through the sample depth, `atten_fac`, is computed
|
||||||
|
from the closed-form solution of
|
||||||
|
`dI_e/dz = -alpha_e I_e - alpha_2d_e I_e^2` rather than the two-branch
|
||||||
|
expression carried over from `BD_Fresnel_func_ni.m`. That expression's
|
||||||
|
pump two-photon branch, `sqrt((B1 B2)/sigma_e)`, failed three ways: it
|
||||||
|
did not reduce to its own `sigma_e2 == 0` branch as `alpha_2d_e -> 0`
|
||||||
|
(it decayed at half the correct rate), it divided by zero whenever
|
||||||
|
`alpha_e` was zero, and it took the square root of a negative number
|
||||||
|
whenever `sigma_e20 > sigma_e`. The net effect was that **every run
|
||||||
|
combining a non-zero `alpha_2d_e` with a non-instantaneous mechanism
|
||||||
|
returned NaN at every delay** -- pump two-photon absorption worked
|
||||||
|
only for the Electronic mechanism, which does not use `atten_fac`.
|
||||||
|
Dropping the stray square root recovers that expression as the
|
||||||
|
linearisation of the exact one in `sigma_e20`, which is how the
|
||||||
|
intent was identified. Results for `alpha_2d_e = 0` are bit-identical
|
||||||
|
to before; the new form agrees with numerical integration of the
|
||||||
|
pump propagation equation to 2e-12 relative over `sigma_e` and
|
||||||
|
`sigma_e20` from 0 to 20, including both limits.
|
||||||
|
- A negative `alpha_2d_e` large enough to make the pump diverge inside
|
||||||
|
the sample (two-photon gain, no finite depth average) is now refused
|
||||||
|
with a message naming the largest `|alpha_2d_e|` that works for the
|
||||||
|
current thickness and pump irradiance, rather than silently returning
|
||||||
|
a meaningless attenuation of order 1e12.
|
||||||
|
- `mpmath` is imported only where it is used, in the pump two-photon
|
||||||
|
absorption term. Importing it at module level made an optional
|
||||||
|
dependency fatal at startup, so the program would not run at all
|
||||||
|
without it. If that term is ever reached without mpmath installed,
|
||||||
|
the error now says which package is missing and why.
|
||||||
|
|
||||||
|
## [2.6] - 2026-09-30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Simulation** run mode: a second toggle in the Operation mode box,
|
||||||
|
offering **Fitting** and **Simulation**. Fitting is the default and
|
||||||
|
behaves as before.
|
||||||
|
- Simulation mode, for computing a signal without a measurement:
|
||||||
|
- No file is imported. **Import...** and the data column and
|
||||||
|
delimiter fields are disabled.
|
||||||
|
- The delay range is entered as `T_d_min` and `T_d_max` (in `tau_p`)
|
||||||
|
in the Simulation parameters box. In Fitting mode these are taken
|
||||||
|
from the imported scan and the fields are disabled.
|
||||||
|
- Only the calculated curves are plotted, without data markers, and
|
||||||
|
the plot legend reads **Simulated** rather than Fit.
|
||||||
|
- The **Fit** button is relabelled **Simulate**, and is enabled by
|
||||||
|
valid parameters alone rather than by an imported file.
|
||||||
|
- The export holds the calculated signals on their own delay grid,
|
||||||
|
with no data columns to pair them with. The parameter log omits the
|
||||||
|
import path and the data column section.
|
||||||
|
- The mode combines with the measurement mode: Pump probe and
|
||||||
|
Simulation together give a single Transmission panel and a
|
||||||
|
two-column table, as Pump probe does when fitting.
|
||||||
|
- The run mode is saved with the other settings and recorded in the
|
||||||
|
parameter log.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- The **Mode** box is renamed **Operation mode** and moved to the top of
|
||||||
|
the parameter panel, above Data columns. The parameter log and status
|
||||||
|
messages use the new name, and the log records both modes on one line.
|
||||||
|
- Changing run mode discards the current result, which described the
|
||||||
|
other mode's delay range or a measurement the new mode does not show.
|
||||||
|
Switching to Simulation sets the imported scan aside and switching
|
||||||
|
back reloads it. The run mode cannot be changed while a fit runs.
|
||||||
|
- `inputs_valid` takes a `require_data` argument, so Simulation can
|
||||||
|
enable its action button without an imported file. Fitting is
|
||||||
|
unaffected.
|
||||||
|
|
||||||
## [2.5] - 2026-09-21
|
## [2.5] - 2026-09-21
|
||||||
|
|
||||||
@@ -38,6 +323,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
mode's column requirements. A file the new mode cannot use is cleared
|
mode's column requirements. A file the new mode cannot use is cleared
|
||||||
with an explanation, and loaded again on switching back. The mode
|
with an explanation, and loaded again on switching back. The mode
|
||||||
cannot be changed while a fit runs.
|
cannot be changed while a fit runs.
|
||||||
|
- The source files carry the GPLv3 notice.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@@ -61,10 +347,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|||||||
is hidden when it collides with its neighbour. A rounding error let some
|
is hidden when it collides with its neighbour. A rounding error let some
|
||||||
such labels through.
|
such labels through.
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- The source files carry the GPLv3 notice.
|
|
||||||
|
|
||||||
## [2.4] - 2026-09-21
|
## [2.4] - 2026-09-21
|
||||||
|
|
||||||
First release recorded in this changelog. Earlier history is not documented
|
First release recorded in this changelog. Earlier history is not documented
|
||||||
|
|||||||
@@ -4,17 +4,21 @@ Beam-deflection pump–probe simulator and fitting tool. A Python port of the
|
|||||||
MATLAB `BD_Fresnel_GUI` suite.
|
MATLAB `BD_Fresnel_GUI` suite.
|
||||||
|
|
||||||
The program models a weak probe beam crossing a sample that has been excited by
|
The program models a weak probe beam crossing a sample that has been excited by
|
||||||
a strong pump, propagates the perturbed probe field to a detector by Fresnel
|
a strong pump, propagates the perturbed probe field to the detector and computes
|
||||||
diffraction, and computes the transmission `T` and normalised beam deflection
|
the transmission `T` and normalised beam deflection `ΔE/E` as a function of
|
||||||
`ΔE/E` as a function of pump–probe delay. Measured scans can be imported and
|
pump–probe delay. Measured scans can be imported and compared against the
|
||||||
compared against the simulation, and the result exported as data, a log, and
|
simulation, and the result exported as data, a log, and publication-sized
|
||||||
publication-sized figures.
|
figures.
|
||||||
|
|
||||||
Two measurement modes are supported. **Beam deflection** fits both signals.
|
Two measurement modes are supported. **Beam deflection** fits both signals.
|
||||||
**Pump probe** is for measurements with the probe centred on the pump, where
|
**Pump probe** is for measurements with the probe centred on the pump, where
|
||||||
there is no deflection: it fits the transmission alone, and needs only delay
|
there is no deflection: it fits the transmission alone, and needs only delay
|
||||||
and transmission data.
|
and transmission data.
|
||||||
|
|
||||||
|
The program also runs without a measurement. In **Simulation** mode nothing is
|
||||||
|
imported: the signal is computed from the parameters alone, over a delay range
|
||||||
|
entered by hand, and only the calculated curves are plotted and exported.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
@@ -27,10 +31,17 @@ and transmission data.
|
|||||||
parameter `rho`.
|
parameter `rho`.
|
||||||
- Excited-state absorption via a five-level population model (S₀, S₁, S₂, T₁,
|
- Excited-state absorption via a five-level population model (S₀, S₁, S₂, T₁,
|
||||||
T₂) solved through the sample depth for a range of radial irradiances.
|
T₂) solved through the sample depth for a range of radial irradiances.
|
||||||
- Side-by-side transmission and deflection plots with imported data overlaid.
|
- Side-by-side transmission and deflection plots, with imported data overlaid
|
||||||
|
when there is any.
|
||||||
- Beam deflection and pump probe measurement modes. Pump probe reads a
|
- Beam deflection and pump probe measurement modes. Pump probe reads a
|
||||||
two-column delay/transmission scan, fixes the probe on the pump axis, and
|
two-column delay/transmission scan, fixes the probe on the pump axis, and
|
||||||
offers only the mechanisms that can change the transmission.
|
offers only the mechanisms that can change the transmission.
|
||||||
|
- Fitting and simulation run modes. Simulation computes the signal with no
|
||||||
|
data imported, over a delay range entered in the panel.
|
||||||
|
- Two interchangeable algorithms. Fresnel propagation carries the exit field to
|
||||||
|
the detector by FFT; the semi-analytical method uses closed-form detector
|
||||||
|
power expressions instead, needing no spatial grid and running about 32x
|
||||||
|
faster, at the cost of holding only to first order in the nonlinear response.
|
||||||
- Optional diagnostic figures showing each mechanism's response function before
|
- Optional diagnostic figures showing each mechanism's response function before
|
||||||
and after convolution, plus the ESA populations and beam transmissions.
|
and after convolution, plus the ESA populations and beam transmissions.
|
||||||
- Export of the data/fit comparison, a full parameter log, and figures at
|
- Export of the data/fit comparison, a full parameter log, and figures at
|
||||||
@@ -62,18 +73,31 @@ python bd_fresnel_gui.py
|
|||||||
The window opens with the parameter panel on the left and three tabs on the
|
The window opens with the parameter panel on the left and three tabs on the
|
||||||
right: **Fitting**, **Diagnostics**, and **Parameter log**.
|
right: **Fitting**, **Diagnostics**, and **Parameter log**.
|
||||||
|
|
||||||
A typical session:
|
Fitting a measured scan:
|
||||||
|
|
||||||
1. Set the **Data columns** to match your file, and the delimiter.
|
1. Under **Operation mode**, choose **Beam deflection** or **Pump probe**,
|
||||||
2. Choose the **Mode**: Beam deflection or Pump probe.
|
leave the second toggle on **Fitting**, and pick an algorithm on the third:
|
||||||
|
**Fresnel propagation** or the faster **Semi-analytical**.
|
||||||
|
2. Set the **Data columns** to match your file, and the delimiter.
|
||||||
3. Press **Import…** and choose a scan. The plots show the measured data.
|
3. Press **Import…** and choose a scan. The plots show the measured data.
|
||||||
4. Fill in the beam, material and geometry parameters, and configure one or
|
4. Fill in the beam, material and geometry parameters, and configure one or
|
||||||
more mechanisms with the **Params…** buttons.
|
more mechanisms with the **Params…** buttons.
|
||||||
5. Press **Fit** to run the simulation and overlay it on the data.
|
5. Press **Fit** to run the simulation and overlay it on the data.
|
||||||
6. Press **Export…** to write the results.
|
6. Press **Export…** to write the results.
|
||||||
|
|
||||||
**Fit** stays disabled until a file is imported, and **Export** until a fit has
|
Simulating without a measurement:
|
||||||
completed.
|
|
||||||
|
1. Under **Operation mode**, choose **Simulation**. **Import…** and the data
|
||||||
|
column fields are disabled, and **Fit** becomes **Simulate**. The algorithm
|
||||||
|
toggle works the same way as in Fitting mode.
|
||||||
|
2. Set `T_d_min` and `T_d_max` in **Simulation parameters** to the delay range
|
||||||
|
to compute over. In Fitting mode these come from the imported file, so they
|
||||||
|
are editable only here.
|
||||||
|
3. Fill in the parameters and mechanisms as above.
|
||||||
|
4. Press **Simulate**, then **Export…**.
|
||||||
|
|
||||||
|
**Fit** stays disabled until a file is imported; **Simulate** needs only valid
|
||||||
|
parameters. **Export** stays disabled until a fit or simulation has completed.
|
||||||
|
|
||||||
Changing the mode, a column number or the delimiter re-reads the imported file.
|
Changing the mode, a column number or the delimiter re-reads the imported file.
|
||||||
Any fit is discarded, since it belonged to the previous settings. If the file
|
Any fit is discarded, since it belonged to the previous settings. If the file
|
||||||
@@ -91,7 +115,7 @@ deflection needs three columns and pump probe two; which ones is set in the
|
|||||||
quantity must come from a different column.
|
quantity must come from a different column.
|
||||||
|
|
||||||
| Quantity | Units | Default column | Needed in |
|
| Quantity | Units | Default column | Needed in |
|
||||||
| --- | --- | --- | --- |
|
|----------|------------------------------|----------------|----------------------|
|
||||||
| `τ_d` | fs | 1 | both modes |
|
| `τ_d` | fs | 1 | both modes |
|
||||||
| `ΔE/E` | fractional | 2 | Beam deflection only |
|
| `ΔE/E` | fractional | 2 | Beam deflection only |
|
||||||
| `T` | fractional (1.0 = no change) | 3 | both modes |
|
| `T` | fractional (1.0 = no change) | 3 | both modes |
|
||||||
@@ -104,78 +128,137 @@ to split on any run of whitespace.
|
|||||||
### Data columns (1-indexed)
|
### Data columns (1-indexed)
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|-------------------|---------|---------------------------------------|
|
|-------------------|---------|---------------------------------|
|
||||||
| `tau_d column` | `1` | Delay column (fs) |
|
| `tau_d column` | `1` | Delay column (fs) |
|
||||||
| `T column` | `3` | Transmission data column |
|
| `T column` | `3` | Transmission data column |
|
||||||
| `DeltaEoE column` | `2` | Deflection data column |
|
| `DeltaEoE column` | `2` | Deflection data column |
|
||||||
| `Delimiter` | `,` | Data column delimiter character |
|
| `Delimiter` | `,` | Data column delimiter character |
|
||||||
|
|
||||||
### Mode
|
### Operation mode
|
||||||
|
|
||||||
| Option | Effect |
|
Three independent toggles. Any combination is valid.
|
||||||
|-------------------|-------------------------------------------------|
|
|
||||||
| `Beam deflection` | Transmission and deflection, offset probe |
|
| Toggle | Option | Effect |
|
||||||
| `Pump probe` | Transmission only, centered probe |
|
|-------------|-----------------------|--------------------------------------------------|
|
||||||
|
| Measurement | `Beam deflection` | Transmission and deflection, offset probe |
|
||||||
|
| | `Pump probe` | Transmission only, centered probe |
|
||||||
|
| Run | `Fitting` | Compare the calculation against an imported scan |
|
||||||
|
| | `Simulation` | Calculate without a scan, over an entered range |
|
||||||
|
| Algorithm | `Fresnel propagation` | Propagate the exit field to the detector by FFT |
|
||||||
|
| | `Semi-analytical` | Closed-form detector power, no spatial grid |
|
||||||
|
|
||||||
|
#### Algorithm
|
||||||
|
|
||||||
|
**Fresnel propagation** is the original method. The field at the exit face is
|
||||||
|
built on an (x, y) grid, propagated to the detector by FFT, and integrated over
|
||||||
|
the detector halves to get the power difference and total at each instant.
|
||||||
|
|
||||||
|
**Semi-analytical** skips the propagation. It evaluates closed-form expressions
|
||||||
|
for the detector power difference `dP` and total `P`, already integrated over
|
||||||
|
the detector plane, then integrates each over time at every delay to get the
|
||||||
|
energy difference `dE` and total `E`. The deflection is `dE/E` and the
|
||||||
|
transmission is `E` normalised. With no spatial grid to size, `X_num` and
|
||||||
|
`X_max` are greyed out; every other parameter, `Delta_n` included, is
|
||||||
|
unaffected. On the four-layer graphene example it runs in 0.11 s against 3.65 s,
|
||||||
|
about **32x faster**.
|
||||||
|
|
||||||
|
The trade-off is that `dP` is **first order in the nonlinear response**, where
|
||||||
|
the Fresnel path keeps every order. The two therefore agree only while the
|
||||||
|
phase is small, which the `eta (peak)` line of the parameter log reports:
|
||||||
|
|
||||||
|
| `eta (peak)` | Peak of `DeltaEoE` displaced by |
|
||||||
|
|--------------|---------------------------------|
|
||||||
|
| 0.14 rad | 0.0003 tau_e |
|
||||||
|
| 1.41 rad | 0.0035 tau_e |
|
||||||
|
| 5.64 rad | 0.077 tau_e |
|
||||||
|
| 14.1 rad | 0.36 tau_e |
|
||||||
|
|
||||||
|
Below roughly 1 rad the two are interchangeable, and the four-layer graphene
|
||||||
|
example sits at 0.049 rad with a correlation of 1.000000 and amplitudes within
|
||||||
|
0.5%. Above a few rad the semi-analytical curve shifts noticeably and is no
|
||||||
|
longer a substitute. Sample thickness, walk-off and pump absorption do not
|
||||||
|
themselves affect the agreement once `eta (peak)` is held fixed.
|
||||||
|
|
||||||
|
The remaining 0.5% amplitude offset is the on-axis approximation: the Fresnel
|
||||||
|
path attenuates by `exp(-2 a_e^2 Gamma)` across the probe profile, where `a_e`
|
||||||
|
is the pump amplitude profile, while the semi-analytical form uses the on-axis
|
||||||
|
`exp(-2 x_0^2)`.
|
||||||
|
|
||||||
|
One coefficient in `dP`'s absorptive term, `SA_ABSORPTIVE_FACTOR`, is at present
|
||||||
|
fitted against the Fresnel path rather than derived. It is isolated in a single
|
||||||
|
function in `bd_fresnel_core.py`, with the measurements behind it recorded
|
||||||
|
there.
|
||||||
|
|
||||||
|
The transmission needs a reference delay, taken from before the pump arrives.
|
||||||
|
In **Fitting** mode it is the first delay point of the imported scan; in
|
||||||
|
**Simulation** mode it is `min(-3 rho, -3)` tau_e, which follows the walk-off
|
||||||
|
when that is the larger scale and is three pulse widths otherwise, so a thin
|
||||||
|
sample still normalises away from the peak.
|
||||||
|
|
||||||
### Simulation parameters
|
### Simulation parameters
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|---------|---------------------------------------|
|
|-----------|---------|-------------------------------------------------|
|
||||||
| `X_num` | `50` | Number of spatial points |
|
| `X_num` | `50` | Number of spatial points, Fresnel only |
|
||||||
| `X_max` | `5.0` | Range of spatial sampling (w_0) |
|
| `X_max` | `5.0` | Range of spatial sampling (w_0_p), Fresnel only |
|
||||||
| `T_num` | `100` | Number of temporal points |
|
| `T_num` | `100` | Number of temporal points |
|
||||||
| `T_max` | `5.0` | Range of temporal sampling (tau_p) |
|
| `T_max` | `5.0` | Range of temporal sampling (tau_e) |
|
||||||
| `T_d_num` | `150` | Number of delay points over range |
|
| `T_d_num` | `150` | Number of delay points over range |
|
||||||
|
| `T_d_min` | `-5.0` | Delay range start (tau_e), Simulation only |
|
||||||
|
| `T_d_max` | `5.0` | Delay range end (tau_e), Simulation only |
|
||||||
|
|
||||||
|
`X_num` and `X_max` size the spatial grid the Fresnel method propagates, so the
|
||||||
|
semi-analytical method greys them out.
|
||||||
|
|
||||||
### Excitation beam parameters
|
### Excitation beam parameters
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|---------|---------------------------------------|
|
|--------------|---------|----------------------------------|
|
||||||
| `E_p` | `1.36` | Excitation pulse energy (uJ) |
|
| `E_e` | `1.36` | Excitation pulse energy (uJ) |
|
||||||
| `tau_p_FWHM` | `55.0` | Excitation pulse duration (fs) |
|
| `tau_e_FWHM` | `55.0` | Excitation pulse duration (fs) |
|
||||||
| `w_0p` | `246.0` | Excitation beam waist (um) |
|
| `w_0_e` | `246.0` | Excitation beam waist (um) |
|
||||||
| `lambda_p` | `800.0` | Excitation pulse wavelength (nm) |
|
| `lambda_e` | `800.0` | Excitation pulse wavelength (nm) |
|
||||||
|
|
||||||
### Probe beam parameters
|
### Probe beam parameters
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|---------|---------------------------------------|
|
|--------------|---------|-----------------------------|
|
||||||
| `tau_FWHM` | `60.0` | Probe pulse duration (fs) |
|
| `tau_p_FWHM` | `60.0` | Probe pulse duration (fs) |
|
||||||
| `w_0` | `43.0` | Probe beam waist (um) |
|
| `w_0_p` | `43.0` | Probe beam waist (um) |
|
||||||
| `lambda` | `650.0` | Probe pulse wavelength (nm) |
|
| `lambda_p` | `650.0` | Probe pulse wavelength (nm) |
|
||||||
|
|
||||||
### Material parameters at excitation wavelength
|
### Material parameters at excitation wavelength
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|-------------|-----------------------------------|
|
|--------------|-------------|--------------------------------|
|
||||||
| `R_p` | `0.0` | Reflectivity |
|
| `R_e` | `0.0` | Reflectivity |
|
||||||
| `alpha_p` | `0.0` | Linear absorption (cm^-1) |
|
| `alpha_e` | `0.0` | Linear absorption (cm^-1) |
|
||||||
| `n_p` | `1.4533` | Linear index |
|
| `n_e` | `1.4533` | Linear index |
|
||||||
| `dndl_p` | `-0.017284` | First order dispersion (um^-1) |
|
| `dndl_e` | `-0.017284` | First order dispersion (um^-1) |
|
||||||
| `alpha_2d` | `0.0` | 2 photon absorption (e-11 m/W) |
|
| `alpha_2d_e` | `0.0` | 2 photon absorption (e-11 m/W) |
|
||||||
|
|
||||||
### Material parameters at probe wavelength
|
### Material parameters at probe wavelength
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|-------------|-----------------------------------|
|
|-----------|-------------|--------------------------------|
|
||||||
| `R` | `0.0` | Reflectivity |
|
| `R_p` | `0.0` | Reflectivity |
|
||||||
| `alpha` | `0.0` | Linear absorption (cm^-1) |
|
| `alpha_p` | `0.0` | Linear absorption (cm^-1) |
|
||||||
| `n` | `1.4565` | Linear index |
|
| `n_p` | `1.4565` | Linear index |
|
||||||
| `dndl` | `-0.027158` | First order dispersion (um^-1) |
|
| `dndl_p` | `-0.027158` | First order dispersion (um^-1) |
|
||||||
|
|
||||||
### Measurement parameters
|
### Measurement parameters
|
||||||
|
|
||||||
| Variable | Default | Column contents |
|
| Variable | Default | Column contents |
|
||||||
|----------------|-------------|-----------------------------------|
|
|----------|---------|-------------------------------|
|
||||||
| `l` | `1.0` | Sample thickness (mm) |
|
| `l` | `1.0` | Sample thickness (mm) |
|
||||||
| `d` | `15.0` | Distance to detector (cm) |
|
| `d` | `15.0` | Distance to detector (cm) |
|
||||||
| `shift` | `0.0` | Temporal shift (fs) |
|
| `shift` | `0.0` | Temporal shift (fs) |
|
||||||
| `x_0` | `0.5` | Displacement of probe (w_0p) |
|
| `x_0` | `0.5` | Displacement of probe (w_0_e) |
|
||||||
|
|
||||||
## Mechanisms
|
## Mechanisms
|
||||||
|
|
||||||
| Mechanism | Parameters |
|
| Mechanism | Parameters |
|
||||||
| --- | --- |
|
|--------------------------------|------------|
|
||||||
| Electronic (both) | 2 |
|
| Electronic (both) | 2 |
|
||||||
| Collisional (NLR) | 3 |
|
| Collisional (NLR) | 3 |
|
||||||
| Librational (NLR) | 4 |
|
| Librational (NLR) | 4 |
|
||||||
@@ -200,8 +283,8 @@ is still empty.
|
|||||||
Exporting to `<name>_fit.txt` also writes, in the same directory:
|
Exporting to `<name>_fit.txt` also writes, in the same directory:
|
||||||
|
|
||||||
| File | Contents |
|
| File | Contents |
|
||||||
| --- | --- |
|
|----------------------------------------|------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `<name>_fit.txt` | delay, data and fit for `T`, `ΔE/E` and `Δn`; in Pump probe, delay and `T` only |
|
| `<name>_fit.txt` | delay, data and fit for `T`, `ΔE/E` and `Δn`; in Pump probe, delay and `T` only. In Simulation, the calculated signals alone |
|
||||||
| `<name>_fit_log.txt` | every parameter, plus a manifest of the files written |
|
| `<name>_fit_log.txt` | every parameter, plus a manifest of the files written |
|
||||||
| `<name>_fit_combined.jpg` / `.svg` | transmission and deflection, 6.5 in at 300 dpi (Beam deflection) |
|
| `<name>_fit_combined.jpg` / `.svg` | transmission and deflection, 6.5 in at 300 dpi (Beam deflection) |
|
||||||
| `<name>_fit_transmission.jpg` / `.svg` | transmission only, 3.25 in at 300 dpi (Pump probe) |
|
| `<name>_fit_transmission.jpg` / `.svg` | transmission only, 3.25 in at 300 dpi (Pump probe) |
|
||||||
@@ -210,15 +293,20 @@ Exporting to `<name>_fit.txt` also writes, in the same directory:
|
|||||||
|
|
||||||
The last two appear only when *Show diagnostic plots during Fit* is ticked.
|
The last two appear only when *Show diagnostic plots during Fit* is ticked.
|
||||||
|
|
||||||
The log records enough to reproduce a run: data columns and delimiter, the
|
In Simulation mode the export is named after the file you choose rather than an
|
||||||
mode, the simulation grid, every beam, material and geometry value, each
|
imported scan, and the table holds the calculated signals on their own delay
|
||||||
mechanism with its parameters, and the derived quantities (`n_g`, `T_lin`,
|
grid, with no data columns to pair them with.
|
||||||
`z_0`, `I_0`, `rho`).
|
|
||||||
|
The log records enough to reproduce a run: both modes, the data columns and
|
||||||
|
delimiter, the simulation grid including the delay range, every beam, material
|
||||||
|
and geometry value, each mechanism with its parameters, and the derived
|
||||||
|
quantities (`n_g`, `T_lin`, `z_0`, `I_0`, `rho`). In Simulation mode the import
|
||||||
|
path and data column sections are omitted, having nothing to describe.
|
||||||
|
|
||||||
## Files
|
## Files
|
||||||
|
|
||||||
| File | Role |
|
| File | Role |
|
||||||
| --- | --- |
|
|------------------------|--------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `bd_fresnel_core.py` | physics: field propagation, mechanism responses, ESA solver, parameter dataclass, settings I/O. No display dependencies. |
|
| `bd_fresnel_core.py` | physics: field propagation, mechanism responses, ESA solver, parameter dataclass, settings I/O. No display dependencies. |
|
||||||
| `bd_fresnel_gui.py` | Tkinter interface, plotting, import/export, logging. Entry point. |
|
| `bd_fresnel_gui.py` | Tkinter interface, plotting, import/export, logging. Entry point. |
|
||||||
| `set_params_dialog.py` | modal dialog for entering one mechanism's parameters. |
|
| `set_params_dialog.py` | modal dialog for entering one mechanism's parameters. |
|
||||||
@@ -227,15 +315,13 @@ mechanism with its parameters, and the derived quantities (`n_g`, `T_lin`,
|
|||||||
|
|
||||||
Please cite the following when using results from this program.
|
Please cite the following when using results from this program.
|
||||||
|
|
||||||
1. Reichert, M., et al. (2014). "Temporal, spectral, and polarization
|
1. M. Reichert, H. Hu, M. R. Ferdinandus, M. Seidel, P. Zhao, T. R. Ensley,
|
||||||
dependence of the nonlinear optical response of carbon disulfide."
|
D. Peceli, J. M. Reed, D. A. Fishman, S. Webster, D. J. Hagan, and
|
||||||
*Optica* **1**(6): 436.
|
E. W. Van Stryland, “Temporal, spectral, and polarization dependence of the
|
||||||
2. Reichert, M., et al. (2014). "Temporal, spectral, and polarization
|
nonlinear optical response of carbon disulfide,” Optica **1**, 436–445 (2014).
|
||||||
dependence of the nonlinear optical response of carbon disulfide:
|
2. M. R. Ferdinandus, H. Hu, M. Reichert, D. J. Hagan, and E. W. Van Stryland,
|
||||||
supplementary material." *Optica* **1**(6): 436.
|
“Beam deflection measurement of time and polarization resolved ultrafast
|
||||||
3. Ferdinandus, M. R., et al. (2013). "Beam deflection measurement of time and
|
nonlinear refraction,” Opt. Lett. **38**, 3518–3521 (2013).
|
||||||
polarization resolved ultrafast nonlinear refraction." *Opt. Lett.*
|
|
||||||
**38**(18): 3518–3521.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
+597
-166
File diff suppressed because it is too large
Load Diff
+471
-154
@@ -61,11 +61,15 @@ from bd_fresnel_core import (
|
|||||||
MECHANISM_NAMES,
|
MECHANISM_NAMES,
|
||||||
calc_beam_params,
|
calc_beam_params,
|
||||||
inputs_valid,
|
inputs_valid,
|
||||||
BD_Fresnel_func_ni,
|
BD_Fresnel_run,
|
||||||
save_settings,
|
save_settings,
|
||||||
load_settings,
|
load_settings,
|
||||||
MODE_BEAM_DEFLECTION,
|
MODE_BEAM_DEFLECTION,
|
||||||
MODE_PUMP_PROBE,
|
MODE_PUMP_PROBE,
|
||||||
|
RUN_MODE_FITTING,
|
||||||
|
RUN_MODE_SIMULATION,
|
||||||
|
ALGO_FRESNEL,
|
||||||
|
ALGO_SEMI_ANALYTICAL,
|
||||||
mechanism_names_for_mode,
|
mechanism_names_for_mode,
|
||||||
set_mode,
|
set_mode,
|
||||||
)
|
)
|
||||||
@@ -79,9 +83,9 @@ SETTINGS_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "last_s
|
|||||||
# bd_fresnel_core.calc_beam_params for why (faithfully preserved from
|
# bd_fresnel_core.calc_beam_params for why (faithfully preserved from
|
||||||
# the original, not a translation gap).
|
# the original, not a translation gap).
|
||||||
CALC_BEAM_PARAMS_FIELDS = {
|
CALC_BEAM_PARAMS_FIELDS = {
|
||||||
"E_p", "tau_p_FWHM", "w_0p", "lambda_p",
|
"E_e", "tau_e_FWHM", "w_0_e", "lambda_e",
|
||||||
"tau_FWHM", "w_0", "lambda_",
|
"tau_p_FWHM", "w_0_p", "lambda_p",
|
||||||
"R_p", "R", "alpha", "alpha_p", "n", "dndl", "n_p", "dndl_p", "alpha_2d",
|
"R_e", "R_p", "alpha_p", "alpha_e", "n_p", "dndl_p", "n_e", "dndl_e", "alpha_2d_e",
|
||||||
}
|
}
|
||||||
|
|
||||||
# (field, label, unit, abs_on_entry, log_name) -- mirrors each
|
# (field, label, unit, abs_on_entry, log_name) -- mirrors each
|
||||||
@@ -93,34 +97,34 @@ CALC_BEAM_PARAMS_FIELDS = {
|
|||||||
# validation there is permissive -- only NaN is actually rejected at
|
# validation there is permissive -- only NaN is actually rejected at
|
||||||
# entry, faithfully preserved).
|
# entry, faithfully preserved).
|
||||||
PUMP_FIELDS = [
|
PUMP_FIELDS = [
|
||||||
("E_p", "E_p (pump energy)", "uJ", True),
|
("E_e", "E_e (pump energy)", "uJ", True),
|
||||||
("tau_p_FWHM", "tau_p_FWHM", "fs", True),
|
("tau_e_FWHM", "tau_e_FWHM", "fs", True),
|
||||||
("w_0p", "w_0p (pump waist)", "um", True),
|
("w_0_e", "w_0_e (pump waist)", "um", True),
|
||||||
("lambda_p", "lambda_p (pump)", "nm", True),
|
("lambda_e", "lambda_e (pump)", "nm", True),
|
||||||
]
|
]
|
||||||
PROBE_FIELDS = [
|
PROBE_FIELDS = [
|
||||||
("tau_FWHM", "tau_FWHM", "fs", True),
|
("tau_p_FWHM", "tau_p_FWHM", "fs", True),
|
||||||
("w_0", "w_0 (probe waist)", "um", True),
|
("w_0_p", "w_0_p (probe waist)", "um", True),
|
||||||
("lambda_", "lambda (probe)", "nm", True),
|
("lambda_p", "lambda_p (probe)", "nm", True),
|
||||||
]
|
]
|
||||||
MAT_PUMP_FIELDS = [
|
MAT_PUMP_FIELDS = [
|
||||||
|
("R_e", "R_e (reflectivity)", "0-1", True),
|
||||||
|
("alpha_e", "alpha_e (absorption)", "cm^-1", True),
|
||||||
|
("n_e", "n_e (index)", "", True),
|
||||||
|
("dndl_e", "dndl_e (dispersion)", "um^-1", False),
|
||||||
|
("alpha_2d_e", "alpha_2d_e (2PA)", "e-11 m/W", False),
|
||||||
|
]
|
||||||
|
MAT_PROBE_FIELDS = [
|
||||||
("R_p", "R_p (reflectivity)", "0-1", True),
|
("R_p", "R_p (reflectivity)", "0-1", True),
|
||||||
("alpha_p", "alpha_p (absorption)", "cm^-1", True),
|
("alpha_p", "alpha_p (absorption)", "cm^-1", True),
|
||||||
("n_p", "n_p (index)", "", True),
|
("n_p", "n_p (index)", "", True),
|
||||||
("dndl_p", "dndl_p (dispersion)", "um^-1", False),
|
("dndl_p", "dndl_p (dispersion)", "um^-1", False),
|
||||||
("alpha_2d", "alpha_2d (2PA)", "e-11 m/W", False),
|
|
||||||
]
|
|
||||||
MAT_PROBE_FIELDS = [
|
|
||||||
("R", "R (reflectivity)", "0-1", True),
|
|
||||||
("alpha", "alpha (absorption)", "cm^-1", True),
|
|
||||||
("n", "n (index)", "", True),
|
|
||||||
("dndl", "dndl (dispersion)", "um^-1", False),
|
|
||||||
]
|
]
|
||||||
SYSTEM_FIELDS = [
|
SYSTEM_FIELDS = [
|
||||||
("l", "l (thickness)", "mm", True),
|
("l", "l (thickness)", "mm", True),
|
||||||
("d", "d (sample->detector)", "cm", True),
|
("d", "d (sample->detector)", "cm", True),
|
||||||
("shift", "shift (delay zero)", "fs", False),
|
("shift", "shift (delay zero)", "fs", False),
|
||||||
("x_0", "x_0 (pump-probe offset)", "w_0p", False),
|
("x_0", "x_0 (pump-probe offset)", "w_0_e", False),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Escape sequences accepted in the Delimiter field. A literal tab
|
# Escape sequences accepted in the Delimiter field. A literal tab
|
||||||
@@ -148,14 +152,17 @@ def describe_delimiter(text: str) -> str:
|
|||||||
# The simulation grid, in the order shown in the "Simulation
|
# The simulation grid, in the order shown in the "Simulation
|
||||||
# parameters" box: (attribute, label, unit, kind). Integer fields are
|
# parameters" box: (attribute, label, unit, kind). Integer fields are
|
||||||
# counts and must be >= 1; the float fields are extents and cannot be
|
# counts and must be >= 1; the float fields are extents and cannot be
|
||||||
# negative. T_d_min/T_d_max are deliberately absent -- they are taken
|
# negative. T_d_min/T_d_max are signed and are entered only in
|
||||||
# from the imported scan's delay range, not entered.
|
# Simulation mode; in Fitting mode they are taken from the imported
|
||||||
|
# scan's delay range and the fields are disabled.
|
||||||
SIM_FIELDS = [
|
SIM_FIELDS = [
|
||||||
("X_num", "X_num (spatial pts)", "points", "int"),
|
("X_num", "X_num (spatial pts)", "points", "int"),
|
||||||
("X_max", "X_max (spatial extent)", "w_0", "float"),
|
("X_max", "X_max (spatial extent)", "w_0_p", "float"),
|
||||||
("T_num", "T_num (time pts)", "points", "int"),
|
("T_num", "T_num (time pts)", "points", "int"),
|
||||||
("T_max", "T_max (time extent)", "tau_p", "float"),
|
("T_max", "T_max (time extent)", "tau_e", "float"),
|
||||||
("T_d_num", "T_d_num (delay pts)", "points", "int"),
|
("T_d_num", "T_d_num (delay pts)", "points", "int"),
|
||||||
|
("T_d_min", "T_d_min (delay start)", "tau_e", "signed"),
|
||||||
|
("T_d_max", "T_d_max (delay end)", "tau_e", "signed"),
|
||||||
]
|
]
|
||||||
|
|
||||||
# The numeric parameter boxes, in panel order. Each entry is
|
# The numeric parameter boxes, in panel order. Each entry is
|
||||||
@@ -177,7 +184,7 @@ FIELD_IS_NONNEGATIVE = {
|
|||||||
for name, _label, _unit, nonneg in fields
|
for name, _label, _unit, nonneg in fields
|
||||||
}
|
}
|
||||||
FIELD_IS_NONNEGATIVE.update(
|
FIELD_IS_NONNEGATIVE.update(
|
||||||
{name: True for name, _l, _u, kind in SIM_FIELDS if kind == "float"})
|
{name: kind == "float" for name, _l, _u, kind in SIM_FIELDS if kind != "int"})
|
||||||
|
|
||||||
class ColumnConflict(ValueError):
|
class ColumnConflict(ValueError):
|
||||||
"""Two quantities are set to read from the same data column. Kept
|
"""Two quantities are set to read from the same data column. Kept
|
||||||
@@ -185,7 +192,8 @@ class ColumnConflict(ValueError):
|
|||||||
state while swapping two column numbers, one field at a time."""
|
state while swapping two column numbers, one field at a time."""
|
||||||
|
|
||||||
|
|
||||||
# The "Mode" box's radio buttons, in display order: (mode, label). The
|
# The "Operation mode" box's radio buttons, in display order:
|
||||||
|
# (mode, label). The
|
||||||
# labels are also what the parameter log records.
|
# labels are also what the parameter log records.
|
||||||
MODE_CHOICES = [
|
MODE_CHOICES = [
|
||||||
(MODE_BEAM_DEFLECTION, "Beam deflection"),
|
(MODE_BEAM_DEFLECTION, "Beam deflection"),
|
||||||
@@ -193,6 +201,24 @@ MODE_CHOICES = [
|
|||||||
]
|
]
|
||||||
MODE_LABELS = dict(MODE_CHOICES)
|
MODE_LABELS = dict(MODE_CHOICES)
|
||||||
|
|
||||||
|
# The run-mode toggle, drawn below the measurement-mode one in the same
|
||||||
|
# box. Fitting compares against an imported scan; Simulation computes
|
||||||
|
# the signal from the parameters alone.
|
||||||
|
RUN_MODE_CHOICES = [
|
||||||
|
(RUN_MODE_FITTING, "Fitting"),
|
||||||
|
(RUN_MODE_SIMULATION, "Simulation"),
|
||||||
|
]
|
||||||
|
RUN_MODE_LABELS = dict(RUN_MODE_CHOICES)
|
||||||
|
|
||||||
|
# The algorithm toggle, drawn below the run-mode one. Fresnel
|
||||||
|
# propagation is the original method; Semi-analytical uses closed-form
|
||||||
|
# detector expressions and integrates only over time.
|
||||||
|
ALGO_CHOICES = [
|
||||||
|
(ALGO_FRESNEL, "Fresnel propagation"),
|
||||||
|
(ALGO_SEMI_ANALYTICAL, "Semi-analytical"),
|
||||||
|
]
|
||||||
|
ALGO_LABELS = dict(ALGO_CHOICES)
|
||||||
|
|
||||||
# Which column of the imported file feeds each quantity. 1-based, in
|
# Which column of the imported file feeds each quantity. 1-based, in
|
||||||
# the order they are shown in the "Data columns" box.
|
# the order they are shown in the "Data columns" box.
|
||||||
DATA_COLUMN_FIELDS = [
|
DATA_COLUMN_FIELDS = [
|
||||||
@@ -271,11 +297,19 @@ class LabeledEntry(ttk.Frame):
|
|||||||
|
|
||||||
|
|
||||||
class LabeledStatic(ttk.Frame):
|
class LabeledStatic(ttk.Frame):
|
||||||
"""Read-only calculated-value display (e.g. rho, I_0_p)."""
|
"""Read-only calculated-value display (e.g. rho, I_0_e)."""
|
||||||
|
|
||||||
|
# Widest label in use is "I_0_e (peak irradiance)" at 23
|
||||||
|
# characters. The width is a minimum request, not a clip, so a
|
||||||
|
# label longer than this does not truncate -- it pushes its own
|
||||||
|
# value right and breaks the column alignment, which is what
|
||||||
|
# happened when the T_lin labels gained "(transmission)".
|
||||||
|
LABEL_WIDTH = 23
|
||||||
|
|
||||||
def __init__(self, parent, label):
|
def __init__(self, parent, label):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
ttk.Label(self, text=label, width=20, anchor="w").pack(side="left")
|
ttk.Label(self, text=label, width=self.LABEL_WIDTH,
|
||||||
|
anchor="w").pack(side="left")
|
||||||
self.var = tk.StringVar(value="--")
|
self.var = tk.StringVar(value="--")
|
||||||
ttk.Label(self, textvariable=self.var, width=16, anchor="w",
|
ttk.Label(self, textvariable=self.var, width=16, anchor="w",
|
||||||
foreground="black").pack(side="left")
|
foreground="black").pack(side="left")
|
||||||
@@ -383,7 +417,7 @@ class BDFresnelApp(tk.Tk):
|
|||||||
|
|
||||||
self.params = self._load_or_default_params()
|
self.params = self._load_or_default_params()
|
||||||
self.data = None # dict with tau_d, tau_d_shifted, T, DeltaEoE, Delta_n
|
self.data = None # dict with tau_d, tau_d_shifted, T, DeltaEoE, Delta_n
|
||||||
self.fit = None # dict, output of BD_Fresnel_func_ni
|
self.fit = None # dict, output of BD_Fresnel_run
|
||||||
# The file loaded this session, if any. A mode change re-reads
|
# The file loaded this session, if any. A mode change re-reads
|
||||||
# it, since the two modes need different columns. Kept even if
|
# it, since the two modes need different columns. Kept even if
|
||||||
# that re-read fails, so switching back can load it again.
|
# that re-read fails, so switching back can load it again.
|
||||||
@@ -537,6 +571,23 @@ class BDFresnelApp(tk.Tk):
|
|||||||
def _build_param_fields(self, parent):
|
def _build_param_fields(self, parent):
|
||||||
self._field_widgets = {}
|
self._field_widgets = {}
|
||||||
|
|
||||||
|
sec = add_section(parent, "Operation mode")
|
||||||
|
self._configure_mode_toggle_style()
|
||||||
|
# Two toggles stacked in one box: what is being measured, then
|
||||||
|
# whether a measurement is being fitted at all. Each row is its
|
||||||
|
# own frame so the pairs stack rather than running together.
|
||||||
|
self.mode_var = tk.StringVar(value=self.params.mode)
|
||||||
|
self._mode_buttons = self._build_toggle_row(
|
||||||
|
sec, MODE_CHOICES, self.mode_var, self._on_mode_change)
|
||||||
|
self.run_mode_var = tk.StringVar(value=self.params.run_mode)
|
||||||
|
self._run_mode_buttons = self._build_toggle_row(
|
||||||
|
sec, RUN_MODE_CHOICES, self.run_mode_var, self._on_run_mode_change,
|
||||||
|
pady=(3, 0))
|
||||||
|
self.algorithm_var = tk.StringVar(value=self.params.algorithm)
|
||||||
|
self._algorithm_buttons = self._build_toggle_row(
|
||||||
|
sec, ALGO_CHOICES, self.algorithm_var, self._on_algorithm_change,
|
||||||
|
pady=(3, 0))
|
||||||
|
|
||||||
sec = add_section(parent, "Data columns")
|
sec = add_section(parent, "Data columns")
|
||||||
for name, label in DATA_COLUMN_FIELDS:
|
for name, label in DATA_COLUMN_FIELDS:
|
||||||
w = LabeledEntry(sec, label, getattr(self.params, name), width=6,
|
w = LabeledEntry(sec, label, getattr(self.params, name), width=6,
|
||||||
@@ -549,21 +600,16 @@ class BDFresnelApp(tk.Tk):
|
|||||||
w.pack(fill="x", pady=2)
|
w.pack(fill="x", pady=2)
|
||||||
self._field_widgets["delimiter"] = w
|
self._field_widgets["delimiter"] = w
|
||||||
|
|
||||||
sec = add_section(parent, "Mode")
|
|
||||||
self._configure_mode_toggle_style()
|
|
||||||
self.mode_var = tk.StringVar(value=self.params.mode)
|
|
||||||
self._mode_buttons = []
|
|
||||||
width = max(len(label) for _, label in MODE_CHOICES)
|
|
||||||
for mode, label in MODE_CHOICES:
|
|
||||||
b = ttk.Radiobutton(sec, text=label, value=mode, variable=self.mode_var,
|
|
||||||
command=self._on_mode_change, style="Mode.Toolbutton",
|
|
||||||
width=width)
|
|
||||||
b.pack(side="left") # abutting, so the pair reads as one control
|
|
||||||
self._mode_buttons.append(b)
|
|
||||||
|
|
||||||
sec = add_section(parent, "Simulation parameters")
|
sec = add_section(parent, "Simulation parameters")
|
||||||
for name, label, unit, kind in SIM_FIELDS:
|
for name, label, unit, kind in SIM_FIELDS:
|
||||||
if kind == "int":
|
if kind == "signed":
|
||||||
|
# Delay range: entered only in Simulation mode, where
|
||||||
|
# there is no file to take it from. T_d_min is normally
|
||||||
|
# negative, so no sign restriction here.
|
||||||
|
w = LabeledEntry(sec, label, getattr(self.params, name),
|
||||||
|
width=6, unit=unit,
|
||||||
|
on_change=lambda n=name: self._on_field_change(n))
|
||||||
|
elif kind == "int":
|
||||||
w = LabeledEntry(sec, label, getattr(self.params, name),
|
w = LabeledEntry(sec, label, getattr(self.params, name),
|
||||||
width=6, unit=unit, integer=True,
|
width=6, unit=unit, integer=True,
|
||||||
on_change=lambda n=name: self._on_int_field_change(n))
|
on_change=lambda n=name: self._on_int_field_change(n))
|
||||||
@@ -596,26 +642,42 @@ class BDFresnelApp(tk.Tk):
|
|||||||
command=self._on_diagnostics_change).pack(anchor="w")
|
command=self._on_diagnostics_change).pack(anchor="w")
|
||||||
|
|
||||||
sec = add_section(parent, "Calculated Parameters (probe)")
|
sec = add_section(parent, "Calculated Parameters (probe)")
|
||||||
self.calc_ng = LabeledStatic(sec, "n_g (group index)")
|
self.calc_ng_p = LabeledStatic(sec, "n_g_p (group index)")
|
||||||
self.calc_ng.pack(fill="x", pady=1)
|
self.calc_ng_p.pack(fill="x", pady=1)
|
||||||
self.calc_Tlin = LabeledStatic(sec, "T_lin")
|
self.calc_Tlin_p = LabeledStatic(sec, "T_lin_p (transmission)")
|
||||||
self.calc_Tlin.pack(fill="x", pady=1)
|
self.calc_Tlin_p.pack(fill="x", pady=1)
|
||||||
self.calc_z0 = LabeledStatic(sec, "z_0 (Rayleigh range)")
|
self.calc_z0_p = LabeledStatic(sec, "z_0_p (Rayleigh range)")
|
||||||
self.calc_z0.pack(fill="x", pady=1)
|
self.calc_z0_p.pack(fill="x", pady=1)
|
||||||
|
|
||||||
|
# Pump side is subscripted _e, probe side bare, matching the
|
||||||
|
# field names and the log.
|
||||||
sec = add_section(parent, "Calculated Parameters (pump)")
|
sec = add_section(parent, "Calculated Parameters (pump)")
|
||||||
self.calc_ngp = LabeledStatic(sec, "n_g (group index)")
|
self.calc_ng_e = LabeledStatic(sec, "n_g_e (group index)")
|
||||||
self.calc_ngp.pack(fill="x", pady=1)
|
self.calc_ng_e.pack(fill="x", pady=1)
|
||||||
self.calc_Tlinp = LabeledStatic(sec, "T_lin")
|
self.calc_sigma_e = LabeledStatic(sec, "sigma_e (absorption)")
|
||||||
self.calc_Tlinp.pack(fill="x", pady=1)
|
self.calc_sigma_e.pack(fill="x", pady=1)
|
||||||
self.calc_z0p = LabeledStatic(sec, "z_0 (Rayleigh range)")
|
self.calc_Tlin_e = LabeledStatic(sec, "T_lin_e (transmission)")
|
||||||
self.calc_z0p.pack(fill="x", pady=1)
|
self.calc_Tlin_e.pack(fill="x", pady=1)
|
||||||
self.calc_I0p = LabeledStatic(sec, "I_0 (peak irradiance)")
|
self.calc_z0_e = LabeledStatic(sec, "z_0_e (Rayleigh range)")
|
||||||
self.calc_I0p.pack(fill="x", pady=1)
|
self.calc_z0_e.pack(fill="x", pady=1)
|
||||||
|
self.calc_I0_e = LabeledStatic(sec, "I_0_e (peak irradiance)")
|
||||||
|
self.calc_I0_e.pack(fill="x", pady=1)
|
||||||
|
|
||||||
sec = add_section(parent, "Other")
|
sec = add_section(parent, "Other")
|
||||||
self.calc_rho = LabeledStatic(sec, "rho (GVM parameter)")
|
self.calc_rho = LabeledStatic(sec, "rho (GVM parameter)")
|
||||||
self.calc_rho.pack(fill="x", pady=1)
|
self.calc_rho.pack(fill="x", pady=1)
|
||||||
|
# Unlike every other value in these panels, which is derived
|
||||||
|
# from the parameters alone and so updates as they are typed,
|
||||||
|
# eta and Gamma come from the result: they are peaks over the
|
||||||
|
# whole (T, T_d) grid, which there is no way to get without
|
||||||
|
# running the calculation. They therefore read "--" until a Fit
|
||||||
|
# or Simulate completes, and go back to "--" whenever that
|
||||||
|
# result is discarded, so a stale phase is never shown beside
|
||||||
|
# freshly edited parameters. See _refresh_result_values.
|
||||||
|
self.calc_eta = LabeledStatic(sec, "eta (peak)")
|
||||||
|
self.calc_eta.pack(fill="x", pady=1)
|
||||||
|
self.calc_Gamma = LabeledStatic(sec, "Gamma (peak)")
|
||||||
|
self.calc_Gamma.pack(fill="x", pady=1)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Field / state synchronization
|
# Field / state synchronization
|
||||||
@@ -636,24 +698,70 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _apply_mode_to_widgets(self):
|
def _apply_mode_to_widgets(self):
|
||||||
"""Makes the panel reflect self.params.mode: the selected radio
|
"""Makes the panel reflect self.params.mode and .run_mode: the
|
||||||
button, whether x_0 can be edited (pump probe fixes it at 0),
|
selected radio buttons, whether x_0 can be edited (pump probe
|
||||||
and which mechanisms each pull-down offers."""
|
fixes it at 0), which mechanisms each pull-down offers, and
|
||||||
|
which inputs Simulation mode takes over or gives up."""
|
||||||
mode = self.params.mode
|
mode = self.params.mode
|
||||||
|
simulating = self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
self.mode_var.set(mode)
|
self.mode_var.set(mode)
|
||||||
|
self.run_mode_var.set(self.params.run_mode)
|
||||||
|
|
||||||
self._field_widgets["x_0"].set_enabled(mode == MODE_BEAM_DEFLECTION)
|
self._field_widgets["x_0"].set_enabled(mode == MODE_BEAM_DEFLECTION)
|
||||||
# Pump probe reads no deflection column, so its number is moot.
|
|
||||||
self._field_widgets["col_DeltaEoE"].set_enabled(mode == MODE_BEAM_DEFLECTION)
|
|
||||||
choices = mechanism_names_for_mode(mode)
|
choices = mechanism_names_for_mode(mode)
|
||||||
for row in self._mechanism_rows:
|
for row in self._mechanism_rows:
|
||||||
row.set_choices(choices)
|
row.set_choices(choices)
|
||||||
|
|
||||||
|
# Simulation reads no file, so the column numbers and delimiter
|
||||||
|
# have nothing to describe.
|
||||||
|
for name in ("col_tau_d", "col_T", "delimiter"):
|
||||||
|
self._field_widgets[name].set_enabled(not simulating)
|
||||||
|
# Pump probe reads no deflection column, so its number is moot.
|
||||||
|
self._field_widgets["col_DeltaEoE"].set_enabled(
|
||||||
|
mode == MODE_BEAM_DEFLECTION and not simulating)
|
||||||
|
|
||||||
|
# The delay range is entered only when there is no scan to take
|
||||||
|
# it from; in Fitting mode it is overwritten at fit time.
|
||||||
|
for name in ("T_d_min", "T_d_max"):
|
||||||
|
self._field_widgets[name].set_enabled(simulating)
|
||||||
|
|
||||||
|
# The semi-analytical expressions are already integrated over
|
||||||
|
# the detector plane, so there is no spatial grid to size.
|
||||||
|
for name in ("X_num", "X_max"):
|
||||||
|
self._field_widgets[name].set_enabled(
|
||||||
|
self.params.algorithm != ALGO_SEMI_ANALYTICAL)
|
||||||
|
self.algorithm_var.set(self.params.algorithm)
|
||||||
|
|
||||||
|
self.import_button.config(state="disabled" if simulating else "normal")
|
||||||
|
self.fit_button.config(text=self.run_action_label)
|
||||||
|
|
||||||
# Selection colour of Tk's "default" theme (its radio-button
|
# Selection colour of Tk's "default" theme (its radio-button
|
||||||
# indicator), so the toggle matches the rest of the panel.
|
# indicator), so the toggle matches the rest of the panel.
|
||||||
MODE_SELECTED_BG = "#4a6984"
|
MODE_SELECTED_BG = "#4a6984"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _build_toggle_row(parent, choices, variable, command, pady=0):
|
||||||
|
"""One segmented toggle: equal-width buttons packed edge to edge
|
||||||
|
so the pair reads as a single control. Returns the buttons.
|
||||||
|
|
||||||
|
The width is taken across both toggles' labels, not just this
|
||||||
|
row's, so the two rows line up as one block."""
|
||||||
|
row = ttk.Frame(parent)
|
||||||
|
row.pack(anchor="w", pady=pady)
|
||||||
|
width = max(len(label)
|
||||||
|
for group in (MODE_CHOICES, RUN_MODE_CHOICES, ALGO_CHOICES)
|
||||||
|
for _, label in group)
|
||||||
|
buttons = []
|
||||||
|
for value, label in choices:
|
||||||
|
b = ttk.Radiobutton(row, text=label, value=value, variable=variable,
|
||||||
|
command=command, style="Mode.Toolbutton",
|
||||||
|
width=width)
|
||||||
|
b.pack(side="left")
|
||||||
|
buttons.append(b)
|
||||||
|
return buttons
|
||||||
|
|
||||||
def _configure_mode_toggle_style(self):
|
def _configure_mode_toggle_style(self):
|
||||||
"""The Mode box's two radio buttons drawn as a segmented toggle:
|
"""The Operation mode box's two radio buttons drawn as a segmented toggle:
|
||||||
a pair of equal-width buttons, the selected one filled.
|
a pair of equal-width buttons, the selected one filled.
|
||||||
|
|
||||||
Built on ttk's Toolbutton, but with a border on both states.
|
Built on ttk's Toolbutton, but with a border on both states.
|
||||||
@@ -678,9 +786,72 @@ class BDFresnelApp(tk.Tk):
|
|||||||
("disabled", "#a3a3a3"),
|
("disabled", "#a3a3a3"),
|
||||||
("selected", "white")])
|
("selected", "white")])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def run_action_label(self):
|
||||||
|
"""What the Fit button is called in the current run mode."""
|
||||||
|
return ("Simulate" if self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
|
else "Fit")
|
||||||
|
|
||||||
def _on_mode_change(self):
|
def _on_mode_change(self):
|
||||||
self._set_mode(self.mode_var.get())
|
self._set_mode(self.mode_var.get())
|
||||||
|
|
||||||
|
def _on_run_mode_change(self):
|
||||||
|
self._set_run_mode(self.run_mode_var.get())
|
||||||
|
|
||||||
|
def _on_algorithm_change(self):
|
||||||
|
self._set_algorithm(self.algorithm_var.get())
|
||||||
|
|
||||||
|
def _set_algorithm(self, algorithm):
|
||||||
|
"""Switches between Fresnel propagation and the semi-analytical
|
||||||
|
expressions. Any result on screen is discarded: it was computed
|
||||||
|
by the other method, and the point of having both is to compare
|
||||||
|
them deliberately rather than to leave one mislabelled."""
|
||||||
|
if algorithm == self.params.algorithm:
|
||||||
|
return # Tk fires on every click, re-selection included
|
||||||
|
self.params.algorithm = algorithm
|
||||||
|
self.params.data_fit = False
|
||||||
|
self.fit = None
|
||||||
|
self._refresh_param_fields_from_state()
|
||||||
|
self._refresh_plots()
|
||||||
|
self._refresh_diagnostics()
|
||||||
|
self._update_action_buttons()
|
||||||
|
self._save_settings()
|
||||||
|
message = f"Algorithm: {ALGO_LABELS[algorithm]}."
|
||||||
|
self.status_var.set(message)
|
||||||
|
print(f"bd_fresnel_gui: {message}")
|
||||||
|
|
||||||
|
def _set_run_mode(self, run_mode):
|
||||||
|
"""Switches between fitting an imported scan and simulating
|
||||||
|
without one. Any result on screen is discarded: a fit describes
|
||||||
|
a measurement that Simulation mode does not show, and a
|
||||||
|
simulation was computed over a hand-entered delay range that
|
||||||
|
Fitting mode replaces with the file's."""
|
||||||
|
if run_mode == self.params.run_mode:
|
||||||
|
return # Tk fires on every click, re-selection included
|
||||||
|
self.params.run_mode = run_mode
|
||||||
|
simulating = run_mode == RUN_MODE_SIMULATION
|
||||||
|
|
||||||
|
# The imported scan is kept in params while simulating, so
|
||||||
|
# switching back restores it rather than asking for it again.
|
||||||
|
if simulating:
|
||||||
|
self.data = None
|
||||||
|
else:
|
||||||
|
self._reread_session_file("could not be read again")
|
||||||
|
|
||||||
|
self.params.data_fit = False
|
||||||
|
self.fit = None
|
||||||
|
self._refresh_param_fields_from_state()
|
||||||
|
self._refresh_plots()
|
||||||
|
self._refresh_diagnostics()
|
||||||
|
self._update_action_buttons()
|
||||||
|
self._save_settings()
|
||||||
|
|
||||||
|
message = f"Operation mode: {RUN_MODE_LABELS[run_mode]}."
|
||||||
|
if simulating:
|
||||||
|
message += " No data is imported; the delay range is set by T_d_min/T_d_max."
|
||||||
|
self.status_var.set(message)
|
||||||
|
print(f"bd_fresnel_gui: {message}")
|
||||||
|
|
||||||
def _set_mode(self, mode):
|
def _set_mode(self, mode):
|
||||||
"""Switches mode, then brings the panel, plots and buttons into
|
"""Switches mode, then brings the panel, plots and buttons into
|
||||||
line with it. Any fit on screen is discarded: it was computed
|
line with it. Any fit on screen is discarded: it was computed
|
||||||
@@ -701,7 +872,7 @@ class BDFresnelApp(tk.Tk):
|
|||||||
self._update_action_buttons()
|
self._update_action_buttons()
|
||||||
self._save_settings()
|
self._save_settings()
|
||||||
|
|
||||||
message = f"Mode: {MODE_LABELS[mode]}."
|
message = f"Operation mode: {MODE_LABELS[mode]}."
|
||||||
if cleared:
|
if cleared:
|
||||||
slots = ", ".join(str(i + 1) for i in cleared)
|
slots = ", ".join(str(i + 1) for i in cleared)
|
||||||
message += (f" Purely refractive mechanism(s) in slot {slots} set aside;"
|
message += (f" Purely refractive mechanism(s) in slot {slots} set aside;"
|
||||||
@@ -714,8 +885,8 @@ class BDFresnelApp(tk.Tk):
|
|||||||
|
|
||||||
def _set_mode_buttons_enabled(self, enabled: bool):
|
def _set_mode_buttons_enabled(self, enabled: bool):
|
||||||
"""The fit runs on a worker thread that reads self.params
|
"""The fit runs on a worker thread that reads self.params
|
||||||
throughout, so the mode must not change underneath it."""
|
throughout, so neither mode must change underneath it."""
|
||||||
for b in self._mode_buttons:
|
for b in self._mode_buttons + self._run_mode_buttons + self._algorithm_buttons:
|
||||||
b.state(["!disabled"] if enabled else ["disabled"])
|
b.state(["!disabled"] if enabled else ["disabled"])
|
||||||
|
|
||||||
def _on_field_change(self, field_name):
|
def _on_field_change(self, field_name):
|
||||||
@@ -870,32 +1041,54 @@ class BDFresnelApp(tk.Tk):
|
|||||||
def _recalc_beam_params(self, refresh_display=False):
|
def _recalc_beam_params(self, refresh_display=False):
|
||||||
calc_beam_params(self.params)
|
calc_beam_params(self.params)
|
||||||
if refresh_display:
|
if refresh_display:
|
||||||
self.calc_ng.set(f"{self.params.ng:.3f}")
|
self.calc_ng_p.set(f"{self.params.ng_p:.3f}")
|
||||||
self.calc_Tlin.set(f"{self.params.Tlin:.3f}")
|
self.calc_Tlin_p.set(f"{self.params.Tlin_p:.3f}")
|
||||||
self.calc_z0.set(f"{self.params.z_0 * 1e3:.3f} mm")
|
self.calc_z0_p.set(f"{self.params.z_0_p * 1e3:.3f} mm")
|
||||||
self.calc_ngp.set(f"{self.params.ng_p:.3f}")
|
self.calc_ng_e.set(f"{self.params.ng_e:.3f}")
|
||||||
self.calc_Tlinp.set(f"{self.params.Tlin_p:.3f}")
|
self.calc_sigma_e.set(f"{self.params.sigma_e:.3f}")
|
||||||
self.calc_z0p.set(f"{self.params.z_0_p * 1e3:.3f} mm")
|
self.calc_Tlin_e.set(f"{self.params.Tlin_e:.3f}")
|
||||||
self.calc_I0p.set(f"{self.params.I_0_p * 1e-13:.3f} GW/cm^2")
|
self.calc_z0_e.set(f"{self.params.z_0_e * 1e3:.3f} mm")
|
||||||
|
self.calc_I0_e.set(f"{self.params.I_0_e * 1e-13:.3f} GW/cm^2")
|
||||||
self.calc_rho.set(f"{self.params.rho:.3f}")
|
self.calc_rho.set(f"{self.params.rho:.3f}")
|
||||||
|
|
||||||
def _update_fit_button_state(self):
|
def _update_fit_button_state(self):
|
||||||
"""Fit needs both a data file (it takes its delay range from
|
"""Fit needs a data file (it takes its delay range from the
|
||||||
the imported scan) and a valid set of beam/material inputs."""
|
imported scan) and a valid set of beam/material inputs.
|
||||||
ready = self.data is not None and inputs_valid(self.params)
|
Simulate needs only the inputs -- its delay range is entered."""
|
||||||
|
simulating = self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
|
ready = (inputs_valid(self.params, require_data=not simulating)
|
||||||
|
and (simulating or self.data is not None))
|
||||||
self.fit_button.config(state="normal" if ready else "disabled")
|
self.fit_button.config(state="normal" if ready else "disabled")
|
||||||
|
|
||||||
def _update_export_button_state(self):
|
def _update_export_button_state(self):
|
||||||
"""Export writes the data/fit comparison table and the plot
|
"""Export writes the plot image and a data table, so it stays
|
||||||
image, so it stays disabled until a fit has actually
|
disabled until a fit or simulation has actually completed.
|
||||||
completed. Importing a new file clears the fit and disables it
|
Importing a new file, or changing mode, clears the result and
|
||||||
again."""
|
disables it again."""
|
||||||
ready = self.data is not None and self.fit is not None
|
ready = self.fit is not None and (
|
||||||
|
self.params.run_mode == RUN_MODE_SIMULATION or self.data is not None)
|
||||||
self.export_button.config(state="normal" if ready else "disabled")
|
self.export_button.config(state="normal" if ready else "disabled")
|
||||||
|
|
||||||
def _update_action_buttons(self):
|
def _update_action_buttons(self):
|
||||||
self._update_fit_button_state()
|
self._update_fit_button_state()
|
||||||
self._update_export_button_state()
|
self._update_export_button_state()
|
||||||
|
self._refresh_result_values()
|
||||||
|
|
||||||
|
def _refresh_result_values(self):
|
||||||
|
"""Fills the result-derived readouts in the "Other" panel, or
|
||||||
|
blanks them when there is no current result.
|
||||||
|
|
||||||
|
Hooked to _update_action_buttons rather than to
|
||||||
|
_recalc_beam_params because the latter fires only for fields in
|
||||||
|
CALC_BEAM_PARAMS_FIELDS -- editing a mechanism coefficient
|
||||||
|
changes eta substantially and would have left a stale value on
|
||||||
|
screen. Every site that assigns self.fit, including every one
|
||||||
|
that clears it, already calls _update_action_buttons, so this
|
||||||
|
cannot be bypassed by a path that forgets to call it."""
|
||||||
|
fit = self.fit or {}
|
||||||
|
eta, gamma = fit.get("eta_peak"), fit.get("Gamma_peak")
|
||||||
|
self.calc_eta.set("--" if eta is None else f"{eta:.3f} rad")
|
||||||
|
self.calc_Gamma.set("--" if gamma is None else f"{gamma:.3f}")
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
# Import
|
# Import
|
||||||
@@ -966,12 +1159,12 @@ class BDFresnelApp(tk.Tk):
|
|||||||
T=T, DeltaEoE=None, Delta_n=None)
|
T=T, DeltaEoE=None, Delta_n=None)
|
||||||
DeltaEoE = raw[:, col_DeltaEoE - 1]
|
DeltaEoE = raw[:, col_DeltaEoE - 1]
|
||||||
|
|
||||||
lambda_ = self.params.lambda_ * 1e-9
|
lambda_p = self.params.lambda_p * 1e-9
|
||||||
l = self.params.l * 1e-3
|
l = self.params.l * 1e-3
|
||||||
w_0 = self.params.w_0 * 1e-6
|
w_0_p = self.params.w_0_p * 1e-6
|
||||||
w_0_p = self.params.w_0p * 1e-6
|
w_0_e = self.params.w_0_e * 1e-6
|
||||||
k_0 = 2 * np.pi / lambda_
|
k_0 = 2 * np.pi / lambda_p
|
||||||
Delta_n = DeltaEoE / (k_0 * l * np.sqrt(2 / np.e) * (w_0 / w_0_p) * (2 / np.sqrt(np.pi)))
|
Delta_n = DeltaEoE / (k_0 * l * np.sqrt(2 / np.e) * (w_0_p / w_0_e) * (2 / np.sqrt(np.pi)))
|
||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
tau_d=tau_d,
|
tau_d=tau_d,
|
||||||
@@ -1017,7 +1210,8 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _on_fit(self):
|
def _on_fit(self):
|
||||||
if self.data is None:
|
simulating = self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
|
if self.data is None and not simulating:
|
||||||
return
|
return
|
||||||
self.fit_button.config(state="disabled", text="Processing...")
|
self.fit_button.config(state="disabled", text="Processing...")
|
||||||
self.import_button.config(state="disabled")
|
self.import_button.config(state="disabled")
|
||||||
@@ -1035,8 +1229,12 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# since refresh_plots.m/pb_Export_Callback.m both compare
|
# since refresh_plots.m/pb_Export_Callback.m both compare
|
||||||
# against the shifted values. This is a deliberate correction,
|
# against the shifted values. This is a deliberate correction,
|
||||||
# not a faithfulness gap.)
|
# not a faithfulness gap.)
|
||||||
self.params.T_d_min = float(np.min(self.data["tau_d_shifted"])) / self.params.tau_p
|
# In Simulation mode there is no scan to take the range from:
|
||||||
self.params.T_d_max = float(np.max(self.data["tau_d_shifted"])) / self.params.tau_p
|
# T_d_min/T_d_max are the values entered in the panel and are
|
||||||
|
# left exactly as they are.
|
||||||
|
if not simulating:
|
||||||
|
self.params.T_d_min = float(np.min(self.data["tau_d_shifted"])) / self.params.tau_e
|
||||||
|
self.params.T_d_max = float(np.max(self.data["tau_d_shifted"])) / self.params.tau_e
|
||||||
# T_d_num is no longer forced here -- it is an input in the
|
# T_d_num is no longer forced here -- it is an input in the
|
||||||
# Simulation Parameters box, defaulting to the 150 this line
|
# Simulation Parameters box, defaulting to the 150 this line
|
||||||
# used to hard-code.
|
# used to hard-code.
|
||||||
@@ -1047,7 +1245,7 @@ class BDFresnelApp(tk.Tk):
|
|||||||
def _fit_worker(self):
|
def _fit_worker(self):
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
try:
|
try:
|
||||||
fit = BD_Fresnel_func_ni(self.params)
|
fit = BD_Fresnel_run(self.params)
|
||||||
elapsed = time.time() - t0
|
elapsed = time.time() - t0
|
||||||
self.after(0, self._on_fit_success, fit, elapsed)
|
self.after(0, self._on_fit_success, fit, elapsed)
|
||||||
except Exception:
|
except Exception:
|
||||||
@@ -1063,18 +1261,22 @@ class BDFresnelApp(tk.Tk):
|
|||||||
self.log_text.delete("1.0", "end")
|
self.log_text.delete("1.0", "end")
|
||||||
self.log_text.insert("1.0", self._build_log_text())
|
self.log_text.insert("1.0", self._build_log_text())
|
||||||
|
|
||||||
self.fit_button.config(text="Fit")
|
self.fit_button.config(text=self.run_action_label)
|
||||||
self.import_button.config(state="normal")
|
self.import_button.config(
|
||||||
|
state="disabled" if self.params.run_mode == RUN_MODE_SIMULATION else "normal")
|
||||||
self._set_mode_buttons_enabled(True)
|
self._set_mode_buttons_enabled(True)
|
||||||
self._update_action_buttons()
|
self._update_action_buttons()
|
||||||
self.progress.stop()
|
self.progress.stop()
|
||||||
self.status_var.set(f"Fit complete in {elapsed:.2f} s.")
|
done = ("Simulation" if self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
print(f"bd_fresnel_gui: fitting complete. Elapsed time: {elapsed:.2f} s.")
|
else "Fit")
|
||||||
|
self.status_var.set(f"{done} complete in {elapsed:.2f} s.")
|
||||||
|
print(f"bd_fresnel_gui: {done.lower()} complete. Elapsed time: {elapsed:.2f} s.")
|
||||||
self._save_settings()
|
self._save_settings()
|
||||||
|
|
||||||
def _on_fit_error(self, tb_text):
|
def _on_fit_error(self, tb_text):
|
||||||
self.fit_button.config(text="Fit")
|
self.fit_button.config(text=self.run_action_label)
|
||||||
self.import_button.config(state="normal")
|
self.import_button.config(
|
||||||
|
state="disabled" if self.params.run_mode == RUN_MODE_SIMULATION else "normal")
|
||||||
self._set_mode_buttons_enabled(True)
|
self._set_mode_buttons_enabled(True)
|
||||||
# Export stays available only if an earlier fit succeeded and
|
# Export stays available only if an earlier fit succeeded and
|
||||||
# is still on screen; _update_export_button_state decides.
|
# is still on screen; _update_export_button_state decides.
|
||||||
@@ -1094,6 +1296,12 @@ class BDFresnelApp(tk.Tk):
|
|||||||
"""Computes the data/fit arrays, axis scale, and shared axis
|
"""Computes the data/fit arrays, axis scale, and shared axis
|
||||||
ranges used by every plot (the two live tabs and the combined
|
ranges used by every plot (the two live tabs and the combined
|
||||||
export image), so they all stay perfectly consistent."""
|
export image), so they all stay perfectly consistent."""
|
||||||
|
# Simulation mode has no measurement: the calculated curve
|
||||||
|
# supplies the delay axis, and there are no markers to size.
|
||||||
|
simulating = self.data is None
|
||||||
|
if simulating:
|
||||||
|
tau_d = tau_d_shifted = self.fit["tau_d"]
|
||||||
|
else:
|
||||||
tau_d = self.data["tau_d"]
|
tau_d = self.data["tau_d"]
|
||||||
tau_d_shifted = self.data["tau_d_shifted"]
|
tau_d_shifted = self.data["tau_d_shifted"]
|
||||||
n_pts = len(tau_d)
|
n_pts = len(tau_d)
|
||||||
@@ -1118,10 +1326,15 @@ class BDFresnelApp(tk.Tk):
|
|||||||
tau_d_disp = tau_d_shifted / scale
|
tau_d_disp = tau_d_shifted / scale
|
||||||
|
|
||||||
has_fit = self.fit is not None and self.params.data_fit
|
has_fit = self.fit is not None and self.params.data_fit
|
||||||
# Pump-probe data carries no deflection column, and has no
|
# Pump probe carries no deflection column, and has no Deflection
|
||||||
# Deflection panel to size.
|
# panel to size.
|
||||||
has_deflection = self.data["DeltaEoE"] is not None
|
has_deflection = (self.params.mode == MODE_BEAM_DEFLECTION if simulating
|
||||||
if has_fit:
|
else self.data["DeltaEoE"] is not None)
|
||||||
|
if simulating:
|
||||||
|
fit_tau_d_disp = self.fit["tau_d"] / scale
|
||||||
|
T_points = self.fit["T"]
|
||||||
|
DeltaEoE_points = self.fit["DeltaEoE"] if has_deflection else None
|
||||||
|
elif has_fit:
|
||||||
fit_tau_d_disp = self.fit["tau_d"] / scale
|
fit_tau_d_disp = self.fit["tau_d"] / scale
|
||||||
T_points = np.concatenate([self.data["T"], self.fit["T"]])
|
T_points = np.concatenate([self.data["T"], self.fit["T"]])
|
||||||
DeltaEoE_points = (np.concatenate([self.data["DeltaEoE"], self.fit["DeltaEoE"]])
|
DeltaEoE_points = (np.concatenate([self.data["DeltaEoE"], self.fit["DeltaEoE"]])
|
||||||
@@ -1142,6 +1355,7 @@ class BDFresnelApp(tk.Tk):
|
|||||||
|
|
||||||
return dict(
|
return dict(
|
||||||
tau_d_disp=tau_d_disp, fit_tau_d_disp=fit_tau_d_disp, has_fit=has_fit,
|
tau_d_disp=tau_d_disp, fit_tau_d_disp=fit_tau_d_disp, has_fit=has_fit,
|
||||||
|
has_data=not simulating,
|
||||||
marker_size=marker_size,
|
marker_size=marker_size,
|
||||||
T_points=T_points, DeltaEoE_points=DeltaEoE_points,
|
T_points=T_points, DeltaEoE_points=DeltaEoE_points,
|
||||||
x_min=x_min, x_max=x_max, scale_label=scale_label,
|
x_min=x_min, x_max=x_max, scale_label=scale_label,
|
||||||
@@ -1326,7 +1540,9 @@ class BDFresnelApp(tk.Tk):
|
|||||||
"""Legend entries listed as Data over Fit, independent of the
|
"""Legend entries listed as Data over Fit, independent of the
|
||||||
order the artists were drawn in (the fit is plotted first so
|
order the artists were drawn in (the fit is plotted first so
|
||||||
the data markers sit on top of it)."""
|
the data markers sit on top of it)."""
|
||||||
handles = [data_line] + ([fit_line] if fit_line is not None else [])
|
handles = [h for h in (data_line, fit_line) if h is not None]
|
||||||
|
if not handles:
|
||||||
|
return
|
||||||
ax.legend(handles=handles, labels=[h.get_label() for h in handles],
|
ax.legend(handles=handles, labels=[h.get_label() for h in handles],
|
||||||
loc="lower right")
|
loc="lower right")
|
||||||
|
|
||||||
@@ -1336,10 +1552,11 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# and drawn by one method.
|
# and drawn by one method.
|
||||||
PANELS = {
|
PANELS = {
|
||||||
"T": dict(key="T", color=TRANSMISSION_COLOR, ylabel="T (%)",
|
"T": dict(key="T", color=TRANSMISSION_COLOR, ylabel="T (%)",
|
||||||
title="Transmission", range_key="T_points"),
|
title="Transmission", range_key="T_points",
|
||||||
|
y_sig_figs=3),
|
||||||
"DeltaEoE": dict(key="DeltaEoE", color=DEFLECTION_COLOR,
|
"DeltaEoE": dict(key="DeltaEoE", color=DEFLECTION_COLOR,
|
||||||
ylabel=r"$\Delta E/E$ (%)", title="Deflection",
|
ylabel=r"$\Delta E/E$ (%)", title="Deflection",
|
||||||
range_key="DeltaEoE_points"),
|
range_key="DeltaEoE_points", y_sig_figs=None),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _plot_signal_axis(self, ax, ctx, which, y_on_right=False):
|
def _plot_signal_axis(self, ax, ctx, which, y_on_right=False):
|
||||||
@@ -1351,15 +1568,24 @@ class BDFresnelApp(tk.Tk):
|
|||||||
the data's delay range and should be cut off at the border
|
the data's delay range and should be cut off at the border
|
||||||
rather than overflow it.
|
rather than overflow it.
|
||||||
"""
|
"""
|
||||||
|
from matplotlib.ticker import FuncFormatter
|
||||||
|
|
||||||
spec = self.PANELS[which]
|
spec = self.PANELS[which]
|
||||||
key, color = spec["key"], spec["color"]
|
key, color = spec["key"], spec["color"]
|
||||||
|
|
||||||
fit_line = None
|
fit_line = None
|
||||||
if ctx["has_fit"]:
|
if ctx["has_fit"]:
|
||||||
|
# "Simulated" rather than "Fit" when there is no
|
||||||
|
# measurement it could be a fit to.
|
||||||
fit_line, = ax.plot(ctx["fit_tau_d_disp"], 100 * self.fit[key],
|
fit_line, = ax.plot(ctx["fit_tau_d_disp"], 100 * self.fit[key],
|
||||||
linestyle="-", color=color, label="Fit")
|
linestyle="-", color=color,
|
||||||
|
label="Fit" if ctx["has_data"] else "Simulated")
|
||||||
fit_line.set_clip_on(True)
|
fit_line.set_clip_on(True)
|
||||||
fit_line.set_clip_path(ax.patch)
|
fit_line.set_clip_path(ax.patch)
|
||||||
|
# Simulation mode plots the calculated curve alone -- there is
|
||||||
|
# no measurement, so no markers and no "Data" legend entry.
|
||||||
|
data_line = None
|
||||||
|
if ctx["has_data"]:
|
||||||
data_line, = ax.plot(ctx["tau_d_disp"], 100 * self.data[key],
|
data_line, = ax.plot(ctx["tau_d_disp"], 100 * self.data[key],
|
||||||
linestyle="none", marker="o", color=color,
|
linestyle="none", marker="o", color=color,
|
||||||
markeredgewidth=0,
|
markeredgewidth=0,
|
||||||
@@ -1373,13 +1599,37 @@ class BDFresnelApp(tk.Tk):
|
|||||||
ax.set_xlabel(rf"$\tau_d$ ({ctx['scale_label']})")
|
ax.set_xlabel(rf"$\tau_d$ ({ctx['scale_label']})")
|
||||||
ax.set_ylabel(spec["ylabel"])
|
ax.set_ylabel(spec["ylabel"])
|
||||||
ax.set_title(spec["title"]) # size from rc context
|
ax.set_title(spec["title"]) # size from rc context
|
||||||
|
sig = spec.get("y_sig_figs")
|
||||||
|
if sig is not None:
|
||||||
|
# Transmission sits near 100%, so the default formatter
|
||||||
|
# spends most of its digits on the leading "99." and the
|
||||||
|
# labels get wide. "%.<n>g" keeps the stated number of
|
||||||
|
# significant digits instead.
|
||||||
|
#
|
||||||
|
# The requested count is a floor, not a cap: a shallow scan
|
||||||
|
# spanning, say, 99.94 to 100% rounds every tick to "100"
|
||||||
|
# at three figures, leaving an unreadable axis. Digits are
|
||||||
|
# added only when that would happen, so an ordinary scan
|
||||||
|
# gets exactly the figures asked for.
|
||||||
|
ticks = [t for t in ax.get_yticks()
|
||||||
|
if min(ax.get_ylim()) <= t <= max(ax.get_ylim())]
|
||||||
|
while sig < 10 and len({f"{t:.{sig}g}" for t in ticks}) < len(ticks):
|
||||||
|
sig += 1
|
||||||
|
ax.yaxis.set_major_formatter(
|
||||||
|
FuncFormatter(lambda value, _pos, n=sig: f"{value:.{n}g}"))
|
||||||
|
|
||||||
if y_on_right:
|
if y_on_right:
|
||||||
ax.yaxis.tick_right()
|
ax.yaxis.tick_right()
|
||||||
ax.yaxis.set_label_position("right")
|
ax.yaxis.set_label_position("right")
|
||||||
self._order_legend(ax, data_line, fit_line)
|
self._order_legend(ax, data_line, fit_line)
|
||||||
|
|
||||||
def _refresh_plots(self):
|
def _refresh_plots(self):
|
||||||
if self.data is None:
|
# Fitting shows the measurement as soon as it is imported;
|
||||||
|
# Simulation has nothing to show until it has been run.
|
||||||
|
if self.data is None and self.fit is None:
|
||||||
|
for child in self.plot_holder.winfo_children():
|
||||||
|
child.destroy()
|
||||||
|
self._plot_view = None
|
||||||
return
|
return
|
||||||
|
|
||||||
fig = self._build_combined_figure()
|
fig = self._build_combined_figure()
|
||||||
@@ -1472,10 +1722,10 @@ class BDFresnelApp(tk.Tk):
|
|||||||
|
|
||||||
# Axis labels as matplotlib mathtext, so Greek letters render as
|
# Axis labels as matplotlib mathtext, so Greek letters render as
|
||||||
# Greek and sub/superscripts sit where they belong rather than
|
# Greek and sub/superscripts sit where they belong rather than
|
||||||
# showing the literal "tau_p" / "m^2" source. Figure *titles* keep
|
# showing the literal "tau_e" / "m^2" source. Figure *titles* keep
|
||||||
# their plain-text form: they double as the Tk frame label and the
|
# their plain-text form: they double as the Tk frame label and the
|
||||||
# export filename, neither of which can render mathtext.
|
# export filename, neither of which can render mathtext.
|
||||||
DIAG_LABEL_T = r"$t$ ($\tau_p$)"
|
DIAG_LABEL_T = r"$t$ ($\tau_e$)"
|
||||||
DIAG_LABEL_R = r"$R[t]$ (m$^2$/W)"
|
DIAG_LABEL_R = r"$R[t]$ (m$^2$/W)"
|
||||||
DIAG_LABEL_A = r"$A[t]$ (m/W)"
|
DIAG_LABEL_A = r"$A[t]$ (m/W)"
|
||||||
DIAG_LABEL_DN = r"$\Delta n$ (unitless)"
|
DIAG_LABEL_DN = r"$\Delta n$ (unitless)"
|
||||||
@@ -1701,11 +1951,15 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
def _on_export(self):
|
def _on_export(self):
|
||||||
if self.data is None or self.fit is None:
|
simulating = self.params.run_mode == RUN_MODE_SIMULATION
|
||||||
|
if self.fit is None or (self.data is None and not simulating):
|
||||||
return
|
return
|
||||||
default_name = self.params.filename.replace(".txt", "_fit.txt")
|
# Simulation has no imported file to name the output after.
|
||||||
|
default_name = (self.params.filename.replace(".txt", "_fit.txt")
|
||||||
|
if not simulating else "simulation.txt")
|
||||||
path = filedialog.asksaveasfilename(
|
path = filedialog.asksaveasfilename(
|
||||||
title="Select filename for fit export",
|
title="Select filename for simulation export" if simulating
|
||||||
|
else "Select filename for fit export",
|
||||||
initialdir=self.params.pathname or os.getcwd(),
|
initialdir=self.params.pathname or os.getcwd(),
|
||||||
initialfile=default_name,
|
initialfile=default_name,
|
||||||
defaultextension=".txt",
|
defaultextension=".txt",
|
||||||
@@ -1716,6 +1970,27 @@ class BDFresnelApp(tk.Tk):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if simulating:
|
||||||
|
# Nothing to interpolate onto and no data columns to
|
||||||
|
# pair with: the calculated signal is written on its
|
||||||
|
# own delay grid.
|
||||||
|
if self.params.mode == MODE_PUMP_PROBE:
|
||||||
|
export_data = np.column_stack([self.fit["tau_d"], self.fit["T"]])
|
||||||
|
header = "Delay (fs), T (Simulated)"
|
||||||
|
else:
|
||||||
|
export_data = np.column_stack([
|
||||||
|
self.fit["tau_d"], self.fit["DeltaEoE"],
|
||||||
|
self.fit["T"], self.fit["Delta_n"]])
|
||||||
|
header = ("Delay (fs), DeltaE / E (Simulated), "
|
||||||
|
"T (Simulated), Delta_n (simulated)")
|
||||||
|
np.savetxt(path, export_data, delimiter=",", fmt="%.8g",
|
||||||
|
header=header, comments="", newline="\r\n")
|
||||||
|
image_paths = self._export_plot_images(path)
|
||||||
|
self._write_export_log(path, image_paths)
|
||||||
|
print(f"bd_fresnel_gui: export of {path} complete.")
|
||||||
|
self._save_settings()
|
||||||
|
return
|
||||||
|
|
||||||
T_interp = np.interp(self.data["tau_d_shifted"], self.fit["tau_d"], self.fit["T"])
|
T_interp = np.interp(self.data["tau_d_shifted"], self.fit["tau_d"], self.fit["T"])
|
||||||
if self.params.mode == MODE_PUMP_PROBE:
|
if self.params.mode == MODE_PUMP_PROBE:
|
||||||
# No deflection was imported, so none is exported: the
|
# No deflection was imported, so none is exported: the
|
||||||
@@ -1754,7 +2029,7 @@ class BDFresnelApp(tk.Tk):
|
|||||||
pump probe -- plus every diagnostic figure as .jpg when the fit
|
pump probe -- plus every diagnostic figure as .jpg when the fit
|
||||||
was run with diagnostics enabled. Returns the paths written, in
|
was run with diagnostics enabled. Returns the paths written, in
|
||||||
the order written."""
|
the order written."""
|
||||||
if self.data is None:
|
if self.data is None and self.fit is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Built fresh here rather than reusing the on-screen figure:
|
# Built fresh here rather than reusing the on-screen figure:
|
||||||
@@ -1849,10 +2124,10 @@ class BDFresnelApp(tk.Tk):
|
|||||||
omitted).
|
omitted).
|
||||||
|
|
||||||
Section order matches the GUI's left-panel field order top to
|
Section order matches the GUI's left-panel field order top to
|
||||||
bottom: Data Columns -> Mode -> Simulation grid (not itself a GUI
|
bottom: Operation mode -> Data Columns -> Simulation grid (not
|
||||||
field, kept as a preamble) -> Pump (Excitation) Beam -> Probe
|
itself a GUI field, kept as a preamble) -> Pump (Excitation)
|
||||||
Beam -> Material @ Pump Wavelength -> Material @ Probe
|
Beam -> Probe Beam -> Material @ Pump Wavelength -> Material @
|
||||||
Wavelength -> System Geometry -> Mechanisms -> Calculated
|
Probe Wavelength -> System Geometry -> Mechanisms -> Calculated
|
||||||
Parameters (probe) -> Calculated Parameters (pump) -> Other
|
Parameters (probe) -> Calculated Parameters (pump) -> Other
|
||||||
(rho). The column numbers are 1-based, as entered in the GUI.
|
(rho). The column numbers are 1-based, as entered in the GUI.
|
||||||
"""
|
"""
|
||||||
@@ -1861,9 +2136,16 @@ class BDFresnelApp(tk.Tk):
|
|||||||
p = self.params
|
p = self.params
|
||||||
lines = []
|
lines = []
|
||||||
lines.append(f"{datetime.datetime.now()}: Begin beam deflection program (bd_fresnel_gui.py).\n")
|
lines.append(f"{datetime.datetime.now()}: Begin beam deflection program (bd_fresnel_gui.py).\n")
|
||||||
|
simulating = p.run_mode == RUN_MODE_SIMULATION
|
||||||
|
# Simulation reads no file, so there is no path and no column
|
||||||
|
# layout to record.
|
||||||
|
if not simulating:
|
||||||
lines.append(f"Import data file {p.import_filepath}.\n")
|
lines.append(f"Import data file {p.import_filepath}.\n")
|
||||||
lines.append(f"Mode: {MODE_LABELS[p.mode]}\n")
|
lines.append(f"Operation mode: {MODE_LABELS[p.mode]}, "
|
||||||
|
f"{RUN_MODE_LABELS[p.run_mode]}\n")
|
||||||
|
lines.append(f"Algorithm: {ALGO_LABELS[p.algorithm]}\n")
|
||||||
|
|
||||||
|
if not simulating:
|
||||||
lines.append("Data Columns:")
|
lines.append("Data Columns:")
|
||||||
lines.append(f" tau_d column: {p.col_tau_d}")
|
lines.append(f" tau_d column: {p.col_tau_d}")
|
||||||
lines.append(f" T column: {p.col_T}")
|
lines.append(f" T column: {p.col_T}")
|
||||||
@@ -1874,49 +2156,50 @@ class BDFresnelApp(tk.Tk):
|
|||||||
lines.append(f" Delimiter: {describe_delimiter(p.delimiter)}\n")
|
lines.append(f" Delimiter: {describe_delimiter(p.delimiter)}\n")
|
||||||
|
|
||||||
# The delay grid is included so a run is reproducible from the
|
# The delay grid is included so a run is reproducible from the
|
||||||
# log alone: T_d_min/T_d_max are not entered but derived from
|
# log alone: in Fitting mode T_d_min/T_d_max are derived from
|
||||||
# the imported scan's delay range at fit time.
|
# the imported scan's delay range at fit time, in Simulation
|
||||||
|
# mode they are entered directly.
|
||||||
lines.append("Simulation Parameters:")
|
lines.append("Simulation Parameters:")
|
||||||
lines.append(f" X_num: {p.X_num}")
|
lines.append(f" X_num: {p.X_num}")
|
||||||
lines.append(f" X_max: {p.X_max} w_0")
|
lines.append(f" X_max: {p.X_max} w_0")
|
||||||
lines.append(f" T_num: {p.T_num}")
|
lines.append(f" T_num: {p.T_num}")
|
||||||
lines.append(f" T_min: {p.T_min} tau_p")
|
lines.append(f" T_min: {p.T_min} tau_e")
|
||||||
lines.append(f" T_max: {p.T_max} tau_p")
|
lines.append(f" T_max: {p.T_max} tau_e")
|
||||||
lines.append(f" T_d_num: {p.T_d_num}")
|
lines.append(f" T_d_num: {p.T_d_num}")
|
||||||
lines.append(f" T_d_min: {p.T_d_min:.6g} tau_p")
|
lines.append(f" T_d_min: {p.T_d_min:.6g} tau_e")
|
||||||
lines.append(f" T_d_max: {p.T_d_max:.6g} tau_p\n")
|
lines.append(f" T_d_max: {p.T_d_max:.6g} tau_e\n")
|
||||||
|
|
||||||
lines.append("Pump (Excitation) Beam:")
|
lines.append("Pump (Excitation) Beam:")
|
||||||
lines.append(f" E_p: {p.E_p} uJ")
|
lines.append(f" E_e: {p.E_e} uJ")
|
||||||
lines.append(f" tau_p_FWHM: {p.tau_p_FWHM} fs")
|
lines.append(f" tau_e_FWHM: {p.tau_e_FWHM} fs")
|
||||||
lines.append(f" tau_p (HW1/eM): {p.tau_p:6.3f} fs")
|
lines.append(f" tau_e (HW1/eM): {p.tau_e:6.3f} fs")
|
||||||
lines.append(f" w_0p: {p.w_0p} um")
|
lines.append(f" w_0_e: {p.w_0_e} um")
|
||||||
lines.append(f" lambda_p: {p.lambda_p} nm\n")
|
lines.append(f" lambda_e: {p.lambda_e} nm\n")
|
||||||
|
|
||||||
lines.append("Probe Beam:")
|
lines.append("Probe Beam:")
|
||||||
lines.append(f" tau_FWHM: {p.tau_FWHM} fs")
|
lines.append(f" tau_p_FWHM: {p.tau_p_FWHM} fs")
|
||||||
lines.append(f" tau (HW1/eM): {p.tau:6.3f} fs")
|
lines.append(f" tau_p (HW1/eM): {p.tau_p:6.3f} fs")
|
||||||
lines.append(f" w_0: {p.w_0} um")
|
lines.append(f" w_0_p: {p.w_0_p} um")
|
||||||
lines.append(f" lambda: {p.lambda_} nm\n")
|
lines.append(f" lambda_p: {p.lambda_p} nm\n")
|
||||||
|
|
||||||
lines.append("Material @ Pump Wavelength:")
|
lines.append("Material @ Pump Wavelength:")
|
||||||
|
lines.append(f" R_e: {p.R_e * 100:6.3f} %")
|
||||||
|
lines.append(f" alpha_e: {p.alpha_e:6.3f} cm^-1")
|
||||||
|
lines.append(f" n_e: {p.n_e}")
|
||||||
|
lines.append(f" dndl_e: {p.dndl_e:6.6f} um^-1")
|
||||||
|
lines.append(f" alpha_2d_e: {p.alpha_2d_e} e-11 m/W\n")
|
||||||
|
|
||||||
|
lines.append("Material @ Probe Wavelength:")
|
||||||
lines.append(f" R_p: {p.R_p * 100:6.3f} %")
|
lines.append(f" R_p: {p.R_p * 100:6.3f} %")
|
||||||
lines.append(f" alpha_p: {p.alpha_p:6.3f} cm^-1")
|
lines.append(f" alpha_p: {p.alpha_p:6.3f} cm^-1")
|
||||||
lines.append(f" n_p: {p.n_p}")
|
lines.append(f" n_p: {p.n_p}")
|
||||||
lines.append(f" dndl_p: {p.dndl_p:6.6f} um^-1")
|
lines.append(f" dndl_p: {p.dndl_p:6.6f} um^-1\n")
|
||||||
lines.append(f" alpha_2d: {p.alpha_2d} e-11 m/W\n")
|
|
||||||
|
|
||||||
lines.append("Material @ Probe Wavelength:")
|
|
||||||
lines.append(f" R: {p.R * 100:6.3f} %")
|
|
||||||
lines.append(f" alpha: {p.alpha:6.3f} cm^-1")
|
|
||||||
lines.append(f" n: {p.n}")
|
|
||||||
lines.append(f" dndl: {p.dndl:6.6f} um^-1\n")
|
|
||||||
|
|
||||||
lines.append("System Geometry:")
|
lines.append("System Geometry:")
|
||||||
lines.append(f" l: {p.l} mm")
|
lines.append(f" l: {p.l} mm")
|
||||||
lines.append(f" d: {p.d} cm")
|
lines.append(f" d: {p.d} cm")
|
||||||
lines.append(f" shift: {p.shift} fs")
|
lines.append(f" shift: {p.shift} fs")
|
||||||
lines.append(f" x_0: {p.x_0} w_0_p\n")
|
lines.append(f" x_0: {p.x_0} w_0_e\n")
|
||||||
|
|
||||||
for i, mech in enumerate(p.mech):
|
for i, mech in enumerate(p.mech):
|
||||||
if mech.name == "None (both)":
|
if mech.name == "None (both)":
|
||||||
@@ -1930,18 +2213,39 @@ class BDFresnelApp(tk.Tk):
|
|||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
lines.append("Calculated Parameters (probe):")
|
lines.append("Calculated Parameters (probe):")
|
||||||
lines.append(f" n_g: {p.ng:6.3f}")
|
lines.append(f" n_g_p: {p.ng_p:6.3f}")
|
||||||
lines.append(f" T_lin: {p.Tlin * 100:6.3f} %")
|
lines.append(f" T_lin_p (transmission): {p.Tlin_p * 100:6.3f} %")
|
||||||
lines.append(f" z_0: {p.z_0 * 1e3:6.3f} mm\n")
|
lines.append(f" z_0_p: {p.z_0_p * 1e3:6.3f} mm\n")
|
||||||
|
|
||||||
|
# Pump-side labels carry _e, matching their field names and the
|
||||||
|
# program-wide convention that the pump is subscripted and the
|
||||||
|
# probe is bare. The probe block above therefore stays n_g,
|
||||||
|
# T_lin, z_0. sigma_e sits next to T_lin_e because the two are
|
||||||
|
# the same statement: with no pump two-photon absorption
|
||||||
|
# T_lin_e = (1 - R_e) exp(-2 sigma_e). All five read from the
|
||||||
|
# parameters, not the result, so they report for either
|
||||||
|
# algorithm.
|
||||||
lines.append("Calculated Parameters (pump):")
|
lines.append("Calculated Parameters (pump):")
|
||||||
lines.append(f" n_g: {p.ng_p:6.3f}")
|
lines.append(f" n_g_e: {p.ng_e:6.3f}")
|
||||||
lines.append(f" T_lin: {p.Tlin_p * 100:6.3f} %")
|
lines.append(f" sigma_e: {p.sigma_e:6.3f}")
|
||||||
lines.append(f" z_0: {p.z_0_p * 1e3:6.3f} mm")
|
lines.append(f" T_lin_e (transmission): {p.Tlin_e * 100:6.3f} %")
|
||||||
lines.append(f" I_0: {p.I_0_p * 1e-13:6.3f} GW/cm^2\n")
|
lines.append(f" z_0_e: {p.z_0_e * 1e3:6.3f} mm")
|
||||||
|
lines.append(f" I_0_e: {p.I_0_e * 1e-13:6.3f} GW/cm^2\n")
|
||||||
|
|
||||||
lines.append("Other:")
|
lines.append("Other:")
|
||||||
lines.append(f" rho: {p.rho:6.3f}\n")
|
lines.append(f" rho: {p.rho:6.3f}")
|
||||||
|
# Peak nonlinear phase and absorption exponent over the whole
|
||||||
|
# grid, from whichever algorithm produced the current result.
|
||||||
|
# eta_peak is the small-signal yardstick: the semi-analytical
|
||||||
|
# dP is first order in the response while Fresnel propagation
|
||||||
|
# keeps every order, so the two agree only while eta_peak stays
|
||||||
|
# small. Guarded because a result from an older session's saved
|
||||||
|
# state may predate these keys.
|
||||||
|
fit = self.fit or {}
|
||||||
|
if "eta_peak" in fit:
|
||||||
|
lines.append(f" eta (peak): {fit['eta_peak']:6.3f} rad")
|
||||||
|
lines.append(f" Gamma (peak): {fit['Gamma_peak']:6.3f}")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
if exported_files:
|
if exported_files:
|
||||||
# Every file this export run produced. They all land in one
|
# Every file this export run produced. They all land in one
|
||||||
@@ -1956,13 +2260,21 @@ class BDFresnelApp(tk.Tk):
|
|||||||
lines.append(f" {os.path.basename(path)}")
|
lines.append(f" {os.path.basename(path)}")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
lines.append("Please cite the following references when using products from this program.\n")
|
lines.append("Please cite the following references when using products from this program.\n")
|
||||||
lines.append(' 1: Reichert, M., et al. (2014). "Temporal, spectral, and polarization '
|
# Optica style: every author, initials first, abbreviated
|
||||||
'dependence of the nonlinear optical response of carbon disulfide." Optica 1(6): 436.\n')
|
# journal, volume, page range, year. Wrapped with a hanging
|
||||||
lines.append(' 2: Reichert, M., et al. (2014). "Temporal, spectral, and polarization '
|
# indent rather than run onto one very long line.
|
||||||
'dependence of the nonlinear optical response of carbon disulfide: supplementary '
|
lines.append(' 1: M. Reichert, H. Hu, M. R. Ferdinandus, M. Seidel, P. Zhao, '
|
||||||
'material." Optica 1(6): 436.\n')
|
'T. R. Ensley,\n'
|
||||||
lines.append(' 3: Ferdinandus, M. R., et al. (2013). "Beam deflection measurement of time '
|
' D. Peceli, J. M. Reed, D. A. Fishman, S. Webster, D. J. Hagan, and\n'
|
||||||
'and polarization resolved ultrafast nonlinear refraction." Opt Lett 38(18): 3518-3521.\n')
|
' E. W. Van Stryland, \u201cTemporal, spectral, and polarization '
|
||||||
|
'dependence of\n'
|
||||||
|
' the nonlinear optical response of carbon disulfide,\u201d '
|
||||||
|
'Optica 1, 436\u2013445 (2014).\n')
|
||||||
|
lines.append(' 2: M. R. Ferdinandus, H. Hu, M. Reichert, D. J. Hagan, and '
|
||||||
|
'E. W. Van Stryland,\n'
|
||||||
|
' \u201cBeam deflection measurement of time and polarization resolved '
|
||||||
|
'ultrafast\n'
|
||||||
|
' nonlinear refraction,\u201d Opt. Lett. 38, 3518\u20133521 (2013).\n')
|
||||||
|
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@@ -1972,7 +2284,12 @@ class BDFresnelApp(tk.Tk):
|
|||||||
# itself -- everything the export run produced.
|
# itself -- everything the export run produced.
|
||||||
exported = [export_path, *image_paths, log_path]
|
exported = [export_path, *image_paths, log_path]
|
||||||
text = self._build_log_text(exported_files=exported)
|
text = self._build_log_text(exported_files=exported)
|
||||||
with open(log_path, "w+", newline="\r\n") as f:
|
# encoding is explicit: the citation block uses typographic
|
||||||
|
# quotes and an en dash, and open() otherwise writes in the
|
||||||
|
# locale's encoding. Windows-1252 happens to contain those
|
||||||
|
# characters, but latin-1, cp437/cp850 and the CJK code pages
|
||||||
|
# do not, and would raise UnicodeEncodeError mid-export.
|
||||||
|
with open(log_path, "w+", newline="\r\n", encoding="utf-8") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 355 KiB |
@@ -0,0 +1,165 @@
|
|||||||
|
{
|
||||||
|
"E_e": 1.0,
|
||||||
|
"tau_e_FWHM": 45.0,
|
||||||
|
"w_0_e": 142.83,
|
||||||
|
"lambda_e": 800.0,
|
||||||
|
"tau_p_FWHM": 100.0,
|
||||||
|
"w_0_p": 22.253,
|
||||||
|
"lambda_p": 650.0,
|
||||||
|
"R_e": 0.0,
|
||||||
|
"alpha_e": 0.0,
|
||||||
|
"n_e": 1.4533,
|
||||||
|
"dndl_e": -0.017284,
|
||||||
|
"alpha_2d_e": 0.0,
|
||||||
|
"R_p": 0.0,
|
||||||
|
"alpha_p": 0.0,
|
||||||
|
"n_p": 1.4565,
|
||||||
|
"dndl_p": -0.027158,
|
||||||
|
"l": 1.72e-06,
|
||||||
|
"d": 15.0,
|
||||||
|
"shift": 70.0,
|
||||||
|
"x_0": 0.5,
|
||||||
|
"tau_e": 27.025254197695123,
|
||||||
|
"tau_p": 60.05612043932249,
|
||||||
|
"sigma_e": 0.0,
|
||||||
|
"I_0_e": 651473158047437.0,
|
||||||
|
"ng_e": 1.4671272,
|
||||||
|
"ng_p": 1.4741526999999999,
|
||||||
|
"rho": 0.8671350632529666,
|
||||||
|
"z_0_p": 0.0023933909907098232,
|
||||||
|
"z_0_e": 0.0801122184130848,
|
||||||
|
"Tlin_p": 1.0,
|
||||||
|
"Tlin_e": 1.0,
|
||||||
|
"X_max": 5.0,
|
||||||
|
"X_num": 50,
|
||||||
|
"T_min": -5.0,
|
||||||
|
"T_max": 5.0,
|
||||||
|
"T_num": 100,
|
||||||
|
"T_d_min": -9.579367435592124,
|
||||||
|
"T_d_max": 39.791355601447556,
|
||||||
|
"T_d_num": 150,
|
||||||
|
"n_mech": 7,
|
||||||
|
"mech": [
|
||||||
|
{
|
||||||
|
"name": "Exponential rise/decay (both)",
|
||||||
|
"param": [
|
||||||
|
3600.0,
|
||||||
|
-200000.0,
|
||||||
|
1.0,
|
||||||
|
170.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Exponential rise/decay (both)",
|
||||||
|
"param": [
|
||||||
|
15000.0,
|
||||||
|
-500000.0,
|
||||||
|
0.1,
|
||||||
|
10000.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "None (both)",
|
||||||
|
"param": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "None (both)",
|
||||||
|
"param": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "None (both)",
|
||||||
|
"param": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "None (both)",
|
||||||
|
"param": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "None (both)",
|
||||||
|
"param": [
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
0.0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"col_tau_d": 1,
|
||||||
|
"col_DeltaEoE": 2,
|
||||||
|
"col_T": 3,
|
||||||
|
"delimiter": ",",
|
||||||
|
"diagnostics": true,
|
||||||
|
"data_imported": true,
|
||||||
|
"data_fit": true,
|
||||||
|
"mode": "beam_deflection",
|
||||||
|
"run_mode": "fitting",
|
||||||
|
"algorithm": "semi_analytical",
|
||||||
|
"x_0_beam_deflection": 0.5,
|
||||||
|
"mech_beam_deflection": [],
|
||||||
|
"filename": "20190802 - BD 4 layer run 2_DeltaEoE_subtraction.txt",
|
||||||
|
"pathname": "/home/manuel/Documents/Projects/Code/BD_Fresnel_GUI/Test data/",
|
||||||
|
"import_filepath": "/home/manuel/Documents/Projects/Code/BD_Fresnel_GUI/Test data/20190802 - BD 4 layer run 2_DeltaEoE_subtraction.txt",
|
||||||
|
"settings_schema": 3
|
||||||
|
}
|
||||||
@@ -9,4 +9,9 @@
|
|||||||
numpy>=2.0
|
numpy>=2.0
|
||||||
scipy>=1.6
|
scipy>=1.6
|
||||||
matplotlib>=3.4
|
matplotlib>=3.4
|
||||||
|
|
||||||
|
# Optional. Only needed for the pump two-photon absorption term
|
||||||
|
# (alpha_2d_e != 0), which uses the polylogarithm Li_3/2. The core
|
||||||
|
# imports it lazily, so the program runs without it until that term is
|
||||||
|
# used, and then says so.
|
||||||
mpmath>=1.2
|
mpmath>=1.2
|
||||||
|
|||||||
Reference in New Issue
Block a user