diff --git a/Sources/SpectroCore/EnergyAxis.swift b/Sources/SpectroCore/EnergyAxis.swift index bd0dea5..57f1944 100644 --- a/Sources/SpectroCore/EnergyAxis.swift +++ b/Sources/SpectroCore/EnergyAxis.swift @@ -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 diff --git a/Sources/SpectroCore/Statistics/CountingInterval.swift b/Sources/SpectroCore/Statistics/CountingInterval.swift index 2d3b664..03cfcee 100644 --- a/Sources/SpectroCore/Statistics/CountingInterval.swift +++ b/Sources/SpectroCore/Statistics/CountingInterval.swift @@ -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 = diff --git a/Sources/SpectroEDX/Fit/Continuum.swift b/Sources/SpectroEDX/Fit/Continuum.swift index 2671ee7..83ea2f1 100644 --- a/Sources/SpectroEDX/Fit/Continuum.swift +++ b/Sources/SpectroEDX/Fit/Continuum.swift @@ -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`, diff --git a/Sources/SpectroEDX/Method/QuantificationMethod.swift b/Sources/SpectroEDX/Method/QuantificationMethod.swift index cb67bec..815bc87 100644 --- a/Sources/SpectroEDX/Method/QuantificationMethod.swift +++ b/Sources/SpectroEDX/Method/QuantificationMethod.swift @@ -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 } diff --git a/Sources/SpectroEDX/Proposer/ProposalRules.swift b/Sources/SpectroEDX/Proposer/ProposalRules.swift index 8a44ff1..6306423 100644 --- a/Sources/SpectroEDX/Proposer/ProposalRules.swift +++ b/Sources/SpectroEDX/Proposer/ProposalRules.swift @@ -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 diff --git a/Sources/SpectroEDX/Quant/BoteSalvatCrossSection.swift b/Sources/SpectroEDX/Quant/BoteSalvatCrossSection.swift index 3e0a970..f46e5c1 100644 --- a/Sources/SpectroEDX/Quant/BoteSalvatCrossSection.swift +++ b/Sources/SpectroEDX/Quant/BoteSalvatCrossSection.swift @@ -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 @@ -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 } diff --git a/Sources/SpectroEDX/Quant/EDXQuantification.swift b/Sources/SpectroEDX/Quant/EDXQuantification.swift index 2ecf8e7..204c359 100644 --- a/Sources/SpectroEDX/Quant/EDXQuantification.swift +++ b/Sources/SpectroEDX/Quant/EDXQuantification.swift @@ -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 { diff --git a/Sources/SpectroEDX/Quant/KrauseFluorescenceYield.swift b/Sources/SpectroEDX/Quant/KrauseFluorescenceYield.swift index c628e91..69fd6fa 100644 --- a/Sources/SpectroEDX/Quant/KrauseFluorescenceYield.swift +++ b/Sources/SpectroEDX/Quant/KrauseFluorescenceYield.swift @@ -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? { diff --git a/Sources/SpectroEDX/Quant/MassAbsorption.swift b/Sources/SpectroEDX/Quant/MassAbsorption.swift index ca4d309..4f2846c 100644 --- a/Sources/SpectroEDX/Quant/MassAbsorption.swift +++ b/Sources/SpectroEDX/Quant/MassAbsorption.swift @@ -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 } diff --git a/Sources/SpectroEELS/EELSMLLS.swift b/Sources/SpectroEELS/EELSMLLS.swift index 86b1a21..2c3a813 100644 --- a/Sources/SpectroEELS/EELSMLLS.swift +++ b/Sources/SpectroEELS/EELSMLLS.swift @@ -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]) } @@ -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) } diff --git a/Sources/SpectroEELS/EELSSpectrumImage.swift b/Sources/SpectroEELS/EELSSpectrumImage.swift index f9ad726..1ba5ccf 100644 --- a/Sources/SpectroEELS/EELSSpectrumImage.swift +++ b/Sources/SpectroEELS/EELSSpectrumImage.swift @@ -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). diff --git a/Sources/SpectroEELS/PowerLawBackground.swift b/Sources/SpectroEELS/PowerLawBackground.swift index 3e309f8..59dcc2d 100644 --- a/Sources/SpectroEELS/PowerLawBackground.swift +++ b/Sources/SpectroEELS/PowerLawBackground.swift @@ -11,7 +11,6 @@ // import Foundation -import SpectroCore package nonisolated struct PowerLawWindow: Sendable, Equatable { package let i1: Int, i2: Int, i3: Int diff --git a/Tests/SpectroCoreTests/DM4VolumeGoneTests.swift b/Tests/SpectroCoreTests/DM4VolumeGoneTests.swift index cd5e356..71699ee 100644 --- a/Tests/SpectroCoreTests/DM4VolumeGoneTests.swift +++ b/Tests/SpectroCoreTests/DM4VolumeGoneTests.swift @@ -1,6 +1,5 @@ import Foundation import Testing -import SpectroCore import FormatoDM /// A DM4 whose disk has been diff --git a/Tests/SpectroCoreTests/VeloxElementSelectionTests.swift b/Tests/SpectroCoreTests/VeloxElementSelectionTests.swift index b8402d3..86f8864 100644 --- a/Tests/SpectroCoreTests/VeloxElementSelectionTests.swift +++ b/Tests/SpectroCoreTests/VeloxElementSelectionTests.swift @@ -1,6 +1,5 @@ import Foundation import Testing -import SpectroCore import FormatoEMD /// Velox's own element selection, read from the file (`VeloxEMDReader.storedElementSelection`). diff --git a/Tests/SpectroEDXTests/AxisGateTests.swift b/Tests/SpectroEDXTests/AxisGateTests.swift index 51fa3ee..10cf827 100644 --- a/Tests/SpectroEDXTests/AxisGateTests.swift +++ b/Tests/SpectroEDXTests/AxisGateTests.swift @@ -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") diff --git a/Tests/SpectroEDXTests/CountsGateTests.swift b/Tests/SpectroEDXTests/CountsGateTests.swift index 851c6f2..625bb7d 100644 --- a/Tests/SpectroEDXTests/CountsGateTests.swift +++ b/Tests/SpectroEDXTests/CountsGateTests.swift @@ -14,7 +14,6 @@ import Foundation import Testing import SpectroTestSupport import SpectroCore -import SpectroEDX import FormatoEMD struct CountsGateTests { diff --git a/Tests/SpectroEDXTests/DemoEDXAutoIDPinTests.swift b/Tests/SpectroEDXTests/DemoEDXAutoIDPinTests.swift index 08e0d4c..7f0459b 100644 --- a/Tests/SpectroEDXTests/DemoEDXAutoIDPinTests.swift +++ b/Tests/SpectroEDXTests/DemoEDXAutoIDPinTests.swift @@ -1,6 +1,5 @@ import Foundation import Testing -import SpectroTestSupport import SpectroCore import SpectroEDX diff --git a/Tests/SpectroEDXTests/DemoEDXAutoIDTests.swift b/Tests/SpectroEDXTests/DemoEDXAutoIDTests.swift index d91c829..5869ec9 100644 --- a/Tests/SpectroEDXTests/DemoEDXAutoIDTests.swift +++ b/Tests/SpectroEDXTests/DemoEDXAutoIDTests.swift @@ -1,6 +1,5 @@ import Foundation import Testing -import SpectroTestSupport import SpectroCore import SpectroEDX diff --git a/Tests/SpectroEDXTests/QuantificationMethodTests.swift b/Tests/SpectroEDXTests/QuantificationMethodTests.swift index ffe486e..ad830d9 100644 --- a/Tests/SpectroEDXTests/QuantificationMethodTests.swift +++ b/Tests/SpectroEDXTests/QuantificationMethodTests.swift @@ -6,7 +6,6 @@ // import Foundation import Testing -import SpectroCore import SpectroEDX @MainActor diff --git a/Tests/SpectroEDXTests/SpectroscopyComputedKTests.swift b/Tests/SpectroEDXTests/SpectroscopyComputedKTests.swift index 87fe936..e665b96 100644 --- a/Tests/SpectroEDXTests/SpectroscopyComputedKTests.swift +++ b/Tests/SpectroEDXTests/SpectroscopyComputedKTests.swift @@ -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, diff --git a/Tests/SpectroEDXTests/SpectroscopyQuantTests.swift b/Tests/SpectroEDXTests/SpectroscopyQuantTests.swift index 8577534..54c545f 100644 --- a/Tests/SpectroEDXTests/SpectroscopyQuantTests.swift +++ b/Tests/SpectroEDXTests/SpectroscopyQuantTests.swift @@ -1,7 +1,6 @@ import Foundation import Testing import SpectroTestSupport -import SpectroCore import SpectroEDX /// k-factors, Cliff-Lorimer / zeta / cross-section quantification and diff --git a/Tests/SpectroEDXTests/SumEscapeIdenticalTests.swift b/Tests/SpectroEDXTests/SumEscapeIdenticalTests.swift index 255d1ff..cf82e46 100644 --- a/Tests/SpectroEDXTests/SumEscapeIdenticalTests.swift +++ b/Tests/SpectroEDXTests/SumEscapeIdenticalTests.swift @@ -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. diff --git a/Tests/SpectroEELSTests/SavitzkyGolayPortTests.swift b/Tests/SpectroEELSTests/SavitzkyGolayPortTests.swift index e4a884e..dc504f6 100644 --- a/Tests/SpectroEELSTests/SavitzkyGolayPortTests.swift +++ b/Tests/SpectroEELSTests/SavitzkyGolayPortTests.swift @@ -12,7 +12,6 @@ import Foundation import Testing import SpectroTestSupport import SpectroEELS -import SpectroCore struct SavitzkyGolayPortTests { diff --git a/Tests/SpectroKitParityTests/EDSQuantPinsTests.swift b/Tests/SpectroKitParityTests/EDSQuantPinsTests.swift index 4d14f98..dbdb3de 100644 --- a/Tests/SpectroKitParityTests/EDSQuantPinsTests.swift +++ b/Tests/SpectroKitParityTests/EDSQuantPinsTests.swift @@ -1,7 +1,6 @@ import Foundation import Testing import SpectroTestSupport -import SpectroCore import SpectroEDX /// eXSpy quantification pins (tools/edx-exspy-pins/quant_pins.py). diff --git a/Tests/SpectroKitParityTests/EDXQuantificationTests.swift b/Tests/SpectroKitParityTests/EDXQuantificationTests.swift index 43701e0..82aa67e 100644 --- a/Tests/SpectroKitParityTests/EDXQuantificationTests.swift +++ b/Tests/SpectroKitParityTests/EDXQuantificationTests.swift @@ -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 diff --git a/Tests/SpectroKitParityTests/LineTableParityTests.swift b/Tests/SpectroKitParityTests/LineTableParityTests.swift index 768eb42..4ae0e81 100644 --- a/Tests/SpectroKitParityTests/LineTableParityTests.swift +++ b/Tests/SpectroKitParityTests/LineTableParityTests.swift @@ -8,7 +8,6 @@ import Foundation import Testing import SpectroTestSupport -import SpectroCore import SpectroEDX struct LineTableParityTests { diff --git a/Tests/SpectroKitParityTests/MLLSPinsTests.swift b/Tests/SpectroKitParityTests/MLLSPinsTests.swift index 2dce302..210e7f1 100644 --- a/Tests/SpectroKitParityTests/MLLSPinsTests.swift +++ b/Tests/SpectroKitParityTests/MLLSPinsTests.swift @@ -14,7 +14,6 @@ import Foundation import Testing -import SpectroTestSupport import SpectroEELS struct MLLSPinsTests { diff --git a/Tests/SpectroKitParityTests/RLMLLSSpeedTests.swift b/Tests/SpectroKitParityTests/RLMLLSSpeedTests.swift index 40b8b95..7027caf 100644 --- a/Tests/SpectroKitParityTests/RLMLLSSpeedTests.swift +++ b/Tests/SpectroKitParityTests/RLMLLSSpeedTests.swift @@ -5,7 +5,6 @@ import Foundation import Testing -import SpectroTestSupport import SpectroEELS struct RLMLLSSpeedTests { diff --git a/Tests/SpectroKitParityTests/SavitzkyGolayBitParityTests.swift b/Tests/SpectroKitParityTests/SavitzkyGolayBitParityTests.swift index d7137f7..6e8ffa6 100644 --- a/Tests/SpectroKitParityTests/SavitzkyGolayBitParityTests.swift +++ b/Tests/SpectroKitParityTests/SavitzkyGolayBitParityTests.swift @@ -13,7 +13,6 @@ import Foundation import Testing import SpectroTestSupport import SpectroEELS -import SpectroCore struct SavitzkyGolayBitParityTests { diff --git a/Tests/SpectroTestSupport/PlantedRuns.swift b/Tests/SpectroTestSupport/PlantedRuns.swift index 03ee046..44c0255 100644 --- a/Tests/SpectroTestSupport/PlantedRuns.swift +++ b/Tests/SpectroTestSupport/PlantedRuns.swift @@ -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).