コード例 #1
0
        private int FilterMdexSources()
        {
            if (Verbose)
            {
                Console.WriteLine();
                Console.WriteLine("Setting mdex source cutoff to snr >= 20");
            }

            Filtered   = Filtered.Filter(IsInSnrRange);
            Unfiltered = Unfiltered.Filter(IsInSnrRange);

            if (Verbose)
            {
                Console.WriteLine(
                    "Filtered mdex reduced to {0} sources",
                    Filtered.Count);

                Console.WriteLine(
                    "Unfiltered mdex reduced to {0} sources",
                    Unfiltered.Count);
            }

            return(Status);

            bool IsInSnrRange(ISource source)
            {
                var snrSource = source as ISnrSource;

                return(snrSource.SignalToNoise >= 20);
            }
        }
コード例 #2
0
 /// <summary>
 /// Disposes the collection (actually does nothing, just to satisfy the interface).
 /// </summary>
 /// <param name="disposing">
 /// true if the object is being disposed;
 /// false, if it is being finalized.
 /// </param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         Unfiltered.UnregisterFilteredCollection(this);
     }
 }
コード例 #3
0
        /// <summary>
        /// Returns true if Entry instances are equal
        /// </summary>
        /// <param name="other">Instance of Entry to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Entry other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                     ) &&
                 (
                     DateString == other.DateString ||
                     DateString != null &&
                     DateString.Equals(other.DateString)
                 ) &&
                 (
                     Date == other.Date ||
                     Date != null &&
                     Date.Equals(other.Date)
                 ) &&
                 (
                     Sgv == other.Sgv ||
                     Sgv != null &&
                     Sgv.Equals(other.Sgv)
                 ) &&
                 (
                     Direction == other.Direction ||
                     Direction != null &&
                     Direction.Equals(other.Direction)
                 ) &&
                 (
                     Noise == other.Noise ||
                     Noise != null &&
                     Noise.Equals(other.Noise)
                 ) &&
                 (
                     Filtered == other.Filtered ||
                     Filtered != null &&
                     Filtered.Equals(other.Filtered)
                 ) &&
                 (
                     Unfiltered == other.Unfiltered ||
                     Unfiltered != null &&
                     Unfiltered.Equals(other.Unfiltered)
                 ) &&
                 (
                     Rssi == other.Rssi ||
                     Rssi != null &&
                     Rssi.Equals(other.Rssi)
                 ));
        }
コード例 #4
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // credit: http://stackoverflow.com/a/263416/677735
            unchecked // Overflow is fine, just wrap
            {
                var hash = 41;
                // Suitable nullity checks etc, of course :)

                if (Type != null)
                {
                    hash = hash * 59 + Type.GetHashCode();
                }

                if (DateString != null)
                {
                    hash = hash * 59 + DateString.GetHashCode();
                }

                if (Date != null)
                {
                    hash = hash * 59 + Date.GetHashCode();
                }

                if (Sgv != null)
                {
                    hash = hash * 59 + Sgv.GetHashCode();
                }

                if (Direction != null)
                {
                    hash = hash * 59 + Direction.GetHashCode();
                }

                if (Noise != null)
                {
                    hash = hash * 59 + Noise.GetHashCode();
                }

                if (Filtered != null)
                {
                    hash = hash * 59 + Filtered.GetHashCode();
                }

                if (Unfiltered != null)
                {
                    hash = hash * 59 + Unfiltered.GetHashCode();
                }

                if (Rssi != null)
                {
                    hash = hash * 59 + Rssi.GetHashCode();
                }

                return(hash);
            }
        }
コード例 #5
0
        private int FilterBounds()
        {
            if (Verbose)
            {
                Console.WriteLine();
                Console.WriteLine("Calculating intersection of regions");
            }

            var bounds1 = SourceMatchLists.GetBounds(Filtered);
            var bounds2 = SourceMatchLists.GetBounds(Spitzer);

            var minRa = Angle.FromRadians(
                Max(bounds1.minRa.Radians, bounds2.minRa.Radians));

            var maxRa = Angle.FromRadians(
                Min(bounds1.maxRa.Radians, bounds2.maxRa.Radians));

            var minDec = Angle.FromRadians(
                Max(bounds1.minDec.Radians, bounds2.minDec.Radians));

            var maxDec = Angle.FromRadians(
                Min(bounds1.maxDec.Radians, bounds2.maxDec.Radians));

            if (Verbose)
            {
                Console.WriteLine("Min RA={0}", minRa);
                Console.WriteLine("Max RA={0}", maxRa);
                Console.WriteLine("Min Dec={0}", minDec);
                Console.WriteLine("Max Dec={0}", maxDec);

                Console.WriteLine();
                Console.WriteLine(
                    "Filtering source lists to bounded region.");
            }

            Filtered   = Filtered.Filter(InBounds);
            Unfiltered = Unfiltered.Filter(InBounds);
            Spitzer    = Spitzer.Filter(InBounds);

            return(Status);

            bool InBounds(ISource source)
            {
                return
                    (source.RA >= minRa &&
                     source.RA <= maxRa &&
                     source.Dec >= minDec &&
                     source.Dec <= maxDec);
            }
        }