Пример #1
0
        /// <summary>
        /// 运行单次仿真
        /// </summary>
        public Dictionary<Fingerprint_Name, Fingerprint> RunSingleSimulation(int num_rays, Transmitter.EMIT_OPTION emit_option, Signal_Type signal_type,
                                                 Noise_Type noise_type, double[] noise_params, int N)
        {
            foreach(Transmitter trans in this.Transmitters)
            {
                trans.Reset();
                trans.EmitRays(num_rays, emit_option);   //各发射机辐射波束
                foreach(Receiver rec in this.Receivers)
                {
                    rec.Reset();
                    if(this.IsLOS(trans.Location, rec.Location))    //若存在LOS情况
                    {
                        LineSegment segLOS = new LineSegment(trans.Location, rec.Location);
                        Ray rayLOS = new Ray(trans, new LineSegment[] { segLOS }, segLOS.DirectionRadian, trans.CenterFrequency, trans.EmitPower * trans.Gain, trans.EmitPower * trans.Gain, true);
                        rec.AcceptRay(rayLOS, this);
                    }
                }
                foreach(Ray ray in trans.Rays)  //更新每条ray, 若被接收,则更新接收它的接收机
                {
                    Receiver rec = null;
                    while (!ray.Update(this, out rec)) ;
                    if (rec != null)
                        rec.AcceptRay(ray, this);
                }
            }

            FingerprintGenerator fg = new FingerprintGenerator();
            Dictionary<Fingerprint_Name, Fingerprint> result = new Dictionary<Fingerprint_Name,Fingerprint>();
            List<double>[] ray_angles = new List<double>[this.receivers.Count];
            List<double>[] ray_strengths = new List<double>[this.receivers.Count];
            List<double>[] ray_taus = new List<double>[this.receivers.Count];
            int i = 0;
            foreach(Receiver rec in this.Receivers)
            {
                ray_angles[i] = new List<double>();
                ray_strengths[i] = new List<double>();
                ray_taus[i] = new List<double>();
                foreach(Ray ray in rec.Rays)
                {
                    ray_angles[i].Add(ray.CurrentDirection);
                    ray_strengths[i].Add(ray.FadedPower(this.MeterPixelRatio));
                    ray_taus[i].Add(ray.GetLifeSpan(this.MeterPixelRatio));
                }
                i++;
            }
            double[] args = null;
            switch (signal_type)
            {
                case Signal_Type.PSEUDO_DOPPLER:
                    if (this.receivers.First().Value.Antenna.AntType != AntennaType.PSEUDO_DOPPLER)
                        return null;
                    Antenna_PseudoDoppler ant = this.receivers.First().Value.Antenna as Antenna_PseudoDoppler;
                    args = fg.PackArgs_PseudoDoppler(this.receivers.First().Value.FrequencyLow, this.receivers.First().Value.CenterFrequency,
                                                     this.receivers.First().Value.SampleFrequency, ant.SwitchFrequency, ant.Radius, ant.AntennaNumber);
                    break;
            }
            for (int j = 0; j < Enum.GetNames(new Fingerprint_Name().GetType()).Length; j++ )
                result[(Fingerprint_Name)j] = fg.SingleFingerprintSim(signal_type, noise_type, noise_params, (Fingerprint_Name)j, ray_angles, ray_strengths, ray_taus,
                                                 N, args);
            return result;
        }
Пример #2
0
 /// <summary>
 /// 生成加噪信号序列
 /// </summary>
 /// <param name="noise_type">噪声类型</param>
 /// <param name="signal">原始信号</param>
 /// <param name="noise_params">噪声参数集合,与噪声类型有关</param>
 /// <returns>加噪的信号序列</returns>
 public double[][] AddNoise(Noise_Type noise_type, double[][] signal, double[] noise_params)
 {
     MWNumericArray arr = AddNoise_MW(noise_type, new MWNumericArray(2, signal[0].Length, signal[0], signal[1]), noise_params);
     if (arr == null)
         return null;
     double[][] result = new double[2][];
     result[0] = (double[])arr.ToVector(MWArrayComponent.Real);
     result[1] = (double[])arr.ToVector(MWArrayComponent.Imaginary);
     return  result;
 }
Пример #3
0
 /// <summary>
 /// 进行单次指纹生成仿真,包括信号生成、加噪和指纹生成
 /// </summary>
 /// <param name="signal_type">信号类型</param>
 /// <param name="noise_type">噪声类型</param>
 /// <param name="noise_params">噪声参数集合,与噪声类型有关</param>
 /// <param name="fingerprint_name">指纹类型</param>
 /// <param name="ray_angles">波束方向集合</param>
 /// <param name="ray_strengths">波束强度集合</param>
 /// <param name="ray_taus">波束时延集合</param>
 /// <param name="N">信号点数</param>
 /// <param name="args">args参数集合,与信号类型有关</param>
 /// <returns></returns>
 public Fingerprint SingleFingerprintSim(Signal_Type signal_type, Noise_Type noise_type, double[] noise_params,
                                      Fingerprint_Name fingerprint_name, List<double>[] ray_angles, List<double>[] ray_strengths,
                                      List<double>[] ray_taus, int N, double[] args)
 {
     MWNumericArray[] signals = new MWNumericArray[ray_angles.GetLength(0)];
     for(int i = 0; i < signals.Length; i++)
     {
         signals[i] = this.GenerateSignal_MW(signal_type, ray_angles[i].ToArray(), ray_strengths[i].ToArray(), ray_taus[i].ToArray(), N, args);
         signals[i] = this.AddNoise_MW(noise_type, signals[i], noise_params);
     }
     Fingerprint fp = this.GenerateFingerprint(signal_type, fingerprint_name, signals, args);
     return fp;
 }
Пример #4
0
 /// <summary>
 /// 生成加噪信号序列
 /// </summary>
 /// <param name="noise_type">噪声类型</param>
 /// <param name="signal">原始信号</param>
 /// <param name="noise_params">噪声参数集合,与噪声类型有关</param>
 /// <returns>加噪的信号序列</returns>
 public MWNumericArray AddNoise_MW(Noise_Type noise_type, MWNumericArray signal, double[] noise_params)
 {
     if (signal == null)
         return null;
     switch(noise_type)
     {
         case Noise_Type.NONE:
             {
                 return signal;
             }
         case Noise_Type.GAUSSIAN:
             {
                 MWNumericArray snr = new MWNumericArray(noise_params[0]);
                 MWNumericArray arr = (MWNumericArray)sptb.AddNoise_Gaussian(signal, snr);
                 return arr;
             }
         case Noise_Type.SAS:
             {
                 MWNumericArray alpha = new MWNumericArray(noise_params[0]);
                 MWNumericArray snr = new MWNumericArray(noise_params[1]);
                 MWNumericArray arr = (MWNumericArray)sptb.AddNoise_SAS(signal, alpha, snr);
                 return arr;
             }
     }
     return null;
 }