将计算振幅提前

pull/3/head
陈增辉 2025-01-03 00:15:08 +08:00
parent e3a6585adb
commit 19dbddd6b5
3 changed files with 164 additions and 142 deletions

View File

@ -459,21 +459,22 @@ __global__ void CUDA_CombinationEchoAmpAndPhase(float* R,
__global__ void CUDAKernel_RFPC_Caluation_R_Gain(
float antX, float antY, float antZ,
float* targetX, float* targetY, float* targetZ, long len,
float* demSlopeX, float* demSlopeY, float* demSlopeZ,
float antXaxisX, float antXaxisY, float antXaxisZ,
float antYaxisX, float antYaxisY, float antYaxisZ,
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ,
float* TransAntpattern,
float Transtarttheta, float Transstartphi, float Transdtheta, float Transdphi, int Transthetapoints, int Transphipoints,
float* ReceiveAntpattern,
float Receivestarttheta, float Receivestartphi, float Receivedtheta, float Receivedphi, int Receivethetapoints, int Receivephipoints,
float NearR, float FarR,
float* outR,
float* outLocalAngle,
float* AmpGain) {
float antX, float antY, float antZ, // 天线的坐标
float* targetX, float* targetY, float* targetZ, long len, // 地面坐标
long* demCls,
float* demSlopeX, float* demSlopeY, float* demSlopeZ, // 地表坡度矢量
float antXaxisX, float antXaxisY, float antXaxisZ, // 天线坐标系的X轴
float antYaxisX, float antYaxisY, float antYaxisZ,// 天线坐标系的Y轴
float antZaxisX, float antZaxisY, float antZaxisZ,// 天线坐标系的Z轴
float antDirectX, float antDirectY, float antDirectZ,// 天线的指向
float Pt,// 发射能量
float* TransAntpattern, float Transtarttheta, float Transstartphi, float Transdtheta, float Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
float* ReceiveAntpattern, float Receivestarttheta, float Receivestartphi, float Receivedtheta, float Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
float NearR, float FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
float* outR, // 输出距离
float* outAmp // 输出增益
) {
long idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < len) {
float RstX = antX - targetX[idx]; // 计算坐标矢量
@ -485,15 +486,15 @@ __global__ void CUDAKernel_RFPC_Caluation_R_Gain(
float RstR = sqrtf(RstX * RstX + RstY * RstY + RstZ * RstZ); // 矢量距离
if (RstR<NearR || RstR>FarR) {
outLocalAngle[idx] = 0;
outR[idx] = 0;
AmpGain[idx] = 0;
outAmp[idx] = 0;
}
else {
// 求解坡度
float slopR = sqrtf(slopeX * slopeX + slopeY * slopeY + slopeZ * slopeZ); //
float dotAB = RstX * slopeX + RstY * slopeY + RstZ * slopeZ;
outLocalAngle[idx] = acosf(dotAB / (RstR * slopR)); // ¾ÖµØÈëÉä½Ç
float localangle = acosf(dotAB / (RstR * slopR)); // 局地入射角
float ampGain = 0;
// 求解天线方向图指向
CUDAVectorEllipsoidal antVector = GPU_SatelliteAntDirectNormal(
@ -519,14 +520,39 @@ __global__ void CUDAKernel_RFPC_Caluation_R_Gain(
Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
temptheta, tempphi);
// 计算
float sigma0 = 0;
{
long clsid = demCls[idx];
CUDASigmaParam tempsigma = sigma0Paramslist[clsid];
if (localangle < 0 || localangle >= LAMP_CUDA_PI / 2) {
sigma0 = 0;
}
else {}
if (abs(tempsigma.p1) < PRECISIONTOLERANCE &&
abs(tempsigma.p2) < PRECISIONTOLERANCE &&
abs(tempsigma.p3) < PRECISIONTOLERANCE &&
abs(tempsigma.p4) < PRECISIONTOLERANCE &&
abs(tempsigma.p5) < PRECISIONTOLERANCE &&
abs(tempsigma.p6) < PRECISIONTOLERANCE
) {
sigma0 = 0;
}
else {
float sigma = GPU_getSigma0dB(tempsigma, localangle);
sigma0 = powf(10.0, sigma / 10.0);// 后向散射系数
}
}
ampGain = TansantPatternGain * antPatternGain;
ampGain = ampGain / (powf(4 * LAMP_CUDA_PI, 2) * powf(RstR, 4)); // 反射强度
AmpGain[idx] = ampGain;
outAmp[idx] = ampGain * Pt * sigma0;
outR[idx] = RstR;
}
else {
outR[idx] = 0;
AmpGain[idx] = 0;
outAmp[idx] = 0;
}
}
}
@ -785,19 +811,23 @@ extern "C" void CUDAInterpSigma(
cudaDeviceSynchronize();
}
extern "C" void CUDARFPC_Caluation_R_Gain(float antX, float antY, float antZ,
float* targetX, float* targetY, float* targetZ, long TargetPixelNumber,
float* demSlopeX, float* demSlopeY, float* demSlopeZ,
float antXaxisX, float antXaxisY, float antXaxisZ,
float antYaxisX, float antYaxisY, float antYaxisZ,
float antZaxisX, float antZaxisY, float antZaxisZ,
float antDirectX, float antDirectY, float antDirectZ,
float* TransAntpattern, float Transtarttheta, float Transstartphi, float Transdtheta, float Transdphi, int Transthetapoints, int Transphipoints,
float* ReceiveAntpattern, float Receivestarttheta, float Receivestartphi, float Receivedtheta, float Receivedphi, int Receivethetapoints, int Receivephipoints,
float NearR, float FarR,
float* outR,
float* outLocalAngle,
float* AmpGain)
extern "C" void CUDARFPC_Caluation_R_Gain(
float antX, float antY, float antZ, // 天线的坐标
float* targetX, float* targetY, float* targetZ, long TargetPixelNumber, // 地面坐标
long* demCls,
float* demSlopeX, float* demSlopeY, float* demSlopeZ, // 地表坡度矢量
float antXaxisX, float antXaxisY, float antXaxisZ, // 天线坐标系的X轴
float antYaxisX, float antYaxisY, float antYaxisZ,// 天线坐标系的Y轴
float antZaxisX, float antZaxisY, float antZaxisZ,// 天线坐标系的Z轴
float antDirectX, float antDirectY, float antDirectZ,// 天线的指向
float Pt,// 发射能量
float* TransAntpattern, float Transtarttheta, float Transstartphi, float Transdtheta, float Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
float* ReceiveAntpattern, float Receivestarttheta, float Receivestartphi, float Receivedtheta, float Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
float NearR, float FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
float* outR, // 输出距离
float* outAmp // 输出增益
)
{
int blockSize = 256; // 每个块的线程数
@ -806,19 +836,20 @@ extern "C" void CUDARFPC_Caluation_R_Gain(float antX, float antY, float antZ,
CUDAKernel_RFPC_Caluation_R_Gain << <numBlocks, blockSize >> > (
antX, antY, antZ,
targetX, targetY, targetZ, TargetPixelNumber,
demCls,
demSlopeX, demSlopeY, demSlopeZ,
antXaxisX, antXaxisY, antXaxisZ,
antYaxisX, antYaxisY, antYaxisZ,
antZaxisX, antZaxisY, antZaxisZ,
antDirectX, antDirectY, antDirectZ,
Pt,
TransAntpattern,
Transtarttheta, Transstartphi, Transdtheta, Transdphi, Transthetapoints, Transphipoints,
ReceiveAntpattern,
Receivestarttheta, Receivestartphi, Receivedtheta, Receivedphi, Receivethetapoints, Receivephipoints,
NearR, FarR,
outR,
outLocalAngle,
AmpGain
outAmp
);

View File

@ -67,18 +67,19 @@ extern "C" void CUDAInterpSigma(
extern "C" void CUDARFPC_Caluation_R_Gain(
float antX,float antY,float antZ, // 天线的坐标
float* targetX,float* targetY, float* targetZ, long TargetPixelNumber, // 地面坐标
long* demCls,
float* demSlopeX, float* demSlopeY, float* demSlopeZ, // 地表坡度矢量
float antXaxisX, float antXaxisY, float antXaxisZ, // 天线坐标系的X轴
float antYaxisX, float antYaxisY, float antYaxisZ,// 天线坐标系的Y轴
float antZaxisX, float antZaxisY, float antZaxisZ,// 天线坐标系的Z轴
float antDirectX, float antDirectY, float antDirectZ,// 天线的指向
float Pt,// 发射能量
float* TransAntpattern, float Transtarttheta, float Transstartphi, float Transdtheta, float Transdphi, int Transthetapoints, int Transphipoints, // 发射天线方向图
float* ReceiveAntpattern, float Receivestarttheta, float Receivestartphi, float Receivedtheta, float Receivedphi, int Receivethetapoints, int Receivephipoints,//接收天线方向图
float NearR,float FarR, // 距离范围
CUDASigmaParam* sigma0Paramslist, long sigmaparamslistlen,// 插值图
float* outR, // 输出距离
float* outLocalAngle, // 输出局地坐标系
float* AmpGain // 输出增益
float* outAmp // 输出增益
);

View File

@ -568,7 +568,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
h_demsloper_x=(float* )mallocCUDAHost( sizeof(float) * blokline * tempDemCols);
h_demsloper_y=(float* )mallocCUDAHost( sizeof(float) * blokline * tempDemCols);
h_demsloper_z=(float* )mallocCUDAHost(sizeof(float) * blokline * tempDemCols);
h_demsloper_angle= (float*)mallocCUDAHost( sizeof(float) * blokline * tempDemCols);
d_dem_x=(float* )mallocCUDADevice( sizeof(float) * blokline * tempDemCols); // 7
d_dem_y=(float* )mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
@ -576,7 +575,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
d_demsloper_x=(float* )mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
d_demsloper_y=(float* )mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
d_demsloper_z=(float* )mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
d_demsloper_angle= (float*)mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
// 提前声明参数变量
float* h_R;// 辐射方向
@ -591,8 +589,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
d_localangle= (float*)mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
float* h_gain = (float*)mallocCUDAHost( sizeof(float)* blokline* tempDemCols);
float* d_gain = (float*)mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
float* h_amp = (float*)mallocCUDAHost( sizeof(float)* blokline* tempDemCols);
float* d_amp = (float*)mallocCUDADevice( sizeof(float) * blokline * tempDemCols);
// 回波
cuComplex* h_echo;
@ -628,10 +626,8 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
FreeCUDAHost(h_demsloper_x); FreeCUDADevice(d_demsloper_x);
FreeCUDAHost(h_demsloper_y); FreeCUDADevice(d_demsloper_y);
FreeCUDAHost(h_demsloper_z); FreeCUDADevice(d_demsloper_z); //6
FreeCUDAHost(h_demsloper_angle); FreeCUDADevice(d_demsloper_angle);//7
FreeCUDAHost(h_R); FreeCUDADevice(d_R);
FreeCUDAHost(h_localangle); FreeCUDADevice(d_localangle); //11
FreeCUDAHost(h_gain); FreeCUDADevice(d_gain);
FreeCUDAHost(h_amp); FreeCUDADevice(d_amp);
FreeCUDAHost(h_echo); FreeCUDADevice(d_echo);//19
FreeCUDAHost(h_demcls); FreeCUDADevice(d_demcls);
@ -643,11 +639,9 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
h_demsloper_z = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
h_demsloper_angle = (float*)mallocCUDAHost(sizeof(float) * blokline * tempDemCols);
h_R = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
h_localangle = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
h_gain = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
h_amp = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
h_echo = (cuComplex*)mallocCUDAHost(sizeof(cuComplex) * newblokline * tempDemCols);
h_demcls = (long*)mallocCUDAHost(sizeof(long) * newblokline * tempDemCols);
h_R = (float*)mallocCUDAHost(sizeof(float) * newblokline * tempDemCols);
d_dem_x=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_dem_y=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
@ -656,9 +650,7 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
d_demsloper_y=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_demsloper_z=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);//6
d_demsloper_angle=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);//7
d_R=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_localangle=(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_gain =(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_amp =(float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
d_echo=(cuComplex*)mallocCUDADevice(sizeof(cuComplex) * newblokline * tempDemCols);
d_demcls = (long*)mallocCUDADevice(sizeof(long) * newblokline * tempDemCols);
d_R = (float*)mallocCUDADevice(sizeof(float) * newblokline * tempDemCols);
@ -683,7 +675,6 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
HostToDevice((void*)h_demsloper_x, (void*)d_demsloper_x, sizeof(float) * newblokline * tempDemCols);
HostToDevice((void*)h_demsloper_y, (void*)d_demsloper_y, sizeof(float) * newblokline * tempDemCols);
HostToDevice((void*)h_demsloper_z, (void*)d_demsloper_z, sizeof(float) * newblokline * tempDemCols);
HostToDevice((void*)h_demsloper_angle, (void*)d_demsloper_angle, sizeof(float) * newblokline * tempDemCols);
HostToDevice((void*)h_demcls, (void*)d_demcls, sizeof(long) * newblokline* tempDemCols);
@ -752,49 +743,49 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
CUDARFPC_Caluation_R_Gain(
antpx, antpy, antpz, // 天线的坐标
d_dem_x, d_dem_y, d_dem_z, pixelcount, // 地面坐标
d_demcls,
d_demsloper_x, d_demsloper_y, d_demsloper_z, // 地表坡度矢量
antXaxisX, antXaxisY, antXaxisZ, // 天线坐标系的X轴
antYaxisX, antYaxisY, antYaxisZ,// 天线坐标系的Y轴
antZaxisX, antZaxisY, antZaxisZ,// 天线坐标系的Z轴
antdirectx, antdirecty, antdirectz,// 天线的指向
Pt,
d_TantPattern, TstartTheta, TstartPhi, Tdtheta, Tdphi, Tthetanum, Tphinum, // 发射天线方向图
d_RantPattern, RstartTheta, RstartPhi, Rdtheta, Rdphi, Rthetanum, Rphinum,//接收天线方向图
NearRange, FarRange,
d_clsSigmaParam, clamapid,
d_R, // 输出距离
d_localangle, // 输出局地入射角
d_gain // 输出增益
d_amp // Êä³öÔöÒæ
);
// 计算某个具体回波
//DeviceToHost(h_echosum_temp, d_echosum_temp, sizeof(cuComplex)* templine* PlusePoint);
for (long freqid = 0; freqid < freqlist.size(); freqid++) {
float freqpoint = freqlist[freqid];
CUDARFPC_Target_Freq_EchoData(d_R,
d_localangle,
d_gain,
d_demcls,
pixelcount,
Pt, freqpoint,
d_clsSigmaParam, clamapid,
d_echo);
// 数据求和
CUDA_MemsetBlock(d_echosum_temp, initSumTemp, grid_size);
long tempechoid = tempprfid * PlusePoint + freqid;
CUDA_DemEchoSUM_NoMalloc(d_echo, pixelcount,
d_echosum_temp + grid_size * freqid, grid_size
);
}
////DeviceToHost(h_echosum_temp, d_echosum_temp, sizeof(cuComplex)* templine* PlusePoint);
//for (long freqid = 0; freqid < freqlist.size(); freqid++) {
// float freqpoint = freqlist[freqid];
// CUDARFPC_Target_Freq_EchoData(d_R,
// d_localangle,
// d_demcls,
// pixelcount,
// Pt, freqpoint,
// d_clsSigmaParam, clamapid,
// d_echo);
// // Êý¾ÝÇóºÍ
// CUDA_MemsetBlock(d_echosum_temp, initSumTemp, grid_size);
// long tempechoid = tempprfid * PlusePoint + freqid;
// CUDA_DemEchoSUM_NoMalloc(d_echo, pixelcount,
// d_echosum_temp + grid_size * freqid, grid_size
// );
//}
CUDA_SumPRF_Temp(d_echosum_temp, PlusePoint, grid_size, d_echo_PRF);
DeviceToHost(h_echo_PRF, d_echo_PRF, sizeof(cuComplex) * PlusePoint);
for (long freqid = 0; freqid < PlusePoint; freqid++) {
echotemp.get()[tempprfid * PlusePoint + freqid] = echotemp.get()[tempprfid * PlusePoint + freqid]
+ std::complex<float>(
h_echo_PRF[freqid].x,
h_echo_PRF[freqid].y);
}
//CUDA_SumPRF_Temp(d_echosum_temp, PlusePoint, grid_size, d_echo_PRF);
//DeviceToHost(h_echo_PRF, d_echo_PRF, sizeof(cuComplex) * PlusePoint);
//for (long freqid = 0; freqid < PlusePoint; freqid++) {
// echotemp.get()[tempprfid * PlusePoint + freqid] =
// echotemp.get()[tempprfid * PlusePoint + freqid]
// + std::complex<float>(
// h_echo_PRF[freqid].x,
// h_echo_PRF[freqid].y);
//}
if (prfid % 100 == 0) {
std::cout << "[" << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString() << "] dem:\t" << startline << "\t-\t" << startline + newblokline << "\t:\t pluse :\t" << prfid << " / " << pluseCount << std::endl;
}
@ -825,8 +816,7 @@ ErrorCode RFPCProcessCls::RFPCMainProcess_GPU( )
// 临时变量释放
FreeCUDAHost(h_R); FreeCUDADevice(d_R);
FreeCUDAHost(h_localangle); FreeCUDADevice(d_localangle); //11
FreeCUDAHost(h_gain); FreeCUDADevice(d_gain);
FreeCUDAHost(h_amp); FreeCUDADevice(d_amp);
FreeCUDAHost(h_demcls); FreeCUDADevice(d_demcls);
FreeCUDAHost(freqpoints);