同步修改

pull/5/head
chenzenghui 2025-02-27 18:30:29 +08:00
parent 47c56eab3c
commit 6463cd4ccd
2 changed files with 61 additions and 56 deletions

View File

@ -32,47 +32,52 @@ __global__ void kernel_TimeBPImageGridNet(double* antPx, double* antPy, double*
long Rid = idx % freqpoints;
if (idx < pixelcount) {
// 计算坐标
Vector3 S = { antPx[prfid], antPy[prfid], antPz[prfid] }; // 卫星位置 (m)
Vector3 ray = { antDirx[prfid], antDiry[prfid], antDirz[prfid] }; // 视线方向
double H = meanH; // 平均高程
double R = Rnear+ dx*Rid; // 目标距离
double R = Rnear + dx * Rid; // 目标距离
// 参数校验
if (R <= 0 || H < -WGS84_A * 0.1 || H > WGS84_A * 0.1) {
//printf("参数错误:\n H范围±%.1f km\n R必须>0\n", WGS84_A * 0.1 / 1000);
imgx[idx] = 1.0 / 0;
imgy[idx] = 1.0 / 0;
imgz[idx] = 1.0 / 0;
printf("idx=%d;prfid=%d;Rid=%d;S=[%f , %f ,%f ];ray=[%f ,%f ,%f ];H=%f;R=%f,imgP=[%f ,%f , %f ];Rextend\n",
idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R,imgx[idx],imgy[idx],imgz[idx]);
// 参数校验
return;
}
// 参数校验
if (R <= 0 || H < -WGS84_A * 0.1 || H > WGS84_A * 0.1) {
//printf("参数错误:\n H范围±%.1f km\n R必须>0\n", WGS84_A * 0.1 / 1000);
imgx[idx] = 1.0/0;
imgy[idx] = 1.0/0;
imgz[idx] = 1.0/0;
// Step 1: 计算交点T
Vector3 T = compute_T(S, ray, H);
if (isnan(T.x)) {
imgx[idx] = 1.0 / 0;
imgy[idx] = 1.0 / 0;
imgz[idx] = 1.0 / 0;
printf("idx=%d;prfid=%d;Rid=%d;S=[%f , %f ,%f ];ray=[%f ,%f ,%f ];H=%f;R=%f;imgT=[%f ,%f ,%f ];imgP=[%f ,%f , %f ];Tnan\n",
idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R,T.x,T.y,T.z, imgx[idx], imgy[idx], imgz[idx]);
return;
}
return ;
}
// Step 1: 计算交点T
Vector3 T = compute_T(S, ray, H);
if (isnan(T.x)) {
imgx[idx] = 1.0/0;
imgy[idx] = 1.0/0;
imgz[idx] = 1.0/0;
return ;
}
// Step 2: 计算目标点P
Vector3 P = compute_P(S, T, R, H);
if (!isnan(P.x)) {
// Step 2: 计算目标点P
Vector3 P = compute_P(S, T, R, H);
imgx[idx] = P.x;
imgy[idx] = P.y;
imgz[idx] = P.z;
}
else {
imgx[idx] = 1.0/0;
imgy[idx] = 1.0/0;
imgz[idx] = 1.0/0;
//printf("未找到有效解\n");
}
if (!isnan(P.x)) {
imgx[idx] = P.x;
imgy[idx] = P.y;
imgz[idx] = P.z;
printf("idx=%d;prfid=%d;Rid=%d;S=[%f , %f ,%f ];ray=[%f ,%f ,%f ];H=%f;R=%f;imgT=[%f ,%f ,%f ];imgP=[%f ,%f , %f ]; \n",
idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R, T.x, T.y, T.z, imgx[idx], imgy[idx], imgz[idx]);
}
else {
imgx[idx] = 1.0 / 0;
imgy[idx] = 1.0 / 0;
imgz[idx] = 1.0 / 0;
printf("idx=%d;prfid=%d;Rid=%d;S=[%f , %f ,%f ];ray=[%f ,%f ,%f ];H=%f;R=%f;imgT=[%f ,%f ,%f ];imgP=[%f ,%f , %f ];Pnan\n",
idx, prfid, Rid, S.x, S.y, S.z, ray.x, ray.y, ray.z, H, R, T.x, T.y, T.z, imgx[idx], imgy[idx], imgz[idx]);
//printf("未找到有效解\n");
}
}
}

View File

@ -82,9 +82,9 @@ void CreatePixelXYZ(std::shared_ptr<EchoL0Dataset> echoL0ds, QString outPixelXYZ
HostToDevice(Pxs.get(), d_Pxs.get(), sizeof(double) * prfcount);
HostToDevice(Pys.get(), d_Pys.get(), sizeof(double) * prfcount);
HostToDevice(Pzs.get(), d_Pzs.get(), sizeof(double) * prfcount);
HostToDevice(d_AntDirectX.get(), d_AntDirectX.get(), sizeof(double) * prfcount);
HostToDevice(d_AntDirectY.get(), d_AntDirectY.get(), sizeof(double) * prfcount);
HostToDevice(d_AntDirectZ.get(), d_AntDirectZ.get(), sizeof(double) * prfcount);
HostToDevice(AntDirectX.get(), d_AntDirectX.get(), sizeof(double) * prfcount);
HostToDevice(AntDirectY.get(), d_AntDirectY.get(), sizeof(double) * prfcount);
HostToDevice(AntDirectZ.get(), d_AntDirectZ.get(), sizeof(double) * prfcount);
for (long startcolidx = 0; startcolidx < freqcount; startcolidx = startcolidx + echocol) {
@ -162,6 +162,7 @@ void TBPImageProcess(QString echofile, QString outImageFolder, QString imagePlan
imagL1->setFarRange(echoL0ds->getFarRange());
imagL1->setFs(echoL0ds->getFs());
imagL1->setLookSide(echoL0ds->getLookSide());
imagL1->OpenOrNew(outImageFolder, echoL0ds->getSimulationTaskName(), echoL0ds->getPluseCount(), echoL0ds->getPlusePoints());
@ -249,13 +250,14 @@ ErrorCode TBPImageAlgCls::Process(long num_thread)
qDebug() << u8"频域回波-> 时域回波 结束";
if (GPURUN) {
return this->ProcessGPU();
}
else {
QMessageBox::information(nullptr,u8"Ìáʾ",u8"Ŀǰֻ֧³ÖÏÔ¿¨");
return ErrorCode::FAIL;
}
//if (GPURUN) {
// return this->ProcessGPU();
//}
//else {
// QMessageBox::information(nullptr,u8"Ìáʾ",u8"Ŀǰֻ֧³ÖÏÔ¿¨");
// return ErrorCode::FAIL;
//}
return ErrorCode::SUCCESS;
}
ErrorCode TBPImageAlgCls::ProcessGPU()
@ -353,6 +355,7 @@ ErrorCode TBPImageAlgCls::ProcessGPU()
imageBlockline = imageBlockline < 1 ? 1 : imageBlockline;
gdalImage imageXYZ(this->outRasterXYZPath);
gdalImageComplex imagetimeimg(this->TimeEchoDataPath);
long startimgrowid = 0;
for (startimgrowid = 0; startimgrowid < rowCount; startimgrowid = startimgrowid + imageBlockline) {
@ -370,13 +373,15 @@ ErrorCode TBPImageAlgCls::ProcessGPU()
std::shared_ptr<std::complex<double>> imgArr = this->L1ds->getImageRaster(startimgrowid, tempimgBlockline);
// 获取回波
long startechoid = 0;
long iffeechoLen = PlusePoints;
for (long startechoid = 0; startechoid < PRFCount; startechoid = startechoid + echoBlockline) {
long tempechoBlockline = echoBlockline;
if (startechoid + tempechoBlockline >= PRFCount) {
tempechoBlockline = PRFCount - startechoid;
}
std::shared_ptr<std::complex<double>> echoArr = this->L0ds->getEchoArr(startechoid, tempechoBlockline);
std::shared_ptr<std::complex<double>> echoArr =
readDataArrComplex < std::complex<double>>(imagetimeimg,startechoid,long(0), tempechoBlockline, iffeechoLen, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);//; this->L0ds->getEchoArr(startechoid, tempechoBlockline);
std::shared_ptr<double> antpx(new double[tempechoBlockline],delArrPtr);
std::shared_ptr<double> antpy(new double[tempechoBlockline], delArrPtr);
std::shared_ptr<double> antpz(new double[tempechoBlockline], delArrPtr);
@ -413,7 +418,7 @@ void TBPImageAlgCls::EchoFreqToTime( )
long PRFCount = this->L0ds->getPluseCount();
long inColCount = this->L0ds->getPlusePoints();
long outColCount = nextpow2(inColCount);
long outColCount = inColCount;// nextpow2(inColCount);
this->TimeEchoRowCount = PRFCount;
this->TimeEchoColCount = outColCount;
qDebug() << "IFFT : " << this->TimeEchoDataPath;
@ -483,10 +488,6 @@ void TBPImageAlgCls::EchoFreqToTime( )
void TBPImageGPUAlg2(std::shared_ptr<double> antPx, std::shared_ptr<double> antPy, std::shared_ptr<double> antPz,
std::shared_ptr<double> img_x, std::shared_ptr<double> img_y, std::shared_ptr<double> img_z,
std::shared_ptr<std::complex<double>> echoArr,
@ -500,8 +501,8 @@ void TBPImageGPUAlg2(std::shared_ptr<double> antPx, std::shared_ptr<double> antP
long IFFTPadNum = nextpow2(freqcount);
// 先处理脉冲傅里叶变换
cuComplex* h_echoArr = (cuComplex*)mallocCUDAHost(sizeof(cuComplex) * prfcount * freqcount);
cuComplex* d_echoArr = (cuComplex*)mallocCUDADevice(sizeof(cuComplex) * prfcount * freqcount);
std::shared_ptr<cuComplex> d_echoArrIFFT((cuComplex*)mallocCUDADevice(sizeof(cuComplex) * prfcount * IFFTPadNum), FreeCUDADevice);
//cuComplex* d_echoArr = (cuComplex*)mallocCUDADevice(sizeof(cuComplex) * prfcount * freqcount);
std::shared_ptr<cuComplex> d_echoArrIFFT((cuComplex*)mallocCUDADevice(sizeof(cuComplex) * prfcount * freqcount), FreeCUDADevice);
// 回波赋值
for (long i = 0; i < prfcount; i++) {
@ -510,11 +511,10 @@ void TBPImageGPUAlg2(std::shared_ptr<double> antPx, std::shared_ptr<double> antP
echoArr.get()[i * freqcount + j].imag());
}
}
HostToDevice(h_echoArr, d_echoArr, sizeof(cuComplex) * prfcount * freqcount);
CUDAIFFT(d_echoArr, d_echoArrIFFT.get(), prfcount, freqcount, IFFTPadNum);
HostToDevice(h_echoArr, d_echoArrIFFT.get(), sizeof(cuComplex) * prfcount * freqcount);
// 结束傅里叶变换
FreeCUDAHost(h_echoArr);
FreeCUDADevice(d_echoArr);
//FreeCUDADevice(d_echoArr);
qDebug() << "IFFT finished!!!";
// 初始化