├── .gitignore ├── README.md ├── notes ├── ESA.md ├── Issues.docx ├── Radar Polarimetry for Weather Observations Notes.docx └── SARRadarAndSignalProcessing.md └── projects ├── SAR信号与图像处理 ├── InterferometricPhaseProcessing │ ├── InterferometricPhaseProcessing.md │ ├── main.m │ ├── pha.tif │ ├── 定位.txt │ └── 报告.pdf ├── MotionCompensation │ ├── createKaiserWin.m │ ├── main_basedOnMovement.m │ └── readdata.m └── RD&CS │ ├── AGC_attenuation_values.mat │ ├── CD_run_params.mat │ ├── CSA_main.m │ ├── RADARSAT_RDA_Imaging.m │ ├── RDA_main.m │ ├── computeAzSpectra.m │ ├── compute_azim_spectra.m │ ├── createKaiserWin.m │ ├── extract_AGC.m │ ├── extract_data.m │ ├── load_AGC_block.m │ ├── load_DATA_block.m │ ├── read_CEOS_raw.m │ └── specify_parameters.m ├── 双偏振雷达气象学 ├── Chapter2 │ ├── calculateNC_W_R_Z.m │ ├── ch2_1.m │ ├── ch2_4.m │ ├── ch2_5.m │ ├── ch2_6.m │ └── getPermittivity.m └── Chapter3 │ ├── ch3_1.m │ ├── ch3_2.m │ ├── ch3_3.m │ ├── getScatterAndExticationCoffByMie.m │ └── 球形粒子Mie散射参量的Matlab改进算法_张合勇.pdf └── 相控阵 └── ESA Simulation ├── BeamWidthRealatedByTheta0.m ├── GA_BF.m ├── chooseParent.m ├── compute1D_AF.m ├── compute1D_EP.m ├── compute1D_PAT.m ├── compute2D_AF.m ├── compute2D_AFQuant.m ├── compute2D_EP.m ├── compute2D_IntGain.m ├── compute2D_PAT.m ├── costFunction.m ├── getTaylorWeights.m ├── mutate.m ├── pattern1D.m ├── pattern1D_GLs.m ├── pattern2D.m ├── plotMatrix.m ├── processMat.m ├── processVector.m ├── subarray1D.m ├── subarray1D_Overlapped.m └── test.m /.gitignore: -------------------------------------------------------------------------------- 1 | *.dat 2 | *.001 3 | *.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Radar Simulation 2 | 3 | 这个仓库包含了两个文件夹:`notes`包含了一些学习的总结和笔记;`projects`包含了相关的仿真,都是`Matlab`仿真代码 4 | 5 | *** 6 | 7 | ### notes 8 | 9 | - `ESA.md`:关于相控阵的一些知识点,差不多是根据《电扫阵列:Matlab仿真与建模》这本书的笔记 10 | - `Issues.txt`:平时看文献时记录下来的Q&A 11 | - `Radar Polarimetry for Weather Observations Notes.txt`:关于雷达气象学以及双偏振的知识点总结,大部分来源于Znric的《Radar Polarimetry for Weather Observations Notes》和GuifuZhang的《双偏振雷达气象学》 12 | - `SARRadarAndSignalProcessing.md`关于SAR信号处理以及图像处理的知识点总结 13 | 14 | ### projects 15 | 16 | - SAR信号与图像处理 17 | - `InterferometricPhaseProcessing`:干涉相位处理以及根据主、辅图像定位 18 | - `MotionCompensation`:运动补偿 19 | - `RD&CS`:RD成像算法与CS成像算法 20 | - 双偏振雷达气象学 21 | - `Chapter 2`:第2章的课后仿真 22 | - `Chapter 3`:第3章的课后仿真 23 | - 相控阵 24 | - `ESA Simulation`:关于相控阵的建模仿真,对《电扫阵列:Matlab仿真与建模》(Electronically Scanned Arrays MATLAB Modeling and Simulation)代码的整理以及注释 25 | 26 | *** 27 | 28 | 由于数据文件过大,我已上传至[百度网盘](https://pan.baidu.com/s/1JaEaczfI9_7xB0aUATzfjg),提取码:`c1lv`,如果对同学有帮助,请不要吝啬你的start~ 29 | 30 | -------------------------------------------------------------------------------- /notes/ESA.md: -------------------------------------------------------------------------------- 1 | # 一维电扫阵列 2 | 3 | ## 方向图公式 4 | 5 | - ![image-20200613104318957](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613104318957.png) 6 | - $EP=cos^{\frac{EF}{2}} \theta$,其中$EF$表示阵元因子,$EP$表示阵元方向图 7 | 8 | ![image-20200613104551942](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613104551942.png) 9 | 10 | ## 基本参数 11 | 12 | - 波束宽度:$\theta_{bw} = \frac{k\lambda}{Mdcos\theta_0}$,其中*k*表示波束宽度因子,当$k=0.886$时且为均匀口径照射,波束宽度为3dB带宽 13 | 14 | - 瞬时带宽:瞬时带宽表示损耗能够在接受范围内的频率变化范围 15 | 16 | $IBW=\frac{kc}{Lsin\theta_0}$ 17 | 18 | - 栅瓣表示主瓣以外的气压方向有规律地形成与主播书类似地辐射波束,栅瓣的位置与频率和阵元间距有关 19 | 20 | ![image-20200613105606723](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613105606723.png) 21 | 22 | - 对于均匀的幅值分布,阵元方向图不发生扫描,阵因子发生扫描,导致增益下降,峰值位置产生偏差,但是均匀加权的方式是能量最高的![image-20200613105809290](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613105809290.png) 23 | 24 | # 二维电扫阵列 25 | 26 | ## 方向图公式 27 | 28 | - ![image-20200613115843143](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613115843143.png) 29 | 30 | 坐标表示: 31 | 32 | $x_m = (m - \frac{M+1}{2})d_x, m = 1, ..., M; x_y = (n - \frac{N+1}{2})d_y, n = 1, ..., N$ 33 | 34 | ![image-20200613120242003](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120242003.png) 35 | 36 | ![image-20200613120312504](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120312504.png) 37 | 38 | 39 | 40 | ## ESA的空间坐标定义 41 | 42 | - 天线坐标系 43 | 44 | ![image-20200613120449873](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120449873.png) 45 | 46 | - 雷达坐标系 47 | 48 | ![image-20200613120532782](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120532782.png) 49 | 50 | - 天线圆锥坐标系 51 | 52 | ![image-20200613120608195](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120608195.png) 53 | 54 | - 三个坐标系之间的转换 55 | 56 | ![image-20200613120644174](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613120644174.png) 57 | 58 | 其中$arctan2(y, x) = arctan(y/x)$ 59 | 60 | - 正弦空间表示法 61 | 62 | ![image-20200613122127456](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613122127456.png) 63 | 64 | ![image-20200613122211231](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613122211231.png) 65 | 66 | - ![image-20200613122314824](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613122314824.png) 67 | 68 | 在这里波束宽度与扫描角无关,扫描波束的峰值为$sin\theta_z$ 69 | 70 | ## 阵元网格 71 | 72 | - 栅瓣扫描盲区,只有当主波束处于栅瓣扫描盲区时,栅瓣才不会出现在真实空间中,即以主波束为中心的圆内 73 | 74 | ![image-20200613134853177](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613134853177.png) 75 | 76 | - ![image-20200613135947750](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613135947750.png) 77 | 78 | - 阵元的三角形分布 79 | 80 | ![image-20200613140250273](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613140250273.png) 81 | 82 | - ![image-20200613140328863](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200613140328863.png) 83 | 84 | ## 二维阵列方向图分析 85 | 86 | - 考虑ESA的误差影响:①相关误差:移相器和衰减器的量化误差②故障元件以及制造偏差等 87 | 88 | - 量化误差引起的副瓣电平峰值和平均值计算公式: 89 | 90 | $Average\ SLL = \frac{\pi ^2}{3n_{elem} 2^{2N}}; Max \ SLL = \frac{1}{2^{2N}}$,其中$N$表示量化位数。 91 | 92 | - 俯仰角、横滚角和偏航角引起的坐标变化可以用旋转矩阵来表示 93 | 94 | ![image-20200614093225010](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200614093225010.png) 95 | 96 | image-20200614093401725 97 | 98 | 99 | 100 | - 101 | 102 | # 子阵列波束形成 103 | 104 | ## 概念 105 | 106 | - ![image-20200624103353525](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200624103353525.png) 107 | - ![image-20200624103409158](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200624103409158.png) 108 | - 只需要在各级子阵后接入移相器就行了 -------------------------------------------------------------------------------- /notes/Issues.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/notes/Issues.docx -------------------------------------------------------------------------------- /notes/Radar Polarimetry for Weather Observations Notes.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/notes/Radar Polarimetry for Weather Observations Notes.docx -------------------------------------------------------------------------------- /notes/SARRadarAndSignalProcessing.md: -------------------------------------------------------------------------------- 1 | # 合成孔径雷达介绍 2 | 3 | #### 参考书籍 4 | 5 | - 《合成孔径雷达成像-算法与实现》 6 | 7 | **课程安排:四次课程设计** 8 | 9 | ------- 10 | 11 | ### Notes 12 | 13 | - 天波超视距雷达使用3MHz-30MHz的短波波段 14 | - 点迹处理:将同一目标的点匹配 15 | - 航迹处理:将不同*PRT*的目标形成的点处理形成目标的运动路径 16 | - “大气窗口”,选择大气透射率较高的波段作为雷达的波段 17 | 18 | ![image-20200506144722759](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200506144722759.png) 19 | 20 | - 垂直极化不是指与地面垂直的极化方向,而是与水平极化和*k*构成的平面右手法则的方向 21 | - 孔径越大,波束越窄,分辨率越高 22 | - 积分旁瓣比,峰值旁瓣比(主瓣与第一旁瓣(旁瓣中峰值最大旁瓣而不是离主瓣最近的旁瓣)的分贝值之差) 23 | - 采用脉冲压缩可以同时提高距离分辨率和占空比:$dR = \frac{c}{2B}$ 24 | - 定位精度与分辨率,如果场景中有多个目标定位精度等同于分辨率,否则定位精度可通过多个测量数据超过分辨率 25 | 26 | ### SAR的成像基本原理 27 | 28 | - ![image-20200506153358528](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200506153358528.png) 29 | 30 | - 成像特点:叠影(距离接收机相同距离的点会叠在一起),前景压缩,阴影。 31 | 32 | - 合成孔径的原理图(D为真实孔径,SAR的分辨率为$\frac{D}{2}$) 33 | 34 | ![image-20200506153907649](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200506153907649.png) 35 | 36 | - SAR的工作模式 37 | 38 | ![image-20200506154348196](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200506154348196.png) 39 | 40 | - 运动补偿方法:①自聚焦方法②基于IMU/GPS的运动补偿 41 | 42 | ----- 43 | 44 | # 信号基础 45 | 46 | ### 信号的描述与分类 47 | 48 | - 从一个脉冲看是$f(t)$一维信号,从多个脉冲看是多维信号 49 | 50 | - 利用矩形脉冲的思想实现傅里叶变换(从理论到实际) 51 | 52 | ![image-20200509143618177](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509143618177.png) 53 | 54 | 坐标转换 55 | 56 | ![image-20200509144033076](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509144033076.png) 57 | 58 | ### 信号与系统的概念 59 | 60 | - 时域分析法优点是精确,频域分析法优点是快 61 | 62 | #### 卷积性质 63 | 64 | - ![image-20200509144811188](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509144811188.png) 65 | - 长为M, N的序列卷积后的结果长度为$M + N - 1$ 66 | 67 | #### 傅里叶变换性质 68 | 69 | - $FT[F(w-w_0)] = f(t) e^{jw_0t}$ 70 | - $FT[f(t-t_0)] = F(w) e^{-jwt_0}$ 71 | - ![image-20200509150512936](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509150512936.png) 72 | - $f(nT_s) = \frac{1}{T_s} \sum_{k=0}^{N-1} F(kw_1)e^{jknw_1T_s}$ 73 | 74 | # 线性调频信号分析与脉冲压缩 75 | 76 | ### 信号抽样 77 | 78 | - ![image-20200509152357654](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509152357654.png) 79 | 80 | 数字信号的频谱由于采样保持$u(t)$ 即$FT[f(t)\otimes u(t)] = F(w)*sinc(w)$导致频谱畸变 81 | 82 | ### 线性调频信号 83 | 84 | - ![image-20200513120939341](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200513120939341.png) 85 | 86 | - 时域表达式$s(t) = rect(\frac{t}{T}) exp \left[j \pi K t^2 \right]$ 87 | 88 | 频域表达式$S(f) = \int _{-\infty}^{\infty}rect(\frac{t}{T}) exp \left[j \pi K t^2 \right]exp\left[-j2\pi ft\right]dt$ 89 | 90 | 难以直接利用傅里叶变换直接推导,可利用驻定相位原理得到近似表达式 91 | 92 | - 驻定相位原理 :对于$g(t) = w(t) exp[j \phi (t)]$的积分,信号在相位驻留点附近是缓变的,而在其他时间点上事捷变的,驻留点附近对积分起主要贡献(只要$TBP$够大,驻定相位原理是相当准确的) 93 | 94 | ![image-20200513120202004](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200513120202004.png) 95 | 96 | ![image-20200513120615855](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200513120615855.png) 97 | 98 | - 线性调频信号与采样间隔的关系,过采样率保持再1.2以上才可以保持不失真 99 | 100 | - 匹配滤波器的物理特点:幅频特性与信号一致;相频特性与信号相反,使得信号同相叠加 101 | 102 | - 时域翻转求共轭对应频域直接求共轭 103 | 104 | - 匹配滤波器:$h(t) = ks^*(t_m - t)$,冲激响应是发射信号的时域翻转和共轭 105 | 106 | $H(jw) = k[S(jw)e^{jwt_m}]^*$ 107 | 108 | ### 脉冲压缩 109 | 110 | - 基本思想:补偿相位 111 | 112 | ![image-20200509155754092](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200509155754092.png) 113 | 114 | - 时域实现: 115 | - ![image-20200516101220386](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516101220386.png) 116 | 117 | 当$TBP>100$时,$S_{out} (t) \approx Tsinc[KT(t - t_0)]$ 118 | 119 | LMF经过匹配滤波后 120 | 121 | ![image-20200516104427092](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516104427092.png) 122 | 123 | ![image-20200516104730241](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516104730241.png) 124 | 125 | 时间量纲下的3dB分辨率: $\rho = \frac{0.886}{|K|T} \approx \frac{1}{|K|T}$ 126 | 127 | 压缩比为时间带宽积:$r = \frac{\rho}{\rho ^{\prime}} = \frac{T}{1/(|K|T)} = |K|T^2$ 128 | 129 | SNR提高倍数为压缩比 130 | 131 | 脉冲压缩后的时间分辨率为信号带宽的倒数 132 | 133 | LMF压缩后的信号为实数。 134 | 135 | ![image-20200516111400087](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516111400087.png) 136 | 137 | 相位为$\pi,0$ 138 | 139 | ----- 140 | 141 | - 频域实现 142 | 143 | 线性调频信号在带宽内均匀扫频,具有平坦的频谱,频域中的脉冲压缩本质就是将信号频谱与含有二次共轭相位 的频域滤波器相乘,以得到具有线性相位的平坦频谱 144 | 145 | 基带信号 146 | 147 | ![image-20200516112303620](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516112303620.png) 148 | 149 | 非基带信号 150 | 151 | ![image-20200516113139820](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516113139820.png) 152 | 153 | 频域匹配滤波器生成方式 154 | 155 | ![image-20200516113451459](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516113451459.png) 156 | 157 | - 峰值旁瓣比与积分旁瓣比 158 | 159 | ![image-20200516114607718](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516114607718.png) 160 | 161 | 如何降低PSLR:加权(加窗),使得PSLR降低,但同时引起波束宽度增加,SNR降低 162 | 163 | - **TBP**:时间带宽积 164 | 165 | - 如何插值:在频域两边补零,然后傅里叶变换 166 | 167 | ### Q&A 168 | 169 | - Q信号带宽 170 | 171 | A例如由三个子基带构成的信号,如果需要3 dB带宽为100 M,则需要每个子基带的1 dB带宽为100 M 172 | 173 | # SAR成像 174 | 175 | ### SAR几何关系 176 | 177 | - 波束宽度分为方位向和距离向 178 | 179 | 斜视角表示SAR天线的朝向;零多普勒面表示多普勒速度为0的位置,位于这个平面内的目标与飞机的径向速度为0 180 | 181 | ![image-20200511145319798](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200511145319798.png) 182 | 183 | - 距离等式的双曲线模型:$R^2 (\eta) = R_0 ^2 + V_r ^ 2 \eta ^2$ 184 | 185 | 其中$R^2 (\eta)$表示斜距,$R_0$表示零多普勒面的斜距,$V_r$表示飞机飞行速度 186 | 187 | 利用泰勒公式进行近似 188 | 189 | ![image-20200516115536916](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516115536916.png) 190 | 191 | 其中$\theta _c$表示零多普勒面与斜视的夹角 192 | 193 | 小斜视角可以近似为 $R(\eta) \approx R_0 + \frac{V^{2}\eta ^2}{2R_0}$ 194 | 195 | ### 距离向信号分析 196 | 197 | - 接收信号的带宽为 $B=|K_r|T_r$ 198 | 199 | 距离向的分辨率(与脉冲宽度有关)$\rho _r = \frac{c}{2|K_r| T_r}$ 200 | 201 | - 距离向的采样率要保证能够准确刻画波形 202 | 203 | ### 方位向信号分析 204 | 205 | - 方位向的波束扫描 206 | 207 | ![image-20200516122146334](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516122146334.png) 208 | 209 | ![image-20200516122717892](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516122717892.png) 210 | 211 | 由四部分构成:发射信号的加权函数$w_r$,天线方向图$w_a$(双程,类似于$sinc^2$),载频的多普勒频移,LFM的多普勒频移 212 | 213 | - 方位向的多普勒参数 214 | 215 | 方位向的多普勒速度 216 | 217 | ![image-20200516144444589](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516144444589.png) 218 | 219 | ![image-20200516145436357](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516145436357.png) 220 | 221 | $\theta _{bw}$表示波束宽度,多普勒带框可以理解为距离向的两端的多普勒频移的差值 222 | 223 | ![image-20200516145814427](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516145814427.png) 224 | 225 | 调频率$K_a$是负数,表明多普勒频率由负到正 226 | 227 | - 方位向分辨率 228 | 229 | ![image-20200516150655537](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200516150655537.png) 230 | 231 | - 合成孔径:$D_s = R_0\lambda / D$ 232 | 233 | ### PRF的选择 234 | 235 | - 测绘带与方位向分辨率对PRF的要求存在悖论:方位向分辨率越高要求多普勒带宽越大,那么PRF就得高即$f_c$高,那么PRT就得小,那么测绘带就得小 236 | - PRF其实就是方位向的采样率 237 | - ![image-20200517175033380](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200517175033380.png) 238 | - $PRT = T_r + T_r + 2(R_2 - R_1)/c$表示为反射脉冲的宽度 + 最后一个接收回波信号的脉冲宽度 + 最近斜距与最远斜距之差 239 | 240 | ----- 241 | 242 | # SAR成像算法 243 | 244 | - 对于“成像”可以有两种理解: 245 | - 将二维 (方位向、距离向)的弥散的回波信号进行距离向和方位向的二维压缩得到点信号,即回波脉冲压缩 246 | - 对回波进行反卷积从而获得目标的点信息 247 | 248 | ### RD算法 249 | 250 | - Range-Doppler算法:距离徙动矫正 > 距离向压缩 > 方位向压缩 251 | 252 | ![image-20200518113600482](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200518113600482.png) 253 | 254 | 由于方位向的多普勒频率是线性调频的,所以可以将不同点目标的回波信号进行距离向的压缩 255 | 256 | 距离徙动矫正的两种表达方式 257 | 258 | ![image-20200518120154669](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200518120154669.png) 259 | 260 | ![image-20200518120237084](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200518120237084.png) 261 | 262 | 其中$f_{dc}$表示多普勒中心频率,$f_{dr}$表示多普勒调频率。线性项表示距离走动,二次项表示距离 263 | 264 | - 距离向脉冲压缩后在距离多普勒域内常常出现卷绕的现象 265 | 266 | ![image-20200518141532205](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200518141532205.png) 267 | 268 | ==原因在于多普勒频率中心$f_{dc}$不为0== 269 | 270 | - ![image-20200518151702491](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200518151702491.png) 271 | 272 | - 估计多普勒中心解决多普勒模糊问题 273 | 274 | # 基于运动补数据运动补偿 275 | 276 | - ![image-20200629114841773](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629114841773.png) 277 | 278 | ### 匀速误差 279 | 280 | - ![image-20200629114907887](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629114907887.png) 281 | 282 | 其中$r_1(\eta) - r(\eta)$省去了$\Delta V_A$的二次项 283 | 284 | ### 匀加速误差 285 | 286 | ![image-20200629115308795](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629115308795.png) 287 | 288 | ### 正弦速度误差 289 | 290 | ![image-20200629115438044](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629115438044.png) 291 | 292 | 当存在与飞行方向垂直的横向速度分量时,产生雷达视线方向运动损失,导致基带线性调频信号变成非基带线性调频![image-20200629115716852](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629115716852.png) 293 | 294 | ![image-20200629120623034](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629120623034.png) 295 | 296 | - 距离重采样:频域乘上线性相位项 297 | - 方位重采样:sinc插值 298 | 299 | - ![image-20200629121305852](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629121305852.png) 300 | 301 | - ![image-20200629113730305](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629113730305.png) 302 | 303 | 第一步针对参考斜距进行一阶运动补偿 304 | 305 | ![image-20200629113809795](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629113809795.png) 306 | 307 | $z_i, x_i$是飞机的坐标 308 | 309 | #### 一阶运动补偿 310 | 311 | ![image-20200629113842455](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629113842455.png) 312 | 313 | #### 距离重采样 314 | 315 | 在距离向频域乘上距离向的相位项(只对中心测绘带的误差进行补偿) 316 | 317 | ![image-20200629114002071](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629114002071.png) 318 | 319 | #### 方位向重采样 320 | 321 | 一点一点算sinc插值 322 | 323 | ![image-20200629140107962](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629140107962.png) 324 | 325 | ![image-20200629223043980](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200629223043980.png) 326 | 327 | 328 | 329 | 330 | 331 | # 基于回波数据的参数估计与运动补偿 332 | 333 | ### 多普勒中心频率估计 334 | 335 | - 一阶相位误差 336 | 337 | - 当波束方向图主瓣没有对准零多普勒中心时,导致模糊比增高![](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601144152201.png) 338 | - 方位模糊比:模糊信号能量之和与主瓣能量之和的比值 339 | - 将每个多普勒频谱点能量用指数概率密度函数进行建模,采用最大似然估计,得到最优滤波器 340 | 341 | ![image-20200601150506559](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601150506559.png) 342 | 343 | - 方向图越陡多普勒中心估计越精确 344 | - ![image-20200601151802679](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601151802679.png) 345 | - 圆周卷积一般用傅里叶域相乘实现,注意傅里叶变换不要补零 346 | 347 | ### 多普勒调频率估计 348 | 349 | - 二次相位误差 350 | 351 | - ![image-20200601155455456](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601155455456.png) 352 | 353 | - ![image-20200601155440610](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601155440610.png) 354 | 355 | ### 相位梯度自聚焦算法 356 | 357 | - 高次相位误差 358 | 359 | - ![image-20200601160159766](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601160159766.png) 360 | - ![image-20200601160520819](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200601160520819.png) 361 | 362 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/InterferometricPhaseProcessing/InterferometricPhaseProcessing.md: -------------------------------------------------------------------------------- 1 | # 平地相位去除 2 | 3 | ### Idea 4 | 5 | - 通过相位信息重建时间序列 6 | - 分别对方位向和距离向进行平地相位去除 7 | - 选取平地相位去除后的相位图像 8 | 9 | ### result 10 | 11 | ![image-20200720131400493](C:\Users\sfpotato\AppData\Roaming\Typora\typora-user-images\image-20200720131400493.png) 12 | 13 | # 定位 14 | 15 | ### idea 16 | 17 | - 利用主图像和辅图像斜距方程以及主图像的多普勒方程解出PT的位置 18 | - 然后利用初始值找到距离初始值最近的解作为PT的定位位置 19 | 20 | ### result 21 | 22 | - $PT = [884608.50 \ \ -4306564.21 \ \ 4606004.50]$ 23 | 24 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/InterferometricPhaseProcessing/main.m: -------------------------------------------------------------------------------- 1 | clc; close all; 2 | fontsize = 16; 3 | 4 | %% Main : clear ground phase 5 | phase = imread('pha.tif'); 6 | TD = exp(1j.*phase); 7 | [Na, Nr] = size(TD); 8 | 9 | %% clear azimuth stripe frequency 10 | FDA = fft(TD, [], 2); 11 | [~, index] = max(sum(FDA, 1)); % find stripe frequency 12 | FDA_new = horzcat(FDA(:, index : Nr), FDA(:, 1 : index - 1)); % move to zero frequency 13 | phase_azimuthGC = angle(ifft(FDA_new, [], 2)); % get phase image 14 | 15 | %% rebuild time sequence 16 | TD__azimuthGC = exp(1j*phase_azimuthGC); 17 | 18 | %% clear range stripe frequency 19 | FDR = fft(TD__azimuthGC); % range fft 20 | [~, index] = max(sum(FDR, 2)); % find stripe frequency 21 | FDR_new = vertcat(FDR(index : Na, :), FDR(1 : index - 1, :)); % move to zero frequency 22 | phase_GC = angle(ifft(FDR_new)); % get phase image 23 | 24 | %% plot original phase image and processed phase image 25 | figure ; 26 | subplot(121) 27 | imshow(phase) 28 | title('original phase image', 'fontsize', fontsize); 29 | subplot(122) 30 | imshow(phase_GC); 31 | title('pahse image cleared ground phase', 'fontsize', fontsize); 32 | imwrite(phase_GC, 'phase_GC.png'); 33 | 34 | %% Main : location 35 | 36 | %% init paramenters 37 | R0_main = 1443640.2; % main image 38 | PS_main = [1466309.6 -4601880.8 4914932.0]; % main image location 39 | VS_main = [-61.062392 -5620.2862 -5236.1316]; 40 | 41 | R0_assist = 1443566.7; 42 | PS_assist = [1466545.1 -4601144.2 4915020.0]; 43 | 44 | lambda = 0.031250000; 45 | fdc = -295.19346; 46 | PT0 = [884704.82 -4306714.2 4605148.9]; 47 | 48 | %% solve R-D equations 49 | syms PT [1 3] 50 | eqn1 = R0_main/2 == sqrt(sum((PT - PS_main).^2)); 51 | eqn2 = R0_assist - R0_main/2 == sqrt(sum((PT - PS_assist).^2)); 52 | eqn3 = fdc == -2*(sum(VS_main.*(PS_main - PT)))/lambda/R0_main; 53 | 54 | eqns = [eqn1 eqn2 eqn3]; 55 | ANS = solve(eqns, PT); 56 | ANS = struct2cell(ANS); 57 | 58 | %% choose the closest answer from PT0 59 | PT = zeros(1, 3); 60 | curPT = zeros(1, 3); 61 | ClosestDistFromPT0 = intmax('int64'); 62 | 63 | N = length(ANS{1}); 64 | for kk = 1 : N 65 | for ii = 1 : 3 66 | curPT(ii) = eval(ANS{ii}(kk)); 67 | end 68 | dist = sum((curPT - PT0).^2); 69 | if dist < ClosestDistFromPT0 70 | PT = curPT; 71 | ClosestDistFromPT0 = dist; 72 | end 73 | end 74 | log = sprintf('PT located at [%.2f %.2f %.2f].', PT(1), PT(2), PT(3)); 75 | 76 | disp(log); -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/InterferometricPhaseProcessing/pha.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/InterferometricPhaseProcessing/pha.tif -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/InterferometricPhaseProcessing/定位.txt: -------------------------------------------------------------------------------- 1 | 主图像发射星地固位置(x,y,z)=(1466309.6 -4601880.8 4914932.0) 单位(米) 2 | 主图像发射星地固速度(Vx,Vy,Vz)=(-61.062392 -5620.2862 -5236.1316) 单位(米/秒) 3 | 主图像接收星地固位置(x,y,z)=(1466309.6 -4601880.8 4914932.0) 单位(米) 4 | 主图像接收星地固速度(Vx,Vy,Vz) =(-61.062392 -5620.2862 -5236.1316) 单位(米/秒) 5 | 辅图像发射星地固位置(x,y,z)=(1466309.6 -4601881.1 4914931.6) 单位(米) 6 | 辅图像接收星地固位置(x,y,z)=(1466545.1 -4601144.2 4915020.0) 单位(米) 7 | 主图像多普勒中心频率 fdc= -295.19346Hz 8 | 主图像斜距 R= 1443640.2 米 9 | 辅图像斜距R=1443566.7 米 10 | 波长= 0.031250000 米 11 | 定位初始输入结果(x,y,z)=(884704.82 -4306714.2 4605148.9) 单位(米) 12 | 13 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/InterferometricPhaseProcessing/报告.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/InterferometricPhaseProcessing/报告.pdf -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/MotionCompensation/createKaiserWin.m: -------------------------------------------------------------------------------- 1 | function win = createKaiserWin(WL, beta, len, center) 2 | im = zeros(len, 1); 3 | im(center) = 1; 4 | win = conv(im, ones(WL, 1), 'same'); 5 | WL = WL + 2*(WL - sum(win)); 6 | factor = kaiser(WL, beta); 7 | win = conv(im, factor, 'same'); 8 | end -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/MotionCompensation/main_basedOnMovement.m: -------------------------------------------------------------------------------- 1 | close all; 2 | %% first order phase compensation 3 | Rref = near_range + Nr/2/Fr*C/2; 4 | alpha = acos(ref_height(1)/Rref); 5 | deltaR = (height - ref_height)*cos(alpha) + cross*sin(alpha); 6 | deltaR_Mat = deltaR'*ones(1, Nr); 7 | S = data.*exp(1j*4*pi*deltaR_Mat/lambda); 8 | 9 | %% range direction resample 10 | fr = linspace(0, Fr, Nr); 11 | fr_Mat = ones(Na, 1)*fr; 12 | phase_a = exp(1j*4*pi*fr_Mat.*deltaR_Mat/C); 13 | S = ifft(fft(S.*phase_a, [], 2), [], 2); 14 | 15 | %% azimuth direction resample 16 | ta = linspace(0, Na - 1, Na)/PRF; 17 | t_moco = time - time(1); 18 | % azimuth direction resample is omited cause 19 | % interval of samples is identical to MOCO 20 | 21 | %% chrip scaling 22 | t = ones(Na, 1)*(linspace(0, Nr - 1, Nr))/Fr; 23 | cell_R0 = near_range + t*C/2; 24 | fdc = 2*Vr*sin_theta/lambda; 25 | Mamb = round(fdc/PRF); 26 | fa = linspace((Mamb - 0.5)*PRF,(Mamb + 0.5)*PRF, Na)'; 27 | fa_Mat = fa*ones(1, Nr); 28 | D = (1 - C^2*fa_Mat.^2/(4*Vr^2*f0^2)).^(1/2); 29 | Km = Kr./(1 - Kr*C*cell_R0.*fa_Mat.^2./(2*Vr^2*f0^3*D.^3)); 30 | fref = fdc; 31 | Dref = (1 - C^2*fref^2/(4*Vr^2*f0^2))^(1/2); 32 | 33 | t_re = 2/C*(cell_R0./Dref - Rref/Dref); 34 | S_cs = exp(1j*pi*Km.*(Dref./D - 1).*t_re.^2); 35 | S_RD = ifftshift(fftshift(fft(data)).*S_cs); 36 | 37 | %% Range Compression 38 | S_2DF = fftshift(fft(S_RD, [], 2), 2); 39 | Hr_match = exp(-1j*pi*D./Km./Dref.*fr_Mat.^2).*exp(1j*4*pi/C*(1./D - 1/Dref).*Rref.*fr_Mat); 40 | S_2DF = ifftshift(S_2DF.*Hr_match, 2); 41 | S_2DT = ifft(ifft(S_2DF, [], 2)); 42 | 43 | %% second order phase compensation 44 | cross_Mat = cross'*ones(1, Nr); 45 | height_Mat = height'*ones(1, Nr); 46 | cell_R0_real = sqrt(((cell_R0.^2 - ref_height(1)^2).^(1/2) - cross_Mat).^2 + height_Mat.^2); 47 | Rref_real = sqrt(((Rref.^2 - ref_height(1)^2).^(1/2) - cross_Mat).^2 + height_Mat.^2); 48 | dR = (cell_R0_real - cell_R0) - (Rref_real - Rref); 49 | S_2DT = S_2DT.*exp(1j*4*pi*dR/lambda); 50 | 51 | %% Azimuth Conpression 52 | S_RD = fftshift(ifft(S_2DT)); 53 | 54 | Ha_size = Na/2; winBeta = 2.5; 55 | Ha_match = exp(1j*4*pi*cell_R0.*D*f0/C).*... 56 | exp(1j*4*pi*Km/C^2.*(1 - D/Dref).*(cell_R0./D - Rref./D).^2); 57 | center = find(fa >= fdc, 1); 58 | Ha_win = createKaiserWin(Ha_size, winBeta, Na, center); 59 | Ha_win = Ha_win*ones(1, Nr); 60 | Ha_match = Ha_match.*Ha_win; 61 | Sout = ifft(ifftshift(Ha_match.*S_RD)); 62 | colormap jet 63 | imagesc(abs(Sout)); 64 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/MotionCompensation/readdata.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/MotionCompensation/readdata.m -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/AGC_attenuation_values.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/RD&CS/AGC_attenuation_values.mat -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/CD_run_params.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/RD&CS/CD_run_params.mat -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/CSA_main.m: -------------------------------------------------------------------------------- 1 | %% load SAR data from CD 2 | clear, format compact 3 | set( 0, 'DefaultTextFontSize', 12 ) % Plotting defaults 4 | set( 0, 'DefaultLineLineWidth', 1.5 ) 5 | set( 0, 'DefaultAxesFontSize', 8 ) 6 | load CD_run_params 7 | block = 1; 8 | file_pre = strcat( output_path, output_prefix, '_', num2str(block) ); 9 | 10 | disp ' ' 11 | disp (['Load or Extract AGC setting and Data for block ' num2str(block) ]) 12 | % Load a block of 'AGC_values' 13 | AGC_values = load_AGC_block( file_pre, first_rg_line, ... 14 | Nrg_lines_blk, block , UseMATfiles ); 15 | 16 | % Load a block of raw SAR data 17 | data = load_DATA_block( file_pre, output_path, Nrg_lines_blk, ... 18 | Nrg_cells, AGC_values, block, UseMATfiles ); 19 | 20 | 21 | %% CS simulation 22 | 23 | %% init SAR paramenters 24 | SAR.f0 = f0; 25 | SAR.lambda = c/SAR.f0; 26 | SAR.Kr = Kr; 27 | SAR.R0 = R0; 28 | SAR.Nrg_cells = Nrg_cells; 29 | SAR.Nrg_lines = Nrg_lines_blk; 30 | SAR.Vr = 7062; 31 | SAR.PRF = PRF; 32 | SAR.Fr = Fr; 33 | SAR.Tr = Tr; 34 | SAR.C = 299790000; 35 | SAR.t_start = 0.0065956; 36 | SAR.fdc = -6900; 37 | SAR.Ka = 1733; 38 | SAR.Mamb = round(SAR.fdc/SAR.PRF); 39 | SAR.winBeta = 2.5; 40 | SAR.Ha_size = 705; 41 | SAR.Hr_size = round(SAR.Tr*SAR.Fr); 42 | 43 | %% chrip scaling 44 | t = ones(SAR.Nrg_lines, 1)*(linspace(0, SAR.Nrg_cells - 1, SAR.Nrg_cells))/SAR.Fr; 45 | cell_R0 = (t + SAR.t_start)*SAR.C/2; 46 | 47 | f_az = linspace((SAR.Mamb - 0.5)*SAR.PRF,(SAR.Mamb + 0.5)*SAR.PRF, SAR.Nrg_lines)'; 48 | f_az = f_az*ones(1, SAR.Nrg_cells); 49 | D = (1 - SAR.C^2*f_az.^2/(4*SAR.Vr^2*SAR.f0^2)).^(1/2); 50 | Km = SAR.Kr./(1 - SAR.Kr*SAR.C*cell_R0.*f_az.^2./(2*SAR.Vr^2*SAR.f0^3*D.^3)); 51 | f_ref = SAR.fdc; 52 | Dref = (1 - SAR.C^2*f_ref^2/(4*SAR.Vr^2*SAR.f0^2))^(1/2); 53 | Rref = (SAR.t_start + SAR.Nrg_cells/2/SAR.Fr)*SAR.C/2; 54 | t_re = 2/SAR.C*(cell_R0./Dref - Rref/Dref); 55 | S_sc = exp(1j*pi*Km.*(Dref./D - 1).*t_re.^2); 56 | S = ifftshift(fftshift(fft(data)).*S_sc); 57 | 58 | %% Range Compression 59 | S_2DF = fftshift(fft(S, [], 2), 2); 60 | f_rg = linspace(0, 1, SAR.Nrg_cells)*SAR.Fr - SAR.Fr/2; 61 | f_rg = ones(SAR.Nrg_lines, 1)*f_rg; 62 | 63 | Hr_match = exp(-1j*pi*D./Km./Dref.*f_rg.^2).*exp(1j*4*pi/SAR.C*(1./D - 1/Dref).*Rref.*f_rg); 64 | S_2DF = ifftshift(S_2DF.*Hr_match, 2); 65 | 66 | %% Azimuth Conpression 67 | S_RD = ifftshift(ifft(S_2DF, [], 2)); 68 | Ha_match = exp(1j*4*pi*cell_R0.*D*SAR.f0/SAR.C).*... 69 | exp(1j*4*pi*Km/SAR.C^2.*(1 - D/Dref).*(cell_R0./D - Rref./D).^2); 70 | center = find(f_az >= SAR.fdc, 1); 71 | Ha_win = createKaiserWin(SAR.Ha_size, SAR.winBeta, SAR.Nrg_lines,center); 72 | Ha_win = Ha_win*ones(1, SAR.Nrg_cells); 73 | Ha_match = Ha_match.*Ha_win; 74 | Sout = ifft(ifftshift(Ha_match.*S_RD)); 75 | colormap jet 76 | imagesc(abs(Sout)); 77 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/RADARSAT_RDA_Imaging.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/SAR信号与图像处理/RD&CS/RADARSAT_RDA_Imaging.m -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/RDA_main.m: -------------------------------------------------------------------------------- 1 | %% load SAR data from CD 2 | clear, format compact 3 | set( 0, 'DefaultTextFontSize', 12 ) % Plotting defaults 4 | set( 0, 'DefaultLineLineWidth', 1.5 ) 5 | set( 0, 'DefaultAxesFontSize', 8 ) 6 | load CD_run_params 7 | block = 1; 8 | file_pre = strcat( output_path, output_prefix, '_', num2str(block) ); 9 | 10 | disp ' ' 11 | disp (['Load or Extract AGC setting and Data for block ' num2str(block) ]) 12 | % Load a block of 'AGC_values' 13 | AGC_values = load_AGC_block( file_pre, first_rg_line, ... 14 | Nrg_lines_blk, block , UseMATfiles ); 15 | 16 | % Load a block of raw SAR data 17 | data = load_DATA_block( file_pre, output_path, Nrg_lines_blk, ... 18 | Nrg_cells, AGC_values, block, UseMATfiles ); 19 | 20 | 21 | %% RD simulation 22 | 23 | %% init SAR paramenters 24 | SAR.f0 = f0; 25 | SAR.lambda = c/SAR.f0; 26 | SAR.Kr = Kr; 27 | SAR.R0 = R0; 28 | SAR.Nrg_cells = Nrg_cells; 29 | SAR.Nrg_lines = Nrg_lines_blk; 30 | SAR.Vr = 7062; 31 | SAR.PRF = PRF; 32 | SAR.Fr = Fr; 33 | SAR.Tr = Tr; 34 | SAR.C = 299790000; 35 | SAR.t_start = 0.0065956; 36 | SAR.fdc = -6900; 37 | SAR.Ka = 1733; 38 | SAR.Mamb = round(SAR.fdc/SAR.PRF); 39 | SAR.winBeta = 2.5; 40 | SAR.Ha_size = 705; 41 | SAR.Hr_size = round(SAR.Tr*SAR.Fr); 42 | 43 | %% Range Compression 44 | f_rg = linspace(0, 1, SAR.Nrg_cells)*SAR.Fr - SAR.Fr/2; 45 | Ksrc = 2*SAR.Vr^2*SAR.f0^3*(sqrt(1 - SAR.lambda^2*SAR.fdc^2/4/SAR.Vr^2)^3)... 46 | /(SAR.C*SAR.R0.*SAR.fdc.^2); 47 | Km = SAR.Kr./(1 - SAR.Kr./Ksrc); 48 | Hr_win = createKaiserWin(SAR.Hr_size, SAR.winBeta, SAR.Nrg_cells, round(SAR.Nrg_cells/2)); 49 | Hr_match = exp(-1j*pi.*f_rg.^2/Km); 50 | Hr_match = Hr_match.*Hr_win'; 51 | Hr_match = ones(SAR.Nrg_lines, 1)*Hr_match; 52 | S_RC = ifft(ifftshift(fftshift(fft(data, [], 2), 2).*Hr_match, 2), [], 2); 53 | 54 | %% RCMC 55 | S_RC_RD = fft(S_RC); 56 | f_az = linspace((SAR.Mamb - 0.5)*SAR.PRF,(SAR.Mamb + 0.5)*SAR.PRF, SAR.Nrg_lines)'; 57 | D = (1 - SAR.lambda^2*f_az.^2/4/SAR.Vr^2).^(1/2); 58 | D = D*ones(1, SAR.Nrg_cells); 59 | 60 | t = ones(SAR.Nrg_lines, 1)*(linspace(0, SAR.Nrg_cells - 1, SAR.Nrg_cells))/SAR.Fr; 61 | cell_R0 = (t + SAR.t_start)*SAR.C/2; 62 | deltaR = ((1 - D)./D).*cell_R0; 63 | deltaTau = deltaR*2/SAR.C; 64 | 65 | % build interpolation kernals table 66 | interK.oversampleRate = 8; 67 | interK.spacing = 1/interK.oversampleRate; 68 | interK.n = 8; 69 | interK.beta = 2.5; 70 | interK.factor = zeros(interK.oversampleRate, interK.n); 71 | timeSeq = [-4:1:3]; 72 | 73 | 74 | for kk = 1 : interK.oversampleRate 75 | timeSeq = timeSeq - interK.spacing; 76 | interK.factor(kk, :) = sinc(timeSeq).*kaiser(interK.n, interK.beta)'; 77 | Norm = sqrt(sum(interK.factor(kk, :).^2)); 78 | interK.factor(kk, :) = interK.factor(kk, :)/Norm; 79 | end 80 | 81 | % sinc interpolation 82 | S_RCMC = zeros(SAR.Nrg_lines, SAR.Nrg_cells); 83 | for kaz = 1 : SAR.Nrg_lines 84 | for krg = 1 : SAR.Nrg_cells 85 | % quantify deltaR 86 | tau = t(kaz, krg) + deltaTau(kaz, krg); 87 | % choose interpolation factors index 88 | quantK = round(mod(tau, 1/SAR.Fr)/interK.spacing*SAR.Fr); 89 | 90 | if quantK == 0 91 | quantK = interK.oversampleRate; 92 | end 93 | 94 | val = zeros(interK.n, 1); 95 | ktauL = ceil(tau*SAR.Fr); 96 | ktauR = ktauL + 1; 97 | % decrease one to use mod operation and 98 | % get cyclical interK.n values of S_RC_RC 99 | ktauL = ktauL - 1; 100 | ktauR = ktauR - 1; 101 | kL = floor(interK.n/2); kR = kL + 1; 102 | while kL > 0 103 | ktauL = mod(ktauL + SAR.Nrg_cells, SAR.Nrg_cells); 104 | val(kL) = S_RC_RD(kaz, ktauL + 1); 105 | kL = kL - 1; 106 | ktauL = ktauL - 1; 107 | end 108 | while kR <= interK.n 109 | ktauR = mod(ktauR, SAR.Nrg_cells); 110 | val(kR) = S_RC_RD(kaz, ktauR + 1); 111 | kR = kR + 1; 112 | ktauR = ktauR + 1; 113 | end 114 | S_RCMC(kaz, krg) = interK.factor(quantK, :)*val; 115 | end 116 | end 117 | 118 | 119 | %% azimuth direction compression 120 | center = find(f_az >= SAR.fdc, 1); 121 | Ha_win = createKaiserWin(SAR.Ha_size, SAR.winBeta, SAR.Nrg_lines,center); 122 | Ha_win = Ha_win*ones(1, SAR.Nrg_cells); 123 | Ha_match = exp(1j*4*pi*cell_R0.*D*SAR.f0/SAR.C); 124 | % Ha_match = exp(-1j*pi*f_az.^2/SAR.Ka)*ones(1, SAR.Nrg_cells); 125 | Ha_match = Ha_match.*Ha_win; 126 | Sout = ifft(ifftshift(Ha_match.*fftshift(S_RCMC))); 127 | imagesc(abs(Sout)); 128 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/computeAzSpectra.m: -------------------------------------------------------------------------------- 1 | function computeAzSpectra(data, SAR) 2 | %% compute azimuth spectra 3 | set( 0, 'DefaultTextFontSize', 12 ) % Plotting defaults 4 | set( 0, 'DefaultLineLineWidth', 1.5 ) 5 | set( 0, 'DefaultAxesFontSize', 8 ) 6 | lfs = 11; 7 | 8 | disp ' ' 9 | disp '---------------------------------------------------------' 10 | fprintf(' UBC RRSG - Plot the azimuth spectrum of each data block') 11 | disp ' ' 12 | disp '---------------------------------------------------------' 13 | 14 | Nrowsg = 3; % Number of subplots in row direction of the figure 15 | Ncolsg = 3; % Number of subplots in column direction of the figure 16 | Nspect = Nrowsg*Ncolsg; % Total number of spectra to calculate 17 | Nrglpb = floor( SAR.Nrg_cells/Nspect ); % No. of range cells per spectra 18 | wd = 0.81/Ncolsg; dx = wd + 0.045; x0 = 0.07; 19 | ht = 0.39/Nrowsg; dy = 0.28; y0 = 1-dy; 20 | 21 | %% test azimuth spectra 22 | disp 'Compute and plot azimuth power spectra' 23 | tic 24 | figure(202), clf 25 | freq = [0:SAR.Nrg_lines-1]*SAR.PRF/SAR.Nrg_lines-1; 26 | 27 | % Find azimuth power spectra and average 28 | ysc = zeros(Nspect, 1); 29 | DATA_aver = zeros(Nspect, SAR.Nrg_lines); 30 | for krg = 1 : Nspect 31 | r1 = 1 + (krg-1)*Nrglpb; r2 = r1 + Nrglpb - 1; 32 | DATA = fft( data(:,r1:r2) ); % azimuth direction fft 33 | DATA_aver(krg,:) = mean( abs(DATA.').^2 )/1000000; 34 | ysc(krg) = 1.05*max(DATA_aver(krg,:)); 35 | end % of for krg = 1 : Nspect 36 | ysc0 = max( ysc ); % Common vertical scaling for all the spectra 37 | 38 | Ffrac = zeros(Nspect, 1); 39 | for krg = 1 : Nspect 40 | subplot(Nrowsg, Ncolsg, krg) 41 | plot( freq, DATA_aver(krg,:) ), grid, hold on 42 | set( gca, 'Pos',... 43 | [x0+dx*mod((krg-1),Ncolsg) y0-dy*floor((krg-1)/Ncolsg) wd ht]) 44 | axis([0 SAR.PRF 0 ysc0]); 45 | 46 | azim_spec = fft( DATA_aver(krg,:) )/ SAR.Nrg_lines;% azimuth 47 | angle_first_harmonic = -angle( azim_spec(2) ); 48 | Ffrac(krg) = SAR.PRF * angle_first_harmonic / (2*pi); 49 | if Ffrac(krg) < 0, Ffrac(krg) = Ffrac(krg) + SAR.PRF; end 50 | sine_fit = real(azim_spec(2)) * cos(2*pi*freq/SAR.PRF) - ... 51 | imag(azim_spec(2)) * sin(2*pi*freq/SAR.PRF) + 0.5*azim_spec(1); 52 | plot( freq, 2*sine_fit, 'r--' ) 53 | 54 | if krg > Nspect - Ncolsg 55 | xlabel('Azimuth frequency (Hz) \rightarrow', 'FontSize', lfs ) 56 | end 57 | if mod(krg,Ncolsg) == 1 58 | ylabel('Power \rightarrow', 'FontSize', lfs ) 59 | end 60 | end 61 | end 62 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/compute_azim_spectra.m: -------------------------------------------------------------------------------- 1 | % compute_azim_spectra.m 2 | % ---------------------- 3 | % 4 | % Divides the range swath (range cells) of this block into Nspect sections 5 | % and finds the average power spectrum for each segment. 6 | % 7 | % Fits a parabola to the baseband Doppler centroid vs. range 8 | % This fit is most useful if the whole range swath is selected, but the 9 | % computing times get large if more than 1024 range lines (azimuth cells) 10 | % are selected in one run. 11 | % 12 | % Run "specify_run_parameters.m" and "extract_data.m" first to extract 13 | % the data from the CD. The data can be stored in MAT or binary files. 14 | % ------------------------------------------------------------------------- 15 | 16 | % Load the parameters for this run 17 | clear, format compact 18 | set( 0, 'DefaultTextFontSize', 12 ) % Plotting defaults 19 | set( 0, 'DefaultLineLineWidth', 1.5 ) 20 | set( 0, 'DefaultAxesFontSize', 8 ) 21 | tfs = 13; lfs = 11; 22 | load CD_run_params 23 | 24 | disp ' ' 25 | disp '---------------------------------------------------------' 26 | fprintf(' UBC RRSG - Plot the azimuth spectrum of each data block') 27 | disp ' ' 28 | disp '---------------------------------------------------------' 29 | 30 | Nrowsg = 3; % Number of subplots in row direction of the figure 31 | Ncolsg = 3; % Number of subplots in column direction of the figure 32 | Nspect = Nrowsg*Ncolsg; % Total number of spectra to calculate 33 | Nrglpb = floor( Nrg_cells/Nspect ); % No. of range cells per spectra 34 | wd = 0.81/Ncolsg; dx = wd + 0.045; x0 = 0.07; 35 | ht = 0.39/Nrowsg; dy = 0.28; y0 = 1-dy; 36 | 37 | for b = 1 : Nblocks 38 | 39 | file_pre = strcat( output_path, output_prefix, '_', num2str(b) ); 40 | 41 | disp ' ' 42 | disp (['Load or Extract AGC setting and Data for block ' num2str(b) ]) 43 | % Load a block of 'AGC_values' 44 | AGC_values = load_AGC_block( file_pre, first_rg_line, ... 45 | Nrg_lines_blk, b , UseMATfiles ); 46 | 47 | % Load a block of raw SAR data 48 | data = load_DATA_block( file_pre, output_path, Nrg_lines_blk, ... 49 | Nrg_cells, AGC_values, b, UseMATfiles ); 50 | 51 | disp 'Compute and plot azimuth power spectra' 52 | tic 53 | figure(202), clf 54 | freq = [0:Nrg_lines_blk-1]*PRF/Nrg_lines_blk; 55 | b1 = first_rg_line + (b-1) * Nrg_lines_blk; 56 | b2 = first_rg_line + b * Nrg_lines_blk - 1; 57 | 58 | % Find azimuth power spectra and average 59 | for krg = 1 : Nspect 60 | r1 = 1 + (krg-1)*Nrglpb; r2 = r1 + Nrglpb - 1; 61 | DATA = fft( data(:,r1:r2) ); % azimuth direction fft 62 | DATA_aver(krg,:) = mean( abs(DATA.').^2 )/1000000; 63 | ysc(krg) = 1.05*max(DATA_aver(krg,:)); 64 | end % of for krg = 1 : Nspect 65 | ysc0 = max( ysc ); % Common vertical scaling for all the spectra 66 | 67 | % Plot the azimuth spectrum 68 | 69 | for krg = 1 : Nspect 70 | subplot(Nrowsg, Ncolsg, krg) 71 | plot( freq, DATA_aver(krg,:) ), grid, hold on 72 | set( gca, 'Pos',... 73 | [x0+dx*mod((krg-1),Ncolsg) y0-dy*floor((krg-1)/Ncolsg) wd ht]) 74 | axis([0 PRF 0 ysc0]); 75 | 76 | azim_spec = fft( DATA_aver(krg,:) )/ Nrg_lines_blk;% azimuth 77 | angle_first_harmonic = -angle( azim_spec(2) ); 78 | Ffrac(krg) = PRF * angle_first_harmonic / (2*pi); 79 | if Ffrac(krg) < 0, Ffrac(krg) = Ffrac(krg) + PRF; end 80 | sine_fit = real(azim_spec(2)) * cos(2*pi*freq/PRF) - ... 81 | imag(azim_spec(2)) * sin(2*pi*freq/PRF) + 0.5*azim_spec(1); 82 | plot( freq, 2*sine_fit, 'r--' ) 83 | 84 | r1 = 1 + (krg-1)*Nrglpb; r2 = r1 + Nrglpb - 1; 85 | title(sprintf('RC %4d - %4d Fdc =%6.0f',... 86 | r1+first_rg_cell-1, r2+first_rg_cell-1, Ffrac(krg) ), ... 87 | 'FontSize', lfs ); 88 | if krg > Nspect - Ncolsg 89 | xlabel('Azimuth frequency (Hz) \rightarrow', 'FontSize', lfs ) 90 | end 91 | if mod(krg,Ncolsg) == 1 92 | ylabel('Power \rightarrow', 'FontSize', lfs ) 93 | end 94 | if krg == 1 95 | text( 1.55*PRF, 1.7*double(ysc0), sprintf(... 96 | 'Azimuth power spectra of range lines%6.0f to%6.0f and sine fit',... 97 | first_rg_line+(b-1)*Nrg_lines_blk, first_rg_line+b*Nrg_lines_blk-1 ),... 98 | 'Hor', 'center', 'FontSize', tfs ) 99 | end 100 | pause(0.1) 101 | end % of for krg = 1 : Nspect 102 | toc 103 | 104 | % Plot Ffrac vs. range 105 | 106 | figure(203), clf 107 | plot( Ffrac, 'bx-', 'MarkerS', 9 ), grid, hold on 108 | eval(['save Ffrac_' num2str(first_rg_line) ' Ffrac']) 109 | axis([0.5 Nspect+0.5 200 800]) 110 | xlabel('Range swath number', 'FontSize', lfs+1 ) 111 | ylabel('Frequency (Hz)', 'FontSize', lfs+1 ) 112 | title(sprintf(... 113 | 'Baseband Doppler centroid over%5.0f lines starting at%6.0f',... 114 | Nrg_lines_blk, first_rg_line+(b-1)*Nrg_lines_blk ), 'FontSize', tfs ) 115 | 116 | coeff = polyfit( [1:Nspect], Ffrac, 2 ); 117 | Fit = polyval( coeff, [1:Nspect] ); 118 | plot( Fit, 'r-' ) 119 | text( 0.79*Nspect, 750, sprintf('C_2 =%6.2f', coeff(1) ), 'FontSize',13 ) 120 | text( 0.79*Nspect, 650, sprintf('C_1 =%7.1f', coeff(2) ), 'FontSize',13 ) 121 | text( 0.79*Nspect, 550, sprintf('C_0 =%5.0f', coeff(3) ), 'FontSize',13 ) 122 | text( 0.13*Nspect, 250, sprintf(... 123 | 'Range cells %3.0f to %4.0f', first_rg_cell, ... 124 | first_rg_cell+Nrg_cells-1 ), 'FontSize',13 ) 125 | pause(0.1) 126 | % Save the plot as .eps file 127 | % file_eps=strcat(output_path,output_prefix,'azimuth_',num2str(b),'.eps') 128 | % saveas(gcf,file_eps,eps) 129 | end % of for b = 1 : Nblocks 130 | beep, pause(0.3), beep, pause(0.3), beep -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/createKaiserWin.m: -------------------------------------------------------------------------------- 1 | function win = createKaiserWin(WL, beta, len, center) 2 | im = zeros(len, 1); 3 | im(center) = 1; 4 | win = conv(im, ones(WL, 1), 'same'); 5 | WL = WL + 2*(WL - sum(win)); 6 | factor = kaiser(WL, beta); 7 | win = conv(im, factor, 'same'); 8 | end -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/extract_AGC.m: -------------------------------------------------------------------------------- 1 | function [AGC_atten_dB] = extract_AGC( file_in, Nlines ) 2 | % 3 | % ------------------------------------------------------------------------- 4 | % This program reads the RADARSAT aux data and calculates the AGC settings 5 | % ------------------------------------------------------------------------- 6 | % file_in : input file name including it's path 7 | % Nlines : number of azimuth lines 8 | % AGC_atten_dB : Receiver attenuation in dB for each range line 9 | % ------------------------------------------------------------------------- 10 | % Created : May 05, 2004 by Kaan Ersahin & Millie Sikdar 11 | % Modified : Nov 22, 2004 by Kaan Ersahin 12 | % ------------------------------------------------------------------------- 13 | 14 | 15 | % The parameters encoded in the auxilary data bits are defined in RSI-D6 16 | % also known as RSCSA-IC0009 (X-band ICD) 17 | % ------------------------------------------------------------------------- 18 | % PARAMETER NAME LOCATION LENGTH ID 19 | % ------------------------------------------------------------------------- 20 | % aux_sync_marker = aux_bits (:, 1: 32); % 32 bit - 1 21 | % image_ref_id = aux_bits (:, 33: 64); % 32 bit - 2 22 | % payload_status = aux_bits (:, 65: 80); % 16 bit - 3 23 | % replica_AGC = aux_bits (:, 81: 86); % 6 bit - 4 24 | % CALN_atten_LPT_pow_set = aux_bits (:, 89: 96); % 8 bit - 6 25 | % pulse_waveform_number = aux_bits (:, 97: 100); % 4 bit - 7 26 | % temperature = aux_bits (:, 113: 144); % 32 bit - 9 27 | % beam_sequence = aux_bits (:, 145: 160); % 16 bit - 10 28 | % ephemeris = aux_bits (:, 161: 176); % 16 bit - 11 29 | % number_of_beams = aux_bits (:, 177: 178); % 2 bit - 12 30 | % ADC_rate = aux_bits (:, 179: 180); % 2 bit - 13 31 | % pulse_count_1 = aux_bits (:, 185: 192); % 8 bit - 15 32 | % pulse_count_2 = aux_bits (:, 193: 200); % 8 bit - 16 33 | % PRF_beam = aux_bits (:, 201: 213); % 13 bit - 17 34 | % beam_select = aux_bits (:, 214: 215); % 2 bit - 18 35 | % Rx_window_start_time = aux_bits (:, 217: 228); % 12 bit - 20 36 | % Rx_window_duration = aux_bits (:, 233: 244); % 12 bit - 22 37 | % altitude = aux_bits (:, 249: 344); % 96 bit - 24 38 | % time = aux_bits (:, 345: 392); % 48 bit - 25 39 | % SC_T02_defaults = aux_bits (:, 393: 393); % 1 bit - 26 40 | % first_replica = aux_bits (:, 394: 394); % 1 bit - 27 41 | % Rx_AGC_setting = aux_bits (:, 395: 400); % 6 bit - 28 42 | % ------------------------------------------------------------------------- 43 | % Total => 50 bytes (400 bits) 44 | % ------------------------------------------------------------------------- 45 | 46 | 47 | 48 | % ------------------------------------------------------------------------- 49 | % read the binary aux data file 50 | % ------------------------------------------------------------------------- 51 | file_in 52 | fid_aux = fopen(file_in,'r'); 53 | aux_bytes = fread(fid_aux,[50, Nlines],'uint8'); 54 | aux_bytes = aux_bytes'; 55 | fclose(fid_aux); 56 | 57 | aux_bits = char(zeros(Nlines,400)); 58 | % ------------------------------------------------------------------------- 59 | % convert 50 bytes to 400 bits in general (it is only done for 50th byte) 60 | % ------------------------------------------------------------------------- 61 | for byte = 50:50 %1:50 %% in general 62 | aux_bits(:,8*(byte-1)+1:8*byte) = num2str(dec2bin(aux_bytes(:,byte),8)); 63 | end 64 | % ------------------------------------------------------------------------- 65 | % Convert last 6 bits from binary to decimal 66 | % ------------------------------------------------------------------------- 67 | d_Rx_AGC = bin2dec( aux_bits (:, 395: 400) ); 68 | 69 | % ------------------------------------------------------------------------- 70 | % For values greater than 31, the binary representation defined in the 71 | % documentation is different and there is the need to substract 24 from 72 | % decimal values to get the AGC setting in dB 73 | % ------------------------------------------------------------------------- 74 | AGC_atten_dB = d_Rx_AGC - ( 24 * (d_Rx_AGC > 31)); 75 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/extract_data.m: -------------------------------------------------------------------------------- 1 | % extract_data.m 2 | % -------------- 3 | % This program extracts the raw signal data from the CD included in the 4 | % Cumming/Wong book. The data on CD are in CEOS format. 5 | % It is assumed that the run parameters are stored in CD_run_params.mat 6 | % in the current directory. 7 | % Run "specify_run_parameters.m" first to create this file. 8 | % ------------------------------------------------------------------------- 9 | % Created : Nov 01, 2004 by Kaan Ersahin 10 | % Modified: Nov 22, 2004 by Kaan Ersahin 11 | % Modified: Dec 3, 2004 by Ian Cumming 12 | % - changed function to m-file 13 | % - fixed the parameter file name 14 | % - added more radar parameters 15 | % ------------------------------------------------------------------------- 16 | 17 | clear, home, format compact 18 | 19 | % Load the input parameters from a matlab data file 20 | load CD_run_params 21 | 22 | disp ' ' 23 | disp '------------------------------------------------' 24 | disp ' UBC RRSG - CEOS Reader for RADARSAT-1 RAW DATA' 25 | disp '------------------------------------------------' 26 | disp ' ' 27 | 28 | % ------------------------------------------------------------------------- 29 | % Quantize the range line limits and block size, if necessary 30 | % ------------------------------------------------------------------------- 31 | 32 | % Move the first range line to the beginning of an 8-line block 33 | first_rg_line = 8 * ( ceil(first_rg_line / 8) - 1 ) + 1; 34 | 35 | % Make 'Nrg_lines_blk' a multiple of 8, to get complete the 8-line blocks 36 | Nrg_lines_blk = 8 * ceil(Nrg_lines_blk / 8); 37 | 38 | % Find the number of complete blocks required to cover the area of interest 39 | Nblocks = ceil(Nrg_lines / Nrg_lines_blk); 40 | 41 | % Make 'Nrg_lines' a multiple of 'Nblocks', to get complete blocks 42 | Nrg_lines = Nrg_lines_blk * Nblocks; 43 | 44 | % ========================================================================= 45 | % These values are specific to the data set, DO NOT CHANGE for this CD 46 | % ========================================================================= 47 | 48 | length_replica = 2880; % Total length (I&Q) of replica record 49 | tot_Nrg_cells = 9288; % Total number of range cells per line 50 | tot_Nrg_lines = 19432; % Total number of range lines (records) 51 | first_replica = 7; % First record that contains the replica 52 | PRF = 1256.98; % Pulse Reputation Frequency (Hz) 53 | Fr = 32.317e+6; % Radar sampling rate (Hz) 54 | f0 = 5.300e+9; % Radar center frequency (Hz) 55 | c = 2.9979e+8; % Speed of light (m/s) 56 | R0 = 0.0065956*c/2; % Slant range of first radar sample (m) 57 | Nrepl = 1349; % No. of valid samples in the replica 58 | Kr = 0.72135e+12; % FM rate of radar pulse (Hz/s) 59 | Tr = 41.75e-6; % Chirp duration (s) 60 | 61 | % ------------------------------------------------------------------------- 62 | % Save parameters in a MAT file that can be used by subsequent programs 63 | 64 | if SaveV6, save -v6 CD_run_params 65 | else, save CD_run_params, end 66 | % ------------------------------------------------------------------------- 67 | 68 | fprintf('Total number of range lines : %5d \n', tot_Nrg_lines ) 69 | fprintf('Total number of range cells : %5d \n', tot_Nrg_cells ) 70 | fprintf('First range cell to be extracted : %5d \n', first_rg_cell ) 71 | fprintf('First range line to be extracted : %5d \n', first_rg_line ) 72 | fprintf('Number of range cells : %5d \n', Nrg_cells ) 73 | fprintf('Number of range lines : %5d \n', Nrg_lines ) 74 | fprintf('Number of range lines per block : %5d \n', Nrg_lines_blk ) 75 | fprintf('Number of blocks : %5d \n', Nblocks ) 76 | disp ' ' 77 | disp '------------------------------------------------' 78 | 79 | % ------------------------------------------------------------------------- 80 | % Check the dimensions of the selected area to be processed. 81 | % ------------------------------------------------------------------------- 82 | 83 | if (first_rg_line <= 0) | ((first_rg_line + Nrg_lines - 1) > tot_Nrg_lines) 84 | disp ' ', disp '*****************************************************' 85 | disp ' ERROR: Check the limits of the range lines !', beep, return 86 | end 87 | if (first_rg_cell <= 0) | ((first_rg_cell + Nrg_cells - 1) > tot_Nrg_cells) 88 | disp ' ', disp '*****************************************************' 89 | disp ' ERROR: Check the limits of the range cells !', beep, return 90 | end 91 | 92 | % ------------------------------------------------------------------------- 93 | % EXTRACT DATA from the area of interest and write data files 94 | % ------------------------------------------------------------------------- 95 | 96 | for blk = 1 : Nblocks 97 | % find the first range line of block 'blk' 98 | start_line_blk = Nrg_lines_blk * (blk-1) + first_rg_line; 99 | fprintf('\nExtracting block number%3.0f, RC1 =%5.0f, RL1 =%6.0f\n',... 100 | blk, first_rg_cell, start_line_blk ) 101 | 102 | % create the output file name for block 'blk' 103 | output_file_pre = strcat(output_path,output_prefix,'_',num2str(blk)); 104 | 105 | % Call 'read_ceos_raw' function to extract the data for block 'blk' 106 | read_CEOS_raw( output_file_pre, start_line_blk, blk ); 107 | 108 | end % of the 'blk' for loop 109 | 110 | beep, pause(0.3), beep 111 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/load_AGC_block.m: -------------------------------------------------------------------------------- 1 | function [AGC_atten_dB] = load_AGC_block( file_pre, first_rg_line, ... 2 | Nrg_lines_blk, block, UseMATfiles ) 3 | % 4 | % ------------------------------------------------------------------------- 5 | % This program returns the RADARSAT-1 receiver attenuation values for 6 | % one block. They are integers from 2 to 17, in 1 dB steps. 7 | % ------------------------------------------------------------------------- 8 | % file_pre : File prefix ( path + prefix + block number) 9 | % first_rg_line : First range line for the extracted data 10 | % Nrg_lines_blk : Number of range lines in a block 11 | % block : the current block number 12 | % UseMATfiles : (0) using extract_AGC and the '_aux.dat' file 13 | % (1) load 'AGC_attenuation_values.mat', 14 | % which has the AGC values for every range line. 15 | % ------------------------------------------------------------------------- 16 | % Created: Nov 01, 2004 by Kaan Ersahin 17 | % Modified: Nov 29, 2004 by Kaan Ersahin 18 | % Modified: Dec 13, 2004 by Ian Cumming 19 | % - added UseMATfiles option 20 | % ------------------------------------------------------------------------- 21 | 22 | if UseMATfiles == 0 % extract AGC values from binary aux data file 23 | 24 | file_in = strcat(file_pre, '_aux.dat'); 25 | tic 26 | AGC_atten_dB = extract_AGC( file_in, Nrg_lines_blk ); 27 | toc 28 | 29 | elseif UseMATfiles == 1 % load all AGC values from .mat file 30 | tic 31 | file_in = 'AGC_attenuation_values.mat' 32 | load( file_in ) 33 | 34 | first = first_rg_line + (Nrg_lines_blk * (block-1)); 35 | last = first + Nrg_lines_blk - 1; 36 | AGC_atten_dB = nom_attenuation( first : last ); 37 | toc 38 | end 39 | 40 | % Use check sum to verify read operation 41 | % lenAGC = length(AGC_atten_dB); 42 | % multfac = ([1:lenAGC] - lenAGC/2)'; 43 | % checksumAGC = sum( multfac .* AGC_atten_dB ); 44 | % fprintf('\nCheck sum of AGC values:%10.0f\n', checksumAGC ) 45 | 46 | figure(201), clf % Plot AGC values 47 | plot( AGC_atten_dB ), grid 48 | axis([-9 length(AGC_atten_dB)+10 0.5 17.5]) 49 | xlabel('Azimuth (sample no. within this block) \rightarrow', 'FontSize', 12 ) 50 | ylabel('Magnitude (dB) \rightarrow', 'FontSize', 12 ) 51 | title('AGC attenuation values for this block of data', 'FontSize', 13 ) 52 | % text( lenAGC/2, 1.6, sprintf(... 53 | % '\nCheck sum of AGC values:%10.0f\n', checksumAGC ), 'Hor', 'c' ) 54 | pause(0.1) -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/load_DATA_block.m: -------------------------------------------------------------------------------- 1 | function [data] = load_DATA_block( file_pre, output_path, ... 2 | Nrg_lines_blk, Nrg_cells, AGC_atten_dB, block, UseMATfiles ) 3 | % 4 | % This program - reads /loads data for a block 5 | % - converts to floating point 6 | % - compansates for the receiver attenuation 7 | % ------------------------------------------------------------------------- 8 | % file_pre : File prefix (path + prefix + block number) 9 | % output_path : Path where the SAR data MAT files are stored 10 | % Nrg_lines_blk : Number of range lines in a block 11 | % Nrg_cells : Number of range cells 12 | % AGC_atten_dB : Nominal attenuation (Rx_AGC_setting) for each line (dB) 13 | % block : block number 14 | % UseMATfiles : Data is stored in MAT files 15 | % ------------------------------------------------------------------------- 16 | % Created: Nov 01, 2004 by Kaan Ersahin 17 | % Modified: Nov 29, 2004 by Kaan Ersahin 18 | % Modified: Dec 4, 2004 by Ian Cumming 19 | % - added single precision option for MATLAB 7 20 | % - added UseMATfiles option 21 | % - moved AGC correction to this function 22 | % ------------------------------------------------------------------------- 23 | 24 | vv = version; vers = str2num(vv(1)); % Find MATLAB version 25 | 26 | % Read 4-bit unsigned data as single (MATLAB 7) or double 27 | % The data is stored as [I Q I Q I Q...] 4-bit words 28 | 29 | if UseMATfiles 30 | % fprintf('\nload_DATA_block: from MAT file CDdata%1.0f.mat\n', block ) 31 | disp ' ' 32 | mat_file = strcat( output_path, 'CDdata', num2str(block) ) 33 | load( mat_file ) % The data is already decoded in this case 34 | 35 | else % Use fread to get all the data and parameters 36 | % fprintf('\nload_DATA_block: from binary files\n') 37 | 38 | file_in = strcat( file_pre, '_data.dat' ) 39 | fid2 = fopen( file_in, 'r' ); 40 | if vers < 7 41 | data = fread( fid2, [2*Nrg_cells, Nrg_lines_blk], 'ubit4=>double' ); 42 | else 43 | data = fread( fid2, [2*Nrg_cells, Nrg_lines_blk], 'ubit4=>single' ); 44 | end 45 | data = data'; % Arrange the range lines as rows of the matrix 46 | 47 | % Compensate for packed data format --> convert to signed numbers 48 | data = 2*( data - 16*(data > 7)) + 1; 49 | 50 | % Separate the I and Q channels and make a complex array 51 | data = complex( data(:, 1:2:2*Nrg_cells), data(:, 2:2:2*Nrg_cells) ); 52 | fclose(fid2); 53 | end 54 | 55 | % Apply gain correction to the data. The attenuation varies from 2 to 17 56 | % dB for this CD, so the linear gain factor varies from 1.26 to 7.08. 57 | % If you want to store the decoded data in one byte arrays, use an additional 58 | % factor of 1.5, so that the maximum abs value is less than 127. 59 | fact = 1.5; 60 | if vers < 7 % For MATLAB version 6 61 | linear_gain_factor = double( fact * 10.^(AGC_atten_dB/20) ); 62 | ones_array = ones(1,Nrg_cells); 63 | data = (linear_gain_factor * ones_array) .* double(data); 64 | else % For MATLAB version 7 65 | linear_gain_factor = single( fact * 10.^(AGC_atten_dB/20) ); 66 | ones_array = single(ones(1,Nrg_cells)); 67 | data = (linear_gain_factor * ones_array) .* single(data); 68 | end 69 | -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/read_CEOS_raw.m: -------------------------------------------------------------------------------- 1 | function read_ceos_raw ( output_file_pre, start_line_blk, blk ) 2 | % 3 | % ------------------------------------------------------------------------- 4 | % This function reads the CEOS format RSAT-1 RAW data from the CD 5 | % This function is called by extract_data.m 6 | % ------------------------------------------------------------------------- 7 | % output_file_pre : output file prefix ( path + prefix + block number) 8 | % start_line_blk : extract data starting from row number 'start_line_blk' 9 | % blk : the block number 10 | % 11 | % input_path : Input file path 12 | % length_replica : Length (I & Q) of replica (for Fine Beam -> 2880 bytes) 13 | % tot_Nrg_cells : Total number of columns available in the dataset 14 | % Nrg_lines_blk : Number of samples in azimuth 15 | % first_rg_cell : Extract data starting from column number 'first_rg_cell' 16 | % Nrg_cells : Number of samples in ranged 17 | % UseMATfiles : Do you want to write MAT files for the data rather than 18 | % binary files for all the data and parameters? 19 | % ------------------------------------------------------------------------- 20 | 21 | % date created : May 05, 2004 by Kaan Ersahin & Millie Sikdar 22 | % date modified : Nov 30, 2004 by Kaan Ersahin 23 | % Modified: Dec 17 by Ian Cumming 24 | % - Added UseMATfiles option 25 | % ------------------------------------------------------------------------- 26 | 27 | % 'RSI - D4' refers to the document RSI-GS-026, Rev 3.0 - May 8, 2000 28 | % that describes the detailed format of the RADARSAT-1 raw data CDs. 29 | tic 30 | num_aux = 50; % RSI - D4 Pg.32 31 | num_header = 192; % RSI - D4 Pg.32 32 | file_header_length = 16252; % RSI - D4 Pg.103 33 | load CD_run_params 34 | 35 | % Specify input data file path and open to read 36 | file_in = strcat( input_path, CD_data_file_name ); 37 | fid = fopen( file_in, 'r' ); 38 | 39 | % Create output file names and open to write if MAT files not used 40 | if ~UseMATfiles 41 | file_replica = '_replica.dat'; % one replica per 8-line 42 | file_data_header = '_data_header.dat'; % header of each line 43 | file_aux = '_aux.dat'; % auxiliary data from each line 44 | file_data = '_data.dat'; % radar signal data 45 | file_file_header = '_file_header.dat'; % header of file 'dat_01.001' 46 | 47 | file_replica = strcat(output_file_pre, file_replica); 48 | file_data_header = strcat(output_file_pre, file_data_header); 49 | file_aux = strcat(output_file_pre, file_aux); 50 | file_data = strcat(output_file_pre, file_data); 51 | file_file_header = strcat(output_file_pre, file_file_header); 52 | 53 | fod1 = fopen( file_replica , 'w' ); 54 | fod2 = fopen( file_data_header, 'w' ); 55 | fod3 = fopen( file_aux , 'w' ); 56 | fod4 = fopen( file_data , 'w' ); 57 | fod5 = fopen( file_file_header, 'w' ); 58 | 59 | % Read file header 60 | file_header = fread( fid, [file_header_length,1], 'uint8' ); 61 | % Write file header in a binary file as unsigned integers 62 | fwrite( fod5, file_header, 'uint8'); 63 | fclose( fod5 ); 64 | end % of if ~UseMATfiles 65 | 66 | % some useful calculations 67 | num_pixel_data = 2*tot_Nrg_cells; % 18576 68 | h = num_header; % 192 69 | ha = num_header + num_aux; % 242 70 | hpa = num_header + num_aux + num_pixel_data; % 18818 71 | 72 | % Define 'rep_block' as the 8-line block of data including one replica 73 | % 'start_rep' and 'end_rep' locates the replica in the 'rep_block' 74 | % 'start_col' and 'end_col' locates the area of interest in the columns 75 | rep_block_length = length_replica + 8*hpa ; 76 | 77 | start_rep = (first_replica-1)*hpa + num_header + num_aux + 1; 78 | end_rep = start_rep + length_replica - 1 ; 79 | 80 | start_col = ha + 2*(first_rg_cell - 1) + 1 ; 81 | end_col = start_col + 2*Nrg_cells - 1; 82 | 83 | % The number of bytes to skip from the beginning of the file (Nbytes_skip) 84 | Nrep_blks_row1 = ceil(start_line_blk/8) - 1; 85 | Nbytes_blocks = Nrep_blks_row1 * rep_block_length; 86 | Nbytes_skip = file_header_length + Nbytes_blocks; 87 | 88 | fseek( fid, Nbytes_skip , 'bof' ); % go to start of the 1st data block 89 | data = int8( zeros(Nrg_lines_blk, 2*Nrg_cells) ); % Allocate data array 90 | 91 | N_8line_blocks = ceil(Nrg_lines_blk/8); 92 | fprintf('\nReading %1.0f small 8-line blocks from range line %5.0f\n',... 93 | N_8line_blocks, start_line_blk ) 94 | 95 | 96 | for kb = 1 : N_8line_blocks % Read and decode 8 lines at a time 97 | 98 | % read one 8-line block of radar data and replica 99 | temp = uint8( fread( fid, [rep_block_length,1], 'uint8' ) ); 100 | 101 | % separate the replica and 8 lines of [header, aux and data] 102 | replica = temp(start_rep : end_rep)'; 103 | temp = [ temp(1 : start_rep-1)' temp(end_rep+1 : rep_block_length)' ]; 104 | temp = reshape(temp, hpa, 8)'; % Shape array as 8 rows by all columns 105 | 106 | % Extract the desired set of range cells 107 | data(1+8*(kb-1):8*kb, :) = temp( : , start_col : end_col ); 108 | 109 | if ~UseMATfiles % Write replica, header, aux and data in a binary file 110 | header (:,1:8) = temp( : , 1 : h )'; 111 | aux (:,1:8) = temp( : , h+1 : ha )'; 112 | count1 = fwrite( fod1, replica, 'ubit4' ); % 4-bit replica 113 | count2 = fwrite( fod2, header , 'uint8' ); % 8-bit header 114 | count3 = fwrite( fod3, aux , 'uint8' ); % 8-bit aux data 115 | count4 = fwrite( fod4, data(1+8*(kb-1):8*kb, :)' , 'ubit4' ); 116 | end % of if UseMATfiles 117 | end 118 | 119 | fclose(fid); % Close input file 120 | if ~UseMATfiles % Close output files 121 | fclose(fod1); fclose(fod2); fclose(fod3); fclose(fod4); 122 | fprintf('This block written to binary file:\n%s\n', file_data ) 123 | end 124 | 125 | %-------------------------------------------------------------------------- 126 | % Decode the data, save as MAT file , if UseMATfiles == 1 127 | %-------------------------------------------------------------------------- 128 | 129 | if UseMATfiles == 1 130 | disp 'Decode data by subtracting 16 from upper register' 131 | vv = version; vers = str2num(vv(1)); % Find MATLAB version 132 | seven = int8( 7 ); 133 | 134 | if vers == 7 135 | one = int8( 1 ); 136 | two = int8( 2 ); 137 | sixteen = int8( 16 ); 138 | data = two*(data - sixteen*int8(data > seven)) + one; 139 | else 140 | data = int8( 2*(double(data) - 16*double(data > seven) ) + 1 ); 141 | end 142 | 143 | % Separate the I and Q channels and form a complex array 144 | data = complex( data(:, 1:2:2*Nrg_cells), data(:, 2:2:2*Nrg_cells) ); 145 | 146 | if SaveV6 147 | eval(['save -v6 ' output_path 'CDdata' num2str(blk) ' data']) 148 | disp 'Save int8 data in MAT file in V6 format' 149 | else 150 | eval(['save ' output_path 'CDdata' num2str(blk) ' data']) 151 | fprintf('Save int8 data in file: CDdata%1.0f.mat\n', blk) 152 | end 153 | % somedata = data(1,1:4) % Check a few data samples 154 | end % of if UseMATfiles 155 | toc -------------------------------------------------------------------------------- /projects/SAR信号与图像处理/RD&CS/specify_parameters.m: -------------------------------------------------------------------------------- 1 | % specify_parameters.m 2 | % 3 | % Run this program first to set up parameters for each data run. The run 4 | % parameters are stored in the file "CD_run_params.mat" in the current 5 | % directory. The program "extract_data.m" reads this file and adds some 6 | % fixed radar parameters to the file. Subsequent programs can read this 7 | % file to obtain the parameters needed for the SAR processing. 8 | % 9 | % The radar data are stored on the CD supplied with the book, but they 10 | % can be read from a disk file copied from the CD to your hard drive. 11 | % 12 | % The only file needed from the CD is "dat_01.001", which contains the 13 | % radar data as well as the chirp replica and auxiliary data for each range 14 | % line. As none of the parameters like PRF and range gate delay change in 15 | % this data set, and the replica is well defined by a linear FM chirp, the 16 | % only data that are really needed from the CD is the raw radar signal data 17 | % contained in "dat_01.001". The radar parameters are stored in the 18 | % program "extract_data.m". 19 | % 20 | % The radar data can be written in one block, or broken up into a number of 21 | % blocks, with a set of files for each block. 22 | % 23 | % The first range cell and the number of range cells can be set to any 24 | % value within the boundaries of the data array. The first range line 25 | % should be set to 1 plus a multiple of 8, and the number of lines per 26 | % block set to a factor of 8. Also, the number of lines should be set to a 27 | % multiple of the number of lines per block. If these rules are not 28 | % obeyed, the "extract_data.m" program will quantize the values accordingly. 29 | 30 | % Parameters to specify for each run: 31 | % ----------------------------------- 32 | % input_path : location of the radar data file 'dat_01.001' 33 | % output_path : location for the extracted data files 34 | % output_prefix : prefix to the extracted data file names 35 | % 36 | % first_rg_cell : first range cell to extract 37 | % Nrg_cells : number of range cells to extract 38 | % first_rg_line : first range line (azimuth sample) to extract 39 | % Nrg_lines : number of range lines to extract 40 | % Nrg_lines_blk : number of range lines per block 41 | % UseMATfiles : Set to 0 if you want binary header, data, aux and replica 42 | % files (.DAT) rather than just the MATLAB data files (.MAT) 43 | % ------------------------------------------------------------------------- 44 | % Created : Nov 29, 2004 by Kaan Ersahin 45 | % Modified: Nov 30, 2004 by Kaan Ersahin 46 | % Modified: Dec 3, 2004 by Ian Cumming 47 | % - moved fixed parameters to "extract_data.m" 48 | % - now use a fixed parameter file name for all programs 49 | % - added UseMATfiles option (=1 for MAT files) 50 | % ------------------------------------------------------------------------- 51 | 52 | clear, home, format compact 53 | 54 | % Define location of data files 55 | % input_path = 'Y:\RSAT\scene01\'; % These values are for runs at UBC 56 | % output_path = 'Y:\RSAT\EXTRACTED_DATA\'; 57 | input_path = 'D:\Assignment\Workspace\Radar Assignments\Materials\CD_SAR_DATA\scene01\'; 58 | output_path = 'C:\tmp\RAW_DATA\'; 59 | CD_data_file_name = 'dat_01.001'; 60 | output_prefix = 'raw'; 61 | 62 | %========================================================================== 63 | % Define area of interest of the radar data to be extracted 64 | % Note that the azimuth parameters are quantized in "extract_data.m" 65 | % 66 | % Here are some possible values for first_rg_cell and first_rg_line: 67 | % For coal & ferry terminals, use range = 970, azimuth = 1801 68 | % For Vancouver airport, use range = 1060, azimuth = 5561 69 | % For UBC and one ship, use range = 760, azimuth = 7097 70 | % For Stanley Park & city, use range = 1850, azimuth = 7657 71 | % For English Bay ships, use range = 1050, azimuth = 7769 72 | % For Squamish & Garibaldi, use range = 2640, azimuth = 16169 73 | % For Brackendale, use range = 2800, azimuth = 17897 (max az) 74 | 75 | first_rg_cell = 1850; % Define the range limits 76 | first_rg_line = 7657; % Define the azimuth limits (19432 max) 77 | 78 | Nrg_cells = 2048 % Suggest 2048 cells 79 | Nrg_lines_blk = 6*256; % Suggest 1536, it should be larger than the 80 | % size of the azimuth match filter (705) 81 | % so that an image can be created. 82 | Nrg_lines = 2*Nrg_lines_blk; 83 | 84 | UseMATfiles = 1; % (1) Use MAT files to save the extracted data 85 | % (0) Use binary files to save the extracted data 86 | SaveV6 = 0; % (1) Save data in MATLAB v6 format when using v7 87 | % (0) Save data in MATLAB v7 format 88 | % This variable is only used if you are running MATLAB 7 89 | %========================================================================== 90 | 91 | % Save the data and run parameters in a matlab data file (*.mat) 92 | 93 | vv = version; vers = str2num(vv(1)); % Find MATLAB version 94 | if vers == 6, SaveV6 = 0; end 95 | 96 | if SaveV6 97 | save -v6 CD_run_params 98 | fprintf('\nData parameters written to: CD_run_params.mat in V6 format') 99 | else 100 | save CD_run_params 101 | fprintf('\nData parameters written to: CD_run_params.mat') 102 | end 103 | 104 | fprintf('\nNow run "extract_data.m"\n\n') 105 | beep, pause(0.4), beep 106 | 107 | %% This setup program is now finished, but you can add calls to subsequent 108 | %% data extraction and processing programs below, if desired. 109 | 110 | % extract_data % Extract the SAR data from the CD 111 | 112 | % compute_azim_spectra % Find the baseband Doppler centroid 113 | 114 | % compress_data % Perform SAR processing 115 | -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/calculateNC_W_R_Z.m: -------------------------------------------------------------------------------- 1 | function calculateNC_W_R_Z(timeIndex, D, ND, V, ModelName) 2 | NC = sum(ND, 1); 3 | LWC = sum((pi/6*10^-6).*D.^3.*ND, 1); 4 | R = sum(6*pi*10^-4.*D.^3.*V.*ND, 1); 5 | Z = sum(D.^6.*ND, 1); 6 | figure(); 7 | subplot(4,1,1) 8 | plot(timeIndex(:,1), NC); 9 | title(strcat(ModelName, ': Number Concentration /m^{-3}')); 10 | xlim([7 13]) 11 | subplot(4,1,2) 12 | plot(timeIndex(:,1), LWC); 13 | title(strcat(ModelName, ': Liquid Water Content /g\cdotm^{-3}')); 14 | xlim([7 13]) 15 | subplot(4,1,3) 16 | plot(timeIndex(:,1), R); 17 | title(strcat(ModelName, ': Rain Rate /mm\cdoth^{-1}')); 18 | xlim([7 13]) 19 | subplot(4,1,4) 20 | plot(timeIndex(:,1), Z); 21 | title(strcat(ModelName, ': Reflectivity /mm^{6}\cdotm^{-3}\cdotmm^{-1}')); 22 | xlim([7 13]) 23 | end 24 | 25 | -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/ch2_1.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter2/ch2_1.m -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/ch2_4.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter2/ch2_4.m -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/ch2_5.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter2/ch2_5.m -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/ch2_6.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter2/ch2_6.m -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter2/getPermittivity.m: -------------------------------------------------------------------------------- 1 | function [constant] = getPermittivity(f, epsilon_s, epsilon_inf, alpha, lambda_s, delta) 2 | c = 3*10^8; 3 | epsilon0 = 8.854*10^-12; 4 | lambda = c/f; 5 | real = epsilon_inf + (epsilon_s - epsilon_inf)*(1 + (lambda_s/lambda)^(1-alpha)*sin(alpha*pi/2))/(1 + 2*(lambda_s/lambda)^(1-alpha)*sin(alpha*pi/2) + (lambda_s/lambda)^(2-2*alpha)); 6 | imag = (epsilon_s - epsilon_inf)*(lambda_s/lambda)^(1-alpha)*cos(alpha*pi/2)/(1 + 2*(lambda_s/lambda)^(1-alpha)*sin(alpha*pi/2) + (lambda_s/lambda)^(2-2*alpha)) + delta*lambda/(2*pi*c*epsilon0); 7 | constant = real - imag*1j; 8 | end 9 | 10 | -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter3/ch3_1.m: -------------------------------------------------------------------------------- 1 | delta1 = 0; delta2 = pi*3/4; 2 | SamplePoints = 10000; 3 | AnimatePoints = 5000; 4 | t = linspace (0, 1, SamplePoints); 5 | w = 2*pi*2.8*10^9; 6 | y = cos(w*t + delta1); 7 | z = cos(w*t + delta2); 8 | h1 = animatedline('MaximumNumPoints', AnimatePoints, 'LineStyle', 'none', 'Marker', 'x', 'MarkerFaceColor', 'r'); 9 | h2 = animatedline('MaximumNumPoints', 2, 'Marker', 'x', 'MarkerFaceColor', 'r', 'LineWidth', 3, 'Color', 'r'); 10 | fig = figure(1); 11 | axis([-1.5 1.5 -1.5 1.5]) 12 | axis equal 13 | ST = tic; 14 | 15 | for k = 1 : SamplePoints 16 | addpoints(h1, y(k), z(k)); 17 | addpoints(h2, 0, 0); 18 | addpoints(h2, y(k), z(k)); 19 | ET = toc(ST); 20 | if ET > 1/100000 21 | drawnow 22 | ST = tic; 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter3/ch3_2.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter3/ch3_2.m -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter3/ch3_3.m: -------------------------------------------------------------------------------- 1 | FileName = 'D:/Assignment/Workspace/Radar Assignments/Materials/Chapter3Material/hw4.dat'; 2 | fid = fopen(FileName); 3 | data = textscan(fid, '%f %f %f %f %f %f %f %f %f', 'HeaderLines', 1); 4 | data = cell2mat(data); 5 | permittivity = 80 - 17*1j; 6 | lambda = 107; 7 | k = 2*pi/lambda; 8 | 9 | D = data(:, 1); 10 | sa_back = data(:, 2).^2 + data(:, 3).^2; 11 | sb_back = data(:, 4).^2 + data(:, 5).^2; 12 | sa_forward = data(:, 6).^2 + data(:, 7).^2; 13 | sb_forward = data(:, 8).^2 + data(:, 9).^2; 14 | 15 | aspect_r = 0.9951 + 0.0251.*D - 0.03644*D.^2 + 0.005303*D.^3 - 0.0002492*D.^4; 16 | g_squared = 1./(aspect_r).^2 - 1; 17 | Lb = (1 + g_squared)./g_squared.*(1 - 1./(sqrt(g_squared)).*atan(sqrt(g_squared))); 18 | La = (1 - Lb)./2; 19 | 20 | % Znric 21 | % sa_re = abs(pi^2.*D.^3/(6*lambda^2).*(La + 1/(permittivity - 1))); 22 | % sb_re = abs(pi^2.*D.^3/(6*lambda^2).*(Lb + 1/(permittivity) - 1)); 23 | 24 | 25 | % Guifu Zhang 26 | sa_re = pi/2*k^2.*(D/2).^3.*(real(permittivity) - 1)./(3*(1 + (real(permittivity) - 1)*La)); 27 | sb_re = pi/2*k^2.*(D/2).^3.*(real(permittivity) - 1)./(3*(1 + (real(permittivity) - 1)*Lb)); 28 | 29 | figure(1); 30 | semilogy(D, sa_back, 'Color', 'r', 'LineStyle', '-', 'LineWidth', 2); 31 | hold on 32 | semilogy(D, sa_forward, 'Color', 'r', 'LineStyle', '--', 'LineWidth', 2); 33 | hold on 34 | semilogy(D, sb_back, 'Color', 'r', 'LineStyle', '-.', 'LineWidth', 2); 35 | hold on 36 | semilogy(D, sb_forward, 'Color', 'r', 'LineStyle', ':', 'LineWidth', 2); 37 | hold on 38 | semilogy(D, sa_re, 'Color', 'k', 'LineStyle', '-', 'LineWidth', 2); 39 | hold on 40 | plot(D, sb_re, 'Color', 'k', 'LineStyle', ':', 'LineWidth', 2); 41 | 42 | 43 | legend('real backscatter S_a', 'real forwardscatter S_a','real backscatter S_b','real forwardscatter S_a',... 44 | 'Rayleigh scatter S_a','Rayleigh scatter S_b',... 45 | 'Location','southeast'); -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter3/getScatterAndExticationCoffByMie.m: -------------------------------------------------------------------------------- 1 | function [ext, sca] = getScatterAndExticationCoffByMie(D, lambda, permittivity) 2 | % Calculate normalized extincttion and scatter cross section 3 | alpha = pi.*D/lambda; 4 | ref = sqrt(permittivity); % refractive index 5 | kext = zeros(size(alpha)); ksca = zeros(size(alpha)); 6 | for n = 1 : 50 % times of sum 7 | syms x f1 f2 8 | if n == 1 % init parameters 9 | f1 = sin(x)./x -cos(x); 10 | f1dot = diff(f1, x, 1); 11 | f2 =(sin(x) + 1j*cos(x))./x - cos(x) + 1j*sin(x); 12 | f2dot = diff(f2, x, 1); 13 | else 14 | f1 =(pi*x/2)^(1/2).*besselj(n+0.5, x); 15 | f1dot = (pi*x/2)^(1/2).*besselj(n-0.5, x) - n*(pi*x/2)^(1/2).*besselj(n + 0.5, x)./x; 16 | f2 = (pi*x/2)^(1/2).*(besselj(n+0.5, x) - 1j*bessely(n+0.5, x)); 17 | f2dot = (pi*x/2)^(1/2).*(besselj(n-0.5, x) - 1j*bessely(n-0.5, x)) - ... 18 | n/x*(pi*x/2)^(1/2).*(besselj(n+0.5, x) - 1j*bessely(n+0.5, x)); 19 | end 20 | g1 = matlabFunction(f1); % transform asign function to numeric function 21 | g1dot = matlabFunction(f1dot); 22 | g2 = matlabFunction(f2); 23 | g2dot = matlabFunction(f2dot); 24 | an = (g1dot(ref*alpha).*g1(alpha) - ref*g1dot(alpha).*g1(ref*alpha))./... 25 | (g1dot(ref*alpha).*g2(alpha) - ref*g2dot(alpha).*g1(ref*alpha)); 26 | bn = (g1dot(ref*alpha).*g1(alpha) - ref*g1dot(alpha).*g1(ref*alpha))./... 27 | (ref*g1dot(ref*alpha).*g2(alpha) - g2dot(alpha).*g1(ref*alpha)); 28 | ksca = ksca + (2*n + 1)*(abs(an).^2 + abs(bn).^2); 29 | kext = kext + (2*n + 1)*real(an + bn); 30 | end 31 | ext = 2./alpha.^2.*kext; 32 | sca = 2./alpha.^2.*ksca; -------------------------------------------------------------------------------- /projects/双偏振雷达气象学/Chapter3/球形粒子Mie散射参量的Matlab改进算法_张合勇.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitHub-Crow/RadarSimulation/00f7cb9047bbbc1f475fbcaa0b608d264fe7550a/projects/双偏振雷达气象学/Chapter3/球形粒子Mie散射参量的Matlab改进算法_张合勇.pdf -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/BeamWidthRealatedByTheta0.m: -------------------------------------------------------------------------------- 1 | %% plot beamwidth related by frequency and incident angle 2 | %% input arguements 3 | freq = [1 5 10 15]; 4 | lambda = 0.3./freq; 5 | theta0 = linspace(0, 60, 100); % incident angle 6 | D = 1; % aperture size 7 | K = 0.886; % beamwidth factor 8 | 9 | %% calculate beamwidth 10 | [~, theta0_mat] = meshgrid(lambda, theta0); 11 | bw = lambda*K./(cosd(theta0_mat)*D); 12 | bw_deg = bw*180/pi; % beamwidth in degree; 13 | 14 | %% plot 15 | clf 16 | figure(1) 17 | set(gca, 'fontsize', 16); 18 | plot(theta0_mat, bw, 'linewidth', 2); 19 | xlabel('\theta_{0} (degrees)'); 20 | ylabel('BW (degress)'); 21 | grid off 22 | legend('1GHz', '5GHz', '10GHz', '15GHz'); -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/GA_BF.m: -------------------------------------------------------------------------------- 1 | clc; close all; 2 | %% init parameters 3 | 4 | Nele = 100; 5 | EF = 1.2; 6 | 7 | % constraints of excitation 8 | 9 | magMin = zeros(Nele, 1); 10 | magMax = ones(Nele, 1); 11 | phsMin = zeros(Nele, 1); 12 | phsMax = ones(Nele, 1)*pi; 13 | 14 | enforceSymmetry = 1; 15 | 16 | % pattern goals 17 | 18 | % define upperbound and lowerbound simplely 19 | upperSidelobeGoalU = [-1 -0.03 0.03 0.4 0.4 0.5 0.5 1]; 20 | upperSidelobeGoaldB = [-55 -30 -30 -39.5 -60 -60 -42.1 -55]; 21 | lowerSidelobeGoalU = [-1 1]; 22 | lowerSidelobeGoaldB = [-80 -80]; 23 | autoExemptMainBeam = 1; % 1 for exempt main beam from cost function 24 | NPatternPoints = 512; 25 | 26 | % optimization parameters 27 | 28 | MaxIterations = 5e2; 29 | popSize = 50; 30 | NMarriages = 25; 31 | Tourment.TournamentEligible = 10; 32 | Tourment.TournamentCompetitors = 5; 33 | 34 | NOrder = 2*Nele; 35 | Mutation.MutationProb = 0.04; 36 | Mutation.MutationRangeMax = 0.2; 37 | Mutation.MutationRangeDecay = 1.5; 38 | Mutation.NMutation = round(Mutation.MutationProb*NOrder); 39 | 40 | 41 | NCrossovers = 2; 42 | 43 | magRange = magMax - magMin; 44 | phsRange = phsMax - phsMin; 45 | sin_theta = [-1 : 2/NPatternPoints : 1 - 2/NPatternPoints]; 46 | cos_theta = sqrt(1 - sin_theta.^2); 47 | % interpolation to the size of theta 48 | lowerbound_dB = interp1(lowerSidelobeGoalU + [0 : size(lowerSidelobeGoalU, 2) - 1]*eps,... 49 | lowerSidelobeGoaldB, sin_theta); 50 | upperbound_dB = interp1(upperSidelobeGoalU + [0 : size(upperSidelobeGoalU, 2) - 1]*eps,... 51 | upperSidelobeGoaldB, sin_theta); 52 | lowerbound = 10.^(lowerbound_dB/20)'; 53 | upperbound = 10.^(upperbound_dB/20)'; 54 | eleWgtPower = cos_theta.^EF; 55 | eleWgtVoltage = sqrt(eleWgtPower)'; 56 | 57 | %% init population 58 | 59 | currentGeneration = rand(NOrder, popSize); 60 | currentGenerationScore = zeros(1, popSize); 61 | for kk = 1 : popSize 62 | magWgts = currentGeneration(1 : Nele, kk).* magRange + magMin; 63 | phsWgts = currentGeneration(Nele + 1 : end, kk).*phsRange + phsMin; 64 | wgts = magWgts.*exp(1j*phsWgts); 65 | currentGenerationScore(kk) = costFunction(wgts, eleWgtVoltage, lowerbound, upperbound,... 66 | autoExemptMainBeam, enforceSymmetry); 67 | end 68 | 69 | %% optimization 70 | 71 | GenerationAverageSocre = zeros(MaxIterations, 1); 72 | GenerationBestScore = zeros(MaxIterations, 1); 73 | [~, sort_index] = sort(currentGenerationScore); 74 | currentGeneration = currentGeneration(:, sort_index); 75 | currentGenerationScore = currentGenerationScore(:, sort_index); 76 | globalBestScore = currentGenerationScore(1); 77 | 78 | for ii = 1 : MaxIterations 79 | t = (ii - 1)/(MaxIterations - 1); 80 | Mutation.mutationRange = Mutation.MutationRangeMax * ... 81 | (exp(-Mutation.MutationRangeDecay*t) - ... 82 | exp(-Mutation.MutationRangeDecay)); 83 | 84 | % for each marriage 85 | Children = zeros(NOrder, NMarriages*2); 86 | for jj = 1 : NMarriages 87 | 88 | % choose parents 89 | [Dad, Mom] = chooseParent(currentGeneration, currentGenerationScore, Tourment); 90 | 91 | % mating 92 | Son = Dad; 93 | Daughter = Mom; 94 | permIndex = randperm(NOrder - 1) + 1; 95 | crossoverPoints = sort(permIndex(1 : NCrossovers)); 96 | for crossoverCount = 1 : NCrossovers 97 | transferRange = [crossoverPoints(crossoverCount) : NOrder]; 98 | geneSlice = Son(transferRange); 99 | Son(transferRange) = Daughter(transferRange); 100 | Daughter(transferRange) = geneSlice; 101 | end 102 | 103 | % mutate son and daughter 104 | Children(:, 2 * jj - 1) = mutate(Son, NOrder, Mutation); 105 | Children(:, 2 * jj) = mutate(Daughter, NOrder, Mutation); 106 | end 107 | 108 | % score children 109 | ChildrenScores = zeros(1, 2*NMarriages); 110 | for kk = 1 : 2*NMarriages 111 | magWgts = Children(1 : Nele, kk).*magRange + magMin; 112 | phsWgts = Children(Nele + 1 : 2*Nele, kk).*phsRange + phsMin; 113 | complexWgts = magWgts.*exp(1j*phsWgts); 114 | ChildrenScores(kk) = costFunction(complexWgts, eleWgtVoltage, ... 115 | lowerbound, upperbound, ... 116 | autoExemptMainBeam, enforceSymmetry); 117 | end 118 | 119 | % survival of the fittset 120 | 121 | combinedGeneration = [currentGeneration Children]; 122 | combinedScores = [currentGenerationScore ChildrenScores]; 123 | 124 | [~, sortIndex] = sort(combinedScores); 125 | survivalIndex = sortIndex(1 : popSize); % keep popsize constant 126 | currentGeneration = combinedGeneration(:, survivalIndex); 127 | currentGenerationScore = combinedScores(:, survivalIndex); 128 | globalBestScore = currentGenerationScore(1); 129 | 130 | % save performance 131 | GenerationAverageSocre(ii) = mean(currentGenerationScore); 132 | GenerationBestScore(ii) = globalBestScore; 133 | end 134 | 135 | GlobalBestIndividual = currentGeneration(:, 1); 136 | 137 | %% calculate best beamforming pattern 138 | 139 | NPatternPointsFine = NPatternPoints*8; 140 | sine_theta_fine = [-1 : 2/NPatternPointsFine : 1 - 2/NPatternPointsFine]; 141 | cosine_theta_fine = sqrt(1 - sine_theta_fine.^2); 142 | eleWgtPowerFine = cosine_theta_fine.^EF; 143 | eleWgtsVoltageFine = sqrt(eleWgtPowerFine); 144 | 145 | complexWgts = (GlobalBestIndividual(1 : Nele).*magRange + magMin).*... 146 | exp(1j*(GlobalBestIndividual(Nele + 1 : 2*Nele).*phsRange + phsMin)); 147 | 148 | if enforceSymmetry 149 | complexWgts(Nele/2 + 1 : Nele) = flipud(complexWgts(1 : Nele/2)); 150 | end 151 | 152 | complexWgts = complexWgts/max(abs(complexWgts)); 153 | BestPattern = eleWgtsVoltageFine.*fftshift(fft(complexWgts, NPatternPointsFine)); 154 | BestPattern_dB = 20*log10(abs(BestPattern) + eps); 155 | BestPatternNorm_dB = BestPattern_dB - max(BestPattern_dB); 156 | 157 | %% plot global best pattern 158 | 159 | figure ; 160 | fontsize = 12; 161 | subplot(2, 2, 1) 162 | set(gca, 'fontsize', fontsize); 163 | plot([1 : MaxIterations], GenerationBestScore,... 164 | [1 : MaxIterations], GenerationAverageSocre,... 165 | 'linewidth', 2); 166 | xlabel('Iteraion #'); 167 | ylabel('cost function'); 168 | legend('Best', 'Average'); 169 | axis tight; 170 | 171 | subplot(2, 2, 2) 172 | eles = linspace(1, Nele, Nele); 173 | yyaxis left 174 | plot(eles, abs(complexWgts), 'Marker', '.'); 175 | ylabel('Amplitude', 'fontsize', fontsize); 176 | yyaxis right 177 | plot(eles, angle(complexWgts) - min(angle(complexWgts)), 'Marker', '+'); 178 | ylabel('Phase', 'fontsize', fontsize); 179 | title('Aperture Weights from GA', 'fontsize', fontsize); 180 | 181 | subplot(2, 1, 2) 182 | set(gca, 'fontsize', fontsize); 183 | plot(sine_theta_fine, BestPatternNorm_dB, 'LineWidth', 2); hold on 184 | plot(lowerSidelobeGoalU, lowerSidelobeGoaldB, 'r-.', 'LineWidth', 2); 185 | plot(upperSidelobeGoalU, upperSidelobeGoaldB, 'r:', 'LineWidth', 2); 186 | axis tight 187 | ylim([-80 0]); 188 | title('Far Field Pattern'); 189 | ylabel('Magnitude(dB)'); 190 | xlabel('sin(\theta)'); -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/chooseParent.m: -------------------------------------------------------------------------------- 1 | function [fa, ma] = chooseParent(currentGeneration, currentGenerationScore, Tournament) 2 | permIndex = randperm(Tournament.TournamentEligible); 3 | competitorFitness = currentGenerationScore(permIndex(1 : Tournament.TournamentCompetitors)); 4 | [~, sortedIndex] = sort(competitorFitness); 5 | fa = currentGeneration(:, permIndex(sortedIndex(1))); 6 | ma = currentGeneration(:, permIndex(sortedIndex(2))); 7 | end 8 | 9 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute1D_AF.m: -------------------------------------------------------------------------------- 1 | function [AF] = compute1D_AF(Am, elementCount, d, f0, f, u0, u) 2 | lambda0 = 0.3/f0; lambda = 0.3/f; 3 | k0 = (2*pi)/lambda0; k = (2*pi)/lambda; 4 | Xm = linspace(1, elementCount, elementCount)*d - (elementCount + 1)/2*d; 5 | AF = zeros(size(u)); 6 | for i = 1 : elementCount 7 | AF = AF + Am(i)*exp(1j*Xm(i)*(k*u - k0*u0)); 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute1D_EP.m: -------------------------------------------------------------------------------- 1 | function [EP] = compute1D_EP(theta, EF) 2 | EP = (cosd(theta).^(EF/2)); 3 | end 4 | 5 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute1D_PAT.m: -------------------------------------------------------------------------------- 1 | function [PAT] = compute1D_PAT(EP, AF) 2 | PAT = EP.*AF; 3 | end 4 | 5 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute2D_AF.m: -------------------------------------------------------------------------------- 1 | function AF = compute2D_AF(amWgts, dx, dy, f, f0, randErrorAm, randErrorPhs, u, u0, v, v0) 2 | lambda = 0.3/f; 3 | lambda0 = 0.3/f0; 4 | k = 2*pi/lambda; 5 | k0 = 2*pi/lambda0; 6 | [nxEle, nyEle] = size(amWgts); 7 | AF = zeros(size(u)); 8 | 9 | randErr = randErrorAm.*exp(1j*randErrorPhs*pi/180); 10 | for ii = 1 : nxEle 11 | xidx = (ii - (nxEle + 1)/2)*dx; 12 | for jj = 1 : nyEle 13 | yidx = (jj - (nyEle + 1)/2)*dy; 14 | AF = AF + amWgts(ii, jj).*randErr(ii, jj).*... 15 | exp(1j*xidx*(k*u - k0*u0)).*exp(1j*yidx*(k*v - k0*v0)); 16 | end 17 | end 18 | 19 | end -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute2D_AFQuant.m: -------------------------------------------------------------------------------- 1 | function [AF] = compute2D_AFQuant(amWgts, dx, dy, f, f0, randAmErr, randPhsErr, u, u0, v, v0, bits) 2 | lambda = 0.3/f; 3 | lambda0 = 0.3/f0; 4 | k = 2*pi/lambda; 5 | k0 = 2*pi/lambda0; 6 | [nxEle, nyEle] = size(amWgts); 7 | AF = zeros(size(u)); 8 | 9 | LSB = 360/2^bits; 10 | randErr = randAmErr.*exp(1j*randPhsErr*pi/180); 11 | for ii = 1 : nxEle 12 | xidx = (ii - (nxEle + 1)/2)*dx; 13 | for jj = 1 : nyEle 14 | yidx = (jj - (nyEle + 1)/2)*dy; 15 | phase = k*u*xidx + k*v*yidx; 16 | phase0 = k0*u0*xidx + k0*v0*yidx; 17 | phase0 = pi/180*round(180/pi*phase0/LSB)*LSB; 18 | AF = AF + amWgts(ii, jj).*randErr(ii, jj).*... 19 | exp(1j*(phase - phase0)); 20 | end 21 | end 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute2D_EP.m: -------------------------------------------------------------------------------- 1 | function EP = compute2D_EP(theta, EF) 2 | EP = cosd(theta).^(EF/2); 3 | end -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute2D_IntGain.m: -------------------------------------------------------------------------------- 1 | function [IntGain, IdealGain] = compute2D_IntGain(pat, f, nxEle, nyEle, dx, dy, theta, phi) 2 | thetaN = length(theta); phiN = length(phi); 3 | dtheta = (theta(end) - theta(1))/thetaN; 4 | dphi = (phi(end) - phi(1))/phiN; 5 | 6 | theta = theta'*ones(1, phiN); 7 | 8 | IntGain = sum(sum(dtheta*dphi*sin(theta)))*pat.^2/... 9 | sum(sum(dtheta*dphi*sin(theta).*sin(theta))); 10 | area = nxEle*dx*nyEle*dy; 11 | lambda = 0.3/f; 12 | IdealGain = 4*pi*area/lambda^2; 13 | end 14 | 15 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/compute2D_PAT.m: -------------------------------------------------------------------------------- 1 | function PAT = compute2D_PAT(EP, AF) 2 | PAT = EP.*AF; 3 | end -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/costFunction.m: -------------------------------------------------------------------------------- 1 | function cost = costFunction(complex_wgts, ele_wgts_voltages,... 2 | lower_bound, upper_bound,... 3 | auto_exempt_main_beam, enforce_symmetry) 4 | 5 | Nele = numel(complex_wgts); 6 | if enforce_symmetry 7 | complex_wgts(Nele/2 + 1 : Nele) = flipud(complex_wgts(1 : Nele/2)); 8 | end 9 | 10 | Npattern_points = numel(ele_wgts_voltages); 11 | % calculate array factor by fft directly 12 | pattern = abs(fftshift(fft(complex_wgts, Npattern_points))) .* ele_wgts_voltages; 13 | 14 | pattern_norm = pattern/max(pattern); 15 | lower_excess = max(lower_bound - pattern_norm, 0); 16 | upper_excess = max(pattern_norm - upper_bound, 0); 17 | 18 | if auto_exempt_main_beam 19 | [~,index_of_max_value] = max(pattern_norm); 20 | spikes = diff(sign(diff(pattern_norm))); 21 | % find loction of main beam 22 | null_indices = find(spikes == 2) + 1; % lower points 23 | right_null_indices = null_indices(null_indices > index_of_max_value(1)); 24 | left_null_indices = null_indices(null_indices < index_of_max_value(1)); 25 | 26 | if isempty(right_null_indices) 27 | index_of_right_null = Npattern_points; 28 | else 29 | index_of_right_null = right_null_indices(1); 30 | end 31 | if isempty(left_null_indices) 32 | index_of_left_null = 1; 33 | else 34 | index_of_left_null = left_null_indices(end); 35 | end 36 | % exempt main beam from cost function 37 | lower_excess(index_of_left_null : index_of_right_null) = 0; 38 | upper_excess(index_of_left_null : index_of_right_null) = 0; 39 | end 40 | 41 | cost = 10*log10(sum(lower_excess) + sum(upper_excess) + eps); 42 | end -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/getTaylorWeights.m: -------------------------------------------------------------------------------- 1 | function [weights] = getTaylorWeights(nele, sll, nbar) 2 | r = 10^(abs(sll)/20); 3 | a = log(r+(r*r-1)^0.5)/pi; 4 | sigma2 = nbar^2/(a^2 + (nbar - 0.5)^2); 5 | F = ones(1, nbar-1); 6 | for m=1:(nbar-1) 7 | for n=1:(nbar-1) 8 | F(m) = F(m)*(1-m*m/sigma2/(a*a+(n-0.5)*(n-0.5))); 9 | if n ~= m 10 | F(m) = F(m)/(1 - m*m/n/n); 11 | end 12 | end 13 | F(m) = ((-1)^(m+1))/2*F(m); 14 | end 15 | jj = [1:nele]'; 16 | xx = (jj-1+0.5)/nele - 1/2; 17 | mm = [1:nbar-1]; 18 | W = 1 + 2*cos(2*pi*xx*mm)*F'; 19 | WPK = 1 + 2*sum(F); 20 | weights = W / WPK; 21 | 22 | % r = 10^(abs(sll)/10); 23 | % a = log(r+(r*r-1)^0.5)/pi; 24 | % deltaSq = nbar^2/(a^2 + (nbar - 0.5)^2); 25 | % SM = ones(1, nbar); 26 | % SM(end) = 0; 27 | % SMweight = 1; 28 | % for m = 1 : nbar - 1 29 | % SMweight = SMweight*(nbar - m)/(nbar + m - 1); 30 | % for i = 1 : nbar - 1 31 | % SM(m) = SM(m)*(1 - (m^2/(deltaSq*(a^2 + (i - 0.5)^2)))); 32 | % end 33 | % SM(m) = SM(m)*SMweight; 34 | % end 35 | % 36 | % p = horzcat([1:1:ceil(nele/2)], [floor(nele/2):-1:1]); %#ok<*NBRAK> 37 | % if mod(nele, 2) == 0 38 | % p = pi*(2*p - 1)/nele; 39 | % else 40 | % p = 2*pi*(p - 1)/nele; 41 | % end 42 | % mvec = transpose(linspace(1, nbar, nbar)); 43 | % weights = 1 + 2*SM*cos(mvec*p); 44 | end 45 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/mutate.m: -------------------------------------------------------------------------------- 1 | function output = mutate(input, NOrder, Mutation) 2 | permIndex = randperm(NOrder); 3 | mutationDecision = zeros(NOrder, 1); 4 | mutationDecision(permIndex(1 : Mutation.NMutation)) = 1; 5 | mutatedMax = min(input + Mutation.mutationRange/2, 1); 6 | mutatedMin = max(input - Mutation.mutationRange/2, 0); 7 | mutatedGene = rand(NOrder, 1).*(mutatedMax - mutatedMin) + mutatedMin; 8 | output = input.*(1 - mutationDecision) + mutatedGene.*mutationDecision; 9 | end 10 | 11 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/pattern1D.m: -------------------------------------------------------------------------------- 1 | %% 1D pattern 2 | close all; clear all; 3 | %% input parameters 4 | Array.f = 10; % operating frequency in GHz 5 | Array.f0 = 10; % tune frequency in GHz 6 | Array.nele = 30; % number of array element 7 | Array.d = 0.5*(0.3/Array.f0); % array element distance 8 | Array.EF = 1.35; 9 | Array.weightFlag = 1; % 0 = uniform, 1 = taylor weighting 10 | % Taylor Weighting paramenters 11 | Array.Taylor.Nbar = 5; 12 | Array.Taylor.SLL = 30; 13 | 14 | % theta angle paramenters 15 | theta.scan = 0; 16 | theta.minAngle = -90; 17 | theta.maxAngle = 90; 18 | theta.nAngles = 721; 19 | 20 | %% set pattern of amplitude weight 21 | if Array.weightFlag == 0 22 | Array.amWeight = ones(1, Array.nele); 23 | else 24 | Array.amWeight = getTaylorWeights(Array.nele, Array.Taylor.SLL, Array.Taylor.Nbar); 25 | end 26 | 27 | theta.vec = linspace(theta.minAngle, theta.maxAngle, theta.nAngles); 28 | theta.u = sind(theta.vec); 29 | theta.u0 = sind(theta.scan); 30 | 31 | % init element pattern, array factor, pattern 32 | Array.size = size(theta.vec); 33 | Array.EP = zeros(Array.size); 34 | Array.AF = zeros(Array.size); 35 | Array.PAT = zeros(Array.size); 36 | 37 | % compute element pattern, array factor, pattern 38 | Array.EP = compute1D_EP(theta.vec, Array.EF); 39 | Array.AF = compute1D_AF(Array.amWeight, Array.nele, Array.d, ... 40 | Array.f0, Array.f, theta.u0, theta.u); 41 | Array.PAT = compute1D_PAT(Array.EP, Array.AF); 42 | 43 | %% plot 44 | [EP.mag, EP.mag_dB, EP.mag_dB_Norm] = processVector(Array.EP); 45 | [AF.mag, AF.mag_dB, AF.mag_dB_Norm] = processVector(Array.AF); 46 | [PAT.mag, PAT.mag_dB, PAT.mag_dB_Norm] = processVector(Array.PAT); 47 | 48 | clf 49 | figure(1) 50 | set(gca, 'fontsize', 14, 'fontweight', 'bold'); 51 | 52 | plot(theta.vec, EP.mag_dB_Norm, 'Color', 'r', 'linestyle', ':', 'linewidth', 2); 53 | hold on 54 | plot(theta.vec, AF.mag_dB_Norm, 'Color', 'b', 'linestyle', ':', 'linewidth', 2); 55 | hold on 56 | plot(theta.vec, PAT.mag_dB_Norm, 'Color', 'k', 'linestyle', '-', 'linewidth', 3); 57 | hold on 58 | xlabel('\theta (degree)'); ylabel('dB'); 59 | legend('EP', 'AF', 'PAT'); 60 | axis ([theta.minAngle, theta.maxAngle, -120 20]); -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/pattern1D_GLs.m: -------------------------------------------------------------------------------- 1 | % compute pattern with different element spacing to 2 | % illustrate grating lobes 3 | %% input parameters 4 | Array.f = 10; % operating frequency in GHz 5 | Array.f0 = 10; % tune frequency in GHz 6 | Array.nele = 30; % number of array element 7 | Array.d = [0.2 0.5, 1, 2]*(0.3/Array.f0); % array element distance 8 | Array.EF = 1.35; 9 | Array.weightFlag = 0; % 0 = uniform, 1 = taylor weighting 10 | % Taylor Weighting paramenters 11 | Array.Taylor.Nbar = 5; 12 | Array.Taylor.SLL = 30; 13 | 14 | % theta angle paramenters 15 | theta.scan = 0; 16 | theta.minAngle = -90; 17 | theta.maxAngle = 90; 18 | theta.nAngles = 721; 19 | %% set pattern of amplitude weight 20 | if Array.weightFlag == 0 21 | Array.amWeights = ones(1, Array.nele); 22 | else 23 | Array.amWeights = getTaylorWeights(Array.nele, Array.Taylor.SLL, Array.Taylor.Nbar); 24 | end 25 | 26 | theta.vec = linspace(theta.minAngle, theta.maxAngle, theta.nAngles); 27 | theta.u = sind(theta.vec); 28 | theta.u0 = sind(theta.scan); 29 | 30 | %% init 31 | Array.size = size(theta.vec); 32 | Array.EP = zeros(Array.size); 33 | Array.AF = zeros(Array.size); 34 | Array.PAT = zeros(Array.size); 35 | 36 | %% plot 37 | figure(1) 38 | 39 | for eleSpacing = Array.d 40 | Array.EP = compute1D_EP(theta.vec, Array.EF); 41 | Array.AF = compute1D_AF(Array.amWeights, Array.nele, eleSpacing, Array.f0, Array.f, theta.u0, theta.u); 42 | Array.PAT = compute1D_PAT(Array.EP, Array.AF); 43 | [EP.mag, EP.mag_dB, EP.mag_dB_Norm] = processVector(Array.EP); 44 | [AF.mag, AF.mag_dB, AF.mag_dB_Norm] = processVector(Array.AF); 45 | [PAT.mag, PAT.mag_dB, PAT.mag_dB_Norm] = processVector(Array.PAT); 46 | plot(theta.vec, PAT.mag_dB_Norm, 'linewidth', 2); hold on 47 | end 48 | set(gca, 'fontsize', 10, 'fontweight', 'bold'); 49 | xlabel('\theta (degree)'); ylabel('dB'); 50 | legend('d = 0.2\lambda', 'd = 0.5\lambda', 'd = \lambda', 'd = 2\lambda'); 51 | axis ([theta.minAngle, theta.maxAngle, -120 20]); -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/pattern2D.m: -------------------------------------------------------------------------------- 1 | %% 2D pattern 2 | %% ESA parameters 3 | Array.f = 3; 4 | Array.f0 = 3; 5 | Array.nxele = 2; 6 | Array.nyele = 2; 7 | Array.lambda = 0.3/Array.f; 8 | Array.dx = 1/(1 + sind(50))*Array.lambda; 9 | Array.dy = 1/(1 + sind(50))*Array.lambda; 10 | Array.EF = 1.5; 11 | Array.flag.wgt = 0; % 0 for uniform, 1 for Taylor Weighting 12 | Array.flag.errRand = 1; % 0 for ideal, 1 for random amplitude and phase error 13 | Array.flag.errQuant = 1; % 0 for ideal, 1 for quant 14 | Array.tilt.opt = 2; % 0 for ideal, 1 for roll, 2 for pitch, 3 for yaw 15 | Array.tilt.angle = 60; 16 | Array.Error.amSigma = 0.5; 17 | Array.Error.phSigma = 6; 18 | Array.qBits = 4; 19 | 20 | % Taylor weights paramenters 21 | Array.Taylor.nbar = 5; 22 | Array.Taylor.SLL = 30; 23 | 24 | % theta angle paramenters 25 | theta.N = 361; 26 | theta.minAngle = 0; 27 | theta.maxAngle = 90; 28 | theta.scanAngle = 60; 29 | 30 | phi.N = 361; 31 | phi.minAngle = 0; 32 | phi.maxAngle = 360; 33 | phi.scanAngle = 90; 34 | 35 | %% computations 36 | 37 | if Array.flag.wgt == 0 38 | Array.amWeights = ones(Array.nyele, Array.nxele); 39 | else 40 | amWeightsX = getTaylorWeights(Array.nxele, Array.Taylor.SLL, Array.Taylor.nbar); 41 | amWeightsY = getTaylorWeights(Array.nyele, Array.Taylor.SLL, Array.Taylor.nbar); 42 | Array.amWeights = amWeightsX*amWeightsY'; 43 | end 44 | 45 | % set random error or ideal error 46 | if Array.flag.errRand == 1 47 | Array.Error.amMatdB = Array.Error.amSigma*randn(Array.nyele, Array.nxele); 48 | Array.Error.amMat = 10.^(Array.Error.amMatdB/10); 49 | Array.Error.phMat = Array.Error.phSigma*randn(Array.nyele, Array.nxele); 50 | else 51 | Array.Error.amMat = ones(Array.nyele, Array.nxele); 52 | Array.Error.amMatdB = 10*log10(Array.Error.amMat); 53 | Array.Error.phMat = zeros(Array.nyele, Array.nxele); 54 | end 55 | 56 | 57 | 58 | theta.vec = linspace(theta.minAngle, theta.maxAngle, theta.N); 59 | phi.vec = linspace(phi.minAngle, phi.maxAngle, phi.N); 60 | [theta.mat, phi.mat] = meshgrid(theta.vec, phi.vec); 61 | 62 | % set rotating matrix 63 | 64 | if Array.tilt.opt == 0 65 | Array.rotMat = eye(3); 66 | elseif Array.tilt.opt == 1 67 | Array.rotMat = [cosd(Array.tilt.angle) -sind(Array.tilt.angle) 0; 68 | sind(Array.tilt.angle) cosd(Array.tilt.angle) 0; 69 | 0 0 1]; 70 | elseif Array.tilt.opt == 2 71 | Array.rotMat = [1 0 0 ; 72 | 0 cosd(Array.tilt.angle) -sind(Array.tilt.angle); 73 | 0 -sind(Array.tilt.angle) cosd(Array.tilt.angle) ]; 74 | elseif Array.tilt.opt == 3 75 | Array.rotMat = [cosd(Array.tilt.angle) 0 -sind(Array.tilt.angle); 76 | 0 1 0 ; 77 | sind(Array.tilt.angle) 0 cosd(Array.tilt.angle) ;]; 78 | end 79 | 80 | sine.uMat = sind(theta.mat).*cosd(phi.mat); 81 | sine.vMat = sind(theta.mat).*sind(phi.mat); 82 | sine.wMat = cosd(theta.mat); 83 | 84 | sine.u0 = sind(theta.scanAngle)*cosd(phi.scanAngle); 85 | sine.v0 = sind(theta.scanAngle)*sind(phi.scanAngle); 86 | sine.w0 = cosd(theta.scanAngle); 87 | 88 | uvwMat = vertcat(sine.uMat(:)', sine.vMat(:)', sine.wMat(:)'); 89 | uvwRotMat = Array.rotMat*uvwMat; 90 | sine.uRotMat = reshape(uvwRotMat(1, :), size(sine.uMat)); 91 | sine.vRotMat = reshape(uvwRotMat(2, :), size(sine.vMat)); 92 | sine.wRotMat = reshape(uvwRotMat(3, :), size(sine.wMat)); 93 | 94 | % compute AF 95 | 96 | if Array.flag.errQuant == 1 97 | Array.AF = compute2D_AFQuant(Array.amWeights, Array.dx, Array.dy,... 98 | Array.f, Array.f0, Array.Error.amMat, Array.Error.phMat,... 99 | sine.uMat, sine.u0, sine.vMat, sine.v0, Array.qBits); 100 | else 101 | Array.AF = compute2D_AF(Array.amWeights, Array.dx, Array.dy, ... 102 | Array.f, Array.f0, Array.Error.amMat, Array.Error.phMat,... 103 | sine.uMat, sine.u0, sine.vMat, sine.v0); 104 | end 105 | 106 | [AF.mag, AF.magdB, AF.magdB_Norm] = processMat(Array.AF); 107 | % compute EP 108 | Array.EP = compute2D_EP(theta.mat, Array.EF); 109 | [EP.mag, EP.magdB, EP.magdB_Norm] = processMat(Array.EP); 110 | 111 | % compute PAT 112 | Array.PAT = compute2D_PAT(Array.EP, Array.AF); 113 | [PAT.mag, PAT.magdB, PAT.magdB_Norm] = processMat(Array.PAT); 114 | 115 | % compute gain 116 | [Array.intGain, Array.idealGain] = compute2D_IntGain(Array.PAT, Array.f, Array.nxele, Array.nyele,... 117 | Array.dx, Array.dy, theta.vec, phi.vec); 118 | [Gain.mag, Gain.magdB, Gain.magdB_Norm] = processMat(Array.intGain); 119 | 120 | %% plot 121 | plotCommand.coordType = 0; % 1 for sinespace, 0 for radar coordination 122 | 123 | plotCommand.plotAll = 0; 124 | plotCommand.plotError = 0; 125 | plotCommand.plotEP = 0; 126 | plotCommand.plotPAT = 1; 127 | plotCommand.plotAF = 0; 128 | plotCommand.plotGain = 0; 129 | 130 | if plotCommand.plotAll || plotCommand.coordType == 0 131 | coord.xLabel = '\theta_{AZ}'; 132 | coord.yLabel = '\theta_{EL}'; 133 | coord.x = 180/pi*atan2(sind(theta.mat).*cosd(phi.mat), cosd(theta.mat)); 134 | coord.y = 180/pi*asin(sind(theta.mat).*sind(phi.mat)); 135 | coord.xMin = -90; 136 | coord.xMax = 90; 137 | coord.yMin = -90; 138 | coord.yMax = 90; 139 | coord.xDelta = 30; 140 | coord.yDelta = 30; 141 | else 142 | coord.xLabel = 'u'; 143 | coord.yLabel = 'v'; 144 | coord.x = sine.uMat; 145 | coord.y = sine.vMat; 146 | coord.xMin = -1; 147 | coord.xMax = 1; 148 | coord.yMin = -1; 149 | coord.yMax = 1; 150 | coord.xDelta = 0.5; 151 | coord.yDelta = 0.5; 152 | end 153 | 154 | 155 | if plotCommand.plotAll || plotCommand.plotError == 1 156 | txt.title = 'Random Amplitude Error(dB)'; 157 | opts.dimension = 2; 158 | opts.setFloor = 0; 159 | opts.setAxis = 0; 160 | plotMatrix(Array.Error.amMatdB, txt, opts, coord); 161 | 162 | figure;clf 163 | binvector=[-2:.1:2]; 164 | set(gcf,'DefaultLineLineWidth',1.5) 165 | histogram(Array.Error.amMatdB(:),binvector); 166 | set(gca,'FontSize',14,'FontWeight','bold') 167 | title('Amplitude Error Distribution') 168 | xlabel('Amplitude Error Bins (dB)') 169 | axis tight 170 | set(gca,'XTick',[-2:0.5:2]) 171 | set(gcf, 'color', 'white'); 172 | 173 | txt.title = 'Random Phase Error(degree)'; 174 | plotMatrix(Array.Error.phMat, txt, opts) 175 | 176 | figure;clf 177 | binvector=[-20:1:20]; 178 | set(gcf,'DefaultLineLineWidth',1.5) 179 | histogram(Array.Error.phMat(:),binvector); 180 | set(gca,'FontSize',14,'FontWeight','bold') 181 | title('Amplitude Error Distribution') 182 | xlabel('Amplitude Error Bins (dB)') 183 | axis tight 184 | set(gca,'XTick',[-20:1:20]) 185 | set(gcf, 'color', 'white'); 186 | end 187 | 188 | if plotCommand.plotAll || plotCommand.plotEP == 1 189 | txt.title = 'Element Pattern'; 190 | opts.dimension = 3; 191 | opts.setFloor = 1; opts.floorValue = -20; 192 | opts.setAxis = 1; 193 | plotMatrix(EP.magdB_Norm, txt, opts, coord); 194 | end 195 | 196 | if plotCommand.plotAll || plotCommand.plotAF == 1 197 | txt.title = 'Array Factor'; 198 | opts.dimension = 3; 199 | opts.setFloor = 1; opts.floorValue = -50; 200 | opts.setAxis = 1; 201 | plotMatrix(AF.magdB_Norm, txt, opts, coord); 202 | end 203 | 204 | if plotCommand.plotAll || plotCommand.plotPAT == 1 205 | txt.title = 'Pattern'; 206 | opts.dimension = 3; 207 | opts.setFloor = 1; opts.floorValue = -50; 208 | opts.setAxis = 1; 209 | plotMatrix(AF.magdB_Norm, txt, opts, coord); 210 | end 211 | 212 | if plotCommand.plotAll || plotCommand.plotGain == 1 213 | txt.title = 'Integrated Gain'; 214 | opts.dimension = 3; 215 | opts.setFloor = 0; opts.floorValue = -50; 216 | opts.setAxis = 1; 217 | plotMatrix(Gain.magdB_Norm, txt, opts, coord); 218 | end 219 | 220 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/plotMatrix.m: -------------------------------------------------------------------------------- 1 | function plotMatrix(matrix, txt, opts, coord) 2 | if opts.setFloor == 1 3 | matrix(matrix < opts.floorValue) = opts.floorValue; 4 | end 5 | figure;clf 6 | set(gcf,'DefaultLineLineWidth',1.5) 7 | if opts.dimension == 2 8 | imagesc(matrix);hold on 9 | else 10 | if opts.setAxis == 0 11 | surf(matrix);hold on 12 | else 13 | surf(coord.x, coord.y, matrix);hold on 14 | end 15 | shading interp 16 | set(gca,'FontSize',10,'FontWeight','bold') 17 | title(txt.title); 18 | xlabel(coord.xLabel),ylabel(coord.yLabel); 19 | axis tight 20 | colorbar 21 | if opts.setAxis == 1 22 | set(gca,'XTick', [coord.xMin: coord.xDelta: coord.xMax]) 23 | set(gca,'YTick', [coord.yMin: coord.yDelta: coord.yMax]) 24 | end 25 | set(gcf, 'color', 'white'); 26 | end 27 | 28 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/processMat.m: -------------------------------------------------------------------------------- 1 | function [mag, magdB, magdB_Norm] = processMat(mat) 2 | mag = abs(mat); 3 | magMax = max(max(mag)); 4 | magdB = 10*log10(mag); 5 | magdB_Norm = magdB - 10*log10(magMax); 6 | end -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/processVector.m: -------------------------------------------------------------------------------- 1 | function [vectorMag, vectorMag_dB, vectorMag_dB_Norm] = processVector(vectorArg) 2 | vectorMag = abs(vectorArg); 3 | vectorMag_dB = 20*log10(vectorMag + eps); 4 | vectorMag_dB_Norm = 20*log10((vectorMag + eps)/max(vectorMag)); 5 | end 6 | 7 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/subarray1D.m: -------------------------------------------------------------------------------- 1 | %% compute subarray architecture pattern 2 | 3 | %% init parameters 4 | IBWratio = 1.1; 5 | f0 = 4; 6 | f = IBWratio*f0; 7 | lambda = 0.3/f; 8 | lambda0 = 0.3/f0; 9 | d = lambda/2; 10 | 11 | theta = linspace(-90, 90, 721); theta0 = 30; 12 | u = sind(theta); u0 = sind(theta0); 13 | Subarray.nele = 4; 14 | Array.nele = 4; 15 | 16 | EF = 1.5; 17 | %% init weights 18 | Subarray.wgts = ones(1, Subarray.nele); 19 | Array.wgts = ones(1, Array.nele); 20 | 21 | %% compute pattern 22 | Subarray.AF = compute1D_AF(Subarray.wgts, Subarray.nele, d, f0, f, u0, u); 23 | % backend array 24 | Array.EP = compute1D_EP(theta, EF); 25 | Array.AF = compute1D_AF(Array.wgts, Array.nele, d, f, f, u0, u); 26 | Array.PAT = Array.EP.*Subarray.AF.*Array.AF; 27 | 28 | [~, ~, Subarray.AF_dBNorm] = processVector(Subarray.AF); 29 | [~, ~, Array.AF_dBNorm] = processVector(Array.AF); 30 | [~, ~, Array.EP_dBNorm] = processVector(Array.EP); 31 | [~, ~, Array.PAT_dBNorm] = processVector(Array.PAT); 32 | % for normalized back end pattern rather than output pattern. 33 | % compensate Array.PAT value loss caused by log operator 34 | compensation = Array.EP_dBNorm(u == u0) + Subarray.AF_dBNorm(u == u0); 35 | %% plot 36 | clf 37 | figure(1) 38 | set(gcf,'DefaultLineLineWidth',2) 39 | plot(theta, Array.EP_dBNorm, 'Color', 'r'); 40 | hold on 41 | plot(theta, Subarray.AF_dBNorm, 'Color', 'b'); 42 | hold on 43 | plot(theta, Array.AF_dBNorm, 'Color', 'k'); 44 | hold on 45 | plot(theta, Array.PAT_dBNorm + compensation, 'Color', 'g'); 46 | hold on 47 | 48 | set(gca, 'fontsize', 14, 'fontweight', 'bold'); 49 | xlabel('\theta (degree)'); ylabel('dB'); 50 | legend('EP', 'Subarray.AF', 'AF', 'PAT'); 51 | axis ([theta(1), theta(end), -80, 0]); 52 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/subarray1D_Overlapped.m: -------------------------------------------------------------------------------- 1 | %% compute subarray architecture pattern 2 | 3 | %% init paramenters 4 | IBWratio = 1.1; 5 | f0 = 4; 6 | f = IBWratio*f0; 7 | lambda = 0.3/f; 8 | lambda0 = 0.3/f0; 9 | d = lambda/2; 10 | 11 | theta = linspace(-10, 50, 721); theta0 = 30; 12 | u = sind(theta); u0 = sind(theta0); 13 | 14 | OSA.ratio = 2; 15 | EF = 1.5; 16 | 17 | SA.nele = 8; SA.nsas = 20; 18 | OSA.nele = OSA.ratio*SA.nele; % number of elements in OSA 19 | OSA.nsas = SA.nsas - (OSA.ratio - 1); % number of OSAs in backend OSA AF 20 | %% init weights 21 | Taylor.nbar = 6; 22 | Taylor.sll = 35; 23 | Taylor.set = true; 24 | SA.wgts.ele = ones(1, SA.nele); 25 | SA.wgts.sas = ones(1, SA.nsas); 26 | OSA.wgts.ele = ones(1, OSA.nele); 27 | OSA.wgts.sas = ones(1, OSA.nsas); 28 | 29 | if Taylor.set 30 | OSA.wgts.ele = getTaylorWeights(OSA.nele, Taylor.sll, Taylor.nbar); 31 | SA.wgts.ele = getTaylorWeights(SA.nele, Taylor.sll, Taylor.nbar); 32 | end 33 | %% compute pattern 34 | EP = compute1D_EP(theta, EF); 35 | SA.AFe = compute1D_AF(SA.wgts.ele, SA.nele, d, f0, f, u0, u); 36 | OSA.AFe = compute1D_AF(OSA.wgts.ele, OSA.nele, d, f0, f, u0, u); 37 | % backend beamforming 38 | SA.AF = compute1D_AF(SA.wgts.sas, SA.nsas, d, f, f, u0, u); 39 | OSA.AF = compute1D_AF(OSA.wgts.sas, OSA.nsas, d, f, f, u0, u); 40 | 41 | SA.PAT = EP.*SA.AFe.*SA.AF; 42 | OSA.PAT = EP.*OSA.AFe.*OSA.AF; 43 | [~, ~, EP_dBNorm] = processVector(EP); 44 | [~, ~, SA.AF_dBNorm] = processVector(SA.AF); 45 | [~, ~, SA.AFe_dBNorm] = processVector(SA.AFe); 46 | [~, ~, OSA.AF_dBNorm] = processVector(OSA.AF); 47 | [~, ~, OSA.AFe_dBNorm] = processVector(OSA.AFe); 48 | [~, ~, SA.PAT_dBNorm] = processVector(SA.PAT); 49 | [~, ~, OSA.PAT_dBNorm] = processVector(OSA.PAT); 50 | % for normalized back end pattern rather than output pattern. 51 | % compensate Array.PAT value loss caused by log operator 52 | OSA.compensation = EP_dBNorm(u == u0) + OSA.PAT_dBNorm(u == u0); 53 | SA.compensation = EP_dBNorm(u == u0) + SA.PAT_dBNorm(u == u0); 54 | %% plot 55 | figure(1); clf 56 | set(gcf,'DefaultLineLineWidth',2) 57 | plot(theta, OSA.AFe_dBNorm, 'Color', 'b'); 58 | hold on 59 | plot(theta, OSA.AF_dBNorm, 'Color', 'k'); 60 | hold on 61 | plot(theta, OSA.PAT_dBNorm + OSA.compensation, 'Color', 'g'); 62 | hold on 63 | set(gca, 'fontsize', 14, 'fontweight', 'bold'); 64 | title(['\it Composite Array Pattern with ',num2str(OSA.ratio),... 65 | ': 1 Overlap and f = ',num2str(IBWratio),'*f_o']) 66 | xlabel('\theta (degree)'); ylabel('dB'); 67 | legend('OSA Subarray Pattern', 'OSA Backend AF', 'OSA pattern'); 68 | axis ([theta(1), theta(end), -80, 0]); 69 | 70 | figure(2); clf 71 | set(gcf,'DefaultLineLineWidth',2) 72 | plot(theta, SA.AFe_dBNorm, 'Color', 'b'); 73 | hold on 74 | plot(theta, SA.AF_dBNorm, 'Color', 'k'); 75 | hold on 76 | plot(theta, SA.PAT_dBNorm + SA.compensation, 'Color', 'g'); 77 | hold on 78 | set(gca, 'fontsize', 14, 'fontweight', 'bold'); 79 | title(['\it Composite Array Pattern with No Overlap and f = ',num2str(IBWratio),'*f_o']) 80 | xlabel('\theta (degree)'); ylabel('dB'); 81 | legend('SA Subarray Pattern', 'SA Backend AF', 'SA pattern'); 82 | axis ([theta(1), theta(end), -80, 0]); 83 | -------------------------------------------------------------------------------- /projects/相控阵/ESA Simulation/test.m: -------------------------------------------------------------------------------- 1 | %% Code to compute subarrayed architecture pattern 2 | % Arik D. Brown 3 | %% Input Parameters 4 | IBWratio=1.1;%IBWratio -> f=fo 5 | fo=4;%GHz Tune Frequency 6 | f=IBWratio*fo;%GHz Operating Frequency 7 | lambda=0.3/f;%inches 8 | lambdao=0.3/fo;%inches 9 | d=lambdao/2;%inches 10 | theta=linspace(-90,90,721);%deg 11 | thetao=30;%deg98 Electronically Scanned Arrays: MATLAB? Modeling and Simulation 12 | u=sind(theta); 13 | uo=sind(thetao); 14 | SA.nelems=4;%Number of elements in Subarray 15 | AF.nelems=4;%Number of elements in Backend AF 16 | EF=1.5; 17 | SA.wgts=ones(1,SA.nelems); 18 | AF.wgts=ones(1,AF.nelems); 19 | plotfigs.flags.EP=1; 20 | plotfigs.flags.SA=1; 21 | plotfigs.flags.AF=1; 22 | plotfigs.flags.PAT=1; 23 | plotfigs.flags.ALL=1; 24 | plotfigs.axis.xlims=[-90 90]; 25 | plotfigs.axis.ylims=[-40 0]; 26 | %% Compute Pattern 27 | % Element Pattern 28 | EP = compute1D_EP(theta,EF); 29 | [EP_mag, EP_dB, EP_dBnorm] = processVector(EP); 30 | % Subarray AF 31 | %!!! To simulate an array of elements without phase shifters 32 | 33 | %the last input to Compute_1D_AF 34 | SA.AF = compute1D_AF(SA.wgts,SA.nelems,d,fo,f,uo,u); 35 | [SA.AF_mag, SA.AF_dB, SA.AF_dBnorm] = processVector(SA.AF); 36 | %Backend AF 37 | AF.AF = compute1D_AF(AF.wgts,AF.nelems,d,fo,f,uo,u); 38 | [AF.AF_mag, AF.AF_dB, AF.AF_dBnorm] = processVector(AF.AF); 39 | %Pattern = Element Pattern x Subarray AF Pattern x AF 40 | 41 | PAT=EP.*SA.AF.*AF.AF; 42 | [PAT_mag,PAT_dB,PAT_dBnorm] = processVector(PAT); 43 | SA.scanvalue.afsa=SA.AF_dBnorm(u==uo); 44 | EPscanvalue=EP_dBnorm(u==uo); 45 | patnorm.sa=SA.scanvalue.afsa+EPscanvalue; 46 | 47 | %Plot Pattern in dB, Unnormalized 48 | figure,clf 49 | set(gcf,'DefaultLineLineWidth',1.5) 50 | set(gcf,'DefaultTextFontSize',12,'DefaultTextFontWeight','bold') 51 | plot(theta,EP_dBnorm,'color',[0 0 0]),hold 52 | plot(theta,SA.AF_dBnorm,'color',[0 .7 0]) 53 | plot(theta,AF.AF_dBnorm,'color',[.7 0 1]) 54 | plot(theta,PAT_dBnorm+patnorm.sa,'color',[0 0 1]) 55 | grid 56 | axis([plotfigs.axis.xlims plotfigs.axis.ylims]) 57 | title(['Composite Array Pattern, f =',num2str(IBWratio),'*f_{o}'],... 58 | 'FontSize',14,'FontWeight','bold') 59 | xlabel('\theta (degrees)','FontSize',12,'FontWeight','bold') 60 | ylabel('dB','FontSize',12,'FontWeight','bold') 61 | set(gca,'FontSize',12,'FontWeight','bold') 62 | set(gcf,'color','white') 63 | legend('EP','SA.AF','AF','Pattern=EP*SA.AF*AF') --------------------------------------------------------------------------------