@photivra/engine 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +289 -1
- package/CITATION.cff +1 -1
- package/NODE_SUPPORT.md +7 -5
- package/README.md +7 -6
- package/SECURITY.md +1 -1
- package/THIRD_PARTY.md +21 -10
- package/dist/capture/dng-lens-correction-opcodes.d.ts +32 -0
- package/dist/capture/dng-lens-correction-opcodes.js +119 -0
- package/dist/capture/dng-lens-correction-opcodes.js.map +1 -0
- package/dist/capture/exposure-build-up-stage.d.ts +16 -0
- package/dist/capture/exposure-build-up-stage.js +4 -0
- package/dist/capture/exposure-build-up-stage.js.map +1 -0
- package/dist/capture/native-environment-lean.d.ts +2 -1
- package/dist/capture/native-environment-lean.js +42 -78
- package/dist/capture/native-environment-lean.js.map +1 -1
- package/dist/capture/native-environment-tabulated.js +4 -3
- package/dist/capture/native-environment-tabulated.js.map +1 -1
- package/dist/capture/native-raw-dng.d.ts +6 -0
- package/dist/capture/native-raw-dng.js +16 -2
- package/dist/capture/native-raw-dng.js.map +1 -1
- package/dist/capture/native-raw.d.ts +3 -2
- package/dist/capture/native-raw.js +5 -4
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/capture/sensor-raw-producer.d.ts +4 -1
- package/dist/capture/sensor-raw-producer.js +15 -8
- package/dist/capture/sensor-raw-producer.js.map +1 -1
- package/dist/core/shared-helpers.d.ts +2 -0
- package/dist/core/shared-helpers.js +4 -0
- package/dist/core/shared-helpers.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-lens-catalogue.d.ts +11 -4
- package/dist/equipment/generic-lens-catalogue.js +49 -7
- package/dist/equipment/generic-lens-catalogue.js.map +1 -1
- package/dist/equipment/generic-tier-assets.d.ts +32 -0
- package/dist/equipment/generic-tier-assets.js +18 -14
- package/dist/equipment/generic-tier-assets.js.map +1 -1
- package/dist/equipment/generic-tier-presets.js +2 -3
- package/dist/equipment/generic-tier-presets.js.map +1 -1
- package/dist/equipment/sensor-profile-body.d.ts +78 -0
- package/dist/equipment/sensor-profile-body.js +77 -0
- package/dist/equipment/sensor-profile-body.js.map +1 -0
- package/dist/equipment/sensor-profiles.d.ts +8 -0
- package/dist/equipment/sensor-profiles.js +82 -0
- package/dist/equipment/sensor-profiles.js.map +1 -0
- package/dist/facade/catalogue-lens-signal.d.ts +2 -2
- package/dist/facade/catalogue-lens-signal.js +58 -71
- package/dist/facade/catalogue-lens-signal.js.map +1 -1
- package/dist/facade/chart-radiance-batch.js +2 -1
- package/dist/facade/chart-radiance-batch.js.map +1 -1
- package/dist/facade/defocus-image-space-provider.d.ts +7 -0
- package/dist/facade/defocus-image-space-provider.js +64 -76
- package/dist/facade/defocus-image-space-provider.js.map +1 -1
- package/dist/facade/display-view-gpu-session.js +2 -0
- package/dist/facade/display-view-gpu-session.js.map +1 -1
- package/dist/facade/display-view-gpu.d.ts +13 -5
- package/dist/facade/display-view-gpu.js +4 -4
- package/dist/facade/display-view-gpu.js.map +1 -1
- package/dist/facade/display-view-lens-signal.d.ts +1 -1
- package/dist/facade/display-view-lens-signal.js +30 -26
- package/dist/facade/display-view-lens-signal.js.map +1 -1
- package/dist/facade/display-view.d.ts +3 -1
- package/dist/facade/display-view.js +6 -24
- package/dist/facade/display-view.js.map +1 -1
- package/dist/facade/expected-signal-setup.d.ts +3 -1
- package/dist/facade/expected-signal-setup.js +1 -1
- package/dist/facade/expected-signal-setup.js.map +1 -1
- package/dist/facade/expected-signal.d.ts +47 -14
- package/dist/facade/expected-signal.js +117 -112
- package/dist/facade/expected-signal.js.map +1 -1
- package/dist/facade/exposure-build-up.d.ts +70 -0
- package/dist/facade/exposure-build-up.js +164 -0
- package/dist/facade/exposure-build-up.js.map +1 -0
- package/dist/facade/fast-methods.d.ts +50 -0
- package/dist/facade/fast-methods.js +58 -0
- package/dist/facade/fast-methods.js.map +1 -0
- package/dist/facade/fast-resolution.d.ts +12 -0
- package/dist/facade/fast-resolution.js +18 -0
- package/dist/facade/fast-resolution.js.map +1 -0
- package/dist/facade/generic-lens-capture.d.ts +5 -4
- package/dist/facade/generic-lens-capture.js +5 -4
- package/dist/facade/generic-lens-capture.js.map +1 -1
- package/dist/facade/image-plane-enable.d.ts +7 -0
- package/dist/facade/image-plane-enable.js +17 -0
- package/dist/facade/image-plane-enable.js.map +1 -0
- package/dist/facade/image-plane-lattice-data.d.ts +6 -0
- package/dist/facade/image-plane-lattice-data.js +10 -0
- package/dist/facade/image-plane-lattice-data.js.map +1 -0
- package/dist/facade/image-plane-support.d.ts +33 -0
- package/dist/facade/image-plane-support.js +11 -0
- package/dist/facade/image-plane-support.js.map +1 -0
- package/dist/facade/image-plane.d.ts +36 -0
- package/dist/facade/image-plane.js +353 -0
- package/dist/facade/image-plane.js.map +1 -0
- package/dist/facade/mixed-illumination.d.ts +108 -0
- package/dist/facade/mixed-illumination.js +174 -0
- package/dist/facade/mixed-illumination.js.map +1 -0
- package/dist/facade/representative-light-sources.d.ts +72 -0
- package/dist/facade/representative-light-sources.js +124 -0
- package/dist/facade/representative-light-sources.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +129 -4
- package/dist/facade/scene-radiance.js +48 -13
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +88 -19
- package/dist/facade/simulate-capture.js +374 -145
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.d.ts +3 -2
- package/dist/facade/simulate-display-view.js +36 -18
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/chart-composite-gpu.d.ts +13 -1
- package/dist/gpu/chart-composite-gpu.js +48 -9
- package/dist/gpu/chart-composite-gpu.js.map +1 -1
- package/dist/gpu/chart-radiance-gpu.js +4 -30
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/gpu/display-view-composite-material-module.d.ts +10 -4
- package/dist/gpu/display-view-composite-material-module.js +39 -13
- package/dist/gpu/display-view-composite-material-module.js.map +1 -1
- package/dist/gpu/display-view-image-material-module.d.ts +86 -0
- package/dist/gpu/display-view-image-material-module.js +339 -0
- package/dist/gpu/display-view-image-material-module.js.map +1 -0
- package/dist/gpu/display-view-image-quality.d.ts +45 -0
- package/dist/gpu/display-view-image-quality.js +380 -0
- package/dist/gpu/display-view-image-quality.js.map +1 -0
- package/dist/gpu/display-view-quality-gpu.d.ts +67 -1
- package/dist/gpu/display-view-quality-gpu.js +136 -205
- package/dist/gpu/display-view-quality-gpu.js.map +1 -1
- package/dist/gpu/display-view-speed-gpu.d.ts +51 -3
- package/dist/gpu/display-view-speed-gpu.js +131 -93
- package/dist/gpu/display-view-speed-gpu.js.map +1 -1
- package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +29 -15
- package/dist/gpu/wgsl-display-view-quality-kernel.js +58 -36
- package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
- package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +21 -6
- package/dist/gpu/wgsl-display-view-speed-kernel.js +46 -11
- package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
- package/dist/gpu/wgsl-exact-sum.d.ts +20 -0
- package/dist/gpu/wgsl-exact-sum.js +42 -0
- package/dist/gpu/wgsl-exact-sum.js.map +1 -0
- package/dist/index.d.ts +18 -3
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/motion/subject-motion.d.ts +66 -0
- package/dist/motion/subject-motion.js +52 -0
- package/dist/motion/subject-motion.js.map +1 -0
- package/dist/optics/aperture-diameter.d.ts +47 -0
- package/dist/optics/aperture-diameter.js +50 -0
- package/dist/optics/aperture-diameter.js.map +1 -0
- package/dist/optics/detail-limit.d.ts +182 -0
- package/dist/optics/detail-limit.js +336 -0
- package/dist/optics/detail-limit.js.map +1 -0
- package/dist/optics/generic-lens-lateral-color.d.ts +83 -0
- package/dist/optics/generic-lens-lateral-color.js +77 -0
- package/dist/optics/generic-lens-lateral-color.js.map +1 -0
- package/dist/optics/generic-lens-psf.d.ts +18 -2
- package/dist/optics/generic-lens-psf.js +79 -48
- package/dist/optics/generic-lens-psf.js.map +1 -1
- package/dist/optics/lens-psf-profile.d.ts +7 -0
- package/dist/optics/lens-psf-profile.js +2 -1
- package/dist/optics/lens-psf-profile.js.map +1 -1
- package/dist/optics/scene-to-sensor-irradiance.d.ts +13 -0
- package/dist/optics/scene-to-sensor-irradiance.js +7 -0
- package/dist/optics/scene-to-sensor-irradiance.js.map +1 -1
- package/dist/output/crop-to-match-focal-length.d.ts +62 -0
- package/dist/output/crop-to-match-focal-length.js +63 -0
- package/dist/output/crop-to-match-focal-length.js.map +1 -0
- package/dist/output/developed-lens-corrections.d.ts +19 -5
- package/dist/output/developed-lens-corrections.js +30 -11
- package/dist/output/developed-lens-corrections.js.map +1 -1
- package/dist/output/generic-lens-corrections.d.ts +41 -3
- package/dist/output/generic-lens-corrections.js +57 -9
- package/dist/output/generic-lens-corrections.js.map +1 -1
- package/dist/output/lens-corrections.d.ts +12 -2
- package/dist/output/lens-corrections.js +22 -7
- package/dist/output/lens-corrections.js.map +1 -1
- package/dist/output/print-contrast-reference.js +1 -1
- package/dist/output/print-contrast-reference.js.map +1 -1
- package/dist/output/print-plan.d.ts +41 -5
- package/dist/output/print-plan.js +59 -14
- package/dist/output/print-plan.js.map +1 -1
- package/dist/output/print-size-blur-noise.d.ts +110 -0
- package/dist/output/print-size-blur-noise.js +138 -0
- package/dist/output/print-size-blur-noise.js.map +1 -0
- package/dist/sensor/binomial-sample.d.ts +3 -0
- package/dist/sensor/binomial-sample.js +86 -0
- package/dist/sensor/binomial-sample.js.map +1 -0
- package/dist/sensor/eqe-electron-rate.js +1 -7
- package/dist/sensor/eqe-electron-rate.js.map +1 -1
- package/dist/sensor/exposure-window.d.ts +2 -0
- package/dist/sensor/exposure-window.js +2 -2
- package/dist/sensor/exposure-window.js.map +1 -1
- package/dist/sensor/readout-timing.js +2 -23
- package/dist/sensor/readout-timing.js.map +1 -1
- package/dist/sensor/response-application-compatibility.js +1 -6
- package/dist/sensor/response-application-compatibility.js.map +1 -1
- package/dist/sensor/responsivity-photocurrent.js +1 -7
- package/dist/sensor/responsivity-photocurrent.js.map +1 -1
- package/dist/sensor/sensor-characteristics.d.ts +147 -0
- package/dist/sensor/sensor-characteristics.js +126 -0
- package/dist/sensor/sensor-characteristics.js.map +1 -0
- package/dist/sensor/spatial-sample-reduction.js +1 -5
- package/dist/sensor/spatial-sample-reduction.js.map +1 -1
- package/dist/sensor/spectral-quadrature.js +1 -6
- package/dist/sensor/spectral-quadrature.js.map +1 -1
- package/dist/sensor/temporal-photo-signal.d.ts +3 -0
- package/dist/sensor/temporal-photo-signal.js +5 -2
- package/dist/sensor/temporal-photo-signal.js.map +1 -1
- package/dist/stabilization/system.d.ts +9 -0
- package/dist/stabilization/system.js +5 -6
- package/dist/stabilization/system.js.map +1 -1
- package/docs/AGENT_GUIDE.md +5 -0
- package/docs/API_REFERENCE.md +173 -2
- package/docs/QUICK_START.md +213 -6
- package/docs/USAGE.md +157 -3
- package/docs/api/capture-native-raw-dng.md +6 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-lens-catalogue.md +17 -7
- package/docs/api/equipment-sensor-profile-body.md +64 -0
- package/docs/api/equipment-sensor-profiles.md +86 -0
- package/docs/api/exports.json +357 -2
- package/docs/api/facade-display-view-gpu.md +5 -2
- package/docs/api/facade-exposure-build-up.md +105 -0
- package/docs/api/facade-fast-methods.md +99 -0
- package/docs/api/facade-image-plane-enable.md +16 -0
- package/docs/api/facade-mixed-illumination.md +67 -0
- package/docs/api/facade-representative-light-sources.md +131 -0
- package/docs/api/facade-scene-radiance.md +54 -3
- package/docs/api/facade-simulate-capture.md +60 -15
- package/docs/api/facade-simulate-display-view.md +3 -2
- package/docs/api/motion-subject-motion.md +23 -0
- package/docs/api/optics-aperture-diameter.md +51 -0
- package/docs/api/optics-detail-limit.md +203 -0
- package/docs/api/optics-generic-lens-lateral-color.md +79 -0
- package/docs/api/output-crop-to-match-focal-length.md +67 -0
- package/docs/api/output-developed-lens-corrections.md +10 -1
- package/docs/api/output-generic-lens-corrections.md +40 -2
- package/docs/api/output-lens-corrections.md +11 -1
- package/docs/api/output-print-plan.md +35 -1
- package/docs/api/output-print-size-blur-noise.md +115 -0
- package/docs/api/sensor-sensor-characteristics.md +105 -0
- package/llms.txt +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectral-quadrature.js","sourceRoot":"","sources":["../../src/sensor/spectral-quadrature.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;GAUG;AAEH,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAKpE,OAAO,EACL,+BAA+B,EAEhC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0CAA0C,EAC1C,kCAAkC,EAClC,yCAAyC,EAK1C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,IAAI,qBAAqB,EAAE,kCAAkC,IAAI,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC1L,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,6BAA6B,GAAG,OAAO,CAAC;AA6I9C,SAAS,eAAe,CACtB,OAAsC,EACtC,SAAiB;IAEjB,IACE,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAC7B,CAAC;QACD,MAAM,IAAI,yBAAyB,CACjC,uCAAuC,CACxC,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CACpC,CAAC,KAAK,EAAE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,EACJ,cAAc;iBACX,iBAAiB,CAAC,MAAM;SAC9B;QACD,sBAAsB,EAAE,KAAK;QAC7B,4BAA4B,EAC1B,KAAK;QACP,4BAA4B,EAC1B,KAAK;QACP,0BAA0B,EACxB,KAAK;QACP,gCAAgC,EAC9B,KAAK;QACP,+BAA+B,EAC7B,KAAK;QACP,uCAAuC,EACrC,IAAI;QACN,4BAA4B,EAC1B,KAAK;QACP,uCAAuC,EACrC,KAAK;QACP,8BAA8B,EAC5B,KAAK;QACP,2BAA2B,EACzB,KAAK;QACP,4BAA4B,EAC1B,KAAK;QACP,iBAAiB,EAAE,KAAK;QACxB,mBAAmB,EAAE,KAAK;QAC1B,oBAAoB,EAAE,KAAK;QAC3B,yBAAyB,EAAE,KAAK;KACjC,EACD,4BAA4B,EAC5B,OAAO,EACP;QACE,0IAA0I;QAC1I,iIAAiI;QACjI,gKAAgK;QAChK,kLAAkL;QAClL,mMAAmM;QACnM,uIAAuI;QACvI,6JAA6J;QAC7J,wMAAwM;QACxM,4NAA4N;QAC5N,oJAAoJ;QACpJ,6HAA6H;KAC9H,CACF,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Spectral quadrature: the wavelength sample points (nodes) and step widths used to integrate light\n * over wavelength for one sensor response channel.\n *\n * Each node is the midpoint of a wavelength interval, with its width dλ in nanometres. The intervals\n * stay inside the range the response supports. Lining nodes up with curve breakpoints does not prove\n * the integral has converged. Discrete (delta-like) emission lines need their own integration and are\n * never silently widened into continuous bins.\n * @see docs/MOTION_AND_SIGNAL.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport {\n approximationResult,\n type CalculationResult\n} from \"../core/calculation-result.js\";\nimport type { EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport { InvalidScientificInputError } from \"../core/validation.js\";\nimport type {\n SpectralWavelengthBasis,\n SpectralWavelengthRangeNanometers\n} from \"../core/spectral.js\";\nimport {\n parseSensorColorSamplingProfile,\n type SensorColorSamplingProfile\n} from \"./color-sampling.js\";\nimport {\n createSensorSpectralResponseChannelBinding,\n parseSensorSpectralResponseProfile,\n resolveSensorSpectralResponseAtWavelength,\n type SensorSpectralReferenceConditions,\n type SensorSpectralResponseProfile,\n type SensorSpectralResponseScientificStatus,\n type SensorSpectralResponseUncertainty\n} from \"./spectral-response.js\";\nimport { requireInputKeys, requireInputPositiveFinite as requirePositiveFinite, requireInputNonNegativeSafeInteger as requireNonNegativeSafeInteger } from \"../core/record-validation.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { responseCurves } from \"./spectral-coverage.js\";\n\nconst MAX_SPECTRAL_QUADRATURE_NODES = 100_000;\n\nexport type SensorSpectralWavelengthRangeNanometers =\n SpectralWavelengthRangeNanometers;\n\nexport interface CalculateSensorSpectralQuadratureInput {\n colorSamplingProfile: SensorColorSamplingProfile;\n spectralResponseProfile: SensorSpectralResponseProfile;\n channelId: string;\n wavelengthBasis: SpectralWavelengthBasis;\n /**\n * Wavelength interval to sample. It is checked only against the range the\n * sensor response supports, not against scene-spectrum or optical-transmission\n * coverage.\n */\n wavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n /**\n * Strict upper limit on the width of each midpoint subinterval.\n *\n * Response breakpoints and any additional breakpoints split the requested\n * range first. Each segment is then subdivided until every subinterval is\n * no wider than this value.\n */\n maximumSubintervalWidthNanometers: number;\n /**\n * Optional strictly increasing wavelength breakpoints from other continuous\n * spectral inputs, such as the interpolation points of a scene spectrum or of\n * optical transmission. Values must be strictly inside the requested range.\n *\n * Passing them does not claim those other inputs are available or valid over\n * the requested range.\n */\n additionalBreakpointsNanometers?:\n readonly number[];\n}\n\nexport interface SensorSpectralQuadratureNode {\n spectralSampleIndex: number;\n segmentIndex: number;\n subdivisionIndex: number;\n segmentSubdivisionCount: number;\n /**\n * Midpoint wavelength for this subinterval. Units: nm in wavelengthBasis.\n */\n wavelengthNanometers: number;\n /**\n * dλ (wavelength width) this node stands for. Units: nm.\n *\n * It is only a wavelength width. It is not response-weighted throughput,\n * a photon count, radiant energy, current or a dimensionless probability.\n */\n wavelengthMeasureNanometers: number;\n /**\n * The wavelength width divided by the requested range width (dimensionless).\n *\n * Useful for averages, but it is not a sensor-response weight.\n */\n normalizedWavelengthWeight: number;\n}\n\nexport interface SensorSpectralQuadrature {\n profileId: string;\n colorSamplingProfileId: string;\n channelId: string;\n sourceResponseKind:\n SensorSpectralResponseProfile[\"channels\"][number][\"kind\"];\n responseScope:\n SensorSpectralResponseProfile[\"channels\"][number][\"responseScope\"];\n responseScientificStatus:\n SensorSpectralResponseScientificStatus;\n responseUncertainty:\n SensorSpectralResponseUncertainty;\n responseChannelBinding?: import(\"./spectral-response.js\").SensorSpectralResponseChannelBinding;\n responseReferenceConditions?:\n SensorSpectralReferenceConditions;\n wavelengthBasis: SpectralWavelengthBasis;\n wavelengthBasisResolved: boolean;\n wavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n responseDeclaredWavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n quadratureScheme:\n \"response-breakpoint-aware-bounded-midpoint\";\n segmentBoundarySource:\n \"requested-range-plus-response-knots-plus-optional-additional-breakpoints\";\n /**\n * Sorted, unique segment boundaries, including the ends of the requested range.\n */\n segmentBoundariesNanometers:\n readonly number[];\n maximumSubintervalWidthNanometers: number;\n segmentCount: number;\n totalNodeCount: number;\n normalizedWavelengthWeightSum: number;\n wavelengthMeasureSumNanometers: number;\n nodes: readonly SensorSpectralQuadratureNode[];\n responseKnotAlignmentIncluded: true;\n componentEvidence: {\n colorSamplingProfile: readonly EvidenceProvenance[];\n profile: readonly EvidenceProvenance[];\n channel: readonly EvidenceProvenance[];\n curves:\n readonly (readonly EvidenceProvenance[])[];\n };\n /**\n * Fixed statements of what this result does not include.\n */\n responseValuesIncluded: false;\n responseApplicationPerformed: false;\n sourceSpectralValuesIncluded: false;\n spectralIrradianceIncluded: false;\n spectralPhotonIrradianceIncluded: false;\n commonSpectralCoverageValidated: false;\n continuousSpectralDensityQuadratureOnly: true;\n discreteLineSpectrumIncluded: false;\n opticalTransmissionIncludedByQuadrature: false;\n wavelengthIntegrationPerformed: false;\n spatialIntegrationPerformed: false;\n temporalIntegrationPerformed: false;\n photonsCalculated: false;\n electronsCalculated: false;\n rawCodeValueProduced: false;\n convergenceErrorEstimated: false;\n}\n\ninterface ResponseCurveSupport {\n wavelengthBasis: SpectralWavelengthBasis;\n samples: readonly {\n wavelengthNanometers: number;\n }[];\n evidence: readonly EvidenceProvenance[];\n}\n\ninterface SegmentPlan {\n minimum: number;\n maximum: number;\n subdivisionCount: number;\n subintervalWidthNanometers: number;\n}\n\nfunction channelResponse(\n profile: SensorSpectralResponseProfile,\n channelId: string\n): SensorSpectralResponseProfile[\"channels\"][number] {\n if (\n typeof channelId !== \"string\" ||\n channelId.trim().length === 0\n ) {\n throw new InvalidConfigurationError(\n \"channelId must be a non-empty string.\"\n );\n }\n\n const response = profile.channels.find(\n (entry) => entry.channelId === channelId\n );\n if (response === undefined) {\n throw new InvalidScientificInputError(\n \"No spectral response is declared for the requested channelId.\"\n );\n }\n return response;\n}\n\nfunction usableResponseRange(\n curves: readonly ResponseCurveSupport[]\n): SensorSpectralWavelengthRangeNanometers {\n const minimum = Math.max(\n ...curves.map(\n (curve) =>\n curve.samples[0]!\n .wavelengthNanometers\n )\n );\n const maximum = Math.min(\n ...curves.map(\n (curve) =>\n curve.samples[\n curve.samples.length - 1\n ]!.wavelengthNanometers\n )\n );\n\n if (!(minimum < maximum)) {\n throw new InvalidScientificInputError(\n \"Spectral-response curves do not have a usable overlapping wavelength interval.\"\n );\n }\n\n return { minimum, maximum };\n}\n\nfunction parseRequestedRange(\n input:\n SensorSpectralWavelengthRangeNanometers,\n usable:\n SensorSpectralWavelengthRangeNanometers\n): SensorSpectralWavelengthRangeNanometers {\n if (\n typeof input !== \"object\" ||\n input === null\n ) {\n throw new InvalidConfigurationError(\n \"wavelengthRangeNanometers must be an object.\"\n );\n }\n\n const minimum = requirePositiveFinite(\n input.minimum,\n \"wavelengthRangeNanometers.minimum\"\n );\n const maximum = requirePositiveFinite(\n input.maximum,\n \"wavelengthRangeNanometers.maximum\"\n );\n\n if (!(minimum < maximum)) {\n throw new InvalidScientificInputError(\n \"wavelengthRangeNanometers.minimum must be less than maximum.\"\n );\n }\n\n if (\n minimum < usable.minimum ||\n maximum > usable.maximum\n ) {\n throw new InvalidScientificInputError(\n \"Requested wavelength range must remain inside the usable spectral-response range; clipping, extrapolation, and implicit zero-fill are not permitted.\"\n );\n }\n\n return { minimum, maximum };\n}\n\nfunction additionalBreakpoints(\n value: readonly number[] | undefined,\n range:\n SensorSpectralWavelengthRangeNanometers\n): readonly number[] {\n if (value === undefined) {\n return [];\n }\n if (!Array.isArray(value)) {\n throw new InvalidConfigurationError(\n \"additionalBreakpointsNanometers must be an array when supplied.\"\n );\n }\n if (\n value.length >=\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"additionalBreakpointsNanometers contains too many entries for the spectral quadrature safety limit.\"\n );\n }\n\n let previous =\n Number.NEGATIVE_INFINITY;\n\n return value.map(\n (entry, index) => {\n const wavelength =\n requirePositiveFinite(\n entry,\n \"additionalBreakpointsNanometers[\" +\n index +\n \"]\"\n );\n if (\n wavelength <= range.minimum ||\n wavelength >= range.maximum\n ) {\n throw new InvalidScientificInputError(\n \"Additional spectral breakpoints must lie strictly inside the requested wavelength range.\"\n );\n }\n if (wavelength <= previous) {\n throw new InvalidScientificInputError(\n \"additionalBreakpointsNanometers must be strictly increasing with no duplicates.\"\n );\n }\n previous = wavelength;\n return wavelength;\n }\n );\n}\n\nfunction partitionBoundaries(\n curves: readonly ResponseCurveSupport[],\n range:\n SensorSpectralWavelengthRangeNanometers,\n additional:\n readonly number[]\n): readonly number[] {\n const boundaries = new Set<number>([\n range.minimum,\n range.maximum,\n ...additional\n ]);\n\n for (const curve of curves) {\n for (const sample of curve.samples) {\n if (\n sample.wavelengthNanometers >\n range.minimum &&\n sample.wavelengthNanometers <\n range.maximum\n ) {\n boundaries.add(\n sample.wavelengthNanometers\n );\n }\n }\n }\n\n return [...boundaries].sort(\n (a, b) => a - b\n );\n}\n\nfunction planSegments(\n boundaries: readonly number[],\n maximumSubintervalWidthNanometers: number\n): {\n segments: readonly SegmentPlan[];\n totalNodeCount: number;\n} {\n const segments: SegmentPlan[] = [];\n let totalNodeCount = 0;\n\n for (\n let segmentIndex = 0;\n segmentIndex < boundaries.length - 1;\n segmentIndex += 1\n ) {\n const minimum =\n boundaries[segmentIndex]!;\n const maximum =\n boundaries[segmentIndex + 1]!;\n const width =\n maximum - minimum;\n\n if (\n !Number.isFinite(width) ||\n width <= 0\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature segment widths must be finite and greater than zero.\"\n );\n }\n\n const subdivisionCount =\n Math.ceil(\n width /\n maximumSubintervalWidthNanometers\n );\n\n if (\n !Number.isSafeInteger(\n subdivisionCount\n ) ||\n subdivisionCount <= 0\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature segment subdivision count must be a positive safe integer.\"\n );\n }\n\n totalNodeCount +=\n subdivisionCount;\n\n if (\n !Number.isSafeInteger(\n totalNodeCount\n )\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature node count must remain a safe integer.\"\n );\n }\n if (\n totalNodeCount >\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature node count exceeds the safety limit of \" +\n MAX_SPECTRAL_QUADRATURE_NODES +\n \".\"\n );\n }\n\n segments.push({\n minimum,\n maximum,\n subdivisionCount,\n subintervalWidthNanometers:\n width / subdivisionCount\n });\n }\n\n if (segments.length === 0) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature requires at least one non-empty segment.\"\n );\n }\n\n return {\n segments,\n totalNodeCount\n };\n}\n\nconst SPECTRAL_VALIDATION_TOLERANCE = 1e-10;\n\nfunction approximatelyEqual(\n actual: number,\n expected: number,\n tolerance = SPECTRAL_VALIDATION_TOLERANCE\n): boolean {\n const scale = Math.max(\n 1,\n Math.abs(actual),\n Math.abs(expected)\n );\n return (\n Math.abs(actual - expected) <=\n tolerance * scale\n );\n}\n\n/**\n * Rechecks a supplied wavelength plan (node identities, coverage and widths in nanometres) before it\n * is used.\n *\n * Lining nodes up with breakpoints does not prove convergence. Discrete (delta-like) lines need their\n * own integration and are never silently widened into continuous bins.\n * @param quadrature - The input; see `SensorSpectralQuadrature` for its fields, units and coordinates.\n * @returns The result. Success does not imply calibration.\n *\n * @see docs/API_REFERENCE.md for the package export and its full type definitions.\n */\nexport function validateSensorSpectralQuadrature(\n quadrature: SensorSpectralQuadrature\n): Map<number, SensorSpectralQuadratureNode> {\n if (\n typeof quadrature !== \"object\" ||\n quadrature === null ||\n !Array.isArray(quadrature.nodes)\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature must contain a nodes array.\"\n );\n }\n\n for (const [field, value] of [\n [\"profileId\", quadrature.profileId],\n [\n \"colorSamplingProfileId\",\n quadrature.colorSamplingProfileId\n ],\n [\"channelId\", quadrature.channelId]\n ] as const) {\n if (\n typeof value !== \"string\" ||\n value.trim().length === 0\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature.\" +\n field +\n \" must be a non-empty string.\"\n );\n }\n }\n\n if (\n quadrature.wavelengthBasis !== \"air\" &&\n quadrature.wavelengthBasis !== \"vacuum\" &&\n quadrature.wavelengthBasis !== \"unspecified\"\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature.wavelengthBasis is invalid.\"\n );\n }\n\n const rangeMinimum = requirePositiveFinite(\n quadrature.wavelengthRangeNanometers.minimum,\n \"spectralQuadrature.wavelengthRangeNanometers.minimum\"\n );\n const rangeMaximum = requirePositiveFinite(\n quadrature.wavelengthRangeNanometers.maximum,\n \"spectralQuadrature.wavelengthRangeNanometers.maximum\"\n );\n if (!(rangeMinimum < rangeMaximum)) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature wavelength range minimum must be less than maximum.\"\n );\n }\n\n const maximumSubintervalWidthNanometers =\n requirePositiveFinite(\n quadrature.maximumSubintervalWidthNanometers,\n \"spectralQuadrature.maximumSubintervalWidthNanometers\"\n );\n\n if (\n !Array.isArray(\n quadrature.segmentBoundariesNanometers\n ) ||\n quadrature.segmentBoundariesNanometers.length <\n 2\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentBoundariesNanometers must contain at least two boundaries.\"\n );\n }\n\n let previousBoundary =\n Number.NEGATIVE_INFINITY;\n quadrature.segmentBoundariesNanometers.forEach(\n (boundary, index) => {\n const parsed = requirePositiveFinite(\n boundary,\n \"spectralQuadrature.segmentBoundariesNanometers[\" +\n index +\n \"]\"\n );\n if (parsed <= previousBoundary) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentBoundariesNanometers must be strictly increasing.\"\n );\n }\n previousBoundary = parsed;\n }\n );\n\n const segmentCount =\n requireNonNegativeSafeInteger(\n quadrature.segmentCount,\n \"spectralQuadrature.segmentCount\"\n );\n if (\n segmentCount <= 0 ||\n segmentCount !==\n quadrature.segmentBoundariesNanometers.length -\n 1\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentCount must be positive and match the boundary count.\"\n );\n }\n\n if (\n !approximatelyEqual(\n quadrature.segmentBoundariesNanometers[0]!,\n rangeMinimum\n ) ||\n !approximatelyEqual(\n quadrature.segmentBoundariesNanometers[\n quadrature.segmentBoundariesNanometers.length -\n 1\n ]!,\n rangeMaximum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature segment boundaries must exactly span the requested wavelength range.\"\n );\n }\n\n const totalNodeCount =\n requireNonNegativeSafeInteger(\n quadrature.totalNodeCount,\n \"spectralQuadrature.totalNodeCount\"\n );\n if (\n totalNodeCount <= 0 ||\n totalNodeCount !== quadrature.nodes.length\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.totalNodeCount must be positive and exactly match spectralQuadrature.nodes.length.\"\n );\n }\n if (\n totalNodeCount >\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.totalNodeCount exceeds the spectral quadrature safety limit.\"\n );\n }\n\n if (\n quadrature.responseApplicationPerformed !==\n false ||\n quadrature.responseValuesIncluded !== false ||\n quadrature.wavelengthIntegrationPerformed !==\n false ||\n quadrature.continuousSpectralDensityQuadratureOnly !==\n true ||\n quadrature.discreteLineSpectrumIncluded !==\n false\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature semantics are incompatible with pre-response continuous-density composition.\"\n );\n }\n\n const span =\n rangeMaximum - rangeMinimum;\n const nodesByIndex =\n new Map<number, SensorSpectralQuadratureNode>();\n const seenSegmentSubdivisions =\n new Set<string>();\n const segmentSubdivisionCounts =\n new Map<number, number>();\n const segmentSeenCounts =\n new Map<number, number>();\n let measureSum = 0;\n let normalizedWeightSum = 0;\n\n quadrature.nodes.forEach(\n (node, nodeArrayIndex) => {\n const spectralSampleIndex =\n requireNonNegativeSafeInteger(\n node.spectralSampleIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].spectralSampleIndex\"\n );\n if (\n nodesByIndex.has(\n spectralSampleIndex\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature contains duplicate spectralSampleIndex values.\"\n );\n }\n\n const segmentIndex =\n requireNonNegativeSafeInteger(\n node.segmentIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].segmentIndex\"\n );\n if (segmentIndex >= segmentCount) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node segmentIndex is outside the declared segment range.\"\n );\n }\n\n const subdivisionIndex =\n requireNonNegativeSafeInteger(\n node.subdivisionIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].subdivisionIndex\"\n );\n const segmentSubdivisionCount =\n requireNonNegativeSafeInteger(\n node.segmentSubdivisionCount,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].segmentSubdivisionCount\"\n );\n if (\n segmentSubdivisionCount <= 0 ||\n subdivisionIndex >=\n segmentSubdivisionCount\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node subdivision identity is invalid.\"\n );\n }\n\n const priorSegmentCount =\n segmentSubdivisionCounts.get(\n segmentIndex\n );\n if (\n priorSegmentCount !== undefined &&\n priorSegmentCount !==\n segmentSubdivisionCount\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature nodes disagree on a segment subdivision count.\"\n );\n }\n segmentSubdivisionCounts.set(\n segmentIndex,\n segmentSubdivisionCount\n );\n\n const subdivisionKey =\n segmentIndex +\n \":\" +\n subdivisionIndex;\n if (\n seenSegmentSubdivisions.has(\n subdivisionKey\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature contains duplicate segment/subdivision identities.\"\n );\n }\n seenSegmentSubdivisions.add(\n subdivisionKey\n );\n segmentSeenCounts.set(\n segmentIndex,\n (segmentSeenCounts.get(\n segmentIndex\n ) ?? 0) + 1\n );\n\n const wavelengthNanometers =\n requirePositiveFinite(\n node.wavelengthNanometers,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].wavelengthNanometers\"\n );\n const wavelengthMeasureNanometers =\n requirePositiveFinite(\n node.wavelengthMeasureNanometers,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].wavelengthMeasureNanometers\"\n );\n const normalizedWavelengthWeight =\n requirePositiveFinite(\n node.normalizedWavelengthWeight,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].normalizedWavelengthWeight\"\n );\n\n const segmentMinimum =\n quadrature.segmentBoundariesNanometers[\n segmentIndex\n ]!;\n const segmentMaximum =\n quadrature.segmentBoundariesNanometers[\n segmentIndex + 1\n ]!;\n const expectedMeasure =\n (segmentMaximum -\n segmentMinimum) /\n segmentSubdivisionCount;\n const expectedWavelength =\n segmentMinimum +\n (subdivisionIndex + 0.5) *\n expectedMeasure;\n const expectedNormalizedWeight =\n expectedMeasure / span;\n\n if (\n !approximatelyEqual(\n wavelengthMeasureNanometers,\n expectedMeasure\n ) ||\n !approximatelyEqual(\n wavelengthNanometers,\n expectedWavelength\n ) ||\n !approximatelyEqual(\n normalizedWavelengthWeight,\n expectedNormalizedWeight\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node geometry/measure does not match its declared segment/subdivision identity.\"\n );\n }\n\n if (\n wavelengthMeasureNanometers >\n maximumSubintervalWidthNanometers &&\n !approximatelyEqual(\n wavelengthMeasureNanometers,\n maximumSubintervalWidthNanometers\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node width exceeds maximumSubintervalWidthNanometers.\"\n );\n }\n\n measureSum +=\n wavelengthMeasureNanometers;\n normalizedWeightSum +=\n normalizedWavelengthWeight;\n if (\n !Number.isFinite(measureSum) ||\n !Number.isFinite(\n normalizedWeightSum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature aggregate measures must remain finite.\"\n );\n }\n\n nodesByIndex.set(\n spectralSampleIndex,\n node\n );\n }\n );\n\n for (\n let spectralSampleIndex = 0;\n spectralSampleIndex < totalNodeCount;\n spectralSampleIndex += 1\n ) {\n if (\n !nodesByIndex.has(\n spectralSampleIndex\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature spectralSampleIndex values must form the exact contiguous range 0..totalNodeCount-1.\"\n );\n }\n }\n\n for (\n let segmentIndex = 0;\n segmentIndex < segmentCount;\n segmentIndex += 1\n ) {\n const expected =\n segmentSubdivisionCounts.get(\n segmentIndex\n );\n const seen =\n segmentSeenCounts.get(\n segmentIndex\n ) ?? 0;\n if (\n expected === undefined ||\n seen !== expected\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature must contain every declared subdivision exactly once.\"\n );\n }\n }\n\n if (\n !approximatelyEqual(\n measureSum,\n span\n ) ||\n !approximatelyEqual(\n normalizedWeightSum,\n 1\n ) ||\n !approximatelyEqual(\n quadrature.wavelengthMeasureSumNanometers,\n measureSum\n ) ||\n !approximatelyEqual(\n quadrature.normalizedWavelengthWeightSum,\n normalizedWeightSum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature aggregate wavelength measures/weights are inconsistent.\"\n );\n }\n\n return nodesByIndex;\n}\n\n/**\n * Builds deterministic wavelength sample points for one exact sensor response\n * channel. It does not apply the response to any spectrum.\n *\n * The requested range must lie fully inside the channel's declared usable\n * range. The response curve's breakpoints, plus any caller-supplied breakpoints\n * from the source spectrum or optics, split that range into segments. Each\n * segment is then subdivided so no midpoint subinterval is wider than\n * maximumSubintervalWidthNanometers.\n *\n * wavelengthMeasureNanometers is dλ in nanometres, not a dimensionless response\n * weight. Multiply it only by a spectral density per nanometre, or convert\n * units explicitly first.\n *\n * QE and A/W responsivity are deliberately not applied. They lead to different\n * signals: QE is photon-to-electron efficiency, while A/W responsivity relates\n * incident radiant power to electrical current. A later step must also match\n * responseScope to the source plane and collection area before integrating any\n * signal.\n */\nexport function calculateSensorSpectralQuadrature(\n input:\n CalculateSensorSpectralQuadratureInput\n): CalculationResult<SensorSpectralQuadrature> {\n requireInputKeys(input, \"calculateSensorSpectralQuadrature\", [\"colorSamplingProfile\", \"spectralResponseProfile\", \"channelId\", \"wavelengthBasis\", \"wavelengthRangeNanometers\", \"maximumSubintervalWidthNanometers\", \"additionalBreakpointsNanometers\"]);\n const maximumSubintervalWidthNanometers =\n requirePositiveFinite(\n input.maximumSubintervalWidthNanometers,\n \"maximumSubintervalWidthNanometers\"\n );\n\n if (\n input.wavelengthBasis !== \"air\" &&\n input.wavelengthBasis !== \"vacuum\" &&\n input.wavelengthBasis !== \"unspecified\"\n ) {\n throw new InvalidConfigurationError(\n \"wavelengthBasis is invalid.\"\n );\n }\n\n const colorProfile =\n parseSensorColorSamplingProfile(\n input.colorSamplingProfile\n );\n const responseProfile =\n parseSensorSpectralResponseProfile(\n input.spectralResponseProfile\n );\n const response = channelResponse(\n responseProfile,\n input.channelId\n );\n const curves =\n responseCurves(response);\n\n if (\n !curves.every(\n (curve) =>\n curve.wavelengthBasis ===\n input.wavelengthBasis\n )\n ) {\n throw new InvalidScientificInputError(\n \"wavelengthBasis must exactly match every response curve used by the requested channel.\"\n );\n }\n\n const usable = usableResponseRange(\n curves\n );\n const range = parseRequestedRange(\n input.wavelengthRangeNanometers,\n usable\n );\n const validationWavelength =\n range.minimum +\n (range.maximum - range.minimum) /\n 2;\n const representative =\n resolveSensorSpectralResponseAtWavelength(\n {\n colorSamplingProfile:\n colorProfile,\n spectralResponseProfile:\n responseProfile,\n channelId: input.channelId,\n wavelengthNanometers:\n validationWavelength,\n wavelengthBasis:\n input.wavelengthBasis\n }\n ).value;\n\n const additional =\n additionalBreakpoints(\n input.additionalBreakpointsNanometers,\n range\n );\n const boundaries =\n partitionBoundaries(\n curves,\n range,\n additional\n );\n const {\n segments,\n totalNodeCount\n } = planSegments(\n boundaries,\n maximumSubintervalWidthNanometers\n );\n\n const totalSpan =\n range.maximum - range.minimum;\n const nodes:\n SensorSpectralQuadratureNode[] = [];\n let spectralSampleIndex = 0;\n\n for (\n let segmentIndex = 0;\n segmentIndex < segments.length;\n segmentIndex += 1\n ) {\n const segment =\n segments[segmentIndex]!;\n\n for (\n let subdivisionIndex = 0;\n subdivisionIndex <\n segment.subdivisionCount;\n subdivisionIndex += 1\n ) {\n const wavelengthNanometers =\n segment.minimum +\n (subdivisionIndex + 0.5) *\n segment\n .subintervalWidthNanometers;\n\n nodes.push({\n spectralSampleIndex,\n segmentIndex,\n subdivisionIndex,\n segmentSubdivisionCount:\n segment.subdivisionCount,\n wavelengthNanometers,\n wavelengthMeasureNanometers:\n segment\n .subintervalWidthNanometers,\n normalizedWavelengthWeight:\n segment\n .subintervalWidthNanometers /\n totalSpan\n });\n\n spectralSampleIndex += 1;\n }\n }\n\n const normalizedWavelengthWeightSum =\n nodes.reduce(\n (sum, node) =>\n sum +\n node.normalizedWavelengthWeight,\n 0\n );\n const wavelengthMeasureSumNanometers =\n nodes.reduce(\n (sum, node) =>\n sum +\n node.wavelengthMeasureNanometers,\n 0\n );\n\n return approximationResult(\n {\n profileId:\n representative.profileId,\n colorSamplingProfileId:\n representative\n .colorSamplingProfileId,\n channelId:\n representative.channelId,\n sourceResponseKind:\n representative\n .sourceResponseKind,\n responseScope:\n representative.responseScope,\n responseScientificStatus:\n representative\n .scientificStatus,\n responseUncertainty:\n representative.uncertainty,\n responseChannelBinding:\n createSensorSpectralResponseChannelBinding(\n response\n ),\n ...(representative.referenceConditions ===\n undefined\n ? {}\n : {\n responseReferenceConditions:\n representative.referenceConditions\n }),\n wavelengthBasis:\n input.wavelengthBasis,\n wavelengthBasisResolved:\n representative\n .wavelengthBasisResolved,\n wavelengthRangeNanometers:\n range,\n responseDeclaredWavelengthRangeNanometers:\n usable,\n quadratureScheme:\n \"response-breakpoint-aware-bounded-midpoint\",\n segmentBoundarySource:\n \"requested-range-plus-response-knots-plus-optional-additional-breakpoints\",\n segmentBoundariesNanometers:\n [...boundaries],\n maximumSubintervalWidthNanometers,\n segmentCount:\n segments.length,\n totalNodeCount,\n normalizedWavelengthWeightSum,\n wavelengthMeasureSumNanometers,\n nodes,\n responseKnotAlignmentIncluded:\n true,\n componentEvidence: {\n colorSamplingProfile:\n colorProfile.evidence,\n profile:\n representative\n .componentEvidence.profile,\n channel:\n representative\n .componentEvidence.channel,\n curves:\n representative\n .componentEvidence.curves\n },\n responseValuesIncluded: false,\n responseApplicationPerformed:\n false,\n sourceSpectralValuesIncluded:\n false,\n spectralIrradianceIncluded:\n false,\n spectralPhotonIrradianceIncluded:\n false,\n commonSpectralCoverageValidated:\n false,\n continuousSpectralDensityQuadratureOnly:\n true,\n discreteLineSpectrumIncluded:\n false,\n opticalTransmissionIncludedByQuadrature:\n false,\n wavelengthIntegrationPerformed:\n false,\n spatialIntegrationPerformed:\n false,\n temporalIntegrationPerformed:\n false,\n photonsCalculated: false,\n electronsCalculated: false,\n rawCodeValueProduced: false,\n convergenceErrorEstimated: false\n },\n \"sensor-spectral-quadrature\",\n \"1.0.0\",\n [\n \"The partition includes requested range edges, response-curve knots, and optional caller-supplied continuous-spectrum/optics breakpoints.\",\n \"Every segment uses deterministic equal-width midpoint subintervals whose width is bounded by maximumSubintervalWidthNanometers.\",\n \"Wavelength measures are d-lambda in nanometres and normalized wavelength weights are geometric wavelength measures only; neither is sensor-response weighting.\",\n \"The requested range is validated against sensor-response support only. Scene-spectrum, optical-transmission, and other spectral-factor coverage are not established by this API.\",\n \"The response profile, exact channel linkage, wavelength basis, response scope, and response-data provenance are validated and preserved, but response values are not applied at quadrature nodes.\",\n \"QE and A/W responsivity remain different physical representations and require different compatible downstream photon/power semantics.\",\n \"Future signal composition must match responseScope to the source plane and collection-area model so upstream transmission is not omitted or double-counted.\",\n \"This midpoint plan targets continuous spectral-density integration. Discrete/delta-like line spectra require a separate explicit representation rather than being approximated by hidden point masses.\",\n \"No source spectral values, spectral irradiance, spectral photon irradiance, optical transmission, spatial integration, temporal integration, photon/electron conversion, current calculation, or RAW output is calculated.\",\n \"Response-knot alignment and a bounded wavelength step do not prove convergence for arbitrary source spectra or other wavelength-dependent factors.\",\n \"No source-independent convergence/error estimate is reported because integration error depends on the downstream integrand.\"\n ]\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"spectral-quadrature.js","sourceRoot":"","sources":["../../src/sensor/spectral-quadrature.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;GAUG;AAEH,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAKpE,OAAO,EACL,+BAA+B,EAEhC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,0CAA0C,EAC1C,kCAAkC,EAClC,yCAAyC,EAK1C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,IAAI,qBAAqB,EAAE,kCAAkC,IAAI,6BAA6B,EAAE,MAAM,8BAA8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,CAAC,QAAQ;YACvB,OAAO,EACL,cAAc;iBACX,iBAAiB,CAAC,OAAO;YAC9B,OAAO,EACL,cAAc;iBACX,iBAAiB,CAAC,OAAO;YAC9B,MAAM,EACJ,cAAc;iBACX,iBAAiB,CAAC,MAAM;SAC9B;QACD,sBAAsB,EAAE,KAAK;QAC7B,4BAA4B,EAC1B,KAAK;QACP,4BAA4B,EAC1B,KAAK;QACP,0BAA0B,EACxB,KAAK;QACP,gCAAgC,EAC9B,KAAK;QACP,+BAA+B,EAC7B,KAAK;QACP,uCAAuC,EACrC,IAAI;QACN,4BAA4B,EAC1B,KAAK;QACP,uCAAuC,EACrC,KAAK;QACP,8BAA8B,EAC5B,KAAK;QACP,2BAA2B,EACzB,KAAK;QACP,4BAA4B,EAC1B,KAAK;QACP,iBAAiB,EAAE,KAAK;QACxB,mBAAmB,EAAE,KAAK;QAC1B,oBAAoB,EAAE,KAAK;QAC3B,yBAAyB,EAAE,KAAK;KACjC,EACD,4BAA4B,EAC5B,OAAO,EACP;QACE,0IAA0I;QAC1I,iIAAiI;QACjI,gKAAgK;QAChK,kLAAkL;QAClL,mMAAmM;QACnM,uIAAuI;QACvI,6JAA6J;QAC7J,wMAAwM;QACxM,4NAA4N;QAC5N,oJAAoJ;QACpJ,6HAA6H;KAC9H,CACF,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Spectral quadrature: the wavelength sample points (nodes) and step widths used to integrate light\n * over wavelength for one sensor response channel.\n *\n * Each node is the midpoint of a wavelength interval, with its width dλ in nanometres. The intervals\n * stay inside the range the response supports. Lining nodes up with curve breakpoints does not prove\n * the integral has converged. Discrete (delta-like) emission lines need their own integration and are\n * never silently widened into continuous bins.\n * @see docs/MOTION_AND_SIGNAL.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport {\n approximationResult,\n type CalculationResult\n} from \"../core/calculation-result.js\";\nimport type { EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport { InvalidScientificInputError } from \"../core/validation.js\";\nimport type {\n SpectralWavelengthBasis,\n SpectralWavelengthRangeNanometers\n} from \"../core/spectral.js\";\nimport {\n parseSensorColorSamplingProfile,\n type SensorColorSamplingProfile\n} from \"./color-sampling.js\";\nimport {\n createSensorSpectralResponseChannelBinding,\n parseSensorSpectralResponseProfile,\n resolveSensorSpectralResponseAtWavelength,\n type SensorSpectralReferenceConditions,\n type SensorSpectralResponseProfile,\n type SensorSpectralResponseScientificStatus,\n type SensorSpectralResponseUncertainty\n} from \"./spectral-response.js\";\nimport { requireInputKeys, requireInputPositiveFinite as requirePositiveFinite, requireInputNonNegativeSafeInteger as requireNonNegativeSafeInteger } from \"../core/record-validation.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { responseCurves } from \"./spectral-coverage.js\";\nimport { approximatelyEqual } from \"../core/shared-helpers.js\";\n\nconst MAX_SPECTRAL_QUADRATURE_NODES = 100_000;\n\nexport type SensorSpectralWavelengthRangeNanometers =\n SpectralWavelengthRangeNanometers;\n\nexport interface CalculateSensorSpectralQuadratureInput {\n colorSamplingProfile: SensorColorSamplingProfile;\n spectralResponseProfile: SensorSpectralResponseProfile;\n channelId: string;\n wavelengthBasis: SpectralWavelengthBasis;\n /**\n * Wavelength interval to sample. It is checked only against the range the\n * sensor response supports, not against scene-spectrum or optical-transmission\n * coverage.\n */\n wavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n /**\n * Strict upper limit on the width of each midpoint subinterval.\n *\n * Response breakpoints and any additional breakpoints split the requested\n * range first. Each segment is then subdivided until every subinterval is\n * no wider than this value.\n */\n maximumSubintervalWidthNanometers: number;\n /**\n * Optional strictly increasing wavelength breakpoints from other continuous\n * spectral inputs, such as the interpolation points of a scene spectrum or of\n * optical transmission. Values must be strictly inside the requested range.\n *\n * Passing them does not claim those other inputs are available or valid over\n * the requested range.\n */\n additionalBreakpointsNanometers?:\n readonly number[];\n}\n\nexport interface SensorSpectralQuadratureNode {\n spectralSampleIndex: number;\n segmentIndex: number;\n subdivisionIndex: number;\n segmentSubdivisionCount: number;\n /**\n * Midpoint wavelength for this subinterval. Units: nm in wavelengthBasis.\n */\n wavelengthNanometers: number;\n /**\n * dλ (wavelength width) this node stands for. Units: nm.\n *\n * It is only a wavelength width. It is not response-weighted throughput,\n * a photon count, radiant energy, current or a dimensionless probability.\n */\n wavelengthMeasureNanometers: number;\n /**\n * The wavelength width divided by the requested range width (dimensionless).\n *\n * Useful for averages, but it is not a sensor-response weight.\n */\n normalizedWavelengthWeight: number;\n}\n\nexport interface SensorSpectralQuadrature {\n profileId: string;\n colorSamplingProfileId: string;\n channelId: string;\n sourceResponseKind:\n SensorSpectralResponseProfile[\"channels\"][number][\"kind\"];\n responseScope:\n SensorSpectralResponseProfile[\"channels\"][number][\"responseScope\"];\n responseScientificStatus:\n SensorSpectralResponseScientificStatus;\n responseUncertainty:\n SensorSpectralResponseUncertainty;\n responseChannelBinding?: import(\"./spectral-response.js\").SensorSpectralResponseChannelBinding;\n responseReferenceConditions?:\n SensorSpectralReferenceConditions;\n wavelengthBasis: SpectralWavelengthBasis;\n wavelengthBasisResolved: boolean;\n wavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n responseDeclaredWavelengthRangeNanometers:\n SensorSpectralWavelengthRangeNanometers;\n quadratureScheme:\n \"response-breakpoint-aware-bounded-midpoint\";\n segmentBoundarySource:\n \"requested-range-plus-response-knots-plus-optional-additional-breakpoints\";\n /**\n * Sorted, unique segment boundaries, including the ends of the requested range.\n */\n segmentBoundariesNanometers:\n readonly number[];\n maximumSubintervalWidthNanometers: number;\n segmentCount: number;\n totalNodeCount: number;\n normalizedWavelengthWeightSum: number;\n wavelengthMeasureSumNanometers: number;\n nodes: readonly SensorSpectralQuadratureNode[];\n responseKnotAlignmentIncluded: true;\n componentEvidence: {\n colorSamplingProfile: readonly EvidenceProvenance[];\n profile: readonly EvidenceProvenance[];\n channel: readonly EvidenceProvenance[];\n curves:\n readonly (readonly EvidenceProvenance[])[];\n };\n /**\n * Fixed statements of what this result does not include.\n */\n responseValuesIncluded: false;\n responseApplicationPerformed: false;\n sourceSpectralValuesIncluded: false;\n spectralIrradianceIncluded: false;\n spectralPhotonIrradianceIncluded: false;\n commonSpectralCoverageValidated: false;\n continuousSpectralDensityQuadratureOnly: true;\n discreteLineSpectrumIncluded: false;\n opticalTransmissionIncludedByQuadrature: false;\n wavelengthIntegrationPerformed: false;\n spatialIntegrationPerformed: false;\n temporalIntegrationPerformed: false;\n photonsCalculated: false;\n electronsCalculated: false;\n rawCodeValueProduced: false;\n convergenceErrorEstimated: false;\n}\n\ninterface ResponseCurveSupport {\n wavelengthBasis: SpectralWavelengthBasis;\n samples: readonly {\n wavelengthNanometers: number;\n }[];\n evidence: readonly EvidenceProvenance[];\n}\n\ninterface SegmentPlan {\n minimum: number;\n maximum: number;\n subdivisionCount: number;\n subintervalWidthNanometers: number;\n}\n\nfunction channelResponse(\n profile: SensorSpectralResponseProfile,\n channelId: string\n): SensorSpectralResponseProfile[\"channels\"][number] {\n if (\n typeof channelId !== \"string\" ||\n channelId.trim().length === 0\n ) {\n throw new InvalidConfigurationError(\n \"channelId must be a non-empty string.\"\n );\n }\n\n const response = profile.channels.find(\n (entry) => entry.channelId === channelId\n );\n if (response === undefined) {\n throw new InvalidScientificInputError(\n \"No spectral response is declared for the requested channelId.\"\n );\n }\n return response;\n}\n\nfunction usableResponseRange(\n curves: readonly ResponseCurveSupport[]\n): SensorSpectralWavelengthRangeNanometers {\n const minimum = Math.max(\n ...curves.map(\n (curve) =>\n curve.samples[0]!\n .wavelengthNanometers\n )\n );\n const maximum = Math.min(\n ...curves.map(\n (curve) =>\n curve.samples[\n curve.samples.length - 1\n ]!.wavelengthNanometers\n )\n );\n\n if (!(minimum < maximum)) {\n throw new InvalidScientificInputError(\n \"Spectral-response curves do not have a usable overlapping wavelength interval.\"\n );\n }\n\n return { minimum, maximum };\n}\n\nfunction parseRequestedRange(\n input:\n SensorSpectralWavelengthRangeNanometers,\n usable:\n SensorSpectralWavelengthRangeNanometers\n): SensorSpectralWavelengthRangeNanometers {\n if (\n typeof input !== \"object\" ||\n input === null\n ) {\n throw new InvalidConfigurationError(\n \"wavelengthRangeNanometers must be an object.\"\n );\n }\n\n const minimum = requirePositiveFinite(\n input.minimum,\n \"wavelengthRangeNanometers.minimum\"\n );\n const maximum = requirePositiveFinite(\n input.maximum,\n \"wavelengthRangeNanometers.maximum\"\n );\n\n if (!(minimum < maximum)) {\n throw new InvalidScientificInputError(\n \"wavelengthRangeNanometers.minimum must be less than maximum.\"\n );\n }\n\n if (\n minimum < usable.minimum ||\n maximum > usable.maximum\n ) {\n throw new InvalidScientificInputError(\n \"Requested wavelength range must remain inside the usable spectral-response range; clipping, extrapolation, and implicit zero-fill are not permitted.\"\n );\n }\n\n return { minimum, maximum };\n}\n\nfunction additionalBreakpoints(\n value: readonly number[] | undefined,\n range:\n SensorSpectralWavelengthRangeNanometers\n): readonly number[] {\n if (value === undefined) {\n return [];\n }\n if (!Array.isArray(value)) {\n throw new InvalidConfigurationError(\n \"additionalBreakpointsNanometers must be an array when supplied.\"\n );\n }\n if (\n value.length >=\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"additionalBreakpointsNanometers contains too many entries for the spectral quadrature safety limit.\"\n );\n }\n\n let previous =\n Number.NEGATIVE_INFINITY;\n\n return value.map(\n (entry, index) => {\n const wavelength =\n requirePositiveFinite(\n entry,\n \"additionalBreakpointsNanometers[\" +\n index +\n \"]\"\n );\n if (\n wavelength <= range.minimum ||\n wavelength >= range.maximum\n ) {\n throw new InvalidScientificInputError(\n \"Additional spectral breakpoints must lie strictly inside the requested wavelength range.\"\n );\n }\n if (wavelength <= previous) {\n throw new InvalidScientificInputError(\n \"additionalBreakpointsNanometers must be strictly increasing with no duplicates.\"\n );\n }\n previous = wavelength;\n return wavelength;\n }\n );\n}\n\nfunction partitionBoundaries(\n curves: readonly ResponseCurveSupport[],\n range:\n SensorSpectralWavelengthRangeNanometers,\n additional:\n readonly number[]\n): readonly number[] {\n const boundaries = new Set<number>([\n range.minimum,\n range.maximum,\n ...additional\n ]);\n\n for (const curve of curves) {\n for (const sample of curve.samples) {\n if (\n sample.wavelengthNanometers >\n range.minimum &&\n sample.wavelengthNanometers <\n range.maximum\n ) {\n boundaries.add(\n sample.wavelengthNanometers\n );\n }\n }\n }\n\n return [...boundaries].sort(\n (a, b) => a - b\n );\n}\n\nfunction planSegments(\n boundaries: readonly number[],\n maximumSubintervalWidthNanometers: number\n): {\n segments: readonly SegmentPlan[];\n totalNodeCount: number;\n} {\n const segments: SegmentPlan[] = [];\n let totalNodeCount = 0;\n\n for (\n let segmentIndex = 0;\n segmentIndex < boundaries.length - 1;\n segmentIndex += 1\n ) {\n const minimum =\n boundaries[segmentIndex]!;\n const maximum =\n boundaries[segmentIndex + 1]!;\n const width =\n maximum - minimum;\n\n if (\n !Number.isFinite(width) ||\n width <= 0\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature segment widths must be finite and greater than zero.\"\n );\n }\n\n const subdivisionCount =\n Math.ceil(\n width /\n maximumSubintervalWidthNanometers\n );\n\n if (\n !Number.isSafeInteger(\n subdivisionCount\n ) ||\n subdivisionCount <= 0\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature segment subdivision count must be a positive safe integer.\"\n );\n }\n\n totalNodeCount +=\n subdivisionCount;\n\n if (\n !Number.isSafeInteger(\n totalNodeCount\n )\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature node count must remain a safe integer.\"\n );\n }\n if (\n totalNodeCount >\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature node count exceeds the safety limit of \" +\n MAX_SPECTRAL_QUADRATURE_NODES +\n \".\"\n );\n }\n\n segments.push({\n minimum,\n maximum,\n subdivisionCount,\n subintervalWidthNanometers:\n width / subdivisionCount\n });\n }\n\n if (segments.length === 0) {\n throw new InvalidScientificInputError(\n \"Spectral quadrature requires at least one non-empty segment.\"\n );\n }\n\n return {\n segments,\n totalNodeCount\n };\n}\n\n\n\n/**\n * Rechecks a supplied wavelength plan (node identities, coverage and widths in nanometres) before it\n * is used.\n *\n * Lining nodes up with breakpoints does not prove convergence. Discrete (delta-like) lines need their\n * own integration and are never silently widened into continuous bins.\n * @param quadrature - The input; see `SensorSpectralQuadrature` for its fields, units and coordinates.\n * @returns The result. Success does not imply calibration.\n *\n * @see docs/API_REFERENCE.md for the package export and its full type definitions.\n */\nexport function validateSensorSpectralQuadrature(\n quadrature: SensorSpectralQuadrature\n): Map<number, SensorSpectralQuadratureNode> {\n if (\n typeof quadrature !== \"object\" ||\n quadrature === null ||\n !Array.isArray(quadrature.nodes)\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature must contain a nodes array.\"\n );\n }\n\n for (const [field, value] of [\n [\"profileId\", quadrature.profileId],\n [\n \"colorSamplingProfileId\",\n quadrature.colorSamplingProfileId\n ],\n [\"channelId\", quadrature.channelId]\n ] as const) {\n if (\n typeof value !== \"string\" ||\n value.trim().length === 0\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature.\" +\n field +\n \" must be a non-empty string.\"\n );\n }\n }\n\n if (\n quadrature.wavelengthBasis !== \"air\" &&\n quadrature.wavelengthBasis !== \"vacuum\" &&\n quadrature.wavelengthBasis !== \"unspecified\"\n ) {\n throw new InvalidConfigurationError(\n \"spectralQuadrature.wavelengthBasis is invalid.\"\n );\n }\n\n const rangeMinimum = requirePositiveFinite(\n quadrature.wavelengthRangeNanometers.minimum,\n \"spectralQuadrature.wavelengthRangeNanometers.minimum\"\n );\n const rangeMaximum = requirePositiveFinite(\n quadrature.wavelengthRangeNanometers.maximum,\n \"spectralQuadrature.wavelengthRangeNanometers.maximum\"\n );\n if (!(rangeMinimum < rangeMaximum)) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature wavelength range minimum must be less than maximum.\"\n );\n }\n\n const maximumSubintervalWidthNanometers =\n requirePositiveFinite(\n quadrature.maximumSubintervalWidthNanometers,\n \"spectralQuadrature.maximumSubintervalWidthNanometers\"\n );\n\n if (\n !Array.isArray(\n quadrature.segmentBoundariesNanometers\n ) ||\n quadrature.segmentBoundariesNanometers.length <\n 2\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentBoundariesNanometers must contain at least two boundaries.\"\n );\n }\n\n let previousBoundary =\n Number.NEGATIVE_INFINITY;\n quadrature.segmentBoundariesNanometers.forEach(\n (boundary, index) => {\n const parsed = requirePositiveFinite(\n boundary,\n \"spectralQuadrature.segmentBoundariesNanometers[\" +\n index +\n \"]\"\n );\n if (parsed <= previousBoundary) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentBoundariesNanometers must be strictly increasing.\"\n );\n }\n previousBoundary = parsed;\n }\n );\n\n const segmentCount =\n requireNonNegativeSafeInteger(\n quadrature.segmentCount,\n \"spectralQuadrature.segmentCount\"\n );\n if (\n segmentCount <= 0 ||\n segmentCount !==\n quadrature.segmentBoundariesNanometers.length -\n 1\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.segmentCount must be positive and match the boundary count.\"\n );\n }\n\n if (\n !approximatelyEqual(\n quadrature.segmentBoundariesNanometers[0]!,\n rangeMinimum\n ) ||\n !approximatelyEqual(\n quadrature.segmentBoundariesNanometers[\n quadrature.segmentBoundariesNanometers.length -\n 1\n ]!,\n rangeMaximum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature segment boundaries must exactly span the requested wavelength range.\"\n );\n }\n\n const totalNodeCount =\n requireNonNegativeSafeInteger(\n quadrature.totalNodeCount,\n \"spectralQuadrature.totalNodeCount\"\n );\n if (\n totalNodeCount <= 0 ||\n totalNodeCount !== quadrature.nodes.length\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.totalNodeCount must be positive and exactly match spectralQuadrature.nodes.length.\"\n );\n }\n if (\n totalNodeCount >\n MAX_SPECTRAL_QUADRATURE_NODES\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature.totalNodeCount exceeds the spectral quadrature safety limit.\"\n );\n }\n\n if (\n quadrature.responseApplicationPerformed !==\n false ||\n quadrature.responseValuesIncluded !== false ||\n quadrature.wavelengthIntegrationPerformed !==\n false ||\n quadrature.continuousSpectralDensityQuadratureOnly !==\n true ||\n quadrature.discreteLineSpectrumIncluded !==\n false\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature semantics are incompatible with pre-response continuous-density composition.\"\n );\n }\n\n const span =\n rangeMaximum - rangeMinimum;\n const nodesByIndex =\n new Map<number, SensorSpectralQuadratureNode>();\n const seenSegmentSubdivisions =\n new Set<string>();\n const segmentSubdivisionCounts =\n new Map<number, number>();\n const segmentSeenCounts =\n new Map<number, number>();\n let measureSum = 0;\n let normalizedWeightSum = 0;\n\n quadrature.nodes.forEach(\n (node, nodeArrayIndex) => {\n const spectralSampleIndex =\n requireNonNegativeSafeInteger(\n node.spectralSampleIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].spectralSampleIndex\"\n );\n if (\n nodesByIndex.has(\n spectralSampleIndex\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature contains duplicate spectralSampleIndex values.\"\n );\n }\n\n const segmentIndex =\n requireNonNegativeSafeInteger(\n node.segmentIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].segmentIndex\"\n );\n if (segmentIndex >= segmentCount) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node segmentIndex is outside the declared segment range.\"\n );\n }\n\n const subdivisionIndex =\n requireNonNegativeSafeInteger(\n node.subdivisionIndex,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].subdivisionIndex\"\n );\n const segmentSubdivisionCount =\n requireNonNegativeSafeInteger(\n node.segmentSubdivisionCount,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].segmentSubdivisionCount\"\n );\n if (\n segmentSubdivisionCount <= 0 ||\n subdivisionIndex >=\n segmentSubdivisionCount\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node subdivision identity is invalid.\"\n );\n }\n\n const priorSegmentCount =\n segmentSubdivisionCounts.get(\n segmentIndex\n );\n if (\n priorSegmentCount !== undefined &&\n priorSegmentCount !==\n segmentSubdivisionCount\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature nodes disagree on a segment subdivision count.\"\n );\n }\n segmentSubdivisionCounts.set(\n segmentIndex,\n segmentSubdivisionCount\n );\n\n const subdivisionKey =\n segmentIndex +\n \":\" +\n subdivisionIndex;\n if (\n seenSegmentSubdivisions.has(\n subdivisionKey\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature contains duplicate segment/subdivision identities.\"\n );\n }\n seenSegmentSubdivisions.add(\n subdivisionKey\n );\n segmentSeenCounts.set(\n segmentIndex,\n (segmentSeenCounts.get(\n segmentIndex\n ) ?? 0) + 1\n );\n\n const wavelengthNanometers =\n requirePositiveFinite(\n node.wavelengthNanometers,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].wavelengthNanometers\"\n );\n const wavelengthMeasureNanometers =\n requirePositiveFinite(\n node.wavelengthMeasureNanometers,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].wavelengthMeasureNanometers\"\n );\n const normalizedWavelengthWeight =\n requirePositiveFinite(\n node.normalizedWavelengthWeight,\n \"spectralQuadrature.nodes[\" +\n nodeArrayIndex +\n \"].normalizedWavelengthWeight\"\n );\n\n const segmentMinimum =\n quadrature.segmentBoundariesNanometers[\n segmentIndex\n ]!;\n const segmentMaximum =\n quadrature.segmentBoundariesNanometers[\n segmentIndex + 1\n ]!;\n const expectedMeasure =\n (segmentMaximum -\n segmentMinimum) /\n segmentSubdivisionCount;\n const expectedWavelength =\n segmentMinimum +\n (subdivisionIndex + 0.5) *\n expectedMeasure;\n const expectedNormalizedWeight =\n expectedMeasure / span;\n\n if (\n !approximatelyEqual(\n wavelengthMeasureNanometers,\n expectedMeasure\n ) ||\n !approximatelyEqual(\n wavelengthNanometers,\n expectedWavelength\n ) ||\n !approximatelyEqual(\n normalizedWavelengthWeight,\n expectedNormalizedWeight\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node geometry/measure does not match its declared segment/subdivision identity.\"\n );\n }\n\n if (\n wavelengthMeasureNanometers >\n maximumSubintervalWidthNanometers &&\n !approximatelyEqual(\n wavelengthMeasureNanometers,\n maximumSubintervalWidthNanometers\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature node width exceeds maximumSubintervalWidthNanometers.\"\n );\n }\n\n measureSum +=\n wavelengthMeasureNanometers;\n normalizedWeightSum +=\n normalizedWavelengthWeight;\n if (\n !Number.isFinite(measureSum) ||\n !Number.isFinite(\n normalizedWeightSum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature aggregate measures must remain finite.\"\n );\n }\n\n nodesByIndex.set(\n spectralSampleIndex,\n node\n );\n }\n );\n\n for (\n let spectralSampleIndex = 0;\n spectralSampleIndex < totalNodeCount;\n spectralSampleIndex += 1\n ) {\n if (\n !nodesByIndex.has(\n spectralSampleIndex\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature spectralSampleIndex values must form the exact contiguous range 0..totalNodeCount-1.\"\n );\n }\n }\n\n for (\n let segmentIndex = 0;\n segmentIndex < segmentCount;\n segmentIndex += 1\n ) {\n const expected =\n segmentSubdivisionCounts.get(\n segmentIndex\n );\n const seen =\n segmentSeenCounts.get(\n segmentIndex\n ) ?? 0;\n if (\n expected === undefined ||\n seen !== expected\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature must contain every declared subdivision exactly once.\"\n );\n }\n }\n\n if (\n !approximatelyEqual(\n measureSum,\n span\n ) ||\n !approximatelyEqual(\n normalizedWeightSum,\n 1\n ) ||\n !approximatelyEqual(\n quadrature.wavelengthMeasureSumNanometers,\n measureSum\n ) ||\n !approximatelyEqual(\n quadrature.normalizedWavelengthWeightSum,\n normalizedWeightSum\n )\n ) {\n throw new InvalidScientificInputError(\n \"spectralQuadrature aggregate wavelength measures/weights are inconsistent.\"\n );\n }\n\n return nodesByIndex;\n}\n\n/**\n * Builds deterministic wavelength sample points for one exact sensor response\n * channel. It does not apply the response to any spectrum.\n *\n * The requested range must lie fully inside the channel's declared usable\n * range. The response curve's breakpoints, plus any caller-supplied breakpoints\n * from the source spectrum or optics, split that range into segments. Each\n * segment is then subdivided so no midpoint subinterval is wider than\n * maximumSubintervalWidthNanometers.\n *\n * wavelengthMeasureNanometers is dλ in nanometres, not a dimensionless response\n * weight. Multiply it only by a spectral density per nanometre, or convert\n * units explicitly first.\n *\n * QE and A/W responsivity are deliberately not applied. They lead to different\n * signals: QE is photon-to-electron efficiency, while A/W responsivity relates\n * incident radiant power to electrical current. A later step must also match\n * responseScope to the source plane and collection area before integrating any\n * signal.\n */\nexport function calculateSensorSpectralQuadrature(\n input:\n CalculateSensorSpectralQuadratureInput\n): CalculationResult<SensorSpectralQuadrature> {\n requireInputKeys(input, \"calculateSensorSpectralQuadrature\", [\"colorSamplingProfile\", \"spectralResponseProfile\", \"channelId\", \"wavelengthBasis\", \"wavelengthRangeNanometers\", \"maximumSubintervalWidthNanometers\", \"additionalBreakpointsNanometers\"]);\n const maximumSubintervalWidthNanometers =\n requirePositiveFinite(\n input.maximumSubintervalWidthNanometers,\n \"maximumSubintervalWidthNanometers\"\n );\n\n if (\n input.wavelengthBasis !== \"air\" &&\n input.wavelengthBasis !== \"vacuum\" &&\n input.wavelengthBasis !== \"unspecified\"\n ) {\n throw new InvalidConfigurationError(\n \"wavelengthBasis is invalid.\"\n );\n }\n\n const colorProfile =\n parseSensorColorSamplingProfile(\n input.colorSamplingProfile\n );\n const responseProfile =\n parseSensorSpectralResponseProfile(\n input.spectralResponseProfile\n );\n const response = channelResponse(\n responseProfile,\n input.channelId\n );\n const curves =\n responseCurves(response);\n\n if (\n !curves.every(\n (curve) =>\n curve.wavelengthBasis ===\n input.wavelengthBasis\n )\n ) {\n throw new InvalidScientificInputError(\n \"wavelengthBasis must exactly match every response curve used by the requested channel.\"\n );\n }\n\n const usable = usableResponseRange(\n curves\n );\n const range = parseRequestedRange(\n input.wavelengthRangeNanometers,\n usable\n );\n const validationWavelength =\n range.minimum +\n (range.maximum - range.minimum) /\n 2;\n const representative =\n resolveSensorSpectralResponseAtWavelength(\n {\n colorSamplingProfile:\n colorProfile,\n spectralResponseProfile:\n responseProfile,\n channelId: input.channelId,\n wavelengthNanometers:\n validationWavelength,\n wavelengthBasis:\n input.wavelengthBasis\n }\n ).value;\n\n const additional =\n additionalBreakpoints(\n input.additionalBreakpointsNanometers,\n range\n );\n const boundaries =\n partitionBoundaries(\n curves,\n range,\n additional\n );\n const {\n segments,\n totalNodeCount\n } = planSegments(\n boundaries,\n maximumSubintervalWidthNanometers\n );\n\n const totalSpan =\n range.maximum - range.minimum;\n const nodes:\n SensorSpectralQuadratureNode[] = [];\n let spectralSampleIndex = 0;\n\n for (\n let segmentIndex = 0;\n segmentIndex < segments.length;\n segmentIndex += 1\n ) {\n const segment =\n segments[segmentIndex]!;\n\n for (\n let subdivisionIndex = 0;\n subdivisionIndex <\n segment.subdivisionCount;\n subdivisionIndex += 1\n ) {\n const wavelengthNanometers =\n segment.minimum +\n (subdivisionIndex + 0.5) *\n segment\n .subintervalWidthNanometers;\n\n nodes.push({\n spectralSampleIndex,\n segmentIndex,\n subdivisionIndex,\n segmentSubdivisionCount:\n segment.subdivisionCount,\n wavelengthNanometers,\n wavelengthMeasureNanometers:\n segment\n .subintervalWidthNanometers,\n normalizedWavelengthWeight:\n segment\n .subintervalWidthNanometers /\n totalSpan\n });\n\n spectralSampleIndex += 1;\n }\n }\n\n const normalizedWavelengthWeightSum =\n nodes.reduce(\n (sum, node) =>\n sum +\n node.normalizedWavelengthWeight,\n 0\n );\n const wavelengthMeasureSumNanometers =\n nodes.reduce(\n (sum, node) =>\n sum +\n node.wavelengthMeasureNanometers,\n 0\n );\n\n return approximationResult(\n {\n profileId:\n representative.profileId,\n colorSamplingProfileId:\n representative\n .colorSamplingProfileId,\n channelId:\n representative.channelId,\n sourceResponseKind:\n representative\n .sourceResponseKind,\n responseScope:\n representative.responseScope,\n responseScientificStatus:\n representative\n .scientificStatus,\n responseUncertainty:\n representative.uncertainty,\n responseChannelBinding:\n createSensorSpectralResponseChannelBinding(\n response\n ),\n ...(representative.referenceConditions ===\n undefined\n ? {}\n : {\n responseReferenceConditions:\n representative.referenceConditions\n }),\n wavelengthBasis:\n input.wavelengthBasis,\n wavelengthBasisResolved:\n representative\n .wavelengthBasisResolved,\n wavelengthRangeNanometers:\n range,\n responseDeclaredWavelengthRangeNanometers:\n usable,\n quadratureScheme:\n \"response-breakpoint-aware-bounded-midpoint\",\n segmentBoundarySource:\n \"requested-range-plus-response-knots-plus-optional-additional-breakpoints\",\n segmentBoundariesNanometers:\n [...boundaries],\n maximumSubintervalWidthNanometers,\n segmentCount:\n segments.length,\n totalNodeCount,\n normalizedWavelengthWeightSum,\n wavelengthMeasureSumNanometers,\n nodes,\n responseKnotAlignmentIncluded:\n true,\n componentEvidence: {\n colorSamplingProfile:\n colorProfile.evidence,\n profile:\n representative\n .componentEvidence.profile,\n channel:\n representative\n .componentEvidence.channel,\n curves:\n representative\n .componentEvidence.curves\n },\n responseValuesIncluded: false,\n responseApplicationPerformed:\n false,\n sourceSpectralValuesIncluded:\n false,\n spectralIrradianceIncluded:\n false,\n spectralPhotonIrradianceIncluded:\n false,\n commonSpectralCoverageValidated:\n false,\n continuousSpectralDensityQuadratureOnly:\n true,\n discreteLineSpectrumIncluded:\n false,\n opticalTransmissionIncludedByQuadrature:\n false,\n wavelengthIntegrationPerformed:\n false,\n spatialIntegrationPerformed:\n false,\n temporalIntegrationPerformed:\n false,\n photonsCalculated: false,\n electronsCalculated: false,\n rawCodeValueProduced: false,\n convergenceErrorEstimated: false\n },\n \"sensor-spectral-quadrature\",\n \"1.0.0\",\n [\n \"The partition includes requested range edges, response-curve knots, and optional caller-supplied continuous-spectrum/optics breakpoints.\",\n \"Every segment uses deterministic equal-width midpoint subintervals whose width is bounded by maximumSubintervalWidthNanometers.\",\n \"Wavelength measures are d-lambda in nanometres and normalized wavelength weights are geometric wavelength measures only; neither is sensor-response weighting.\",\n \"The requested range is validated against sensor-response support only. Scene-spectrum, optical-transmission, and other spectral-factor coverage are not established by this API.\",\n \"The response profile, exact channel linkage, wavelength basis, response scope, and response-data provenance are validated and preserved, but response values are not applied at quadrature nodes.\",\n \"QE and A/W responsivity remain different physical representations and require different compatible downstream photon/power semantics.\",\n \"Future signal composition must match responseScope to the source plane and collection-area model so upstream transmission is not omitted or double-counted.\",\n \"This midpoint plan targets continuous spectral-density integration. Discrete/delta-like line spectra require a separate explicit representation rather than being approximated by hidden point masses.\",\n \"No source spectral values, spectral irradiance, spectral photon irradiance, optical transmission, spatial integration, temporal integration, photon/electron conversion, current calculation, or RAW output is calculated.\",\n \"Response-knot alignment and a bounded wavelength step do not prove convergence for arbitrary source spectra or other wavelength-dependent factors.\",\n \"No source-independent convergence/error estimate is reported because integration error depends on the downstream integrand.\"\n ]\n );\n}\n"]}
|
|
@@ -21,6 +21,9 @@ export interface SensorEqeTemporalPhotoSignal extends Omit<SensorEqeExposureInte
|
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
export type SensorEqePhotoExposure = SensorEqeExposureIntegration | SensorEqeTemporalPhotoSignal;
|
|
24
|
+
/** The photo-signal flags that must be true, and (after the first) false, shared with the RAW producer's checks. */
|
|
25
|
+
export declare const PHOTO_SIGNAL_TRUE_FIELDS: readonly ["temporalIntegrationApplied", "exposureDurationApplied", "countsAreExpectationValues"];
|
|
26
|
+
export declare const PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS: readonly ["multiFrameSequenceIntegrated", "darkChargeIncluded", "otherChargeIncluded", "physicalFullWellAssessmentAuthorized", "cameraSaturationAssessmentAuthorized", "saturationAssessed", "shotNoiseApplied", "readNoiseApplied", "adcQuantizationApplied", "rawCodeValueProduced", "integerPhotonCountSampled", "integerElectronCountSampled", "chargeCalculated", "currentCalculated"];
|
|
24
27
|
/** Parses a time-resolved photo signal and recomputes its midpoint sums exactly. Declarations do not prove the source is correct. */
|
|
25
28
|
export declare function parseSensorEqeTemporalPhotoSignal(value: unknown): SensorEqeTemporalPhotoSignal;
|
|
26
29
|
/**
|
|
@@ -15,11 +15,14 @@ import { InvalidConfigurationError } from "../core/configuration-error.js";
|
|
|
15
15
|
import { parseEvidenceList } from "../core/evidence-provenance.js";
|
|
16
16
|
import { freezeOwnedData } from "../core/owned-data.js";
|
|
17
17
|
import { calculateSensorEqeTemporalExposure } from "./eqe-temporal-exposure.js";
|
|
18
|
-
|
|
19
|
-
const
|
|
18
|
+
/** The photo-signal flags that must be true, and (after the first) false, shared with the RAW producer's checks. */
|
|
19
|
+
export const PHOTO_SIGNAL_TRUE_FIELDS = ["temporalIntegrationApplied", "exposureDurationApplied", "countsAreExpectationValues"];
|
|
20
|
+
export const PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS = ["multiFrameSequenceIntegrated", "darkChargeIncluded", "otherChargeIncluded",
|
|
20
21
|
"physicalFullWellAssessmentAuthorized", "cameraSaturationAssessmentAuthorized", "saturationAssessed", "shotNoiseApplied",
|
|
21
22
|
"readNoiseApplied", "adcQuantizationApplied", "rawCodeValueProduced", "integerPhotonCountSampled", "integerElectronCountSampled",
|
|
22
23
|
"chargeCalculated", "currentCalculated"];
|
|
24
|
+
const trueFields = PHOTO_SIGNAL_TRUE_FIELDS;
|
|
25
|
+
const falseFields = ["timeStationarityEstablished", ...PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS];
|
|
23
26
|
function record(value, keys) {
|
|
24
27
|
return requireAllowlistedRecord(value, keys, "Invalid temporal photo-signal fields.");
|
|
25
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-photo-signal.js","sourceRoot":"","sources":["../../src/sensor/temporal-photo-signal.ts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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnH,MAAM,WAAW,GAAG,eAAe,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,mBAAmB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kCAAkC,EAAE,OAAO,EAAE;QACjG,0GAA0G;QAC1G,oHAAoH;KACrH,CAAC,CAAC;AACL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Time-resolved photo signal: a compact record of the expected photon and electron counts for one site\n * over one exposure, with the rate at each midpoint time.\n *\n * Creating it re-evaluates the physical input at every time. Parsing it recomputes the midpoint sums\n * exactly. Neither proves the light source is correct.\n * @see docs/MOTION_AND_SIGNAL.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport { requireAllowlistedRecord, requirePublicOpaqueId, requireInputKeys } from \"../core/record-validation.js\";\nimport { sumTemporalEqeRateExpectations } from \"./temporal-eqe-sum.js\";\nimport { approximationResult, type CalculationResult } from \"../core/calculation-result.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { parseEvidenceList, type EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport type { SensorEqeExposureIntegration } from \"./constant-rate-temporal-integration.js\";\nimport { calculateSensorEqeTemporalExposure, type CalculateSensorEqeTemporalExposureInput } from \"./eqe-temporal-exposure.js\";\n\n/** Compact expected photo signal, before any processing. Being tied to a time window is not evidence that the light was constant. */\nexport interface SensorEqeTemporalPhotoSignal extends Omit<SensorEqeExposureIntegration,\n \"kind\" | \"stationarityProfileId\" | \"stationarityStatus\" | \"integrationMethod\" | \"timeStationarityEstablished\" |\n \"timeVaryingSignalIntegrated\" | \"incidentPhotonRatePerSecond\" | \"expectedGeneratedElectronRatePerSecond\" | \"componentEvidence\"> {\n kind: \"eqe-temporal-photo-signal\";\n temporalIntegrationId: string;\n stationarityProfileId?: never;\n integrationMethod: \"uniform-midpoint-rate-quadrature\";\n timeStationarityEstablished: false;\n timeVaryingSignalIntegrated: true;\n temporalSamples: readonly {\n timeSecondsFromOpeningReference: number;\n incidentPhotonRatePerSecond: number;\n expectedGeneratedElectronRatePerSecond: number;\n }[];\n componentEvidence: {\n temporalResponse: readonly EvidenceProvenance[];\n exposureBinding: SensorEqeExposureIntegration[\"componentEvidence\"][\"exposureBinding\"];\n };\n}\n\nexport type SensorEqePhotoExposure = SensorEqeExposureIntegration | SensorEqeTemporalPhotoSignal;\n\nconst trueFields = [\"temporalIntegrationApplied\", \"exposureDurationApplied\", \"countsAreExpectationValues\"] as const;\nconst falseFields = [\"timeStationarityEstablished\", \"multiFrameSequenceIntegrated\", \"darkChargeIncluded\", \"otherChargeIncluded\",\n \"physicalFullWellAssessmentAuthorized\", \"cameraSaturationAssessmentAuthorized\", \"saturationAssessed\", \"shotNoiseApplied\",\n \"readNoiseApplied\", \"adcQuantizationApplied\", \"rawCodeValueProduced\", \"integerPhotonCountSampled\", \"integerElectronCountSampled\",\n \"chargeCalculated\", \"currentCalculated\"] as const;\nfunction record(value: unknown, keys: readonly string[]): Record<string, unknown> {\n return requireAllowlistedRecord(value, keys, \"Invalid temporal photo-signal fields.\");\n}\nfunction identity(value: unknown): string {\n return requirePublicOpaqueId(value, \"Temporal photo signal requires public identities.\");\n}\nfunction finite(value: unknown, nonnegative = true): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || (nonnegative && value < 0)) {\n throw new InvalidConfigurationError(\"Temporal photo-signal numeric quantity is invalid.\");\n }\n return value;\n}\n/** Parses a time-resolved photo signal and recomputes its midpoint sums exactly. Declarations do not prove the source is correct. */\nexport function parseSensorEqeTemporalPhotoSignal(value: unknown): SensorEqeTemporalPhotoSignal {\n const r = record(value, [...trueFields, ...falseFields, \"kind\", \"temporalIntegrationId\", \"colorSamplingProfileId\", \"channelId\", \"site\",\n \"bindingId\", \"timeReference\", \"startOffsetSecondsFromOpeningReference\", \"endOffsetSecondsFromOpeningReference\",\n \"localExposureDurationSeconds\", \"integrationMethod\", \"timeVaryingSignalIntegrated\", \"accumulatedSignalCompleteness\",\n \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\", \"temporalSamples\", \"componentEvidence\"]);\n if (r.kind !== \"eqe-temporal-photo-signal\" || r.integrationMethod !== \"uniform-midpoint-rate-quadrature\" ||\n r.timeReference !== \"first-opening-boundary-phase\" || r.timeVaryingSignalIntegrated !== true ||\n r.accumulatedSignalCompleteness !== \"photo-signal-only\" || trueFields.some(k => r[k] !== true) || falseFields.some(k => r[k] !== false)) {\n throw new InvalidConfigurationError(\"Temporal photo signal requires untreated midpoint-integrated EQE expectations.\");\n }\n const site = record(r.site, [\"x\", \"y\"]);\n for (const v of [site.x, site.y]) if (!Number.isSafeInteger(v) || (v as number) < 0) throw new InvalidConfigurationError(\"Invalid temporal photo site.\");\n const start = finite(r.startOffsetSecondsFromOpeningReference), end = finite(r.endOffsetSecondsFromOpeningReference);\n const duration = finite(r.localExposureDurationSeconds);\n if (!(end > start) || duration !== end-start) throw new InvalidConfigurationError(\"Temporal photo signal requires exact local duration.\");\n if (!Array.isArray(r.temporalSamples) || r.temporalSamples.length < 1 || r.temporalSamples.length > 256) {\n throw new InvalidConfigurationError(\"Temporal photo signal requires 1 through 256 dense midpoint samples.\");\n }\n const measure = duration / r.temporalSamples.length;\n let previous = -Infinity;\n const temporalSamples = Array.from(r.temporalSamples, (v, i) => {\n const s = record(v, [\"timeSecondsFromOpeningReference\", \"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\"]);\n const time = finite(s.timeSecondsFromOpeningReference), pr = finite(s.incidentPhotonRatePerSecond), er = finite(s.expectedGeneratedElectronRatePerSecond);\n if (time !== start + (i+0.5)*measure || !(time > start && time > previous && time < end) || er > pr) {\n throw new InvalidConfigurationError(\"Temporal photo midpoint time or EQE rate domain is invalid.\");\n }\n previous = time;\n return { timeSecondsFromOpeningReference: time, incidentPhotonRatePerSecond: pr, expectedGeneratedElectronRatePerSecond: er };\n });\n const { photonCount: photons, electronCount: electrons } = sumTemporalEqeRateExpectations(temporalSamples, measure);\n if (!Number.isFinite(photons) || !Number.isFinite(electrons) ||\n finite(r.expectedIncidentPhotonCount) !== photons || finite(r.expectedGeneratedElectronCount) !== electrons) {\n throw new InvalidConfigurationError(\"Temporal photo counts do not match the exact midpoint rate integral.\");\n }\n const e = record(r.componentEvidence, [\"temporalResponse\", \"exposureBinding\"]);\n const b = record(e.exposureBinding, [\"binding\", \"colorSamplingProfile\", \"nominalExposureDuration\", \"openingBoundary\", \"closingBoundary\"]);\n const optional = (v: unknown): readonly EvidenceProvenance[] => Array.isArray(v) && v.length === 0 ? [] : parseEvidenceList(v, \"temporalExposureEvidence\");\n return { ...r, colorSamplingProfileId: identity(r.colorSamplingProfileId), channelId: identity(r.channelId),\n bindingId: identity(r.bindingId), temporalIntegrationId: identity(r.temporalIntegrationId), site: { x: site.x as number, y: site.y as number }, temporalSamples,\n componentEvidence: { temporalResponse: parseEvidenceList(e.temporalResponse, \"temporalResponse\"), exposureBinding: {\n binding: parseEvidenceList(b.binding, \"binding\"), colorSamplingProfile: parseEvidenceList(b.colorSamplingProfile, \"colorSamplingProfile\"),\n nominalExposureDuration: parseEvidenceList(b.nominalExposureDuration, \"nominalExposureDuration\"),\n openingBoundary: optional(b.openingBoundary), closingBoundary: optional(b.closingBoundary) } }\n } as unknown as SensorEqeTemporalPhotoSignal;\n}\n\n/**\n * Re-evaluates the physical input at every time, then commits a compact photo\n * signal. Detailed per-step evidence and uncertainty stay in the returned\n * exposure diagnostics. This does not show that a renderer or source actually ran.\n */\nexport function createSensorEqeTemporalPhotoSignal(input: {\n temporalIntegrationId: string;\n exposure: CalculateSensorEqeTemporalExposureInput;\n}): CalculationResult<{ photoSignal: SensorEqeTemporalPhotoSignal; exposure: ReturnType<typeof calculateSensorEqeTemporalExposure> }> {\n requireInputKeys(input, \"createSensorEqeTemporalPhotoSignal\", [\"temporalIntegrationId\", \"exposure\"]);\n identity(input.temporalIntegrationId);\n const exposure = calculateSensorEqeTemporalExposure(input.exposure), v = exposure.value;\n const p = { kind: \"eqe-temporal-photo-signal\", temporalIntegrationId: input.temporalIntegrationId,\n colorSamplingProfileId: v.colorSamplingProfileId, channelId: v.channelId, site: v.site, bindingId: v.bindingId,\n timeReference: v.timeReference, startOffsetSecondsFromOpeningReference: v.startOffsetSecondsFromOpeningReference,\n endOffsetSecondsFromOpeningReference: v.endOffsetSecondsFromOpeningReference, localExposureDurationSeconds: v.localExposureDurationSeconds,\n expectedIncidentPhotonCount: v.expectedIncidentPhotonCount, expectedGeneratedElectronCount: v.expectedGeneratedElectronCount,\n integrationMethod: v.integrationMethod, timeVaryingSignalIntegrated: true, accumulatedSignalCompleteness: \"photo-signal-only\",\n temporalSamples: v.samples.map(s => ({ timeSecondsFromOpeningReference: s.timeSecondsFromOpeningReference,\n incidentPhotonRatePerSecond: s.stages.electronRate.value.incidentPhotonRatePerSecond,\n expectedGeneratedElectronRatePerSecond: s.stages.electronRate.value.expectedGeneratedElectronRatePerSecond })),\n componentEvidence: { temporalResponse: v.samples[0]!.stages.spectralQuadrature.value.componentEvidence.profile,\n exposureBinding: v.samples[0]!.stages.exposureBinding.value.componentEvidence },\n ...Object.fromEntries(trueFields.map(k => [k, true])), ...Object.fromEntries(falseFields.map(k => [k, false])) };\n const photoSignal = freezeOwnedData(parseSensorEqeTemporalPhotoSignal(p));\n return approximationResult({ photoSignal, exposure }, \"sensor-eqe-temporal-photo-signal\", \"0.1.0\", [\n \"Photo signal commits explicit midpoint EQE rate expectations, not stationarity or source-truth evidence.\",\n \"Child diagnostics retain separate validity, evidence and uncombined uncertainty; no convergence bound is inferred.\"\n ]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"temporal-photo-signal.js","sourceRoot":"","sources":["../../src/sensor/temporal-photo-signal.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEt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AE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnH,MAAM,WAAW,GAAG,eAAe,CAAC,iCAAiC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,OAAO,mBAAmB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,kCAAkC,EAAE,OAAO,EAAE;QACjG,0GAA0G;QAC1G,oHAAoH;KACrH,CAAC,CAAC;AACL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Time-resolved photo signal: a compact record of the expected photon and electron counts for one site\n * over one exposure, with the rate at each midpoint time.\n *\n * Creating it re-evaluates the physical input at every time. Parsing it recomputes the midpoint sums\n * exactly. Neither proves the light source is correct.\n * @see docs/MOTION_AND_SIGNAL.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport { requireAllowlistedRecord, requirePublicOpaqueId, requireInputKeys } from \"../core/record-validation.js\";\nimport { sumTemporalEqeRateExpectations } from \"./temporal-eqe-sum.js\";\nimport { approximationResult, type CalculationResult } from \"../core/calculation-result.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { parseEvidenceList, type EvidenceProvenance } from \"../core/evidence-provenance.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport type { SensorEqeExposureIntegration } from \"./constant-rate-temporal-integration.js\";\nimport { calculateSensorEqeTemporalExposure, type CalculateSensorEqeTemporalExposureInput } from \"./eqe-temporal-exposure.js\";\n\n/** Compact expected photo signal, before any processing. Being tied to a time window is not evidence that the light was constant. */\nexport interface SensorEqeTemporalPhotoSignal extends Omit<SensorEqeExposureIntegration,\n \"kind\" | \"stationarityProfileId\" | \"stationarityStatus\" | \"integrationMethod\" | \"timeStationarityEstablished\" |\n \"timeVaryingSignalIntegrated\" | \"incidentPhotonRatePerSecond\" | \"expectedGeneratedElectronRatePerSecond\" | \"componentEvidence\"> {\n kind: \"eqe-temporal-photo-signal\";\n temporalIntegrationId: string;\n stationarityProfileId?: never;\n integrationMethod: \"uniform-midpoint-rate-quadrature\";\n timeStationarityEstablished: false;\n timeVaryingSignalIntegrated: true;\n temporalSamples: readonly {\n timeSecondsFromOpeningReference: number;\n incidentPhotonRatePerSecond: number;\n expectedGeneratedElectronRatePerSecond: number;\n }[];\n componentEvidence: {\n temporalResponse: readonly EvidenceProvenance[];\n exposureBinding: SensorEqeExposureIntegration[\"componentEvidence\"][\"exposureBinding\"];\n };\n}\n\nexport type SensorEqePhotoExposure = SensorEqeExposureIntegration | SensorEqeTemporalPhotoSignal;\n\n/** The photo-signal flags that must be true, and (after the first) false, shared with the RAW producer's checks. */\nexport const PHOTO_SIGNAL_TRUE_FIELDS = [\"temporalIntegrationApplied\", \"exposureDurationApplied\", \"countsAreExpectationValues\"] as const;\nexport const PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS = [\"multiFrameSequenceIntegrated\", \"darkChargeIncluded\", \"otherChargeIncluded\",\n \"physicalFullWellAssessmentAuthorized\", \"cameraSaturationAssessmentAuthorized\", \"saturationAssessed\", \"shotNoiseApplied\",\n \"readNoiseApplied\", \"adcQuantizationApplied\", \"rawCodeValueProduced\", \"integerPhotonCountSampled\", \"integerElectronCountSampled\",\n \"chargeCalculated\", \"currentCalculated\"] as const;\nconst trueFields = PHOTO_SIGNAL_TRUE_FIELDS;\nconst falseFields = [\"timeStationarityEstablished\", ...PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS] as const;\nfunction record(value: unknown, keys: readonly string[]): Record<string, unknown> {\n return requireAllowlistedRecord(value, keys, \"Invalid temporal photo-signal fields.\");\n}\nfunction identity(value: unknown): string {\n return requirePublicOpaqueId(value, \"Temporal photo signal requires public identities.\");\n}\nfunction finite(value: unknown, nonnegative = true): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || (nonnegative && value < 0)) {\n throw new InvalidConfigurationError(\"Temporal photo-signal numeric quantity is invalid.\");\n }\n return value;\n}\n/** Parses a time-resolved photo signal and recomputes its midpoint sums exactly. Declarations do not prove the source is correct. */\nexport function parseSensorEqeTemporalPhotoSignal(value: unknown): SensorEqeTemporalPhotoSignal {\n const r = record(value, [...trueFields, ...falseFields, \"kind\", \"temporalIntegrationId\", \"colorSamplingProfileId\", \"channelId\", \"site\",\n \"bindingId\", \"timeReference\", \"startOffsetSecondsFromOpeningReference\", \"endOffsetSecondsFromOpeningReference\",\n \"localExposureDurationSeconds\", \"integrationMethod\", \"timeVaryingSignalIntegrated\", \"accumulatedSignalCompleteness\",\n \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\", \"temporalSamples\", \"componentEvidence\"]);\n if (r.kind !== \"eqe-temporal-photo-signal\" || r.integrationMethod !== \"uniform-midpoint-rate-quadrature\" ||\n r.timeReference !== \"first-opening-boundary-phase\" || r.timeVaryingSignalIntegrated !== true ||\n r.accumulatedSignalCompleteness !== \"photo-signal-only\" || trueFields.some(k => r[k] !== true) || falseFields.some(k => r[k] !== false)) {\n throw new InvalidConfigurationError(\"Temporal photo signal requires untreated midpoint-integrated EQE expectations.\");\n }\n const site = record(r.site, [\"x\", \"y\"]);\n for (const v of [site.x, site.y]) if (!Number.isSafeInteger(v) || (v as number) < 0) throw new InvalidConfigurationError(\"Invalid temporal photo site.\");\n const start = finite(r.startOffsetSecondsFromOpeningReference), end = finite(r.endOffsetSecondsFromOpeningReference);\n const duration = finite(r.localExposureDurationSeconds);\n if (!(end > start) || duration !== end-start) throw new InvalidConfigurationError(\"Temporal photo signal requires exact local duration.\");\n if (!Array.isArray(r.temporalSamples) || r.temporalSamples.length < 1 || r.temporalSamples.length > 256) {\n throw new InvalidConfigurationError(\"Temporal photo signal requires 1 through 256 dense midpoint samples.\");\n }\n const measure = duration / r.temporalSamples.length;\n let previous = -Infinity;\n const temporalSamples = Array.from(r.temporalSamples, (v, i) => {\n const s = record(v, [\"timeSecondsFromOpeningReference\", \"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\"]);\n const time = finite(s.timeSecondsFromOpeningReference), pr = finite(s.incidentPhotonRatePerSecond), er = finite(s.expectedGeneratedElectronRatePerSecond);\n if (time !== start + (i+0.5)*measure || !(time > start && time > previous && time < end) || er > pr) {\n throw new InvalidConfigurationError(\"Temporal photo midpoint time or EQE rate domain is invalid.\");\n }\n previous = time;\n return { timeSecondsFromOpeningReference: time, incidentPhotonRatePerSecond: pr, expectedGeneratedElectronRatePerSecond: er };\n });\n const { photonCount: photons, electronCount: electrons } = sumTemporalEqeRateExpectations(temporalSamples, measure);\n if (!Number.isFinite(photons) || !Number.isFinite(electrons) ||\n finite(r.expectedIncidentPhotonCount) !== photons || finite(r.expectedGeneratedElectronCount) !== electrons) {\n throw new InvalidConfigurationError(\"Temporal photo counts do not match the exact midpoint rate integral.\");\n }\n const e = record(r.componentEvidence, [\"temporalResponse\", \"exposureBinding\"]);\n const b = record(e.exposureBinding, [\"binding\", \"colorSamplingProfile\", \"nominalExposureDuration\", \"openingBoundary\", \"closingBoundary\"]);\n const optional = (v: unknown): readonly EvidenceProvenance[] => Array.isArray(v) && v.length === 0 ? [] : parseEvidenceList(v, \"temporalExposureEvidence\");\n return { ...r, colorSamplingProfileId: identity(r.colorSamplingProfileId), channelId: identity(r.channelId),\n bindingId: identity(r.bindingId), temporalIntegrationId: identity(r.temporalIntegrationId), site: { x: site.x as number, y: site.y as number }, temporalSamples,\n componentEvidence: { temporalResponse: parseEvidenceList(e.temporalResponse, \"temporalResponse\"), exposureBinding: {\n binding: parseEvidenceList(b.binding, \"binding\"), colorSamplingProfile: parseEvidenceList(b.colorSamplingProfile, \"colorSamplingProfile\"),\n nominalExposureDuration: parseEvidenceList(b.nominalExposureDuration, \"nominalExposureDuration\"),\n openingBoundary: optional(b.openingBoundary), closingBoundary: optional(b.closingBoundary) } }\n } as unknown as SensorEqeTemporalPhotoSignal;\n}\n\n/**\n * Re-evaluates the physical input at every time, then commits a compact photo\n * signal. Detailed per-step evidence and uncertainty stay in the returned\n * exposure diagnostics. This does not show that a renderer or source actually ran.\n */\nexport function createSensorEqeTemporalPhotoSignal(input: {\n temporalIntegrationId: string;\n exposure: CalculateSensorEqeTemporalExposureInput;\n}): CalculationResult<{ photoSignal: SensorEqeTemporalPhotoSignal; exposure: ReturnType<typeof calculateSensorEqeTemporalExposure> }> {\n requireInputKeys(input, \"createSensorEqeTemporalPhotoSignal\", [\"temporalIntegrationId\", \"exposure\"]);\n identity(input.temporalIntegrationId);\n const exposure = calculateSensorEqeTemporalExposure(input.exposure), v = exposure.value;\n const p = { kind: \"eqe-temporal-photo-signal\", temporalIntegrationId: input.temporalIntegrationId,\n colorSamplingProfileId: v.colorSamplingProfileId, channelId: v.channelId, site: v.site, bindingId: v.bindingId,\n timeReference: v.timeReference, startOffsetSecondsFromOpeningReference: v.startOffsetSecondsFromOpeningReference,\n endOffsetSecondsFromOpeningReference: v.endOffsetSecondsFromOpeningReference, localExposureDurationSeconds: v.localExposureDurationSeconds,\n expectedIncidentPhotonCount: v.expectedIncidentPhotonCount, expectedGeneratedElectronCount: v.expectedGeneratedElectronCount,\n integrationMethod: v.integrationMethod, timeVaryingSignalIntegrated: true, accumulatedSignalCompleteness: \"photo-signal-only\",\n temporalSamples: v.samples.map(s => ({ timeSecondsFromOpeningReference: s.timeSecondsFromOpeningReference,\n incidentPhotonRatePerSecond: s.stages.electronRate.value.incidentPhotonRatePerSecond,\n expectedGeneratedElectronRatePerSecond: s.stages.electronRate.value.expectedGeneratedElectronRatePerSecond })),\n componentEvidence: { temporalResponse: v.samples[0]!.stages.spectralQuadrature.value.componentEvidence.profile,\n exposureBinding: v.samples[0]!.stages.exposureBinding.value.componentEvidence },\n ...Object.fromEntries(trueFields.map(k => [k, true])), ...Object.fromEntries(falseFields.map(k => [k, false])) };\n const photoSignal = freezeOwnedData(parseSensorEqeTemporalPhotoSignal(p));\n return approximationResult({ photoSignal, exposure }, \"sensor-eqe-temporal-photo-signal\", \"0.1.0\", [\n \"Photo signal commits explicit midpoint EQE rate expectations, not stationarity or source-truth evidence.\",\n \"Child diagnostics retain separate validity, evidence and uncombined uncertainty; no convergence bound is inferred.\"\n ]);\n}\n"]}
|
|
@@ -16,6 +16,15 @@ import { type CalculationResult } from "../core/calculation-result.js";
|
|
|
16
16
|
import { type EvidenceBackedFact, type EvidenceProvenance } from "../core/evidence-provenance.js";
|
|
17
17
|
import type { RasterPoint } from "../output/capture-geometry.js";
|
|
18
18
|
import type { ResolvedCaptureModeTiming } from "../sensor/capture-mode-timing.js";
|
|
19
|
+
/** The scope flags every stabilization profile declares false, in this order (shared with the generic tier assets). */
|
|
20
|
+
export declare const STABILIZATION_UNMODELED_SCOPE: Readonly<{
|
|
21
|
+
controlTransientModeled: false;
|
|
22
|
+
spontaneousDriftModeled: false;
|
|
23
|
+
cameraTranslationCorrectionModeled: false;
|
|
24
|
+
digitalStabilizationIncluded: false;
|
|
25
|
+
supportPolicyIncluded: false;
|
|
26
|
+
stopRatingUsedAsDynamicResponse: false;
|
|
27
|
+
}>;
|
|
19
28
|
export declare const STABILIZATION_SYSTEM_PROFILE_SCHEMA_VERSION: "0.1.0";
|
|
20
29
|
export declare const STABILIZATION_DISTURBANCE_TRAJECTORY_VERSION: "0.1.0";
|
|
21
30
|
export type StabilizationRotationAxis = "pitch" | "yaw" | "roll";
|
|
@@ -19,6 +19,10 @@ import { parseEvidenceList } from "../core/evidence-provenance.js";
|
|
|
19
19
|
import { InvalidScientificInputError, requirePositiveInteger } from "../core/validation.js";
|
|
20
20
|
import { requireInputKeys, requireInputObject, rejectUnknownVariantFields, requireConfigRecord as requireRecord, requireTrimmedConfigString as requireNonEmptyString, requireConfigFinite as requireFinite, parseConfigLimitations as parseLimitations, requireConfigFiniteAtLeastZero as requireNonNegativeFinite, requireConfigUnitInterval as requireFraction } from "../core/record-validation.js";
|
|
21
21
|
import { parseNonNegativeFact, parsePositiveFact } from "../sensor/raw-readout.js";
|
|
22
|
+
/** The scope flags every stabilization profile declares false, in this order (shared with the generic tier assets). */
|
|
23
|
+
export const STABILIZATION_UNMODELED_SCOPE = /* @__PURE__ */ Object.freeze({ controlTransientModeled: false, spontaneousDriftModeled: false,
|
|
24
|
+
cameraTranslationCorrectionModeled: false, digitalStabilizationIncluded: false, supportPolicyIncluded: false,
|
|
25
|
+
stopRatingUsedAsDynamicResponse: false });
|
|
22
26
|
export const STABILIZATION_SYSTEM_PROFILE_SCHEMA_VERSION = "0.1.0";
|
|
23
27
|
export const STABILIZATION_DISTURBANCE_TRAJECTORY_VERSION = "0.1.0";
|
|
24
28
|
const AXES = new Set([
|
|
@@ -219,12 +223,7 @@ export function parseStabilizationSystemProfile(value) {
|
|
|
219
223
|
: {
|
|
220
224
|
coordinatedAllocation
|
|
221
225
|
}),
|
|
222
|
-
|
|
223
|
-
spontaneousDriftModeled: false,
|
|
224
|
-
cameraTranslationCorrectionModeled: false,
|
|
225
|
-
digitalStabilizationIncluded: false,
|
|
226
|
-
supportPolicyIncluded: false,
|
|
227
|
-
stopRatingUsedAsDynamicResponse: false,
|
|
226
|
+
...STABILIZATION_UNMODELED_SCOPE,
|
|
228
227
|
evidence: parseEvidenceList(record.evidence, "stabilizationSystemProfile.evidence"),
|
|
229
228
|
limitations: parseLimitations(record.limitations, "stabilizationSystemProfile.limitations")
|
|
230
229
|
};
|