/// <summary> /// /// </summary> /// <param name="lightSource"></param> /// <returns>TargetData[0] => APASS star /// TargetData[1] => GAIA star</returns> public static TargetData AcquireNearestQualifiedStar(TargetData lightSource) { //Find the nearest APASS star and the nearest GAIA star // const string GAIACatalogName = "Gaia"; const string APASSCatalogName = "APASS"; const string GCVSCatalogPrefix = "GCVS"; InfoObj gaiaCatData = new InfoObj(); InfoObj apassCatData = new InfoObj(); //Populate target data with catalog data, if found sky6StarChart tsxsc = new sky6StarChart(); sky6Utils tsxut = new sky6Utils(); //Ultimately, we want to center the star chart on the FOV of the image, // but not resize the chart tsxsc.EquatorialToStarChartXY(lightSource.SourceRA, lightSource.SourceDec); int xC = (int)tsxsc.dOut0; int yC = (int)tsxsc.dOut1; InfoObj[] catStarList = GetNearbyStars(tsxsc, xC, yC); //First, find the nearest star to the light source in the list from the catalog //Initialize a catalog info object with the first found star from a catalog gaiaCatData.CatalogSeparation = 1000; apassCatData.CatalogSeparation = 1000; double separation; //Now find an APASS star that is closest, or default to the initial one // go through the catalog list of stars. foreach (InfoObj iob in catStarList) { //Disqualify any light source with a GCVS star nearby if (iob.CatalogedName.Contains(GCVSCatalogPrefix)) { lightSource.IsGCVSCataloged = true; } tsxut.ComputeAngularSeparation(lightSource.SourceRA, lightSource.SourceDec, iob.CatalogRA, iob.CatalogDec); separation = (double)tsxut.dOut0 * 3600.0; if (separation < apassCatData.CatalogSeparation & iob.CatalogedName.Contains(APASSCatalogName)) { apassCatData.CatalogedName = iob.CatalogedName; apassCatData.CatalogRA = iob.CatalogRA; apassCatData.CatalogDec = iob.CatalogDec; apassCatData.CatalogMag = iob.CatalogMag; apassCatData.CatalogMagB = iob.CatalogMagB; apassCatData.CatalogMagV = iob.CatalogMagV; apassCatData.CatalogMagR = iob.CatalogMagR; apassCatData.CatalogMagG = iob.CatalogMagG; apassCatData.CatalogSeparation = separation; } if (separation < gaiaCatData.CatalogSeparation & iob.CatalogedName.Contains(GAIACatalogName)) { gaiaCatData.CatalogedName = iob.CatalogedName; gaiaCatData.CatalogRA = iob.CatalogRA; gaiaCatData.CatalogDec = iob.CatalogDec; gaiaCatData.CatalogMag = iob.CatalogMag; gaiaCatData.CatalogMagB = iob.CatalogMagB; gaiaCatData.CatalogMagG = iob.CatalogMagG; gaiaCatData.CatalogMagR = iob.CatalogMagR; gaiaCatData.CatalogSeparation = separation; } //check for APASS entry and hold again if so and separation is smaller than thelast } lightSource.APASSCatalogName = apassCatData.CatalogedName; lightSource.APASSCatalogMagnitude = apassCatData.CatalogMag; lightSource.APASSCatalogMagnitudeB = apassCatData.CatalogMagB; lightSource.APASSCatalogMagnitudeV = apassCatData.CatalogMagV; lightSource.APASSCatalogMagnitudeR = apassCatData.CatalogMagR; lightSource.APASSCatalogMagnitudeG = apassCatData.CatalogMagG; lightSource.APASSCatalogRA = apassCatData.CatalogRA; lightSource.APASSCatalogDec = apassCatData.CatalogDec; lightSource.SourceToAPASSCatalogPositionError = apassCatData.CatalogSeparation; tsxut.ComputeAngularSeparation(lightSource.TargetRA, lightSource.TargetDec, lightSource.APASSCatalogRA, lightSource.APASSCatalogDec); lightSource.TargetToAPASSCatalogPositionError = (double)tsxut.dOut0 * 3600.0; lightSource.GAIACatalogName = gaiaCatData.CatalogedName; lightSource.GAIACatalogMagnitude = gaiaCatData.CatalogMag; lightSource.GAIACatalogMagnitudeB = gaiaCatData.CatalogMagB; lightSource.GAIACatalogMagnitudeG = gaiaCatData.CatalogMagG; lightSource.GAIACatalogMagnitudeR = gaiaCatData.CatalogMagR; lightSource.GAIACatalogRA = gaiaCatData.CatalogRA; lightSource.GAIACatalogDec = gaiaCatData.CatalogDec; lightSource.SourceToGAIACatalogPositionError = gaiaCatData.CatalogSeparation; tsxut.ComputeAngularSeparation(lightSource.TargetRA, lightSource.TargetDec, lightSource.GAIACatalogRA, lightSource.GAIACatalogDec); lightSource.TargetToGAIACatalogPositionError = (double)tsxut.dOut0 * 3600.0; if (lightSource.APASSCatalogName != null) { string catPrefix = lightSource.APASSCatalogName.Split(' ')[0]; lightSource.APASSCatalogName = Utility.CreateStarLabel("APASS ", lightSource.APASSCatalogRA, lightSource.APASSCatalogDec); lightSource.IsAPASSCataloged = true; } else { lightSource.IsAPASSCataloged = false; } if (lightSource.GAIACatalogName != null) { lightSource.GAIACatalogName = Utility.CreateStarLabel("Gaia ", lightSource.GAIACatalogRA, lightSource.GAIACatalogDec); lightSource.IsGAIACataloged = true; } else { lightSource.IsGAIACataloged = false; } return(lightSource); }