XRF Spectral Processing

From SoftwareGuy
Revision as of 18:10, 19 March 2023 by Mark (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

XRF Spectral Processing

Spectrum_Processing.c

combinePreviousSpectra

<code>void combinePreviousSpectra ( volatile STRUCT_READING_DATA* reading, int whatFilter)</code>

getWorkingSpectrumAvgPower

<code>float getWorkingSpectrumAvgPower( volatile STRUCT_READING_DATA* reading)</code>

processMeasurementSpectrum

<code>processMeasurementSpectrum(...)</code>:

  • This function gets a float version of the raw data and puts it into a local buffer (on the stack as of now).
  • It converts the spectrum to cps/uA.
  • Removes escape peaks.
  • Does Sum Peak correction.
  • Load the reading structure.

getFinalSpectrum_float

<code>void getFinalSpectrum_float(float *spectrum, int numberOfBins)</code>

convertSpectrumToLive_Ev_Ua

<code>convertSpectrumToLive_Ev_Ua(...)</code>

  • This function re-bins the spectrum based on the current escale.

removeSpectrumEscapePeak

<code>void removeSpectrumEscapePeak (int numBins, float *spectrum)</code>

fullSpectrumSumPeakCorrection

<code>void fullSpectrumSumPeakCorrection(int numBins, float *spectrum)</code>

Test Code

I am adding a little piece of test code to display the raw spectrum at the end of the reading. To do this I first need to save the raw spectrum into a temp buffer. This is done repeatedly until the trigger is release.

This first piece is done in

processMeasurementSpectrum

<pre> for (int i = 0; i < SPECTRA_SIZE; i++) tempSpectrum[i] = processedSpectrum[i]; </pre>

Now at the end of <code>MakeMeasurement</code> I add a little piece of code to print out the final spectrum.

<pre> for (int i = 0; i < SPECTRA_SIZE; i++) s_msg("%d, %f", i, tempSpectrum[i] ); </pre>