Exemple #1
0
        private float ModelStarAmplitude(IStar star, float starMag, ModelConfig modelConfig, int bitPix, uint maxSignalValue)
        {
            if (Math.Abs(modelConfig.BVSlope) > 0.001)
            {
                UCAC4Entry ucac4Star = star as UCAC4Entry;
                if (ucac4Star != null)
                {
                    double bv = ucac4Star.MagB - ucac4Star.MagV;
                    if (double.IsNaN(bv))
                    {
                        bv = 0.5;                   // Default value
                    }
                    starMag += (float)(modelConfig.BVSlope * bv);
                }
            }

            if (modelConfig.PSFMagnitudeModelling)
            {
                return((float)((double)(modelConfig.MaxPixelValue - (modelConfig.NoiseMean + modelConfig.DarkFrameMean) * modelConfig.Integration) / Math.Pow(10, (starMag - modelConfig.BrighestUnsaturatedStarMag) / 2.5)));
            }
            else
            {
                InitStarAmplitudeModelling(modelConfig, 0.02f, bitPix, maxSignalValue);
                double starMagPeak = ModelStarAmplitudePeak(modelConfig, starMag);
                return((float)starMagPeak);
            }
        }
        public ClientConnectEvents(IStar star, StarDbContext db, IStarEventManager evtManager)
        {
            _star = star;
            _db = db;

            evtManager.RegisterPacketEvent<IClientConnectPacket>(OnClientConnect);
        }
Exemple #3
0
        public static void PSFPhotometry(FitInfo astrometricFit, List <IStar> catalogueStars, AstroImage currentAstroImage, Rectangle osdRectToExclude, Rectangle rectToInclude, bool limitByInclusion)
        {
            StringBuilder output = new StringBuilder();

            foreach (PlateConstStarPair pair in astrometricFit.AllStarPairs)
            {
                uint[,] data = currentAstroImage.GetMeasurableAreaPixels(
                    (int)Math.Round(pair.x), (int)Math.Round(pair.y), 9);

                if (limitByInclusion && !rectToInclude.Contains((int)pair.x, (int)pair.y))
                {
                    continue;
                }
                if (!limitByInclusion && osdRectToExclude.Contains((int)pair.x, (int)pair.y))
                {
                    continue;
                }

                PSFFit gaussian = new PSFFit((int)Math.Round(pair.x), (int)Math.Round(pair.y));
                gaussian.Fit(data);
                if (gaussian.IsSolved)
                {
                    IStar star = catalogueStars.Find(s => s.StarNo == pair.StarNo);
                    if (star != null &&
                        !double.IsNaN(star.MagR))
                    {
                        output.AppendLine(string.Format("{0}, {1}, {2}, {3}, {4}", pair.StarNo, star.MagR, gaussian.R0, gaussian.IMax, gaussian.I0));
                    }
                }
            }

            File.WriteAllText(@"C:\PSF_Photo.csv", output.ToString());
        }
Exemple #4
0
        public PlateConstStarPair AddStar(ImagePixel plateStar, IStar celestialPyramidStarEntry, StarMapFeature feature)
        {
            double detectionCertainty = plateStar.SignalNoise;

            PlateConstStarPair starPair =
                AddStar(
                    plateStar.XDouble,
                    celestialPyramidStarEntry.RADeg,
                    plateStar.YDouble,
                    celestialPyramidStarEntry.DEDeg,
                    celestialPyramidStarEntry.Mag,
                    plateStar.Brightness,
                    detectionCertainty,
                    plateStar.IsSaturated);

#if ASTROMETRY_DEBUG
            Trace.Assert(m_Pairs.Find((pair) => pair.StarNo == celestialPyramidStarEntry.StarNo) == null);
#endif

            starPair.StarNo    = celestialPyramidStarEntry.StarNo;
            starPair.FeatureId = feature != null ? feature.FeatureId : -1;
            starPair.RADeg     = celestialPyramidStarEntry.RADeg;
            starPair.DEDeg     = celestialPyramidStarEntry.DEDeg;

            return(starPair);
        }
Exemple #5
0
        internal DistanceEntry(IStar star1, IStar star2, double distArcSec)
        {
            Star1 = star1;
            Star2 = star2;

            DistanceArcSec = distArcSec;
        }
Exemple #6
0
        internal DistanceEntry(IStar star1, IStar star2, double distArcSec)
        {
            Star1 = star1;
            Star2 = star2;

            DistanceArcSec = distArcSec;
        }
Exemple #7
0
        protected virtual void IdentifyStar(StarMapFeature feature, IStar star)
        {
            if (m_SolvedPlate != null)
            {
                ImagePixel featureCenter = feature.GetCenter();

                if (m_PreviousStar == null ||
                    m_PreviousStar.StarNo == star.StarNo)
                {
                    // Translation only
                    double x, y;
                    m_SolvedPlate.GetImageCoordsFromRADE(star.RADeg, star.DEDeg, out x, out y);

                    double newCenterX = m_Image.FullFrame.Width / 2 - featureCenter.X + x;
                    double newCenterY = m_Image.FullFrame.Height / 2 - featureCenter.Y + y;

                    m_SolvedPlate.GetRADEFromImageCoords(newCenterX, newCenterY, out m_RADegCenter, out m_DEDegCenter);

                    m_PreviousFeature = feature;
                    m_PreviousStar    = star;
                }
                else
                {
                    // TODO: Rotate and streach until the feature fits
                }


                ReinitializePlateConstants();
                DrawCatalogStarsFit();

                // TODO: For now we only support 1 star centering
                m_PreviousStar = null;
                m_PreviousStar = null;
            }
        }
        public static Distance Generate(IStar primaryStar, IOrbitingBody companionStar, short orbitNumberToGenerate)
        {
            if (companionStar.OrbitNumber >= 99)
            {
                return(OrbitRangeGenerator.Generate(orbitNumberToGenerate));
            }

            IOrbitingBody innerObject = primaryStar.InnerOrbitingBody(companionStar.OrbitNumber);
            IOrbitingBody outerObject = primaryStar.OuterOrbitingBody(companionStar.OrbitNumber);

            Distance min = new Distance(0.1, DistanceUnits.AstronomicalUnit);
            Distance max;

            Distance maxPrimary = companionStar.OrbitalDistance / 4;

            if (innerObject == null &&
                outerObject == null)
            {
                max = maxPrimary;
            }
            else if (innerObject == null)
            {
                Distance maxOuter = (outerObject.OrbitalDistance - companionStar.OrbitalDistance) / 4;

                if (maxOuter > maxPrimary)
                {
                    max = maxPrimary;
                }
                else
                {
                    max = maxOuter;
                }
            }
            else if (outerObject == null)
            {
                max = (companionStar.OrbitalDistance - innerObject.OrbitalDistance) / 4;
            }
            else
            {
                Distance maxInner = (companionStar.OrbitalDistance - innerObject.OrbitalDistance) / 4;
                Distance maxOuter = (outerObject.OrbitalDistance - companionStar.OrbitalDistance) / 4;

                if (maxInner > maxOuter)
                {
                    max = maxOuter;
                }
                else
                {
                    max = maxInner;
                }
            }

            Distance orbitalStep = (max - min) / SystemConstants.MaxOrbits;
            Distance variation   = orbitalStep * .4; //So outer can't hit inner

            Distance baseOrbit = orbitalStep * orbitNumberToGenerate;

            return(PerturbHelper.Change(baseOrbit - variation, baseOrbit + variation));
        }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StarData" /> class.
 /// </summary>
 /// <param name="star">The star.</param>
 /// <param name="starStat">The stat.</param>
 /// <param name="owner">The owner.</param>
 public StarData(IStar star, StarStat starStat, Player owner)
     : base(star, owner) {
     Category = starStat.Category;
     Radius = starStat.Radius;
     CloseOrbitInnerRadius = starStat.CloseOrbitInnerRadius;
     Capacity = starStat.Capacity;
     Resources = starStat.Resources;
     Topography = Topography.System;
     SectorID = References.SectorGrid.GetSectorIdThatContains(Position);
 }
        private void lvStars_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnOK.Enabled = false;
            SelectedStar = null;

            if (lvStars.SelectedItems != null &&
                lvStars.SelectedItems.Count == 1)
            {
                SelectedStar = (IStar)lvStars.SelectedItems[0].Tag;
                btnOK.Enabled = true;
            }
        }
Exemple #11
0
        private void lvStars_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnOK.Enabled = false;
            SelectedStar  = null;

            if (lvStars.SelectedItems != null &&
                lvStars.SelectedItems.Count == 1)
            {
                SelectedStar  = (IStar)lvStars.SelectedItems[0].Tag;
                btnOK.Enabled = true;
            }
        }
Exemple #12
0
        public static void Generate(IStar parentStar, IStellarOrbitingBody parentBody, double combinedLuminosity)
        {
            List <IOrbitingBody> satellites = new List <IOrbitingBody>();

            int numberOfSatellites = NumberOfSatellitesGenerator.Generate(parentBody.OrbitOccupiedType, parentBody.Size);

            for (int i = 0; i < numberOfSatellites; i++)
            {
                var satellite = SatelliteGenerator.Generate(parentStar, parentBody, combinedLuminosity);

                parentBody.OrbitingBodies.Add(satellite.OrbitNumber, satellite);
            }
        }
Exemple #13
0
        public StarServer(IStar star, ILogger<IStarServer> logger)
        {
            _star = star;
            _logger = logger;

            _host = star.Configuration["BindHost"];
            _port = int.Parse(star.Configuration["BindPort"]);

            _sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            #if DNX46
            _sock.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.ReuseUnicastPort, true);
            #endif
        }
Exemple #14
0
        public bool MarkStar(IStar star)
        {
            if (IncludedStarNos.Contains(star.StarNo) &&
                !m_UsedStarNos.Contains(star.StarNo))
            {
                m_UsedStarNos.Add(star.StarNo);

                MarkedStars++;

                return(MarkedStars < m_MaxStarsInArea);
            }

            return(false);
        }
Exemple #15
0
        public static IOrbitingBody Generate(
            Distance orbitalDistance,
            short orbitNumber,
            string occupiedType,
            string orbitType,
            IStar parentStar,
            double combinedLuminosity)
        {
            var p = new Planet();

            p.Size     = SystemBodySizeGenerator.Generate(orbitNumber, parentStar.Classification);
            p.Diameter = PlanetDiameterGenerator.Generate(occupiedType, p.Size);
            p.Density  = DensityGenerator.Generate(orbitType);
            p.Mass     = PlanetMassGenerator.Generate(p.Diameter, p.Density);

            p.OrbitNumber       = orbitNumber;
            p.OrbitalDistance   = orbitalDistance;
            p.OrbitalPeriod     = OrbitalPeriodGenerator.Generate(parentStar, p);
            p.OrbitEccentricity = OrbitalEccentricityGenerator.Generate();
            p.OrbitFactor       = OrbitFactorGenerator.Generate(p);
            p.RotationPeriod    = RotationPeriodGenerator.Generate(parentStar.Mass, p.OrbitalDistance);
            p.AxialTilt         = AxialTiltGenerator.Generate();
            p.AxialTiltEffect   = TiltEffectGenerator.Generate(p.AxialTilt);

            p.Atmosphere             = AtmosphereGenerator.Generate(orbitType, p.Size);
            p.AtmosphereCode         = AtmosphereCodeGenerator.Generate(p.Atmosphere);
            p.Hydrographics          = HydrographicsGenerator.Generate(orbitType, p.Atmosphere, p.Size);
            p.MaxPopulation          = MaxPopulationGenerator.Generate(orbitNumber, orbitType, p.Size, p.Atmosphere, p.Hydrographics, parentStar.HabitableZone);
            p.EnergyAbsorptionFactor = EnergyAbsorptionGenerator.Generate(orbitType, p.Hydrographics, p.AtmosphereCode);
            p.GreenhouseFactor       = GreenhouseTables.GreenHouse[p.Atmosphere];

            if (SystemConstants.UseGaiaFactor &&
                p.MaxPopulation > 5)
            {
                p.EnergyAbsorptionFactor = GaiaFactorGenerator.Generate(combinedLuminosity, p.OrbitFactor, p.GreenhouseFactor, p.EnergyAbsorptionFactor);
            }

            p.MeanTemperature = MeanTemperatureGenerator.Generate(combinedLuminosity, p.OrbitFactor,
                                                                  p.EnergyAbsorptionFactor, p.GreenhouseFactor);

            p.Seasons = SeasonsGenerator.Generate(p.Size, p.AxialTilt, p.AxialTiltEffect, p.OrbitFactor,
                                                  p.MeanTemperature, combinedLuminosity, p.OrbitalDistance, p.RotationPeriod, p.Atmosphere);

            SatellitesGenerator.Generate(parentStar, p, combinedLuminosity);

            return(p);
        }
Exemple #16
0
        private float GetStarMag(IStar star, ModelledFilter filter)
        {
            UCAC4Entry ucac4Star = star as UCAC4Entry;

            if (ucac4Star != null)
            {
                switch (filter)
                {
                case ModelledFilter.B:
                    return(double.IsNaN(ucac4Star.MagB) || ucac4Star.MagB > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.MagB);

                case ModelledFilter.V:
                    return(double.IsNaN(ucac4Star.MagV) || ucac4Star.MagV > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.MagV);

                case ModelledFilter.Sloan_g:
                    return(double.IsNaN(ucac4Star.Mag_g) || ucac4Star.Mag_g > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_g);

                case ModelledFilter.Sloan_r:
                    return(double.IsNaN(ucac4Star.Mag_r) || ucac4Star.Mag_r > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_r);

                case ModelledFilter.Sloan_i:
                    return(double.IsNaN(ucac4Star.Mag_i) || ucac4Star.Mag_i > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_i);
                }
            }
            else
            {
                switch (filter)
                {
                case ModelledFilter.B:
                    return(double.IsNaN(star.MagB) || star.MagB > 25 ? (float)star.Mag : (float)star.MagB);

                case ModelledFilter.V:
                case ModelledFilter.Sloan_g:
                    return(double.IsNaN(star.MagV) || star.MagV > 25 ? (float)star.Mag : (float)star.MagV);

                case ModelledFilter.Sloan_r:
                    return(double.IsNaN(star.MagR) || star.MagR > 25 ? (float)star.Mag : (float)star.MagR);

                case ModelledFilter.Sloan_i:
                    return((float)star.Mag);
                }
            }

            return((float)star.Mag);
        }
Exemple #17
0
        static void Main(string[] args)
        {
            StarFactory factory = new StarFactory();

            for (int i = 0; i < 20; i++)
            {
                IStar red = factory.GetStar("Red");
                Console.WriteLine("Red star created");

                IStar green = factory.GetStar("Green");
                Console.WriteLine("Green star created");
            }

            Console.WriteLine("RedStar objects created: {0}", RedStar.objectCount);
            Console.WriteLine("GreenStar objects created: {0}", GreenStar.objectCount);

            Console.ReadLine();
        }
        public static StellarSystem Generate(int x, int y)
        {
            var output = new StellarSystem();

            output.X            = x;
            output.Y            = y;
            output.SystemNature = SystemNatureGenerator.Generate();

            //Add Primary
            IStar primary = StarGenerator.Generate(1);

            output.Stars.Add(primary);
            output.CombinedLuminosity = primary.Luminosity;

            //Add Secondary Star
            if (output.SystemNature == SystemNature.Binary ||
                output.SystemNature == SystemNature.Trinary)
            {
                IStar star = StarGenerator.Generate(2, output.Stars[0]);
                output.Stars.Add(star);
            }

            //Add Third Star
            if (output.SystemNature == SystemNature.Trinary)
            {
                output.Stars.Add(StarGenerator.Generate(3, output.Stars[0]));
            }

            //Generate primary star bodies
            SystemBodiesGenerator.Generate(output, 0);

            if (output.Stars.Count > 1)
            {
                SystemBodiesGenerator.Generate(output, 1);
            }

            if (output.Stars.Count > 2)
            {
                SystemBodiesGenerator.Generate(output, starToGenerate: 2);
            }

            return(output);
        }
Exemple #19
0
        public FieldSolveContext(SerializationInfo info, StreamingContext context)
        {
            RADeg          = info.GetDouble("RADeg");
            DEDeg          = info.GetDouble("DEDeg");
            ErrFoVs        = info.GetDouble("ErrFoVs");
            Method         = (RecognitionMethod)info.GetInt32("Method");
            DataBaseServer = info.GetString("DataBaseServer");
            DataBaseName   = info.GetString("DataBaseName");
            CellX          = info.GetDouble("CellX");
            CellY          = info.GetDouble("CellY");
            FocalLength    = info.GetDouble("FocalLength");
            LimitMagn      = info.GetDouble("LimitMagn");
            PyramidMinMag  = info.GetDouble("MinMag");
            PyramidMaxMag  = info.GetDouble("MaxMag");

            UtcTime          = info.GetDateTime("UtcTime");
            FrameNoOfUtcTime = info.GetInt32("FrameNoOfUtcTime");

            FrameNoOfUtcTime = info.GetInt32("FrameNoOfUtcTime");
            ObsCode          = info.GetString("ObsCode");

            byte[] data = (byte[])info.GetValue("CatalogueStars", typeof(byte[]));

            BinaryFormatter fmt = new BinaryFormatter();

            using (MemoryStream mem = new MemoryStream(data))
            {
                CatalogueStars = new List <IStar>();

                int count = (int)fmt.Deserialize(mem);
                for (int i = 0; i < count; i++)
                {
                    IStar star = (Star)fmt.Deserialize(mem);
                    CatalogueStars.Add(star);
                }
            }

            try
            {
            }
            catch (InvalidCastException)
            { }
        }
        public static IOrbitingBody Generate(
            Distance orbitalDistance,
            short orbitNumber,
            string occupiedType,
            string orbitType,
            IStar parentStar,
            double combinedLuminosity)
        {
            AsteroidBelt belt = new AsteroidBelt
            {
                Size            = 0,
                OrbitNumber     = orbitNumber,
                OrbitalDistance = orbitalDistance,
                Diameter        = new Distance(0, DistanceUnits.AstronomicalUnit),
                Mass            = new Mass()
            };


            return(belt);
        }
Exemple #21
0
        public static IOrbitingBody Generate(IStar parentStar, IStellarOrbitingBody parentBody, double combinedLuminosity)
        {
            Moon moon = new Moon();

            //Body Details
            moon.Size     = SatelliteSizeGenerator.Generate(parentBody.Size);
            moon.Density  = DensityGenerator.Generate(parentBody.OrbitType);
            moon.Diameter = PlanetDiameterGenerator.Generate(OccupiedTypes.World, moon.Size);
            moon.Mass     = PlanetMassGenerator.Generate(moon.Diameter, moon.Density);

            //Orbital
            moon.OrbitalDistance   = SatelliteOrbitDistanceGenerator.Generate(parentBody);
            moon.OrbitalPeriod     = OrbitalPeriodGenerator.Generate(parentBody, moon);
            moon.OrbitFactor       = OrbitFactorGenerator.Generate(parentBody);
            moon.OrbitEccentricity = OrbitalEccentricityGenerator.Generate();
            moon.RotationPeriod    = (4 * (DieRoll.Roll2D6() - 2)) + 5;
            moon.AxialTilt         = AxialTiltGenerator.Generate();
            moon.AxialTiltEffect   = TiltEffectGenerator.Generate(moon.AxialTilt);

            //Environmental
            moon.Atmosphere     = AtmosphereGenerator.Generate(parentBody.OrbitType, parentBody.Size);
            moon.AtmosphereCode = AtmosphereCodeGenerator.Generate(moon.Atmosphere);
            moon.Hydrographics  = HydrographicsGenerator.Generate(parentBody.OrbitType, moon.Size, moon.Atmosphere);
            moon.MaxPopulation  = MaxPopulationGenerator.Generate(parentBody.OrbitNumber, parentBody.OrbitType, moon.Size,
                                                                  moon.Atmosphere, moon.Hydrographics, parentStar.HabitableZone);
            moon.EnergyAbsorptionFactor = EnergyAbsorptionGenerator.Generate(parentBody.OrbitType, moon.Hydrographics, moon.AtmosphereCode);
            moon.GreenhouseFactor       = GreenhouseTables.GreenHouse[moon.Atmosphere];

            if (SystemConstants.UseGaiaFactor &&
                moon.MaxPopulation > 5)
            {
                moon.EnergyAbsorptionFactor = GaiaFactorGenerator.Generate(combinedLuminosity, moon.OrbitFactor, moon.GreenhouseFactor, moon.EnergyAbsorptionFactor);
            }

            moon.MeanTemperature = MeanTemperatureGenerator.Generate(combinedLuminosity, moon.OrbitFactor, moon.EnergyAbsorptionFactor, moon.GreenhouseFactor);

            moon.Seasons = SeasonsGenerator.Generate(moon.Size, moon.AxialTilt, moon.AxialTiltEffect, moon.OrbitFactor,
                                                     moon.MeanTemperature, combinedLuminosity, moon.OrbitalDistance, moon.RotationPeriod, moon.Atmosphere);

            return(moon);
        }
Exemple #22
0
        public static GasGiant Generate(Distance orbitalDistance, short orbitNumber, string occupiedType,
                                        string orbitType, IStar parentStar, double combinedLuminosity)
        {
            int size;

            var gasGiant = new GasGiant
            {
                OrbitalDistance = orbitalDistance,
                Density         = PlanetDensities.Low
            };

            if (DieRoll.Roll1D6() < 3)
            {
                //Small
                size = -1;
                gasGiant.Description = "Small";
            }
            else
            {
                //Large
                size = -2;
                gasGiant.Description = "Large";
            }

            gasGiant.Diameter          = PlanetDiameterGenerator.Generate(occupiedType, size);
            gasGiant.Mass              = PlanetMassGenerator.Generate(gasGiant.Diameter, gasGiant.Density);
            gasGiant.OrbitNumber       = orbitNumber;
            gasGiant.OrbitalDistance   = orbitalDistance;
            gasGiant.OrbitEccentricity = OrbitalEccentricityGenerator.Generate();

            gasGiant.OrbitalPeriod = OrbitalPeriodGenerator.Generate(parentStar, gasGiant);

            gasGiant.RotationPeriod  = RotationPeriodGenerator.Generate(parentStar.Mass, gasGiant.OrbitalDistance);
            gasGiant.AxialTilt       = AxialTiltGenerator.Generate();
            gasGiant.AxialTiltEffect = TiltEffectGenerator.Generate(gasGiant.AxialTilt);

            SatellitesGenerator.Generate(parentStar, gasGiant, combinedLuminosity);

            return(gasGiant);
        }
Exemple #23
0
        public static IOrbitingBody Generate(short orbitNumber, Distance orbitalDistance, string occupiedType,
                                             string orbitType, IStar parentStar, StellarSystem stellarSystem)
        {
            switch (occupiedType)
            {
            case OccupiedTypes.GasGiant:
                return(GasGiantGenerator.Generate(orbitalDistance, orbitNumber, occupiedType, orbitType, parentStar, stellarSystem.CombinedLuminosity));

            case OccupiedTypes.CapturedPlanet:
            case OccupiedTypes.World:
                return(WorldGenerator.Generate(orbitalDistance, orbitNumber, occupiedType, orbitType, parentStar, stellarSystem.CombinedLuminosity));

            case OccupiedTypes.Planetoid:
                break;

            case OccupiedTypes.Star:
                //Do nothing for this.  Should already be done
                break;
            }

            return(null);
        }
Exemple #24
0
        public void Run(BaseScenario scenario)
        {
            Constants   = scenario.Constants;
            this.star   = scenario.Star;
            this.events = scenario.ScenarioEvents;

            star.Init(Constants);
            world  = new World(Constants);
            logger = new SimLogger();

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"D:\CSharp_Projects\Daisy_World\WriteLines2.txt"))
            {
                for (int i = 0; i < scenario.FrameCount; i++)
                {
                    UpdateUniverse();
                    Expose();

                    if (!IsWorldAlive())
                    {
                        Console.WriteLine($"Done at i {i}.");
                        return;
                    }

                    RunScenarioEvents(i);
                    Breed();

                    //Console.WriteLine($"i: {i} W: {world.WhiteDaisies} B: {world.BlackDaisies} WD: {logger.WhiteKilledCount} BD: {logger.BlackKilledCount} T: {world.Temperature:0.####} A: {world.AlbedoTotal:0.####}, SH: {sun.Heat:0.####}");
                    file.WriteLine($"{i} {world.WhiteDaisies} {world.BlackDaisies} {logger.WhiteKilledCount} {logger.BlackKilledCount} {world.Temperature * 5000d:0.####} {world.AlbedoTotal * 5000d:0.####} {star.Heat * 100000d:0.####}");

                    if (i % 1000 == 0 && i != 0)
                    {
                        Console.WriteLine($"i == {i}");
                    }

                    logger.Reset();
                }
            }
        }
Exemple #25
0
        public static IStar Generate(int number = 1, IStar primary = null)
        {
            IStar output;

            if (number == 1)
            {
                output = new Star();
                output.Classification  = StellarClassificationGenerator.Generate(false);
                output.LuminosityClass = StellarLuminosityClassGenerator.Generate(output.Classification);
                output.DecimalNotation = StellarDecimalNotationGenerator.Generate(output.Classification, output.LuminosityClass);
                output.Mass            = StellarMassGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass);
                output.Luminosity      = StellarLuminosityGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass);
                output.Diameter        = StellarRadiusGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass) * 2;
            }
            else
            {
                output = new CompanionStar();

                output.Classification  = StellarClassificationGenerator.Generate(true);
                output.LuminosityClass = StellarLuminosityClassGenerator.Generate(output.Classification, primary.LuminosityClass);
                output.DecimalNotation = StellarDecimalNotationGenerator.Generate(output.Classification, output.LuminosityClass);
                output.Mass            = StellarMassGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass);
                output.Luminosity      = StellarLuminosityGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass);
                output.Diameter        = StellarRadiusGenerator.Generate(output.Classification, output.DecimalNotation, output.LuminosityClass) * 2;

                var companion = (CompanionStar)output;
                companion.OrbitNumber = CompanionStarOrbitGenerator.Generate();

                if (primary.OrbitingBodies.ContainsKey(companion.OrbitNumber))
                {
                    companion.OrbitNumber += 1;
                    primary.OrbitingBodies.Add(companion.OrbitNumber, companion);
                }
            }

            return(output);
        }
Exemple #26
0
        public bool CheckAndAddStar(IStar star)
        {
            if (star.RADeg >= m_RAFrom && star.RADeg <= m_RATo &&
                star.DEDeg >= m_DEFrom && star.DEDeg <= m_DETo)
            {
                if (IncludedStarNos.Count < m_MaxStarsInArea)
                {
                    IncludedStarNos.Add(star.StarNo);
                }
                else
                {
                    if (DebugStarNosWithAppliedExclusions != null &&
                        DebugStarNosWithAppliedExclusions.Contains(star.StarNo))
                    {
                        Trace.Assert(false,
                                     string.Format("Debug Star {0} not added as cap is reached in {1}.", star.StarNo, AreaId));
                    }
                }

                return(true);
            }

            return(false);
        }
Exemple #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StarData" /> class
 /// with the owner initialized to NoPlayer.
 /// </summary>
 /// <param name="star">The star.</param>
 /// <param name="starStat">The stat.</param>
 public StarData(IStar star, StarStat starStat)
     : this(star, starStat, TempGameValues.NoPlayer) { }
        private float ModelStarAmplitude(IStar star, float starMag, ModelConfig modelConfig, int bitPix, uint maxSignalValue)
        {
            if (Math.Abs(modelConfig.BVSlope) > 0.001)
            {
                UCAC4Entry ucac4Star = star as UCAC4Entry;
                if (ucac4Star != null)
                {
                    double bv = ucac4Star.MagB - ucac4Star.MagV;
                    if (double.IsNaN(bv)) bv = 0.5; // Default value

                    starMag += (float)(modelConfig.BVSlope * bv);
                }
            }

            if (modelConfig.PSFMagnitudeModelling)
                return (float)((double)(modelConfig.MaxPixelValue - (modelConfig.NoiseMean + modelConfig.DarkFrameMean) * modelConfig.Integration) / Math.Pow(10, (starMag - modelConfig.BrighestUnsaturatedStarMag) / 2.5));
            else
            {
                InitStarAmplitudeModelling(modelConfig, 0.02f, bitPix, maxSignalValue);
                double starMagPeak = ModelStarAmplitudePeak(modelConfig, starMag);
                return (float)starMagPeak;
            }
        }
Exemple #29
0
 public CommandsPlugin(IStar star, ILogger<CommandsPlugin> logger, IStarEventManager evtManager)
 {
     _star = star;
     _logger = logger;
     _eventManager = evtManager;
 }
 public bool CheckStarReturnTrueIfParticipating(IStar star)
 {
     return IncludedStarNos.Contains(star.StarNo);
 }
Exemple #31
0
        public StarCommandManager(IStar star, ILogger<StarCommandManager> logger)
        {
            _logger = logger;

            star.ConsoleInput += (s, e) => PassConsoleCommand(e.Input);
        }
 public void MarkStar(IStar s)
 {
     Areas.ForEach(a => a.MarkStar(s));
 }
Exemple #33
0
        public static List <Orbit> Generate(StellarSystem stellarSystem, int starToGenerate = 1)
        {
            Star primaryStar = (Star)stellarSystem.Stars[0];

            CompanionStar secondaryStar = null;

            if (stellarSystem.Stars.Count > 1)
            {
                secondaryStar = (CompanionStar)stellarSystem.Stars[1];
            }

            CompanionStar tertiaryStar = null;

            if (stellarSystem.Stars.Count > 2)
            {
                tertiaryStar = (CompanionStar)stellarSystem.Stars[2];
            }

            IStar currentStar = stellarSystem.Stars[starToGenerate - 1];

            List <Orbit> output = new List <Orbit>();

            int habitableZone = -2;

            for (short i = 0; i < SystemConstants.MaxOrbits; i++)
            {
                Distance orbitalDistance;

                if (currentStar == primaryStar ||
                    currentStar == tertiaryStar)              //All tertiary stars are put at far orbit
                {
                    orbitalDistance = OrbitRangeGenerator.Generate(i);
                }
                else
                {
                    orbitalDistance = CompanionStarOrbitalDistanceGenerator.Generate(primaryStar, secondaryStar, i);
                }

                Orbit o = new Orbit
                {
                    OrbitalDistance = orbitalDistance,
                    OccupiedType    = null,
                    OrbitType       = OrbitTypeGenerator.Generate(orbitalDistance, primaryStar.Luminosity, 0)
                };

                if (o.OrbitType == OrbitTypes.Habitable)
                {
                    habitableZone = i;
                }

                if (o.OrbitType == OrbitTypes.Outer &&
                    habitableZone == -2)
                {
                    habitableZone = i - 1;
                }

                output.Add(o);
            }

            if (habitableZone == -2)
            {
                habitableZone = 10;
            }

            currentStar.HabitableZone = (short)habitableZone;

            int numberOfOrbits = NumberOfOrbitsGenerator.Generate(currentStar.Classification, currentStar.LuminosityClass);

            int emptyOrbits = NumberOfEmptyOrbitsGenerator.Generate(currentStar.Classification);

            RandomOrbitAssignment.Assign(output, emptyOrbits, OccupiedTypes.Empty, -2);

            int capturedPlanets = NumberOfCapturedPlanetsGenerator.Generate(currentStar.Classification);

            RandomOrbitAssignment.Assign(output, capturedPlanets, OccupiedTypes.CapturedPlanet);

            int gasGiants = NumberOfGasGiantsGenerator.Generate(currentStar.Classification);

            RandomOrbitAssignment.Assign(output, gasGiants, OccupiedTypes.GasGiant, -3 + habitableZone);

            int planetoids = NumberOfPlanetoidsGenerator.Generate();

            //Note Slight deviation from source.
            RandomOrbitAssignment.Assign(output, planetoids, OccupiedTypes.Planetoid, -1);

            //Clear out orbits in excess of Number of Orbits, but keep captured planets
            for (int i = 0; i < SystemConstants.MaxOrbits; i++)
            {
                Orbit o = output[i];

                if (i > numberOfOrbits)
                {
                    if (o.OccupiedType != OccupiedTypes.CapturedPlanet)
                    {
                        o.OccupiedType = null;
                    }
                }
                else
                {
                    if (o.OccupiedType == OccupiedTypes.Empty)
                    {
                        o.OccupiedType = null;
                    }
                }
            }

            if (secondaryStar != null &&
                currentStar == primaryStar)
            {
                secondaryStar.OrbitNumber = CompanionStarOrbitGenerator.Generate();

                if (secondaryStar.OrbitNumber < 99)
                {
                    if (secondaryStar.OrbitNumber > 2)
                    {
                        for (int i = secondaryStar.OrbitNumber / 2; i < secondaryStar.OrbitNumber; i++)
                        {
                            Orbit o = output[i];
                            o.OrbitType    = OrbitTypes.Star;
                            o.OccupiedType = null;
                        }
                    }
                    else
                    {
                        Orbit o = output[secondaryStar.OrbitNumber];
                        o.OccupiedType = OccupiedTypes.Star;
                        o.OrbitType    = OrbitTypes.Star;

                        o = output[secondaryStar.OrbitNumber + 1];
                        o.OccupiedType = null;
                        o.OrbitType    = OrbitTypes.Star;
                    }

                    secondaryStar.OrbitalDistance = output[secondaryStar.OrbitNumber].OrbitalDistance;

                    stellarSystem.CombinedLuminosity += SystemConstants.HabitNum /
                                                        Math.Sqrt(secondaryStar.OrbitalDistance.ToAstronomicalUnits().Value);
                }
                else
                {
                    //No impact on luminosity
                    secondaryStar.OrbitalDistance = FarOrbitDistanceGenerator.Generate();
                }

                secondaryStar.OrbitalPeriod     = OrbitalPeriodGenerator.Generate(primaryStar, secondaryStar);
                secondaryStar.OrbitEccentricity = OrbitalEccentricityGenerator.Generate();
                secondaryStar.AxialTilt         = AxialTiltGenerator.Generate();
                secondaryStar.AxialTiltEffect   = TiltEffectGenerator.Generate(secondaryStar.AxialTilt);
            }

            //Third stars a pushed to a far orbit
            //No impact on luminosity
            if (tertiaryStar != null &&
                currentStar == primaryStar)
            {
                if (secondaryStar.OrbitNumber == 99)
                {
                    tertiaryStar.OrbitNumber = 100;
                }
                else
                {
                    tertiaryStar.OrbitNumber = 99;
                }

                tertiaryStar.OrbitalDistance   = FarOrbitDistanceGenerator.Generate();
                tertiaryStar.OrbitalPeriod     = OrbitalPeriodGenerator.Generate(primaryStar, tertiaryStar);
                tertiaryStar.OrbitEccentricity = OrbitalEccentricityGenerator.Generate();
                tertiaryStar.AxialTilt         = AxialTiltGenerator.Generate();
                tertiaryStar.AxialTiltEffect   = TiltEffectGenerator.Generate(tertiaryStar.AxialTilt);
            }

            return(output);
        }
 protected void ResetPreviousStar()
 {
     m_PreviousStar = null;
     m_PreviousFeature = null;
 }
Exemple #35
0
 public bool CheckStar(IStar s)
 {
     return(Areas
            .Select(a => a.CheckStarReturnTrueIfParticipating(s))
            .Aggregate((a, b) => a || b));
 }
Exemple #36
0
 public void MarkStar(IStar s)
 {
     Areas.ForEach(a => a.MarkStar(s));
 }
Exemple #37
0
 public AccountCommands(IStar star, ILogger<AccountCommands> logger, StarDbContext db)
 {
     _star = star;
     _logger = logger;
     _db = db;
 }
Exemple #38
0
        public void DrawCatalogStarsFit(Graphics g)
        {
            if (m_CatalogueStars == null)
            {
                m_LimitMag = -100;
                return;
            }

            bool hasManualStars =
                m_Is3StarIdMode &&
                m_UserStarIdentification != null &&
                m_UserStarIdentification.Count > 0;

            LeastSquareFittedAstrometry astrometry = null;

            astrometry = FittedAstrometryFromUserSelectedFitGrade();
            IAstrometricFit fit = null;

            if (astrometry != null)
            {
                fit = astrometry;
            }
            else
            {
                fit = m_SolvedPlate;
            }

            if (fit != null)
            {
                double limitMag = (astrometry != null && astrometry.FitInfo.AllStarPairs.Count > 0)
                                        ? astrometry.FitInfo.AllStarPairs.Max(p => p.Mag)
                                        : m_LimitMag;

                foreach (IStar star in m_CatalogueStars)
                {
                    if (star.Mag > limitMag)
                    {
                        continue;
                    }

                    double x, y;
                    fit.GetImageCoordsFromRADE(star.RADeg, star.DEDeg, out x, out y);

                    Pen   starPen     = catalogStarPen;
                    Brush labelBruish = catalogBrushUnrecognized;

                    if (astrometry != null)
                    {
                        PlateConstStarPair pair = astrometry.FitInfo.AllStarPairs.Find((p) => p.StarNo == star.StarNo);

                        if (pair != null && pair.FitInfo.UsedInSolution)
                        {
                            starPen     = referenceStarPen;
                            labelBruish = catalogBrushReference;
                        }
                        else if (pair != null && pair.FitInfo.ExcludedForHighResidual)
                        {
                            starPen     = rejectedStarPen;
                            labelBruish = catalogBrushRejected;
                        }
                        else
                        {
                            starPen     = unrecognizedStarPen;
                            labelBruish = catalogBrushUnrecognized;
                        }

                        if (pair != null)
                        {
                            g.DrawLine(starPen, (float)x, (float)y, (float)pair.x, (float)pair.y);
                        }
                    }

                    if (!m_Is3StarIdMode || astrometry != null)
                    {
                        float rad = (float)GetStarDiameter(m_LimitMag, 5, star.Mag) / 2;
                        g.DrawEllipse(starPen, (float)x - rad, (float)y - rad, 2 * rad, 2 * rad);
                    }

                    if (m_ShowLabels || m_ShowMagnitudes)
                    {
                        string label;
                        if (m_ShowLabels && m_ShowMagnitudes)
                        {
                            label = string.Format("{0} ({1}m)", star.GetStarDesignation(0), star.Mag);
                        }
                        else if (m_ShowLabels)
                        {
                            label = string.Format("{0}", star.GetStarDesignation(0));
                        }
                        else
                        {
                            label = string.Format("{0}m", star.Mag);
                        }

                        g.DrawString(label, m_StarInfoFont, labelBruish, (float)x + 10, (float)y + 10);
                    }
                }

                if (m_Is3StarIdMode && astrometry == null)
                {
                    // Draw all features from the starMap (unless the configuration has been solved)
                    if (AstrometryContext.Current.StarMap != null)
                    {
                        foreach (StarMapFeature feature in AstrometryContext.Current.StarMap.Features)
                        {
                            ImagePixel center = feature.GetCenter();

                            PSFFit psfFit;
                            AstrometryContext.Current.StarMap.GetPSFFit(center.X, center.Y, PSFFittingMethod.NonLinearAsymetricFit, out psfFit);

#if ASTROMETRY_DEBUG
                            PSFFit psfFit2;
                            AstrometryContext.Current.StarMap.GetPSFFit(center.X, center.Y, PSFFittingMethod.NonLinearFit, out psfFit2);
                            double elong     = psfFit.RX0 / psfFit.RY0;
                            double elongPerc = Math.Abs(1 - elong) * 100;
                            Trace.WriteLine(string.Format("({0:0}, {1:0}) Rx = {2:0.00} Ry = {3:0.00}, e = {4:0.000} ({5:0}%), FWHMxy = {6:0.0} | FWHMxx = {7:0.0}",
                                                          center.X, center.Y, psfFit.RX0, psfFit.RY0, elong, elongPerc,
                                                          psfFit.FWHM, psfFit2.FWHM));
#endif
                            Pen pen = catalogStarPen;

#if ASTROMETRY_DEBUG
                            if (psfFit.FWHM < TangraConfig.Settings.Astrometry.MinReferenceStarFWHM ||
                                psfFit.FWHM > TangraConfig.Settings.Astrometry.MaxReferenceStarFWHM ||
                                psfFit.ElongationPercentage > TangraConfig.Settings.Astrometry.MaximumPSFElongation)
                            {
                                pen = rejectedStarPen;
                            }
#endif

                            g.DrawLine(pen, (float)center.XDouble - 9, (float)center.YDouble, (float)center.XDouble - 5, (float)center.YDouble);
                            g.DrawLine(pen, (float)center.XDouble + 5, (float)center.YDouble, (float)center.XDouble + 9, (float)center.YDouble);
                            g.DrawLine(pen, (float)center.XDouble, (float)center.YDouble - 9, (float)center.XDouble, (float)center.YDouble - 5);
                            g.DrawLine(pen, (float)center.XDouble, (float)center.YDouble + 5, (float)center.XDouble, (float)center.YDouble + 9);
                        }
                    }
                }
                else
                {
                    if (m_Grid)
                    {
                        DrawEquatorialGrid(g);
                    }
                }

                #region Draw the manual single star identification
                if (hasManualStars)
                {
                    foreach (PSFFit psf in m_UserStarIdentification.Keys)
                    {
                        IStar star = m_UserStarIdentification[psf];

                        float rad = (float)GetStarDiameter(m_LimitMag, 5, star.Mag) / 2;

                        g.DrawEllipse(Pens.DarkRed, (float)psf.XCenter - rad, (float)psf.YCenter - rad, 2 * rad, 2 * rad);
                        g.DrawEllipse(Pens.DarkRed, (float)psf.XCenter - rad - 2, (float)psf.YCenter - rad - 2, 2 * rad + 4, 2 * rad + 4);
                    }
                }
                #endregion ;
            }

            UpdateToolControlDisplay();
        }
		private bool RegisterRecognizedPair(ImagePixel starCenter, IStar celestialStar, int featureId)
		{
			if (m_MatchedPairs.ContainsKey(starCenter))
			{
				// The feature has been already matched with a different star (from a different triangle)
				// Probably the two stars are very close to each other. In this case we don't add the second match
				// and mark the first match as ambigous. Then later on if there is sufficient amount of pairs
				// the first match may be removed as well.
				if (m_AmbiguousMatches.IndexOf(starCenter) == -1)
					m_AmbiguousMatches.Add(starCenter);

				return false;
			}

			m_MatchedPairs.Add(starCenter, celestialStar);
			m_MatchedFeatureIdToStarIdIndexes.Add(featureId, celestialStar.StarNo);
			return true;
		}
Exemple #40
0
        public void Initialize(List <ulong> alwaysIncludeStars)
        {
            if (DebugResolvedStarsWithAppliedExclusions != null)
            {
                List <ulong> debugStarIds = DebugResolvedStarsWithAppliedExclusions.Values.ToList();
                List <IStar> missingstars = m_Stars.Where(s => !debugStarIds.Contains(s.StarNo)).ToList();
                Trace.Assert(missingstars.Count == 0,
                             string.Format("There are {0} of the debug stars not found among the initial pyramid stars", missingstars.Count));
            }

            if (alwaysIncludeStars != null && alwaysIncludeStars.Count > 0)
            {
                foreach (var starNo in alwaysIncludeStars.ToArray())
                {
                    if (m_Stars.FirstOrDefault(s => s.StarNo == starNo) == null)
                    {
                        Trace.WriteLine(string.Format("Cannot locate always include star {0}. Removing ...", starNo));
                        alwaysIncludeStars.Remove(starNo);
                    }
                }
            }

            double minDE = double.MaxValue;
            double maxDE = double.MinValue;
            double minRA = double.MaxValue;
            double maxRA = double.MinValue;

            for (int i = 0; i < m_Stars.Count; i++)
            {
                IStar star = m_Stars[i];
                if (star.RADeg > maxRA)
                {
                    maxRA = star.RADeg;
                }
                if (star.RADeg < minRA)
                {
                    minRA = star.RADeg;
                }
                if (star.DEDeg > maxDE)
                {
                    maxDE = star.DEDeg;
                }
                if (star.DEDeg < minDE)
                {
                    minDE = star.DEDeg;
                }
            }

            TangentalTransRotAstrometry            astrometryBase = new TangentalTransRotAstrometry(m_Image, m_RA0Deg, m_DE0Deg, 0);
            TangentalNormalizedDirectionAstrometry astrometry     = new TangentalNormalizedDirectionAstrometry(astrometryBase);
            DensityArea middleArea = new DensityArea(astrometry, MAX_STARS_IN_AREA, m_RA0Deg - m_XAreaSideDeg / 2, m_RA0Deg + m_XAreaSideDeg / 2, m_DE0Deg - m_YAreaSideDeg / 2, m_DE0Deg + m_YAreaSideDeg / 2);

            middleArea.DebugResolvedStarsWithAppliedExclusions = DebugResolvedStarsWithAppliedExclusions;

            double xSidePlatePix = Math.Abs(middleArea.XTo - middleArea.XFrom);
            double ySidePlatePix = Math.Abs(middleArea.YTo - middleArea.YFrom);

            double raInterval = astrometryBase.GetDistanceInArcSec(middleArea.XFrom, middleArea.YMiddle, middleArea.XTo, middleArea.YMiddle) / 3600.0;
            double deInterval = astrometryBase.GetDistanceInArcSec(middleArea.XMiddle, middleArea.YFrom, middleArea.XMiddle, middleArea.YTo) / 3600.0;

            List <DensityArea> areasToCheckFurther = new List <DensityArea>();

            areasToCheckFurther.Add(middleArea);
            Areas.Add(middleArea);

            do
            {
                DensityArea[] areasToCheckNow = areasToCheckFurther.ToArray();
                areasToCheckFurther.Clear();

                foreach (DensityArea area in areasToCheckNow)
                {
                    List <DensityArea> potentiallyNewAreas = GetSurroundingAreas(area, astrometry, xSidePlatePix, ySidePlatePix);
                    foreach (DensityArea par in potentiallyNewAreas)
                    {
                        bool areadyAdded = Areas.Exists(a => a.ContainsPoint(par.XMiddle, par.YMiddle));
                        if (!areadyAdded)
                        {
                            if (par.RAFrom + raInterval < minRA ||
                                par.RATo - raInterval > maxRA ||
                                par.DEFrom + deInterval < minDE ||
                                par.DETo - deInterval > maxDE)
                            {
                                // Area not in the coordinates of interest
                            }
                            else
                            {
                                areasToCheckFurther.Add(par);
                                Areas.Add(par);
                            }
                        }
                    }
                }
            }while (areasToCheckFurther.Count > 0);

            m_Stars.Sort((s1, s2) => s1.Mag.CompareTo(s2.Mag));
            var aiss = (alwaysIncludeStars != null && alwaysIncludeStars.Count > 0) ? m_Stars.Where(s => alwaysIncludeStars.Contains(s.StarNo)).ToArray() : new IStar[0];

            Areas.ForEach(a =>
            {
                foreach (var star in m_Stars)
                {
                    a.CheckAndAddStar(star);
                    if (a.IncludedStarNos.Count >= MAX_STARS_IN_AREA)
                    {
                        break;
                    }
                }

                foreach (var ais in aiss)
                {
                    if (a.CheckAndAddStar(ais))
                    {
                        if (!a.IncludedStarNos.Contains(ais.StarNo))
                        {
                            a.IncludedStarNos.Add(ais.StarNo);
                        }
                    }
                }
            });
        }
Exemple #41
0
 public Star(IStar copyFrom)
     : this(copyFrom.StarNo, copyFrom.RADeg, copyFrom.DEDeg, copyFrom.Mag)
 {
 }
Exemple #42
0
 public bool CheckStarReturnTrueIfParticipating(IStar star)
 {
     return(IncludedStarNos.Contains(star.StarNo));
 }
Exemple #43
0
 public ProxyStar(IStar star)
 {
     _star = star;
 }
 public void AddStar(ImagePixel plateStar, IStar celestialPyramidStarEntry)
 {
     AddStar(plateStar, celestialPyramidStarEntry, null);
 }
 public bool CheckStar(IStar s)
 {
     return Areas
         .Select(a => a.CheckStarReturnTrueIfParticipating(s))
         .Aggregate((a, b) => a || b);
 }
 public void AddStar(ImagePixel plateStar, IStar celestialPyramidStarEntry, int featureId)
 {
     var starPair = AddStar(plateStar, celestialPyramidStarEntry, null);
     starPair.FeatureId = featureId;
 }
        public bool MarkStar(IStar star)
        {
            if (IncludedStarNos.Contains(star.StarNo) &&
                !m_UsedStarNos.Contains(star.StarNo))
            {
                m_UsedStarNos.Add(star.StarNo);

                MarkedStars++;

                return MarkedStars < m_MaxStarsInArea;
            }

            return false;
        }
        public PlateConstStarPair AddStar(ImagePixel plateStar, IStar celestialPyramidStarEntry, StarMapFeature feature)
        {
            double detectionCertainty = plateStar.SignalNoise;

            PlateConstStarPair starPair =
                AddStar(
                    plateStar.XDouble,
                    celestialPyramidStarEntry.RADeg,
                    plateStar.YDouble,
                    celestialPyramidStarEntry.DEDeg,
                    celestialPyramidStarEntry.Mag,
                    plateStar.Brightness,
                    detectionCertainty,
                    plateStar.IsSaturated);

            #if ASTROMETRY_DEBUG
            Trace.Assert(m_Pairs.Find((pair) => pair.StarNo == celestialPyramidStarEntry.StarNo) == null);
            #endif

            starPair.StarNo = celestialPyramidStarEntry.StarNo;
            starPair.FeatureId = feature != null ? feature.FeatureId : -1;
            starPair.RADeg = celestialPyramidStarEntry.RADeg;
            starPair.DEDeg = celestialPyramidStarEntry.DEDeg;

            return starPair;
        }
 public void CheckAndAddStar(IStar star)
 {
     if (star.RADeg >= m_RAFrom && star.RADeg <= m_RATo &&
         star.DEDeg >= m_DEFrom && star.DEDeg <= m_DETo)
     {
         if (IncludedStarNos.Count < m_MaxStarsInArea)
         {
             IncludedStarNos.Add(star.StarNo);
         }
         else if (m_AlwaysIncludeStars.Any(x => x == star.StarNo))
         {
             IncludedStarNos.Add(star.StarNo);
         }
         else
         {
             if (DebugStarNosWithAppliedExclusions != null &&
                 DebugStarNosWithAppliedExclusions.Contains(star.StarNo))
             {
                 Trace.Assert(false,
                     string.Format("Debug Star {0} not added as cap is reached in {1}.", star.StarNo, AreaId));
             }
         }
     }
 }
        protected virtual void IdentifyStar(StarMapFeature feature, IStar star)
        {
            if (m_SolvedPlate != null)
            {
                ImagePixel featureCenter = feature.GetCenter();

                if (m_PreviousStar == null ||
                    m_PreviousStar.StarNo == star.StarNo)
                {
                    // Translation only
                    double x, y;
                    m_SolvedPlate.GetImageCoordsFromRADE(star.RADeg, star.DEDeg, out x, out y);

                    double newCenterX = m_Image.FullFrame.Width / 2 - featureCenter.X + x;
                    double newCenterY = m_Image.FullFrame.Height / 2 - featureCenter.Y + y;

                    m_SolvedPlate.GetRADEFromImageCoords(newCenterX, newCenterY, out m_RADegCenter, out m_DEDegCenter);

                    m_PreviousFeature = feature;
                    m_PreviousStar = star;
                }
                else
                {
                    // TODO: Rotate and streach until the feature fits

                }

                ReinitializePlateConstants();
                DrawCatalogStarsFit();

                // TODO: For now we only support 1 star centering
                m_PreviousStar = null;
                m_PreviousStar = null;
            }
        }
        private float GetStarMag(IStar star, ModelledFilter filter)
        {
            UCAC4Entry ucac4Star = star as UCAC4Entry;
            if (ucac4Star != null)
            {
                switch (filter)
                {
                    case ModelledFilter.B:
                        return double.IsNaN(ucac4Star.MagB) || ucac4Star.MagB > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.MagB;

                    case ModelledFilter.V:
                        return double.IsNaN(ucac4Star.MagV) || ucac4Star.MagV > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.MagV;

                    case ModelledFilter.Sloan_g:
                        return double.IsNaN(ucac4Star.Mag_g) || ucac4Star.Mag_g > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_g;

                    case ModelledFilter.Sloan_r:
                        return double.IsNaN(ucac4Star.Mag_r) || ucac4Star.Mag_r > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_r;

                    case ModelledFilter.Sloan_i:
                        return double.IsNaN(ucac4Star.Mag_i) || ucac4Star.Mag_i > 25 ? (float)ucac4Star.Mag : (float)ucac4Star.Mag_i;
                }
            }
            else
            {
                switch (filter)
                {
                    case ModelledFilter.B:
                        return double.IsNaN(star.MagB) || star.MagB > 25 ? (float)star.Mag : (float)star.MagB;

                    case ModelledFilter.V:
                    case ModelledFilter.Sloan_g:
                        return double.IsNaN(star.MagV) || star.MagV > 25 ? (float)star.Mag : (float)star.MagV;

                    case ModelledFilter.Sloan_r:
                        return double.IsNaN(star.MagR) || star.MagR > 25 ? (float)star.Mag : (float)star.MagR;

                    case ModelledFilter.Sloan_i:
                        return (float)star.Mag;
                }
            }

            return (float)star.Mag;
        }
Exemple #52
0
        public override void MouseDown(Point location)
        {
            if (m_SelectedCalibrationStar != null)
            {
                frmIdentifyCalibrationStar frmIdentifyCalibrationStar = new frmIdentifyCalibrationStar(m_CatalogueStars, m_UserStarIdentification);
                DialogResult res = m_VideoController.ShowDialog(frmIdentifyCalibrationStar);
                if (res == DialogResult.Abort)
                {
                    m_UserStarIdentification.Clear();
                }
                else if (res == DialogResult.OK &&
                         frmIdentifyCalibrationStar.SelectedStar != null)
                {
                    m_UserStarIdentification.Add(m_SelectedCalibrationStar, frmIdentifyCalibrationStar.SelectedStar);
                    if (m_UserStarIdentification.Keys.Count > 0 &&
                        m_UserStarIdentification.Keys.Count < 3)
                    {
                        m_VideoController.ShowMessageBox(
                            string.Format("Identify another {0} star(s) to attempt calibration", 3 - m_UserStarIdentification.Keys.Count),
                            "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (m_UserStarIdentification.Keys.Count > 2)
                    {
                        List <PSFFit> keysList = m_UserStarIdentification.Keys.ToList();
                        IStar         star1    = m_UserStarIdentification[keysList[0]];
                        IStar         star2    = m_UserStarIdentification[keysList[1]];
                        IStar         star3    = m_UserStarIdentification[keysList[2]];
                        double        ArcSec1  = 1 / 3600.0;
                        bool          badRA    = false;
                        bool          badDE    = false;
                        if (Math.Abs(star1.RADeg - star2.RADeg) < ArcSec1 || Math.Abs(star1.RADeg - star3.RADeg) < ArcSec1 || Math.Abs(star2.RADeg - star3.RADeg) < ArcSec1)
                        {
                            badRA = true;
                        }

                        if (Math.Abs(star1.DEDeg - star2.DEDeg) < ArcSec1 || Math.Abs(star1.DEDeg - star3.DEDeg) < ArcSec1 || Math.Abs(star2.DEDeg - star3.DEDeg) < ArcSec1)
                        {
                            badDE = true;
                        }

                        if (badRA)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Right Ascension. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else if (badDE)
                        {
                            m_VideoController.ShowMessageBox(
                                "Two of the stars have almost identical Declination. Please try again with different stars.",
                                "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                            m_UserStarIdentification.Clear();
                        }
                        else
                        {
                            ThreeStarAstrometry threeStarSolution = ThreeStarAstrometry.SolveByThreeStars(m_Image, m_UserStarIdentification, m_Tolerance);
                            if (threeStarSolution != null)
                            {
                                m_SolvedPlate = threeStarSolution;

                                m_PlatesolveController.UpdateFocalLength((int)Math.Round(threeStarSolution.Image.EffectiveFocalLength));
                                m_RADegCenter = threeStarSolution.RA0Deg;
                                m_DEDegCenter = threeStarSolution.DE0Deg;
                                m_Image.EffectiveFocalLength = threeStarSolution.Image.EffectiveFocalLength;

                                m_UserStarIdentification.Clear();

                                m_AstrometryController.RunCalibrationWithCurrentPreliminaryFit();
                            }
                            else
                            {
                                m_VideoController.ShowMessageBox(
                                    "Cannot complete calibration. Please try again with higher initial fit tolerance and/or with different stars. Be sure that the stars are well separated.",
                                    "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                m_UserStarIdentification.Remove(m_UserStarIdentification.Keys.ToList()[2]);
                            }
                        }
                    }
                }

                DrawCatalogStarsFit();
            }
            else
            {
                m_StarPoint = new Point(location.X, location.Y);
                m_Panning   = true;
                m_VideoController.SetPictureBoxCursor(CustomCursors.PanEnabledCursor);
            }
        }
 public ClientConnectEvents(IStar star, StarDbContext db, ILogger<ClientConnectEvents> logger)
 {
     _star = star;
     _db = db;
     _logger = logger;
 }
Exemple #54
0
 protected void ResetPreviousStar()
 {
     m_PreviousStar    = null;
     m_PreviousFeature = null;
 }