private TargetData SearchForLightSourceInventory(ccdsoftImage tsximg, TargetData lightSource) { sky6Utils tsxu = new sky6Utils(); double ra = lightSource.TargetRA; double dec = lightSource.TargetDec; double rDelta = 1000; double rmsDelta; int sIndex = -1; for (int iSource = 0; iSource < XPosArr.Length; iSource++) { tsximg.XYToRADec((double)XPosArr[iSource], (double)YPosArr[iSource]); double raSrc = tsximg.XYToRADecResultRA(); double decSrc = tsximg.XYToRADecResultDec();; tsxu.ComputeAngularSeparation(ra, dec, raSrc, decSrc); rmsDelta = tsxu.dOut0; if (rmsDelta <= rDelta) { rDelta = rmsDelta; sIndex = iSource; lightSource.InventoryArrayIndex = sIndex; lightSource.TargetToSourcePositionError = rDelta * 3600.0; lightSource.SourceRA = raSrc; lightSource.SourceDec = decSrc; lightSource.SourceUncorrectedMagnitude = (double)MagArr[sIndex]; lightSource.SourceX = (double)XPosArr[sIndex]; lightSource.SourceY = (double)YPosArr[sIndex]; } } return(lightSource); }
public static (double, double) GetCurrentTelePosition() { sky6RASCOMTele tsxm = new sky6RASCOMTele(); tsxm.GetRaDec(); sky6Utils tsxu = new sky6Utils(); tsxu.PrecessNowTo2000(tsxm.dRa, tsxm.dDec); return(tsxu.dOut0, tsxu.dOut1); }
private double ComputeDistance(double ra1, double dec1, double ra2, double dec2) //Computes the angular distance between two polar coordinates using TSX utility function // { sky6Utils tsx_ut = new sky6Utils(); tsx_ut.ComputeAngularSeparation(ra1, dec1, ra2, dec2); double dist = tsx_ut.dOut0; return(dist); }
/// ******************************************************************************** private void TargetLoop() { string szPathToMapFile = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Exported Data\\map.txt"; ///Set the exposure time for the image double dExposure = 1.0; string LineFromFile; double dAz; double dAlt; //Connect to TSX TheSky and Uility methods sky6Utils tsx_util = new sky6Utils(); sky6RASCOMTheSky tsx_sky = new sky6RASCOMTheSky(); sky6RASCOMTele tsx_tele = new sky6RASCOMTele(); ccdsoftCamera tsx_cam = new ccdsoftCamera(); ///Open the observing list export file for targets StreamReader MyFile = File.OpenText(szPathToMapFile); ///Stream object for Export Data text file ///Get the first line -- headers ///Exit if the file is empty if (MyFile.EndOfStream == true) { return; } ; LineFromFile = MyFile.ReadLine(); int iRAindex = LineFromFile.IndexOf("RA"); int iDecindex = LineFromFile.IndexOf("Dec"); while (MyFile.EndOfStream == false) { LineFromFile = MyFile.ReadLine(); MessageBox.Show("RA: " + LineFromFile.Substring(iRAindex, 13) + " Dec: " + LineFromFile.Substring(iDecindex, 13)); string sname = LineFromFile.Substring((LineFromFile.Length - 12), 12); tsx_util.ConvertStringToRA(LineFromFile.Substring(iRAindex, 13)); dAz = tsx_util.dOut0; tsx_util.ConvertStringToDec(LineFromFile.Substring(iDecindex, 13)); dAlt = tsx_util.dOut0; ///Slew to object tsx_tele.SlewToAzAlt(dAz, dAlt, sname); ///Set exposure time and try { for image, exit if error tsx_cam.ExposureTime = dExposure; tsx_cam.TakeImage(); ///Add to T-point Model tsx_sky.AutoMap(); } ; //Loop }
private Point LocateCenter(double ra, double dec) { //Center the star chart on 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.RightAscension = ra; tsxsc.Declination = dec; return(new Point(tsxsc.WidthInPixels / 2, tsxsc.HeightInPixels / 2)); }
public bool IsUp(double ra, double dec, double minAlt) { sky6Utils tsxu = new sky6Utils(); tsxu.ConvertRADecToAzAlt(ra, dec); double alt = tsxu.dOut1; if (minAlt > alt) { return(false); } else { return(true); } }
public TargetXDescriptor NextClosestTarget(double az, double alt) { //Sets the first target for the session at alt/az and gets the closest target sky6Utils tsxu = new sky6Utils(); tsxu.ConvertAzAltToRADec(az, alt); double ra = (double)tsxu.dOut0; double dec = (double)tsxu.dOut1; XElement bogusTargetX = new XElement(TargetListRecordX, new XElement(NameX, "Bogus"), new XElement(RAX, ra.ToString()), new XElement(DecX, dec.ToString()), new XElement(FilterX, "0"), new XElement(LastDateX, DateTime.Now)); TargetXDescriptor bogusTarget = new TargetXDescriptor(bogusTargetX); TargetXDescriptor firstTgt = NextClosestTarget(bogusTarget); return(firstTgt); }
private XElement UpdatePosition(XElement xGalList) //Updates the values of HA and Altitude, then derives Side in the galaxy list by performing a TSX ComputeHA on each entry // { string gname; string gRA; string gHA; string gDec; string gAlt; //Open a TSX utility object for computing the hour angle sky6Utils tsx_ut = new sky6Utils(); var xgals = from grec in xGalList.Elements("Galaxy") select grec; foreach (var grec in xgals) { //Look up the target by galaxy name and get the hourangle gname = grec.Element("Name").Value.ToString(); gRA = grec.Element("RA").Value.ToString(); gDec = grec.Element("Dec").Value.ToString(); tsx_ut.ComputeHourAngle(System.Convert.ToDouble(gRA)); gHA = tsx_ut.dOut0.ToString(); grec.Element("HA").Value = gHA; tsx_ut.ConvertRADecToAzAlt(System.Convert.ToDouble(gRA), System.Convert.ToDouble(gDec)); gAlt = tsx_ut.dOut1.ToString(); grec.Element("Altitude").Value = gAlt; if (System.Convert.ToDouble(gHA) < 0) { grec.Element("Side").Value = "East"; } else { grec.Element("Side").Value = "West"; }; } return(xGalList); }
static bool SlewToStar(string starName, double starRA, double starDec) { //Moves the mount to center the calibration star in the guider FOV //Async slew to target (letting dome catch up), then CLS to align (does not coordinate with dome) // //First, convert RA and Dec to topocentric (Epoch now) as that is what the slew expects sky6Utils tsxu = new sky6Utils(); tsxu.Precess2000ToNow(starRA, starDec); starRA = tsxu.dOut0; starDec = tsxu.dOut1; sky6RASCOMTele tsxm = new sky6RASCOMTele { Asynchronous = 0 }; try { tsxm.SlewToRaDec(starRA, starDec, starName); } catch (Exception ex) { return(false); } return(true); }
/// Windows C# Sample Console Application: ListSearch /// /// ------------------------------------------------------------------------ /// Vaguely adapted from ErrorHandling.vbs (Visual Basic Script) /// Copyright (C) Software Bisque (2013) /// /// Converted 2015, R.McAlister /// /// ------------------------------------------------------------------------ /// /// This C# console application demonstrates how to run the telescope through a list of targets as defined /// by a list of names. /// /// Note: The gist of the orginal VBS script was entitled "ErrorHandling.vbs". However, that /// script, however labeled, performed the functions as adapted to VB herein. /// public void ListSearchSample() { ///Set the exposure time for the image double dExposure = 1.0; ///Target List string[] targetlist = new string[] { "NGC1348", "NGC1491", "NGC1708", "NGC179", "NGC1798", "NGC2165", "NGC2334", "NGC2436", "NGC2519", "NGC2605", "NGC2689", "NGC2666", "NGC4381", "NGC5785", "NGC5804", "NGC6895", "NGC6991", "NGC7011", "NGC7058", "M39", "NGC7071", "NGC7150", "NGC7295", "NGC7394", "NGC7686", "NGC7801" }; ///Create objects sky6StarChart objChrt = new sky6StarChart(); sky6RASCOMTele objTele = new sky6RASCOMTele(); ccdsoftCamera objCam = new ccdsoftCamera(); sky6Utils objUtil = new sky6Utils(); sky6ObjectInformation objInfo = new sky6ObjectInformation(); ///Connect Objects objTele.Connect(); objCam.Connect(); ///Run loop over array of target names double dAlt; double dAz; bool iError; foreach (string target in targetlist) { objChrt.Find(target); objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT); dAlt = objInfo.ObjInfoPropOut; objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM); dAz = objInfo.ObjInfoPropOut; try { objTele.SlewToAzAlt(dAz, dAlt, target); } catch { MessageBox.Show("An error has occurred running slew"); return; }; ///Set exposure time and try for image, exit if error objCam.ExposureTime = dExposure; try { objCam.TakeImage(); } catch { MessageBox.Show("An error has occurred running image"); }; } ///Disconnect telescope and camera objTele.Disconnect(); objCam.Disconnect(); return; }
/// <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); }
public static bool CLSToTarget(string tgtName, SpeedVector sv, bool IsPrecision = false) { //first, couple dome to telescope, if there is one sky6Dome tsxd = new sky6Dome(); try { tsxd.Connect(); tsxd.IsCoupled = 1; } catch (Exception ex) { //do nothing } int clsStatus = 123; sky6RASCOMTele tsxmt = new sky6RASCOMTele(); ClosedLoopSlew tsx_cl = new ClosedLoopSlew(); sky6StarChart tsxsc = new sky6StarChart(); sky6Utils tsxu = new sky6Utils(); //Check to see if target is above horizon double tgtRAH = Transform.DegreesToHours(sv.RA_Degrees); double tgtDecD = sv.Dec_Degrees; tsxu.ConvertRADecToAzAlt(tgtRAH, tgtDecD); double tgtAzmD = tsxu.dOut0; double tgtAltD = tsxu.dOut1; if (tgtAltD <= 0) { MessageBox.Show("Slew failure: Target is below the horizon"); return(false); } //Clear any image reduction, otherwise full reduction might cause a problem ccdsoftCamera tsxcam = new ccdsoftCamera() { ImageReduction = ccdsoftImageReduction.cdNone, Asynchronous = 1 //make sure nothing else happens while setting this up }; //Abort any ongoing imaging tsxcam.Abort(); bool returnStatus = true; // diagnostic string strRA = Utils.HourString(tgtRAH, false); string strDec = Utils.DegreeString(tgtDecD, false); // tsxsc.Find(tgtRAH.ToString() + ", " + tgtDecD.ToString()); tsxmt.Connect(); tsxu.Precess2000ToNow(tgtRAH, tgtDecD); double jnRAH = tsxu.dOut0; double jnDecD = tsxu.dOut1; //tsxmt.Asynchronous = 0; try { tsxmt.SlewToRaDec(jnRAH, jnDecD, tgtName); } catch (Exception ex) { MessageBox.Show("Slew Failure: " + ex.Message); returnStatus = false; } if (IsPrecision && returnStatus) { //*** precision slew try { clsStatus = tsx_cl.exec(); } catch (Exception ex) { returnStatus = false; } } try { tsxsc.Find(tgtName); } catch (Exception ex) { returnStatus = true; } return(returnStatus); }
static DBQStar FindStar(double gIsolation) { /* Locates a nearby star for running a guider calibration * * Generate and observing list from the AtFocus database search near the current location * (sometime in the future, cull this list for stars on the wrong side of the meridian. * Get the calibration distances (arc min for now) to use for framing * Look through the observing list array for a star isolated from it's neighbors by at least * twice the calibration distance. This means that once the FOV is centered on this ster, * you can move the mount at least the calibration distance without the other star coming into * the FOV. */ //Find the first star that is isolated from all the other stars on the list // and from the edge of the search area. Note that the search area is in degrees and // centered on the star chart center. // The star position <-> center position <= search radius - isolation radius. // sky6StarChart tsxsc = new sky6StarChart(); double gMaxRadius = (searchAreaDeg * 60) - gIsolation; //arc mins double scRA = tsxsc.RightAscension; double scDec = tsxsc.Declination; sky6Utils tsxut = new sky6Utils(); //Loop through all the stars in the prospect list // For each star, loop through from that star forward to see if any other star is // within gMinRadius of the center of the star chart // if so, then look through the rest of the list for any star within the gisolation // distance. // // Eventually, need to check for meridian side as well // // if not, then that's our star int gStarIdx = 0; double gStarRadius; double gRA; double gDec; StarProspects starList = new StarProspects(searchAreaDeg); for (int i = 0; i < starList.Count; i++) { gStarIdx = i; gRA = starList.StarRA(i); gDec = starList.StarDec(i); tsxut.ComputeAngularSeparation(scRA, scDec, gRA, gDec); gStarRadius = tsxut.dOut0 * 60; if (gStarRadius < gMaxRadius) { for (int j = i + 1; j < starList.Count; j++) { tsxut.ComputeAngularSeparation(starList.StarRA(j), starList.StarDec(j), gRA, gDec); if ((tsxut.dOut0 * 60) < gIsolation) { break; } if (j == starList.Count - 1) { return(starList.Star(gStarIdx)); } } } } return(null); }
//Calendar generation methods private void GenerateCalendar() { sky6StarChart tdoc = new sky6StarChart(); sky6Utils tute = new sky6Utils(); sky6ObjectInformation tobj = new sky6ObjectInformation(); double traH; //target RA in hours double tdecD; //target Dec in degrees double tlatD; //Observer Latitude in degrees double tlongD; //Observer Longitude in degrees try { tdoc.Find(TargetNameBox.Text); } catch (Exception ex) { //! found System.Windows.Forms.MessageBox.Show("Target not Found: " + TargetNameBox.Text + " " + ex.Message); TargetNameBox.Text = ""; return; } //Reset the target name to whatever TSX found tobj.Index = 0; //tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); //TargetNameBox.Text = tobj.ObjInfoPropOut; enteringTargetState = false; //TargetNameBox.Text = TargetNameBox.Text.Replace(" ", ""); int vj = tobj.Count; tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); traH = tobj.ObjInfoPropOut; tobj.Property(TheSky64Lib.Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); tdecD = tobj.ObjInfoPropOut; tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Latitude); tlatD = tdoc.DocPropOut; tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Longitude); tlongD = tdoc.DocPropOut; tdoc.DocumentProperty(TheSky64Lib.Sk6DocumentProperty.sk6DocProp_Time_Zone); Celestial.RADec tgtRADec = new Celestial.RADec(Transform.HoursToRadians(traH), Transform.DegreesToRadians(tdecD)); Celestial.LatLon obsLocation = new Celestial.LatLon(Transform.DegreesToRadians(tlatD), Transform.DegreesToRadians(-tlongD)); sundata = TargetControl.SunCycle((int)CurrentYearPick.Value, obsLocation); tgtdata = TargetControl.TargetCycle(tgtRADec, sundata, obsLocation, (double)MinAltitudeBox.Value); tgtdata = TargetControl.MoonPhase(tgtdata); moondata = TargetControl.MoonCycle(tgtdata, obsLocation); //Update the target positions with the moonfree properties tgtdata = TargetControl.MoonClear(tgtdata, moondata); WriteTitle(TargetNameBox.Text, CurrentYearPick.Value.ToString()); SpawnCalendar(tgtdata); if ((CurrentYearPick.Value % 4) != 0) { ClearLeapDay(); } WriteMoonTip(moondata); Show(); System.Windows.Forms.Application.DoEvents(); return; }