修复除法精度不足acos的边界溢出问题

pull/3/head
陈增辉 2025-01-27 23:37:25 +08:00
parent fb8f0409e1
commit aca14ee0cc
4 changed files with 37 additions and 12 deletions

View File

@ -75,9 +75,13 @@ __device__ CUDAVectorEllipsoidal GPU_SatelliteAntDirectNormal(
// 计算theta 与 phi
double Norm = sqrtf(Xant * Xant + Yant * Yant + Zant * Zant); // 计算 pho
double ThetaAnt = acosf(Zant / Norm); // theta 与 Z轴的夹角
double ThetaAnt = abs(Zant - Norm)<PRECISIONTOLERANCE?0: acosf(Zant / Norm); // theta Óë ZÖáľÄźĐ˝Ç
double PhiAnt = atanf(Yant / Xant); // -pi/2 ~pi/2
if (isnan(ThetaAnt)) {
printf("theta is nan,[Xant,Yant,Zant,Norm,Zn,Z1]=[%f,%f,%f,%f,%f,%f];\n",
Xant, Yant, Zant,Norm, Zant / Norm, Zant / Norm-1);
}
if (abs(Yant) < PRECISIONTOLERANCE) { // X轴上
PhiAnt = 0;
@ -106,7 +110,6 @@ __device__ CUDAVectorEllipsoidal GPU_SatelliteAntDirectNormal(
printf("V=[%f,%f,%f];norm=%f;thetaAnt=%f;phiAnt=%f;\n", Xant, Yant, Zant, Norm, ThetaAnt, PhiAnt);
}
result.theta = ThetaAnt;
result.phi = PhiAnt;
result.Rho = Norm;
@ -278,9 +281,24 @@ __global__ void CUDA_Kernel_Computer_R_amp(
else {}
ampGain = ampGain / (powf(4 * LAMP_CUDA_PI, 2) * powf(RstR, 4)); // 反射强度
d_temp_amps[idx] = float(ampGain * Pt * sigma0);
d_temp_R[idx] = float(RstR - refPhaseRange);
float temp_amp = float(ampGain * Pt * sigma0);
float temp_R = float(RstR - refPhaseRange);
if (isnan(temp_amp) || isnan(temp_R)|| isinf(temp_amp) || isinf(temp_R)) {
printf("amp is nan or R is nan,amp=%f;R=%f; \n", temp_amp, temp_R);
d_temp_R[idx] = 0;
d_temp_amps[idx] = 0;
return;
}
else {}
d_temp_amps[idx] = temp_amp;
d_temp_R[idx] = temp_R;
return;
}
else {
@ -355,6 +373,11 @@ __global__ void CUDA_Kernel_Computer_echo(
//if (dataid > 5000) {
// printf("echo_ID=%d; dataid=%d;ehodata=(%f,%f);R=%f;amp=%f;\n", echo_ID, dataid, temp_real, temp_imag, s_R[0], s_amp[0]);
//}
if (isnan(temp_phi) || isnan(temp_amp) || isnan(temp_real) || isnan(temp_imag)
|| isinf(temp_phi) || isinf(temp_amp) || isinf(temp_real) || isinf(temp_imag)
) {
printf("[amp,phi,real,imag]=[%f,%f,%f,%f];\n",temp_amp,temp_phi,temp_real,temp_imag);
}
}
//printf("echo_ID=%d; ehodata=(%f,%f)\n", echo_ID, temp_real, temp_imag);

View File

@ -22,7 +22,7 @@
<x>0</x>
<y>0</y>
<width>1920</width>
<height>22</height>
<height>23</height>
</rect>
</property>
</widget>
@ -43,6 +43,12 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTreeWidget" name="treeWidgetToolBox">
<property name="font">
<font>
<family>黑体</family>
<pointsize>16</pointsize>
</font>
</property>
<column>
<property name="text">
<string>工具箱</string>

View File

@ -103,7 +103,7 @@
</size>
</property>
<property name="text">
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/landcover_center_int32.dat</string>
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/landcover_aligned2.dat</string>
</property>
</widget>
</item>
@ -233,7 +233,7 @@
</size>
</property>
<property name="text">
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/demxyz_center.bin</string>
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/demxyz.bin</string>
</property>
</widget>
</item>
@ -350,7 +350,7 @@
</size>
</property>
<property name="text">
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/demsloper_center.bin</string>
<string>D:/Programme/vs2022/RasterMergeTest/simulationData/demdataset/demsloper.bin</string>
</property>
</widget>
</item>

View File

@ -828,10 +828,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU() {
HostToDevice(h_demsloper_x, d_demsloper_x , sizeof(double) * blockline * demCol);
HostToDevice(h_demsloper_y, d_demsloper_y , sizeof(double) * blockline * demCol);
HostToDevice(h_demsloper_z, d_demsloper_z , sizeof(double) * blockline * demCol);
HostToDevice(h_demcls, d_demcls ,sizeof(long)* blockline* demCol);
// 分块处理
qDebug() << "Start PRF: " << sprfid << "\t-\t" << sprfid + PRF_len << "\t:GPU Computer target data (" << startline << "-" << startline + blockline << ")";
@ -876,8 +874,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU() {
FreeCUDAHost(h_temp_R);
FreeCUDAHost(h_temp_amp);
#endif
DeviceToHost(h_echo_block_real, d_echo_block_real, sizeof(float) * PRF_len * freqnum);
DeviceToHost(h_echo_block_imag, d_echo_block_imag, sizeof(float) * PRF_len * freqnum);