private void GraphAltitude(DateTime gStart, DateTime gEnd, Celestial.RADec gRaDec, Celestial.LatLon gloc, string gName, Color gcolor) { //Graph the altitude change on 10 min intervals between gstart and gend for the position gRaDec for th observer at location gloc const int gPoints = 60; //number of points to graph double gInterval = (gEnd - gStart).TotalHours / gPoints; DateTime gTime = gStart; while (gTime <= gEnd) { double haR = gRaDec.HourAngle(gTime, gloc); double haH = Transform.RadiansToHours(haR); double altR = gRaDec.Altitude(haR, gloc); double altitude = Transform.RadiansToDegrees(altR); // double gst = Celestial.DateUTCToGST(gTime); double lst = Celestial.GSTToLST(gst, gloc.Lon); // if (altitude > 0) { DateTime localTime = gTime.ToLocalTime(); AltitudeChart.Series[gName].Points.AddXY(localTime, altitude); } //If (TargetControl.IsMoonUp(ImageForecastForm.tgtdata, ImageForecastForm.moondata, gTime))) Then // AltitudeChart.Series("AltitudePath").Points. gTime = gTime.AddHours(gInterval); } return; }
private double ComputeAltitude(DateTime timeLocal, double RAHours, double DecDegrees, double latitudeDegrees, double longitudeDegrees) // Returns maximum altitude for object at RA/Dec between times dusk and dawn { Celestial.LatLon location = new Celestial.LatLon(Transform.DegreesToRadians(latitudeDegrees), Transform.DegreesToRadians(longitudeDegrees)); Celestial.RADec position = new Celestial.RADec(Transform.HoursToRadians(RAHours), Transform.DegreesToRadians(DecDegrees)); double maxAlt = Transform.RadiansToDegrees(position.Altitude((position.HourAngle(timeLocal.ToUniversalTime(), location)), location)); return(maxAlt); }
private double ComputeMaxAltitude(DateTime duskLocal, DateTime dawnLocal, double RAHours, double DecDegrees, double latitudeDegrees, double longitudeDegrees) // Returns maximum altitude for object at RA/Dec between times dusk and dawn { Celestial.LatLon location = new Celestial.LatLon(Transform.DegreesToRadians(latitudeDegrees), Transform.DegreesToRadians(longitudeDegrees)); Celestial.RADec position = new Celestial.RADec(Transform.HoursToRadians(RAHours), Transform.DegreesToRadians(DecDegrees)); double maxAlt = Transform.RadiansToDegrees(AstroMath.DailyPosition.MaxAltitude(duskLocal.ToUniversalTime(), dawnLocal.ToUniversalTime(), position, location)); return(maxAlt); }
public FormTargetTrack(DailyPosition dp, DailyPosition mp, string targetNameS) { InitializeComponent(); targetName = targetNameS; tgtDateUTC = dp.UTCdate; moonDateUTC = mp.iRise; tgtUpH = dp.Rising.ToLocalTime().Hour + (dp.Rising.ToLocalTime().Minute / 60.0); tgtDownH = dp.Setting.ToLocalTime().Hour + (dp.Setting.ToLocalTime().Minute / 60.0); tgtDecD = 90.0 - Transform.RadiansToDegrees(dp.Position.Dec); tgtPosition = dp.Position; MoonPosition = mp.Position; obsLocation = dp.Location; //Set lat obsLatD = Transform.RadiansToDegrees(dp.Location.Lat); //Moon look up stuff Celestial.RADec moonRADec = DailyPosition.MoonRaDec(Celestial.DateToJ2kC(dp.UTCdate)); moonDecD = 90 - Transform.RadiansToDegrees(mp.Position.Dec); //Get the rise/set times from TSX sky6StarChart tsxs = new sky6StarChart(); sky6ObjectInformation tsxo = new sky6ObjectInformation(); //Set the date/time to the local date for the target tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, Celestial.DateToJulian(tgtDateUTC)); //Get some target stuff that's hard to calculate tsxs.Find(targetName); //wait a second System.Threading.Thread.Sleep(500); tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_TRANSIT_TIME); tgtTransitH = tsxo.ObjInfoPropOut; //Test stuff //double testmoontransitH = MoonPosition.TransitTime(tgtDateUTC, obsLocation); //Get some moon stuff now tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, Celestial.DateToJulian(moonDateUTC)); tsxs.Find("Moon"); //wait a second System.Threading.Thread.Sleep(500); tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME); moonRiseH = tsxo.ObjInfoPropOut; tsxo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME); moonSetH = tsxo.ObjInfoPropOut; //put the target back in tsxs.Find(targetName); tsxs = null; tsxo = null; return; }
public static DailyPosition[] TargetCycle(Celestial.RADec tgtRADec, DailyPosition[] sunspots, Celestial.LatLon obsLocation, double minalt) { //Calculate an array of dailypositions for dark periods of the given target (as an RA/Dec object) DailyPosition[] tgtspots = new DailyPosition[sunspots.Length]; for (int dayidx = 0; dayidx < sunspots.Length - 1; dayidx++) { tgtspots[dayidx] = new DailyPosition(sunspots[dayidx].Setting, sunspots[dayidx + 1].Rising, tgtRADec, obsLocation, minalt); } tgtspots[tgtspots.Length - 1] = new DailyPosition(); tgtspots[sunspots.Length - 1] = tgtspots[sunspots.Length - 2]; return(tgtspots); }
public DBQStar OffsetCenter(DBQStar tgtStar, double imagePA) { /*Calculates an offset position that places the input position in the center * of the guider FOV. * * Note that the bearing for moving off the target star is opposite for different * sides of the pier. If the scope is peering over the meridian, then this wont work * well. */ //Set the star chart FOV 4 times the y distance (arcmin) center of the ccd // fov to the center of the guider fov -- not really needed but helps viewing during processing SetStarChartSize(); // Convert target star RA and Dec to radians and place in RA/Dec structure double tgtRA = Transform.HoursToRadians(tgtStar.StarRA); double tgtDec = Transform.DegreesToRadians(tgtStar.StarDec); Celestial.RADec tgtStarPosition = new Celestial.RADec(tgtRA, tgtDec); // Compute the rotation (radians) associated with any guider FOV offset from the image PA double gRotationR = -Math.Atan2(gfov.CenterX, gfov.CenterY); // Increment the image PA by the guider offset double bearingR = gRotationR + Transform.DegreesToRadians(imagePA); // Reverse bearing if the mount is pointing east //if (!pierEast) { bearingR = -bearingR; } // Compute the distance beween the center of the Image FOV and the center of the Guider FOV double distanceR = Transform.DegreesToRadians((SumOfSquares(gfov.CenterX, gfov.CenterY)) / 60.0); // Calculate an offset position such that the guider FOV will have the target star in its center //Celestial.RADec endPosition = Celestial.Travel(tgtStarPosition, -gVectorR, gRotationR); Celestial.RADec endPosition = Celestial.ComputePositionFromBearingAndRange(tgtStarPosition, bearingR, -distanceR); // Convert this position back to hours and degrees (RA and Dec) and return the result // as a DBQStar structure DBQStar endStar = new DBQStar() { StarRA = Transform.RadiansToHours(endPosition.RA), StarDec = Transform.RadiansToDegrees(endPosition.Dec) }; return(endStar); }
//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; }
public DailyPosition(DateTime utcdateStart, DateTime utcdateEnd, Celestial.RADec tradec, Celestial.LatLon tlatlon, double tminAlt) { //utcdate as utc date (datetime) //tradec as position of tar{ get { (RADec) //tlatlon as location of observer (LatLon) //minAlt as minimum horizon (degrees): negative is below horizon, positive is above horizon bool AboveToStart; bool rise; bool sett; t_state = VisibilityState.UpSome; t_moonfree = 0; t_moonphase = 0; double thour; double utriseH = 0; double utsetH = 0; double yminus, yzero, yplus; Planar.QuadRoot solve; double sinMinAltD = Transform.SinD(tminAlt); //Rise at h = 0 arcminutes DateTime udate = utcdateStart; rise = false; sett = false; AboveToStart = false; thour = 1; double altitude = tradec.Altitude(tradec.HourAngle(udate.AddHours(thour - 1), tlatlon), tlatlon); yminus = Math.Sin(tradec.Altitude(tradec.HourAngle(udate.AddHours(thour - 1), tlatlon), tlatlon)) - sinMinAltD; if (yminus > 0) { AboveToStart = true; } do { yzero = Math.Sin(tradec.Altitude(tradec.HourAngle(udate.AddHours(thour), tlatlon), tlatlon)) - sinMinAltD; yplus = Math.Sin(tradec.Altitude(tradec.HourAngle(udate.AddHours(thour + 1), tlatlon), tlatlon)) - sinMinAltD; solve = Planar.Quad(yminus, yzero, yplus); switch (solve.nz) { case 0: break; case 1: if (yminus < 0) { utriseH = thour + solve.zero1; rise = true; } else { utsetH = thour + solve.zero1; sett = true; } break; case 2: if (solve.ye < 0) { utriseH = thour + solve.zero2; utsetH = thour + solve.zero1; } else { utriseH = thour + solve.zero1; utsetH = thour + solve.zero2; } rise = true; sett = true; break; } yminus = yplus; thour = thour + 2; }while (!((thour == 25) || (rise && sett) || (utcdateStart.AddHours(thour + 1) > utcdateEnd))); t_utcdate = utcdateStart; t_position = tradec; t_location = tlatlon; t_minalt = tminAlt; i_rise = utcdateStart; i_set = utcdateEnd; //Condition abovetostart and rise or not abovetostart and sett cannot occur (at least on paper) if (AboveToStart && (!(rise || sett))) { //Tar{ get { path is always above minimum altitude (e.g. horizon) t_state = VisibilityState.UpAlways; t_rise = utcdateStart; t_set = utcdateEnd; } else if ((!AboveToStart) && (rise && (!sett))) { //Tar{ get { path starts below) { ascends above minimum altitude (e.g. horizon) t_state = VisibilityState.Rises; t_rise = udate.AddHours(utriseH); t_set = utcdateEnd; //if (t_rise > t_set) { // t_set = t_set.AddDays(1) //} } else if (AboveToStart && ((!rise) && sett)) { //Tar{ get { path starts above) { decends below minimum altitude (e.g. horizon) t_state = VisibilityState.Falls; t_rise = utcdateStart; t_set = udate.AddHours(utsetH); if (t_rise > t_set) { t_set = t_set.AddDays(1); } } else if (AboveToStart && (rise && sett)) { //Tar{ get { path decends below) { rises above minimum altitude (e.g. horizon) //Choose the longer of the two rise/set intervals t_state = VisibilityState.DownSome; t_rise = udate.AddHours(utriseH); t_set = udate.AddHours(utsetH); if ((t_set - i_rise) > (i_set - t_rise)) { t_rise = i_rise; } else { t_set = i_set; } //rise should be after set //if (t_rise < t_set) { // t_rise += TimeSpan.FromDays(1) //} } else { if ((!AboveToStart) && (rise && sett)) { //Tar{ get { path rises above) { decends below minimum altitude (e.g. horizon) //Save the t_state = VisibilityState.UpSome; t_rise = udate.AddHours(utriseH); t_set = udate.AddHours(utsetH); //set should be after rise if (t_rise > t_set) { t_set += TimeSpan.FromDays(1); } } else { //not above at all //Tar{ get { path is always below minimum altitude (e.g. horizon) t_state = VisibilityState.UpNever; t_rise = utcdateStart; t_set = utcdateStart; } //The rise time should not precede the beginning of the interval... if (t_rise < i_rise) { t_rise = i_rise; } //The set time should not exceed the end of the interval... if (t_set > i_set) { t_set = i_set; } return; } }