Skip to content

Commit

Permalink
Fix export ECSV precision with smooth
Browse files Browse the repository at this point in the history
  • Loading branch information
Am6er committed Dec 16, 2024
1 parent 8f3b386 commit eea404e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions BecquerelMonitor/BecquerelMonitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<MinimumRequiredVersion>2022.07.08.7</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>index.html</WebPage>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>2024.11.17.3</ApplicationVersion>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>2024.12.16.1</ApplicationVersion>
<UseApplicationTrust>true</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
10 changes: 7 additions & 3 deletions BecquerelMonitor/DocumentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ public void ExportDocumentToECSV(DocEnergySpectrum doc, BackgroundMode bgMode, S
PolynomialEnergyCalibration cal = (PolynomialEnergyCalibration)doc.ActiveResultData.EnergySpectrum.EnergyCalibration;

EnergySpectrum energySpectrum;
double[] dSpectrum = new double[doc.ActiveResultData.EnergySpectrum.NumberOfChannels];
SpectrumAriphmetics sa = new SpectrumAriphmetics();
if (bgMode == BackgroundMode.Substract && doc.ActiveResultData.BackgroundEnergySpectrum != null)
{
Expand All @@ -1043,11 +1044,14 @@ public void ExportDocumentToECSV(DocEnergySpectrum doc, BackgroundMode bgMode, S
{
case SmoothingMethod.SimpleMovingAverage:
int points = GlobalConfigManager.GetInstance().GlobalConfig.ChartViewConfig.NumberOfSMADataPoints;
energySpectrum.Spectrum = sa.SMA(energySpectrum.Spectrum, points, countlimit: countlimit);
dSpectrum = sa.SMA2(Array.ConvertAll(energySpectrum.Spectrum, i => (double)i), points, countlimit: countlimit);
break;
case SmoothingMethod.WeightedMovingAverage:
points = GlobalConfigManager.GetInstance().GlobalConfig.ChartViewConfig.NumberOfWMADataPoints;
energySpectrum.Spectrum = sa.WMA(energySpectrum.Spectrum, points, countlimit: countlimit);
dSpectrum = sa.WMA2(Array.ConvertAll(energySpectrum.Spectrum, i => (double)i), points, countlimit: countlimit);
break;
default:
dSpectrum = Array.ConvertAll(energySpectrum.Spectrum, i => (double)i);
break;
}

Expand All @@ -1058,7 +1062,7 @@ public void ExportDocumentToECSV(DocEnergySpectrum doc, BackgroundMode bgMode, S
streamWriter.WriteLine("channel, energy, count");
for (int i = 0; i < energySpectrum.NumberOfChannels; i++)
{
streamWriter.WriteLine(i + "," + cal.ChannelToEnergy(i) + "," + energySpectrum.Spectrum[i]);
streamWriter.WriteLine(i + "," + cal.ChannelToEnergy(i) + "," + dSpectrum[i]);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions BecquerelMonitor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion("2024.11.17.3")]
[assembly: AssemblyVersion("2024.12.16.1")]
[assembly: AssemblyProduct("BecquerelMonitor")]
[assembly: AssemblyCopyright("free")]
[assembly: AssemblyTrademark("none")]
[assembly: AssemblyConfiguration("")]
[assembly: Guid("40110b38-4882-47c1-ad94-a71e58dcb5f8")]
[assembly: AssemblyFileVersion("2024.11.17.3")]
[assembly: AssemblyFileVersion("2024.12.16.1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCompany("free")]
[assembly: CompilationRelaxations(8)]
Expand Down

0 comments on commit eea404e

Please sign in to comment.