Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sources/SpectroCore/EnergyAxis.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public nonisolated struct EnergyAxis: Equatable, Sendable {
/// Channel width, keV (> 0).
public let scale: Double
public let size: Int
package var units: String { "keV" }

public init(offset: Double, scale: Double, size: Int) {
// DEVIATION: hyperspy also handles a negative scale (its rounding branch
Expand Down
1 change: 0 additions & 1 deletion Sources/SpectroCore/Statistics/CountingInterval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ package nonisolated struct CountingInterval: Equatable, Sendable {
return CountingInterval(count: n, lower: lower, upper: upper, confidence: confidence)
}

package var width: Double { upper - lower }
package func contains(_ mean: Double) -> Bool { mean >= lower && mean <= upper }

/// The same interval shrunk about the observed count by `factor` (0.5 =
Expand Down
2 changes: 0 additions & 2 deletions Sources/SpectroEDX/Fit/Continuum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ public nonisolated struct ContinuumForm: Sendable, Equatable {
self.efficiency = efficiency; self.edgeStep = edgeStep
}

package var coefficientCount: Int { orders.reduce(0) { $0 + $1 + 1 } }

/// The basis columns over `energies` (ascending, the fitted channels). A coefficient with no
/// support (an empty segment) is not produced. `names` label them for the result.
/// `resolutionMnKaEV`: the detector resolution that broadens each edge step (the line model's). nil, or `edgeStep == .sharp`,
Expand Down
2 changes: 0 additions & 2 deletions Sources/SpectroEDX/Method/QuantificationMethod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public nonisolated struct QuantificationMethod: Codable, Equatable, Sendable {
/// efficiency; unvalidated) or typed with its source. No zeta in the menu.
public enum KFactorSource: String, CaseIterable, Codable, Sendable {
case computed
/// The name the room used before the addendum replaced Brown-Powell; same value as `computed`.
package static var brownPowell: KFactorSource { .computed }
case typed
}

Expand Down
8 changes: 0 additions & 8 deletions Sources/SpectroEDX/Proposer/ProposalRules.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,6 @@ import Foundation
public nonisolated struct ProposalRules: Equatable, Sendable {
public enum Rule: String, Sendable, CaseIterable {
case hygiene = "R1", corroboration = "R2", release = "R3"
/// Plain words, as the row's hover and the notes say them.
package var title: String {
switch self {
case .hygiene: return "hygiene"
case .corroboration: return "L/M corroboration"
case .release: return "sum-peak release"
}
}
}

public var hygiene: Bool
Expand Down
8 changes: 0 additions & 8 deletions Sources/SpectroEDX/Quant/BoteSalvatCrossSection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import Foundation

package nonisolated struct BoteSalvatCrossSection: IonisationCrossSection {
package static let shellNames = ["K", "L1", "L2", "L3", "M1", "M2", "M3", "M4", "M5"]
private static let bohrRadiusCm = 5.291772083e-11 * 100
private static let restMassEV = 8.1871047e-14 / 1.60217653e-19
private static let fourPiA0Sq = 4 * Double.pi * bohrRadiusCm * bohrRadiusCm
Expand Down Expand Up @@ -66,13 +65,6 @@ package nonisolated struct BoteSalvatCrossSection: IonisationCrossSection {
self.init(tableA: try read("SalvatXionA.csv"), tableB: try read("SalvatXionB.csv"), edges: try read("xionUis.csv"))
}

package static func bundled(in bundle: Bundle? = nil) -> BoteSalvatCrossSection? {
let bundle = bundle ?? .module // SpectroKit's own copy (Resources/Spectroscopy); an app may pass its own bundle
guard let url = bundle.url(forResource: "xionUis", withExtension: "csv", subdirectory: "Spectroscopy")
?? bundle.url(forResource: "xionUis", withExtension: "csv") else { return nil }
return try? BoteSalvatCrossSection(directory: url.deletingLastPathComponent())
}

/// Ionisation energy (eV) of `shell` (0 = K, 1 = L1, ...), nil if untabulated.
package func edgeEV(z: Int, shell: Int) -> Double? {
guard let u = uis[z], u.indices.contains(shell) else { return nil }
Expand Down
1 change: 0 additions & 1 deletion Sources/SpectroEDX/Quant/EDXQuantification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
//

import Foundation
import SpectroCore

/// Which quantification method, with its factors in the order of `EDXQuantificationSetup.elements`.
public nonisolated enum EDXQuantificationMethod: Sendable, Equatable {
Expand Down
7 changes: 0 additions & 7 deletions Sources/SpectroEDX/Quant/KrauseFluorescenceYield.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ package nonisolated struct KrauseFluorescenceYield: FluorescenceYield {

package init(contentsOf url: URL) throws { self.init(csv: try String(contentsOf: url, encoding: .utf8)) }

package static func bundled(in bundle: Bundle? = nil) -> KrauseFluorescenceYield? {
let bundle = bundle ?? .module // SpectroKit's own copy (Resources/Spectroscopy); an app may pass its own bundle
guard let url = bundle.url(forResource: "Krause1979", withExtension: "csv", subdirectory: "Spectroscopy")
?? bundle.url(forResource: "Krause1979", withExtension: "csv") else { return nil }
return try? KrauseFluorescenceYield(contentsOf: url)
}

package func omegaK(z: Int) -> Double? { omegaK[z] }

package func omega(element: String, line: String) -> Double? {
Expand Down
8 changes: 0 additions & 8 deletions Sources/SpectroEDX/Quant/MassAbsorption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ package nonisolated struct MassAbsorptionTable: Sendable {
self.init(csv: try String(contentsOf: url, encoding: .utf8), stripSentinel: stripSentinel)
}

/// The copy shipped in the app bundle (Resources/Spectroscopy/FFastMAC.csv).
package static func bundled(in bundle: Bundle? = nil) -> MassAbsorptionTable? {
let bundle = bundle ?? .module // SpectroKit's own copy (Resources/Spectroscopy); an app may pass its own bundle
guard let url = bundle.url(forResource: "FFastMAC", withExtension: "csv", subdirectory: "Spectroscopy")
?? bundle.url(forResource: "FFastMAC", withExtension: "csv") else { return nil }
return try? MassAbsorptionTable(contentsOf: url)
}

package func hasElement(_ symbol: String) -> Bool {
QuantElementData.entry(symbol).map { curves[$0.z] != nil } ?? false
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SpectroEELS/EELSMLLS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ public enum EELSMLLS {
try coreLoss.counts.withUnsafeBufferPointer { counts in
nonisolated(unsafe) let input = counts
try EELSParallel.forEachPixel(count: np, cancelled: cancelled, progress: progress) { p in
if let mask, !mask[p] { slots.set(p, failed(.masked, references: options.references.count, edges: m)); return }
guard let r = exponents[p] else { slots.set(p, failed(.fitFailed, references: options.references.count, edges: m)); return }
if let mask, !mask[p] { slots.set(p, failed(.masked)); return }
guard let r = exponents[p] else { slots.set(p, failed(.fitFailed)); return }
let y = Array(UnsafeBufferPointer(start: input.baseAddress! + p * n + window.lowerBound, count: window.count))
var columns: [[Double]] = [logE.map { exp(-r * $0) * basis.scale }]
for g in 0 ..< m { columns.append(basis.column(group: g, pixel: p, rows: window)) }
columns.append(contentsOf: refColumns)
guard let s = solve(columns: columns, y: y) else {
slots.set(p, failed(.fitFailed, references: options.references.count, edges: m)); return
slots.set(p, failed(.fitFailed)); return
}
let dof = window.count - k
func amplitude(_ j: Int) -> EELSAmplitude { EELSAmplitude(value: s.x[j], standardError: s.standardError[j]) }
Expand All @@ -198,7 +198,7 @@ public enum EELSMLLS {
convolved: basis.convolved, methodName: methodName, validation: "none", basis: basis, references: options.references)
}

private static func failed(_ why: EELSUnavailable, references: Int, edges: Int) -> EELSMLLSPixel {
private static func failed(_ why: EELSUnavailable) -> EELSMLLSPixel {
EELSMLLSPixel(background: nil, exponent: nil, intensities: [], references: [], residualSumOfSquares: nil, degreesOfFreedom: 0, unavailable: why)
}

Expand Down
1 change: 0 additions & 1 deletion Sources/SpectroEELS/EELSSpectrumImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//

import Foundation
import SpectroCore

/// A spectrum image on a uniform energy axis: `counts[(y * nx + x) * channels + c]`, channel `c` at `energyOffsetEV + energyScaleEV * c`.
/// `LowLossSpectrumImage` and `CoreLossSpectrumImage` conform; the initialiser validates as theirs do (finite counts, scale > 0).
Expand Down
1 change: 0 additions & 1 deletion Sources/SpectroEELS/PowerLawBackground.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
//

import Foundation
import SpectroCore

package nonisolated struct PowerLawWindow: Sendable, Equatable {
package let i1: Int, i2: Int, i3: Int
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroCoreTests/DM4VolumeGoneTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import Testing
import SpectroCore
import FormatoDM

/// A DM4 whose disk has been
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroCoreTests/VeloxElementSelectionTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import Testing
import SpectroCore
import FormatoEMD

/// Velox's own element selection, read from the file (`VeloxEMDReader.storedElementSelection`).
Expand Down
2 changes: 0 additions & 2 deletions Tests/SpectroEDXTests/AxisGateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ struct AxisGateTests {

// MARK: E3

private struct CalRow { let cell: [String: Any]; let counts: [Double] }

private func calibrationRows() -> [(id: String, delta: Double, gain: Double, r: Double, nAl: Double, real: Int, trueOffset: Double, trueScale: Double, counts: [Double])] {
let cal = EDXFixtures.calibration
let nwin = cal.i("nwin"), k0 = cal.i("k0")
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/CountsGateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX
import FormatoEMD

struct CountsGateTests {
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/DemoEDXAutoIDPinTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/DemoEDXAutoIDTests.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/QuantificationMethodTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
import Foundation
import Testing
import SpectroCore
import SpectroEDX

@MainActor
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/SpectroscopyComputedKTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

/// WP3 lane K round 2: computed k from NIST EPQ data (Bote-Salvat 2008 sigma, Krause 1979 omega,
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEDXTests/SpectroscopyQuantTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

/// k-factors, Cliff-Lorimer / zeta / cross-section quantification and
Expand Down
3 changes: 1 addition & 2 deletions Tests/SpectroEDXTests/SumEscapeIdenticalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ struct SumEscapeIdenticalTests {
mutating func normal() -> Double { (-2 * log(uniform())).squareRoot() * cos(2 * Double.pi * uniform()) }
}

/// The 1500-channel test axis (0 to 14.99 keV) and the short axis that ends between V K-alpha and V K-beta (top 5.115 keV).
private static let axis = EnergyAxis(offset: 0, scale: 0.01, size: 1500)
/// The short axis that ends between V K-alpha and V K-beta (top 5.115 keV).
private static let shortAxis = EnergyAxis(offset: 0, scale: 0.005, size: 1024)

/// Kramers x window continuum (as SpectroscopyProposerTests), E0 = 200 keV, plus the planted line areas (counts) of the fit's own groups.
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroEELSTests/SavitzkyGolayPortTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Foundation
import Testing
import SpectroTestSupport
import SpectroEELS
import SpectroCore

struct SavitzkyGolayPortTests {

Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroKitParityTests/EDSQuantPinsTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

/// eXSpy quantification pins (tools/edx-exspy-pins/quant_pins.py).
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroKitParityTests/EDXQuantificationTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

/// The public per-pixel EDX quantification against eXSpy 0.3.2 / HyperSpy 2.4.0 (`tools/edx-quant-maps/pins.py`, fixture
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroKitParityTests/LineTableParityTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import Foundation
import Testing
import SpectroTestSupport
import SpectroCore
import SpectroEDX

struct LineTableParityTests {
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroKitParityTests/MLLSPinsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import Foundation
import Testing
import SpectroTestSupport
import SpectroEELS

struct MLLSPinsTests {
Expand Down
1 change: 0 additions & 1 deletion Tests/SpectroKitParityTests/RLMLLSSpeedTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import Foundation
import Testing
import SpectroTestSupport
import SpectroEELS

struct RLMLLSSpeedTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Foundation
import Testing
import SpectroTestSupport
import SpectroEELS
import SpectroCore

struct SavitzkyGolayBitParityTests {

Expand Down
4 changes: 0 additions & 4 deletions Tests/SpectroTestSupport/PlantedRuns.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ package extension Array where Element == MgRun {
var pReported: Double { isEmpty ? .nan : Double(filter(\.reported).count) / Double(count) }
var meanNet: Double { map(\.net).reduce(0, +) / Double(count) }
var meanSigma: Double { map(\.sigma).reduce(0, +) / Double(count) }
var sdNet: Double {
let m = meanNet
return (map { ($0.net - m) * ($0.net - m) }.reduce(0, +) / Double(Swift.max(count - 1, 1))).squareRoot()
}
}

/// Runs cached for the process (the checks and the diagnosis experiments read the same spectra; every run happens once).
Expand Down
Loading