/// <summary> /// Recovers the tracklet on a given set of images (typically pipeline input ones). /// </summary> /// <returns><c>true</c>, if tracklet was recovered, <c>false</c> otherwise.</returns> /// <param name="tvr"><see cref="TrackletVelocityRegression"/> from which the positions are computed.</param> /// <param name="InputImages">Images on which to perform the recovery.</param> /// <param name="Recovered">Recovered tracklet.</param> public bool RecoverTracklet(TrackletVelocityRegression tvr, IEnumerable <Image> InputImages, out Tracklet Recovered) { List <ImageDetection> Detections = new List <ImageDetection>(); foreach (Image img in InputImages) { /* Compute location */ ObservationTime obTime = img.GetProperty <ObservationTime>(); double Secs = (obTime.Time - tvr.ZeroTime).TotalSeconds; EquatorialPoint eqp = new EquatorialPoint() { RA = tvr.P_TR.Slope * Secs + tvr.P_TR.Intercept, Dec = tvr.P_TD.Slope * Secs + tvr.P_TD.Intercept }; Position p = new Position(eqp, img.Transform.GetPixelPoint(eqp)); /* Perform recovery */ if (RecoverDetection(p, img, RecoverRadius, InputImages, out ImageDetection RecD)) { Detections.Add(RecD); } } if (Detections.Count >= MinDetections) { Recovered = StandardTrackletFactory.CreateTracklet(Detections.ToArray()); return(true); } else { Recovered = null; return(false); } }
public override int GetHashCode() { var hashCode = ObservationPoint.GetHashCode(); hashCode = (hashCode * 397) ^ EstimatedValue.GetHashCode(); hashCode = (hashCode * 397) ^ ObservationTime.GetHashCode(); return(hashCode); }
void IXmlSerializable.WriteXml(XmlWriter writer) { var xmlSerializer = new XmlSerializer(typeof(Coordinates)); xmlSerializer.Serialize(writer, ObservationPoint); writer.WriteElementString(nameof(Intensity), Intensity.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString(nameof(DurationMs), DurationMs.ToString()); writer.WriteElementString(nameof(ObservationTime), ObservationTime.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString(nameof(EstimatedValue), EstimatedValue.ToString(CultureInfo.InvariantCulture)); }
/// <inheritdoc/> public TimeSpan CalculateAvailability(ObservationTime observation) { TimeSpan step = TimeSpan.FromHours(24); var totalSpan = observation.ObservationInterval.End.Subtract(observation.ObservationInterval.Start).Ticks; long availableTicks = 0; DateTime iterationDate = observation.ObservationInterval.Start; if (step.Days > 1) { throw new ArgumentOutOfRangeException(nameof(step), "step should be less then a day in ticks"); } var modulo = totalSpan % step.Ticks; long totalMistake = 0; for (long i = 0; i <= totalSpan; i = i + step.Ticks) { var isNewDay = iterationDate.AddTicks(step.Ticks).Date != iterationDate.Date || i == 0; if (observation.WeekWorkingDays.All(it => it.Value != (int)iterationDate.DayOfWeek)) { iterationDate = iterationDate.AddTicks(step.Ticks); continue; } if (observation.FullDayLeaves.Any(it => it.Start <= iterationDate && iterationDate <= it.End)) { iterationDate = iterationDate.AddTicks(step.Ticks); continue; } if (!isNewDay) { totalMistake = iterationDate.Date.AddDays(1).Ticks - iterationDate.Ticks + totalMistake; iterationDate = iterationDate.AddTicks(step.Ticks); continue; } iterationDate = iterationDate.AddTicks(step.Ticks); availableTicks += step.Ticks; } availableTicks += modulo; return(TimeSpan.FromTicks(availableTicks)); }
public override string ToString() { return($"FlashObservation: ObservationPoint = {ObservationPoint.ToString()}, Intensity = {Intensity.ToString()}, " + $"Duration(ms) = {DurationMs.ToString()}, ObservationTime = {ObservationTime.ToString()}, EstimatedValue = {EstimatedValue.ToString()}"); }
/// <summary> /// Creates a ImageDetection from the given arguments. This constructor is internally called by the ImageDetection factories. /// </summary> public ImageDetection(Position Barycenter, ObservationTime Time, Image ParentImage) { this.Barycenter = Barycenter; this.Time = Time; this.ParentImage = ParentImage; ExtendedProperties = new Dictionary <Type, IExtensionProperty>(); }
/// <summary> /// Wrapper for the original ImageDetection constructor. /// </summary> /// <param name="Barycenter">Object barycenter.</param> /// <param name="Time">Time at which the object was observed.</param> /// <param name="ParentImage">Image on which the object was detected.</param> /// <returns></returns> public static ImageDetection CreateDetection(Position Barycenter, ObservationTime Time, Image ParentImage) => new ImageDetection(Barycenter, Time, ParentImage);