142 lines
6.2 KiB
C++
142 lines
6.2 KiB
C++
/*
|
|
* 仿真测试代码
|
|
*
|
|
*
|
|
*/
|
|
#include <stdio.h>
|
|
#include <QString>
|
|
|
|
#include "EchoDataFormat.h"
|
|
#include "ImageShowDialogClass.h"
|
|
#include "GPUBaseLibAPI.h"
|
|
#include "BaseConstVariable.h"
|
|
#include "GPUTool.cuh"
|
|
#include "GPUBPTool.cuh"
|
|
#include "BPBasic0_CUDA.cuh"
|
|
#include "ImageOperatorBase.h"
|
|
#include "GPUBpSimulation.cuh"
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
/** 1. 轨道 **************************************************************************************************/
|
|
qDebug() << u8"1.轨道文件读取中。。。";
|
|
QString inGPSPath = u8"C:\\Users\\30453\\Desktop\\script\\data\\GF3_Simulation.gpspos.data";
|
|
long gpspoints = gdalImage(inGPSPath).height;
|
|
std::shared_ptr<SatelliteAntPos> antpos = SatelliteAntPosOperator::readAntPosFile(inGPSPath, gpspoints);
|
|
std::shared_ptr<double> antX((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|
std::shared_ptr<double> antY((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|
std::shared_ptr<double> antZ((double*)mallocCUDAHost(sizeof(double) * gpspoints), FreeCUDAHost);
|
|
for (long i = 0; i < gpspoints; i++) {
|
|
antX.get()[i] = antpos.get()[i].Px;
|
|
antY.get()[i] = antpos.get()[i].Py;
|
|
antZ.get()[i] = antpos.get()[i].Pz;
|
|
}
|
|
/** 2. 成像网格 **************************************************************************************************/
|
|
qDebug() << u8"轨道文件读取结束\n2.成像网格读取。。。";
|
|
QString demxyzPath = u8"C:\\Users\\30453\\Desktop\\script\\data\\demxyz.bin";
|
|
gdalImage demgridimg(demxyzPath);
|
|
long dem_rowCount = demgridimg.height;
|
|
long dem_ColCount = demgridimg.width;
|
|
std::shared_ptr<double> demX = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 1, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|
std::shared_ptr<double> demY = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 2, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|
std::shared_ptr<double> demZ = readDataArr<double>(demgridimg, 0, 0, dem_rowCount, dem_ColCount, 3, GDALREADARRCOPYMETHOD::VARIABLEMETHOD);
|
|
|
|
std::shared_ptr<double> imgX((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|
std::shared_ptr<double> imgY((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|
std::shared_ptr<double> imgZ((double*)mallocCUDAHost(sizeof(double) * dem_rowCount * dem_ColCount), FreeCUDAHost);
|
|
for (long i = 0; i < dem_rowCount; i++) {
|
|
for (long j = 0; j < dem_ColCount; j++) {
|
|
imgX.get()[i * dem_ColCount + j] = demX.get()[i * dem_ColCount + j];
|
|
imgY.get()[i * dem_ColCount + j] = demY.get()[i * dem_ColCount + j];
|
|
imgZ.get()[i * dem_ColCount + j] = demZ.get()[i * dem_ColCount + j];
|
|
}
|
|
}
|
|
qDebug() << u8"成像网格读取结束";
|
|
/** 3. 频率网格 **************************************************************************************************/
|
|
qDebug() << u8"3.处理频率";
|
|
double centerFreq = 5.3e9;
|
|
double bandwidth = 40e6;
|
|
long freqpoints = 8096;
|
|
std::shared_ptr<double> freqlist(getFreqPoints_mallocHost(centerFreq - bandwidth / 2, centerFreq + bandwidth / 2, freqpoints), FreeCUDAHost);
|
|
qDebug() << "start Freq:\t" << centerFreq - bandwidth / 2;
|
|
qDebug() << "end Freq:\t" << centerFreq + bandwidth / 2;
|
|
qDebug() << "freq points:\t" << freqpoints;
|
|
qDebug() << "delta freq:\t" << freqlist.get()[0] - freqlist.get()[1];
|
|
qDebug() << u8"频率结束";
|
|
/** 4. 初始化回波 **************************************************************************************************/
|
|
qDebug() << u8"4.初始化回波";
|
|
std::shared_ptr<cuComplex> phdata (createEchoPhase_mallocHost(gpspoints, freqpoints),FreeCUDAHost);
|
|
qDebug() << "Azimuth Points:\t"<<gpspoints;
|
|
qDebug() << "Range Points:\t"<< freqpoints;
|
|
qDebug() << u8"初始化回波结束";
|
|
/** 5. 初始化图像 **************************************************************************************************/
|
|
qDebug() << u8"5.初始化图像";
|
|
std::shared_ptr<cuComplex> im_final(createEchoPhase_mallocHost(dem_rowCount, dem_ColCount), FreeCUDAHost);
|
|
qDebug() << "Azimuth Points:\t" << gpspoints;
|
|
qDebug() << "Range Points:\t" << freqpoints;
|
|
qDebug() << u8"初始化图像结束";
|
|
|
|
/** 6. 模型参数初始化 **************************************************************************************************/
|
|
qDebug() << u8"6.模型参数初始化";
|
|
GPUDATA h_data;
|
|
h_data.AntX = antX.get();
|
|
h_data.AntX = antY.get();
|
|
h_data.AntX = antZ.get();
|
|
|
|
h_data.x_mat = imgX.get();
|
|
h_data.y_mat = imgY.get();
|
|
h_data.z_mat = imgZ.get();
|
|
|
|
h_data.Freq = freqlist.get();
|
|
h_data.Nfft = freqpoints;
|
|
h_data.K = h_data.Nfft;
|
|
h_data.phdata = phdata.get();
|
|
h_data.im_final = im_final.get();
|
|
qDebug() << u8"模型参数结束";
|
|
|
|
|
|
/** 7. 目标 **************************************************************************************************/
|
|
double Tx = -2028380.625000, Ty = 4139373.250000, Tz = 4393382.500000;
|
|
double Tslx = -2028380.625000, Tsly = 4139373.250000, Tslz = 4393382.500000;
|
|
|
|
double p1 = 1, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0;
|
|
|
|
/** 7. 构建回波 **************************************************************************************************/
|
|
GPUDATA d_data;
|
|
initGPUData(h_data, d_data);
|
|
|
|
RFPCProcess(Tx, Ty, Tz,
|
|
Tslx, Tsly, Tslz, // 目标的坡面向量
|
|
p1, p2, p3, p4, p5, p6,
|
|
d_data);
|
|
|
|
HostToDevice(h_data.phdata, d_data.phdata, sizeof(cuComplex) * d_data.Np * d_data.Nfft);
|
|
/** 8. 展示回波 **************************************************************************************************/
|
|
ImageShowDialogClass* dialog = new ImageShowDialogClass;
|
|
std::shared_ptr<cuComplex> h_ifftphdata((cuComplex*)mallocCUDAHost(sizeof(cuComplex) * d_data.Np * d_data.Nfft), FreeCUDAHost);
|
|
std::shared_ptr<cuComplex> d_ifftphdata((cuComplex*)mallocCUDADevice(sizeof(cuComplex) * d_data.Np * d_data.Nfft), FreeCUDADevice);
|
|
CUDAIFFT(d_data.phdata, d_ifftphdata.get(), d_data.Np, d_data.Nfft, d_data.Nfft);
|
|
FFTShift1D(d_ifftphdata.get(), d_data.Np, d_data.Nfft);
|
|
DeviceToHost(h_ifftphdata.get(), d_ifftphdata.get(), sizeof(cuComplex) * d_data.Np * d_data.Nfft);
|
|
std::shared_ptr<double> echoAmpArr(new double[d_data.Np * d_data.Nfft], delArrPtr);
|
|
{
|
|
for (long i = 0; i < d_data.Np * d_data.Nfft; i++) {
|
|
echoAmpArr.get()[i] =
|
|
20 * std::log10(std::sqrt(std::pow(h_ifftphdata.get()[i].x, 2) + std::pow(h_ifftphdata.get()[i].y, 2)));
|
|
}
|
|
}
|
|
dialog->load_double_data(echoAmpArr.get(), d_data.Np, d_data.Nfft, QString("ifft"));
|
|
dialog->exec();
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|