Пример #1
0
        public void PixelsInRing()
        {
            var man = new HealpixManager(0);

            Assert.AreEqual(4, man.PixelsCountInRing(1));
            Assert.AreEqual(4, man.PixelsCountInRing(2));
            Assert.AreEqual(4, man.PixelsCountInRing(3));
            man = new HealpixManager(1);
            Assert.AreEqual(2, man.Nside);
            Assert.AreEqual(4, man.PixelsCountInRing(1));
            Assert.AreEqual(8, man.PixelsCountInRing(2));
            Assert.AreEqual(8, man.PixelsCountInRing(3));
            Assert.AreEqual(8, man.PixelsCountInRing(4));
            Assert.AreEqual(8, man.PixelsCountInRing(5));
            Assert.AreEqual(8, man.PixelsCountInRing(6));
            Assert.AreEqual(4, man.PixelsCountInRing(7));
            man = new HealpixManager(2);
            Assert.AreEqual(4, man.Nside);
            Assert.AreEqual(4, man.PixelsCountInRing(1));
            Assert.AreEqual(8, man.PixelsCountInRing(2));
            Assert.AreEqual(12, man.PixelsCountInRing(3));
            Assert.AreEqual(16, man.PixelsCountInRing(4));
            Assert.AreEqual(16, man.PixelsCountInRing(5));
            Assert.AreEqual(16, man.PixelsCountInRing(6));
            Assert.AreEqual(16, man.PixelsCountInRing(7));
            Assert.AreEqual(16, man.PixelsCountInRing(8));
            Assert.AreEqual(16, man.PixelsCountInRing(9));
            Assert.AreEqual(16, man.PixelsCountInRing(10));
            Assert.AreEqual(16, man.PixelsCountInRing(11));
            Assert.AreEqual(16, man.PixelsCountInRing(12));
            Assert.AreEqual(12, man.PixelsCountInRing(13));
            Assert.AreEqual(8, man.PixelsCountInRing(14));
            Assert.AreEqual(4, man.PixelsCountInRing(15));
        }
Пример #2
0
        public WaterAndBottomData(HealpixManager man, double?min = null, double?max = null) : base(man, min, max)
        {
            ColorsMiddle = 0;

            var p = 0;

            for (var ring = 1; ring <= MaxRing; ring++)
            {
                var basin            = PixMan.Pixels[ring - 1];
                var waterHeightAll   = 0d;
                var surfaceHeightAll = 0d;
                var pixelsInRing     = HealpixManager.PixelsCountInRing(ring);
                for (var inRing = 1; inRing < pixelsInRing; inRing++, p++)
                {
                    var coor = HealpixManager.GetCenter <HealCoor>(p);

                    int waterHeight;
                    surfaceHeightAll += GetHeights(coor, (int)basin.rOfEllipse, out waterHeight);
                    waterHeightAll   += waterHeight;
                }

                if (waterHeightAll > 0)
                {
                    basin.hOQ   = 0;
                    basin.Depth = waterHeightAll / pixelsInRing;
                }
                else
                {
                    basin.hOQ   = surfaceHeightAll / pixelsInRing;
                    basin.Depth = -surfaceHeightAll / pixelsInRing;
                }
            }

            CheckOcean();
        }
Пример #3
0
        private void FindNearestPixelInRing(Point2 coor, ref int nearestPixel, out int previous)
        {
            var wasNearestPixel = nearestPixel;

            if (ColorsManager.FindNearest(
                    coor.X,
                    P => Pixels[P].X,
                    false,
                    PrecisionGrad,
                    nearestPixel + HealpixManager.PixelsCountInRing(Pixels[nearestPixel].Ring),
                    ref nearestPixel)) // todo add approximation
            {
                previous = nearestPixel;
            }
            else
            {
                previous = nearestPixel - 1;
                if (nearestPixel == Pixels.Length || Pixels[nearestPixel].PixelInRing == 1 /*next ring*/)
                {
                    var pixelsInRing = HealpixManager.PixelsCountInRing(Pixels[wasNearestPixel].Ring);
                    if (wasNearestPixel == nearestPixel)
                    {
                        previous += pixelsInRing;
                    }
                    else
                    {
                        nearestPixel -= pixelsInRing;
                    }
                }
            }
        }
Пример #4
0
        public void GetCenter_5()
        {
            var man = new HealpixManager(5);

            for (int p = 24; p < 24 + man.PixelsCountInRing(4); p++)
            {
                Assert.AreEqual(4, man.GetCenter(p).Ring);
                Assert.AreEqual(84.15, man.GetCenter(p).Y, .001);
            }
            Assert.AreEqual(3, man.GetCenter(18).Ring);
        }
Пример #5
0
        public KeyValuePair <int, double>[] GetDeltas(Coor coor)
        {
            // find nearest 2 rings, may be 1 ring in polar areas
            var approximately = (int)((90 - coor.Y) / 180 * Pixels.Length);

            // beginning of ring above coor
            var nearestFirstRingPixelUp = Math.Max(Math.Min(Pixels.Length - 1, approximately), 0);

            nearestFirstRingPixelUp -= Pixels[nearestFirstRingPixelUp].PixelInRing - 1;

            while (nearestFirstRingPixelUp > 0 && coor.Y > Pixels[nearestFirstRingPixelUp].Y)
            {
                nearestFirstRingPixelUp -= HealpixManager.PixelsCountInRing(Pixels[nearestFirstRingPixelUp - 1].Ring);
            }

            // beginning of ring under coor
            var nearestFirstRingPixelDown = Math.Max(0, nearestFirstRingPixelUp);

            while (nearestFirstRingPixelDown < Pixels.Length && coor.Y < Pixels[nearestFirstRingPixelDown].Y)
            {
                nearestFirstRingPixelDown += HealpixManager.PixelsCountInRing(Pixels[nearestFirstRingPixelDown].Ring);
            }

            var deltas = new Dictionary <int, double>();

            if (nearestFirstRingPixelUp >= 0)
            {
                AddDelta(coor, deltas, nearestFirstRingPixelUp);
            }

            if (nearestFirstRingPixelDown < Pixels.Length &&
                nearestFirstRingPixelDown != nearestFirstRingPixelUp)
            {
                AddDelta(coor, deltas, nearestFirstRingPixelDown);
            }

            // approximation-normalization only for 2 closest points
            return((from d in deltas orderby d.Value select d).Take(2).ToArray());
        }