예제 #1
0
        public static SpectrumTransition GetPeaks(SpectrumTransition source)
        {
            SpectrumSearchSettings settings = new SpectrumSearchSettings();

            double[] resultDataY;
            double[] peakX;
            _search(source.GetDataYArray(), out resultDataY, out peakX, source.Data.Count, settings);

            List <Bin> resultDataYList = new List <Bin>();

            for (int i = 0; i < source.Data.Count; i++)
            {
                resultDataYList.Add(new Bin(source.Data[i].X, (float)resultDataY[i]));
            }

            var result = new SpectrumTransition();

            result.Name = "Peaks";

            for (int i = 0; i < peakX.Length; i++)
            {
                if (peakX[i] == 0)
                {
                    continue;
                }

                var nearestBin = GetNearestBin(peakX[i], resultDataYList);
                result.Data.Add(nearestBin);
            }

            return(result);
        }
예제 #2
0
        private LineSeries BuildLineSeries(SpectrumTransition transition, Action <object, OxyMouseDownEventArgs> onSeriesClicked)
        {
            var series = new LineSeries()
            {
                StrokeThickness = 1,
                Title           = transition.Name
            };

            switch (transition.Name)
            {
            case "Source":
            {
                series.Color            = OxyColors.Red;
                series.MarkerType       = MarkerType.Circle;
                series.MarkerSize       = 2;
                series.MarkerFill       = OxyColors.Red;
                series.MarkerResolution = 50;
                break;
            }

            case "Optimized":
            {
                series.Color            = OxyColors.Blue;
                series.MarkerType       = MarkerType.Square;
                series.MarkerSize       = 2;
                series.MarkerFill       = OxyColors.Blue;
                series.MarkerResolution = 50;
                if (onSeriesClicked != null)
                {
                    series.MouseDown += (s, e) => { onSeriesClicked(s, e); };
                }
                break;
            }

            case "Imported":
            {
                series.Color            = OxyColors.Green;
                series.MarkerType       = MarkerType.Triangle;
                series.MarkerSize       = 3;
                series.MarkerFill       = OxyColors.Green;
                series.MarkerResolution = 50;
                break;
            }

            default:
            {
                series.Color = OxyColors.Yellow;
                break;
            }
            }

            series.Points.AddRange(transition.Data.Select(bin => (DataPoint)bin));

            return(series);
        }
예제 #3
0
 public Spectrum(SpectrumBase spectrumBase)
 {
     this.Name      = spectrumBase.Name;
     this.Type      = SpectrumType.Imported;
     this.Optimized = new SpectrumTransition
     {
         Name = "Imported",
         Data = Database.ParseSpectrum(spectrumBase.Data)
     };
     this.Peaks = new SpectrumTransition
     {
         Name = "Imported Peaks",
         Data = Database.ParseSpectrum(spectrumBase.Peaks)
     };
 }
예제 #4
0
        private ScatterSeries BuildScatterSeries(SpectrumTransition peaks, string peakSeriesName)
        {
            ScatterSeries result;
            Series        existingSeries = GetExistingSeries(peakSeriesName);

            if (existingSeries != null)
            {
                result = existingSeries as ScatterSeries;
            }
            else
            {
                result = CreatePeakSeries(peakSeriesName); // (string)Application.Current.Resources["str_plotter_PeakSeriesTitle"]
            }

            return(result);
        }
예제 #5
0
        internal static SpectrumTransition GetOptimized(SpectrumTransition source)
        {
            var result = new SpectrumTransition();

            result.Name = "Optimized";

            SpectrumSearchSettings settings = new SpectrumSearchSettings();

            double[] smoothedSpectrum;
            double[] peakX;
            Spectrum._search(source.GetDataYArray(), out smoothedSpectrum, out peakX, source.Data.Count, settings);

            for (int i = 0; i < source.Data.Count; i++)
            {
                result.Data.Add(new Bin(source.Data[i].X, (float)smoothedSpectrum[i]));
            }

            return(result);
        }
예제 #6
0
        internal static SpectrumTransition ParseFromString(string contents, string name)
        {
            var _contents = contents.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            var result    = new SpectrumTransition();

            if (_contents.Length > 2)
            {
                result.Data = new List <Bin>();

                for (int i = 0; i < _contents.Length; i++)
                {
                    var str = _contents[i];
                    if (Settings.IgnoredPhrases.Any(str.Contains))
                    {
                        continue;
                    }
                    result.Data.Add(Bin.Parse(str));
                }
            }
            result.Name = name;
            return(result);
        }