コード例 #1
0
        private static IReadOnlyDictionary <double, Fraction> GetFractionDictionary(
            SourceList matchedSources,
            SourceList allSources)
        {
            var brightest = GetBrightestMagSource(allSources);
            var result    = new Dictionary <double, Fraction>();

            for (var mag = 19.0; mag >= brightest; mag -= 0.25)
            {
                var matches  = matchedSources.Filter(IsInBin);
                var total    = allSources.Filter(IsInBin);
                var fraction = new Fraction(
                    matches.Count,
                    total.Count);

                result.Add(mag, fraction);

                bool IsInBin(ISource source)
                {
                    var magSource = source as IMagSource;

                    var sourceMag = magSource.Magnitude1;

                    return

                        (sourceMag <= mag + 0.125 &&
                         true); // sourceMag > mag - 0.125;
                }
            }

            return(result);
        }