Commit cb3d909d authored by Francesco Carraro's avatar Francesco Carraro
Browse files

working again on smoothing

parent 918900d1
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -235,5 +235,37 @@ namespace INAF.Apps.Uwp.SLabDataManager.Charts.Containers
            return Summaries.FirstOrDefault(x => x.Type == spectrumType);
        }
        #endregion

        #region retrieve aligned spectrum (by smoothing type)
        public SpectrumModel getAlignedSpectrum()
        {
            SpectrumModel spectrum = null;

            /* look for the right aligned type by descending order of importance */
            if (isAnySpectrumOfType(SpectrumType.AlignedSmoothed))
                spectrum = tryGetSpectrumOfType(SpectrumType.AlignedSmoothed);
            else if (isAnySpectrumOfType(SpectrumType.AlignedSmoothedBySegments))
                spectrum = tryGetSpectrumOfType(SpectrumType.AlignedSmoothedBySegments);
            else if (isAnySpectrumOfType(SpectrumType.Aligned))
                spectrum = tryGetSpectrumOfType(SpectrumType.Aligned);

            return spectrum;
        }

        public SpectrumType getAlignedSpectrumType()
        {
            SpectrumType spectrumType = SpectrumType.None;

            /* look for the right aligned type by descending order of importance */
            if (isAnySpectrumOfType(SpectrumType.AlignedSmoothed))
                spectrumType = SpectrumType.AlignedSmoothed;
            else if (isAnySpectrumOfType(SpectrumType.AlignedSmoothedBySegments))
                spectrumType = SpectrumType.AlignedSmoothedBySegments;
            else if (isAnySpectrumOfType(SpectrumType.Aligned))
                spectrumType = SpectrumType.Aligned;

            return spectrumType;
        }
        #endregion
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -46,8 +46,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
                var segmentsFitModelContainer = serviceProvider.GetRequiredService<SegmentsFitModelHelper>();

                /*  find closest points on spectrum to mouse position */
                var spectrum = workingItems.SpectraContainer.tryGetSpectrumOfType(SpectrumType.Aligned);
                (PointModel lowBoundary, PointModel highBoundary) boundaries = getSegmentBoundaries(spectrum,
                (PointModel lowBoundary, PointModel highBoundary) boundaries = getSegmentBoundaries(workingItems.SpectraContainer.getAlignedSpectrum(),
                                                                                                    (double)point.Item1,
                                                                                                    (double)point.Item2);

+1 −1
Original line number Diff line number Diff line
@@ -133,7 +133,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart
            IsContinuumRemovalCompleted = false;

            /* retrieve spectra for removing continuum */
            CloneForContinuumRemoval = spectraContainer.getClonedSpectrum(SpectrumType.Aligned,
            CloneForContinuumRemoval = spectraContainer.getClonedSpectrum(spectraContainer.getAlignedSpectrumType(),
                                                                          SpectrumType.ContinuumRemoved);
            Continuum = spectraContainer.tryGetSpectrumOfType(SpectrumType.Continuum);

+5 −0
Original line number Diff line number Diff line
@@ -58,5 +58,10 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.UI.Chart.ProcessingHelpers
                return (clonedSpectrum, isOk);
            });
        }

        //public async Task<(SpectrumModel filteredSpectrum, bool isOk)> applySmoothingToSpectrum(SpectrumModel clonedSpectrum)
        //{

        //}
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -11,15 +11,15 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.XmlReaders
{
    public sealed class SmoothingDefaultBoundariesReader : XmlReader
    {
        private readonly SmoothingBoundariesContainer smoothingBoundaries;
        private readonly SmoothingBoundariesContainer smoothingBoundariesContainer;

        public SmoothingDefaultBoundariesReader(IServiceProvider serviceProvider,
                                                SmoothingBoundariesContainer smoothingBoundaries,
                                                SmoothingBoundariesContainer smoothingBoundariesContainer,
                                                XmlHelper xmlHelper,
                                                Logger logger) : base(serviceProvider, xmlHelper, logger)
        {
            this.smoothingBoundaries = smoothingBoundaries;
            smoothingBoundaries.init();
            this.smoothingBoundariesContainer = smoothingBoundariesContainer;
            smoothingBoundariesContainer.init();
        }

        public override async Task readFileAsync()
@@ -46,7 +46,7 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.XmlReaders
                    string _currentValue = node.InnerText;
                    double currentValue = _currentValue.ToDoubleInvariant();

                    smoothingBoundaries.add(currentValue);
                    smoothingBoundariesContainer.add(currentValue);
                }
            }
            catch (Exception ex)
Loading