Repository navigation
feat: exspy's window path for an SEM spectrum: lines in range, windows, intensities and Cliff-Lorimer - #154
Merged
Merged
Conversation
…s, intensities and Cliff-Lorimer EDSWindowPath (public) puts the kit's own functions behind the calls Electron Microscopy Studio's SEMEDSLines makes: the lines add_lines() picks for a list of elements at a beam energy, the lines in the spectral range, integration and background windows, line intensities on Double counts through WindowIntensity.resolve, the acquisition conditions with exspy's defaults and their take-off angle, and Cliff-Lorimer with the single-line rule named by the caller (.refuse, the kit's default, or .exspyHundredPercent, exspy's raw arithmetic). No default of the kit changes and no number moves. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKZEUynSt6RczY9oKhrDU
Byte-identical copies (equal sha256) of Electron Microscopy Studio's tools/parity/sem m7/eds-lines-tm002 and m7/eds-quant-tm002 bundles and their input exspy_EDS_SEM_TM002.hspy (at e7212f9), under Tests/SpectroEDXTests/Fixtures/sem. The moved tests run on EDSWindowPath at the bundles' tolerances, unchanged; the hspy file is read with FormatoHDF5. A new test holds the app's line table (the bundle's db_ arrays) against XRayLines and QuantElementData. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKZEUynSt6RczY9oKhrDU
… NOTICE Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKZEUynSt6RczY9oKhrDU
…iations Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkKZEUynSt6RczY9oKhrDU
Paullo9
enabled auto-merge (squash)
November 27, 2026 18:39
Contributor
Author
|
The same gate ( I re-ran the failed jobs once. Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Paul · project thread
Fixes #131
Step 3 of the kit move (EMSuite/Electron-Microscopy-Studio#848). This merges the app's
SEMEDSLinesinto the kit. The kit's own functions are the only implementation, and the new public file sits in front of them.Public API (
Sources/SpectroEDX/EDSWindowPath.swift)EDSWindowPath.Conditionsholds the beam energy, resolution and angles, with eXSpy's defaults, plus the take-off angle.lines(forElements:axis:beamEnergyKeV:onlyOne:onlyLines:)andlinesInSpectralRange.integrationWindowsandbackgroundWindows.intensities(counts:axis:integrationWindows:backgroundWindows:)gives the raw and the net intensities.cliffLorimer(intensities:kFactors:singleLine:)returns weight and atomic fractions. It has no default, so both behaviours are named:.refuseis the kit's route and staysEDXQuantificationSetup's default..exspyHundredPercentis eXSpy's raw arithmetic, which the app's figure F17 pins.EDSWindowPathError, plus a package-levelResolvedWindow.net(Double, Double, Double). The new overload does the same arithmetic as the integer form, and the existing callers are unchanged.No kit default and no existing number changes.
Parity
exspy._misc.elements) andXRayLineDataagree on all 947 lines (energy, weight and Z exact). Neither table has a line the other lacks.m7/eds-lines-tm002andm7/eds-quant-tm002(BAM TM002) are moved with equal sha256. The line table and the channel rule are exact; everything else is checked at rtol 1e-7, as in the app's parity rows.EnergyAxis.index, the same as HyperSpy 2.5.0value2index. The reviewer checked [0, 10, 20, 21, 6] against HyperSpy.docs/parity.md:XRayLines.notRealLines, an existing deviation). eXSpy and the app give H_Ka and He_Ka.WindowIntensityError.axis(.notANumber). eXSpy clamps a NaN integration edge and raises on a NaN background edge.widthUndefined. eXSpy gives NaN windows instead.What stays app-side for the switch
SEMEDSLines.table/LineRowandquantify, with its refusals and their locale text.quantifyrefuses fewer than two rows and k-factors that are not finite and positive;cliffLorimerdoes not check k-factors.EnergyAxis: itsprecondition(scale > 0 && size > 0)traps, where the app'sAxisdid not.Review
I ran one independent review before the PR, as the rules require for numerics and public API. It found no compile errors. A Python port of the chain reproduced every array in both bundles exactly. Its two doc findings, on NaN behaviour, are fixed in 9d2ea18.
Tests are
SEMEDSParityTests(XCTest beside the kit's swift-testing, the same pattern as FormatoKit's EDS tests). The test target gains FormatoCore and FormatoHDF5; the floor of 0.12.0 has every API used.Generated by Claude Code