2025-02-17 09:13:18 +00:00
|
|
|
|
#include "LookTableComputerClass.h"
|
|
|
|
|
#include "SatelliteOribtModel.h"
|
|
|
|
|
#include "SARSimulationTaskSetting.h"
|
2025-02-19 02:06:45 +00:00
|
|
|
|
#include "ImageOperatorBase.h"
|
|
|
|
|
#include "FileOperator.h"
|
|
|
|
|
#include "BaseConstVariable.h"
|
|
|
|
|
#include "GPUTool.cuh"
|
2025-02-19 04:29:15 +00:00
|
|
|
|
#include "LookTableSimulationComputer.cuh"
|
2025-02-17 09:13:18 +00:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
|
2025-02-19 02:06:45 +00:00
|
|
|
|
|
2025-02-17 09:13:18 +00:00
|
|
|
|
// dingy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace LookTableSimualtionMainProcessSpace {
|
2025-02-19 02:06:45 +00:00
|
|
|
|
void LookTableSimualtionMainProcess(
|
|
|
|
|
QString sateName,
|
|
|
|
|
QString orbitpath, QString SatePath, QString DEMPath, QString outDirPath,
|
|
|
|
|
bool gpuflag,
|
|
|
|
|
bool looktableflag,
|
|
|
|
|
bool checkBoxIncAngle,
|
|
|
|
|
bool DopplerFlag)
|
2025-02-17 09:13:18 +00:00
|
|
|
|
{
|
2025-02-19 02:06:45 +00:00
|
|
|
|
if (!isExists(orbitpath)) {
|
|
|
|
|
qDebug() << "Orbit model file is not exist !!!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isExists(SatePath)) {
|
|
|
|
|
qDebug() << "Satellite Model file is not exist !!!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isExists(DEMPath)) {
|
|
|
|
|
qDebug() << "DEM file is not exist !!!";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-17 09:13:18 +00:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
|
|
|
|
qDebug() << "load orbit model params from xml :" << orbitpath;
|
|
|
|
|
PolyfitSatelliteOribtModel orbitmodel;
|
|
|
|
|
orbitmodel.loadFromXml(orbitpath);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
long double OribtStartTime = orbitmodel.getOribtStartTime();
|
2025-02-19 02:06:45 +00:00
|
|
|
|
std::vector<double> PolyfitPx = orbitmodel.getPolyfitPx();
|
|
|
|
|
std::vector<double> PolyfitPy = orbitmodel.getPolyfitPy();
|
|
|
|
|
std::vector<double> PolyfitPz = orbitmodel.getPolyfitPz();
|
|
|
|
|
std::vector<double> PolyfitVx = orbitmodel.getPolyfitVx();
|
|
|
|
|
std::vector<double> PolyfitVy = orbitmodel.getPolyfitVy();
|
|
|
|
|
std::vector<double> PolyfitVz = orbitmodel.getPolyfitVz();
|
2025-02-17 09:13:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
|
|
|
|
qDebug() << "load simulation setting params from xml :" << orbitpath;
|
|
|
|
|
std::shared_ptr<AbstractSARSatelliteModel> SARSetting = ReadSimulationSettingsXML(SatePath);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>
|
|
|
|
|
double dopplerRefrenceTime = SARSetting->getDopplerParametersReferenceTime();
|
|
|
|
|
std::vector<double> DopplerCentroidCoefficients = SARSetting->getDopplerCentroidCoefficients();
|
|
|
|
|
std::vector<double> DopplerRateValuesCoefficient = SARSetting->getDopplerRateValuesCoefficients();
|
|
|
|
|
|
2025-02-19 02:06:45 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
double startTime = SARSetting->getSARImageStartTime();
|
|
|
|
|
double endTime = SARSetting->getSARImageStartTime();
|
|
|
|
|
|
|
|
|
|
double PRF = SARSetting->getPRF();
|
|
|
|
|
double Fs = SARSetting->getFs();
|
|
|
|
|
double nearRange = SARSetting->getNearRange();
|
|
|
|
|
double farRange = SARSetting->getFarRange();
|
|
|
|
|
double lamda = SARSetting->getCenterLamda();
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
QString outLookTablePath = "";
|
|
|
|
|
QString outIncPath = "";
|
|
|
|
|
gdalImage demimg(DEMPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (looktableflag|| checkBoxIncAngle) {
|
|
|
|
|
outLookTablePath = JoinPath(outDirPath, sateName+"__looktable.bin");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LookTableSimulationDopplerProcess(
|
|
|
|
|
DEMPath, outLookTablePath,
|
|
|
|
|
OribtStartTime,
|
|
|
|
|
PolyfitPx, PolyfitPy, PolyfitPz,
|
|
|
|
|
PolyfitVx, PolyfitVy, PolyfitVz,
|
|
|
|
|
dopplerRefrenceTime,
|
|
|
|
|
DopplerCentroidCoefficients,
|
|
|
|
|
startTime,
|
|
|
|
|
endTime,
|
|
|
|
|
nearRange,
|
|
|
|
|
farRange,
|
|
|
|
|
PRF,
|
|
|
|
|
Fs,
|
|
|
|
|
lamda,
|
|
|
|
|
gpuflag,
|
|
|
|
|
looktableflag,
|
|
|
|
|
checkBoxIncAngle
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (checkBoxIncAngle) {
|
|
|
|
|
outIncPath = JoinPath(outDirPath, sateName + "__incAngle.bin");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LookTableSimulationDopplerProcess(
|
|
|
|
|
QString DEMPath,
|
|
|
|
|
QString outLookTablePath,
|
|
|
|
|
|
|
|
|
|
long double OribtStartTime,
|
|
|
|
|
std::vector<double> PolyfitPx,
|
|
|
|
|
std::vector<double> PolyfitPy,
|
|
|
|
|
std::vector<double> PolyfitPz,
|
|
|
|
|
std::vector<double> PolyfitVx,
|
|
|
|
|
std::vector<double> PolyfitVy,
|
|
|
|
|
std::vector<double> PolyfitVz,
|
|
|
|
|
double dopplerRefrenceTime,
|
|
|
|
|
std::vector<double>
|
|
|
|
|
DopplerCentroidCoefficients,
|
|
|
|
|
double starttime,
|
|
|
|
|
double endtime,
|
|
|
|
|
double nearRange,
|
|
|
|
|
double farRange,
|
|
|
|
|
double PRF,
|
|
|
|
|
double Fs,
|
|
|
|
|
double lamda,
|
|
|
|
|
bool gpuflag,
|
|
|
|
|
bool looktableflag,
|
|
|
|
|
bool incflag
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
qDebug() << "generate look table ";
|
|
|
|
|
qDebug() << "DEMPath\t" << DEMPath;
|
|
|
|
|
qDebug() << "outLookTablePath\t" << outLookTablePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gdalImage demimg(DEMPath);
|
|
|
|
|
gdalImage outLookTable = CreategdalImage( // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ұ<EFBFBD>
|
|
|
|
|
outLookTablePath,
|
|
|
|
|
demimg.height, demimg.width, 2,
|
|
|
|
|
demimg.gt,
|
|
|
|
|
demimg.projection,
|
|
|
|
|
true,
|
|
|
|
|
true,
|
|
|
|
|
true
|
|
|
|
|
);
|
2025-02-17 09:13:18 +00:00
|
|
|
|
|
|
|
|
|
|
2025-02-19 02:06:45 +00:00
|
|
|
|
starttime = starttime - OribtStartTime; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
|
|
|
|
endtime = endtime - OribtStartTime;
|
2025-02-17 09:13:18 +00:00
|
|
|
|
|
2025-02-19 02:06:45 +00:00
|
|
|
|
// <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
|
|
|
|
double Xp0=0,Yp0=0,Zp0=0,Xv0=0,Yv0=0,Zv0=0;
|
|
|
|
|
double Xp1=0,Yp1=0,Zp1=0,Xv1=0,Yv1=0,Zv1=0;
|
|
|
|
|
double Xp2=0,Yp2=0,Zp2=0,Xv2=0,Yv2=0,Zv2=0;
|
|
|
|
|
double Xp3=0,Yp3=0,Zp3=0,Xv3=0,Yv3=0,Zv3=0;
|
|
|
|
|
double Xp4=0,Yp4=0,Zp4=0,Xv4=0,Yv4=0,Zv4=0;
|
|
|
|
|
double Xp5=0,Yp5=0,Zp5=0,Xv5=0,Yv5=0,Zv5=0;
|
|
|
|
|
int degree = PolyfitPx.size();
|
|
|
|
|
switch (degree){
|
|
|
|
|
case(6):
|
|
|
|
|
Xp5 = PolyfitPx[5];
|
|
|
|
|
Yp5 = PolyfitPy[5];
|
|
|
|
|
Zp5 = PolyfitPz[5];
|
|
|
|
|
Xv5 = PolyfitVx[5];
|
|
|
|
|
Yv5 = PolyfitVy[5];
|
|
|
|
|
Zv5 = PolyfitVz[5];
|
|
|
|
|
case(5):
|
|
|
|
|
Xp4 = PolyfitPx[4];
|
|
|
|
|
Yp4 = PolyfitPy[4];
|
|
|
|
|
Zp4 = PolyfitPz[4];
|
|
|
|
|
Xv4 = PolyfitVx[4];
|
|
|
|
|
Yv4 = PolyfitVy[4];
|
|
|
|
|
Zv4 = PolyfitVz[4];
|
|
|
|
|
case(4):
|
|
|
|
|
Xp3 = PolyfitPx[3];
|
|
|
|
|
Yp3 = PolyfitPy[3];
|
|
|
|
|
Zp3 = PolyfitPz[3];
|
|
|
|
|
Xv3 = PolyfitVx[3];
|
|
|
|
|
Yv3 = PolyfitVy[3];
|
|
|
|
|
Zv3 = PolyfitVz[3];
|
|
|
|
|
case(3):
|
|
|
|
|
Xp2 = PolyfitPx[2];
|
|
|
|
|
Yp2 = PolyfitPy[2];
|
|
|
|
|
Zp2 = PolyfitPz[2];
|
|
|
|
|
Xv2 = PolyfitVx[2];
|
|
|
|
|
Yv2 = PolyfitVy[2];
|
|
|
|
|
Zv2 = PolyfitVz[2];
|
|
|
|
|
case(2):
|
|
|
|
|
Xp1 = PolyfitPx[1];
|
|
|
|
|
Yp1 = PolyfitPy[1];
|
|
|
|
|
Zp1 = PolyfitPz[1];
|
|
|
|
|
Xv1 = PolyfitVx[1];
|
|
|
|
|
Yv1 = PolyfitVy[1];
|
|
|
|
|
Zv1 = PolyfitVz[1];
|
|
|
|
|
case(1):
|
|
|
|
|
Xp0 = PolyfitPx[0];
|
|
|
|
|
Yp0 = PolyfitPy[0];
|
|
|
|
|
Zp0 = PolyfitPz[0];
|
|
|
|
|
Xv0 = PolyfitVx[0];
|
|
|
|
|
Yv0 = PolyfitVy[0];
|
|
|
|
|
Zv0 = PolyfitVz[0];
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD>
|
|
|
|
|
double r0 = 0, r1 = 0, r2 = 0, r3 = 0, r4 = 0;
|
|
|
|
|
degree = DopplerCentroidCoefficients.size();
|
|
|
|
|
switch (degree)
|
|
|
|
|
{
|
|
|
|
|
case(5):
|
|
|
|
|
r4 = DopplerCentroidCoefficients[4];
|
|
|
|
|
case(4):
|
|
|
|
|
r3 = DopplerCentroidCoefficients[3];
|
|
|
|
|
case(3):
|
|
|
|
|
r2 = DopplerCentroidCoefficients[2];
|
|
|
|
|
case(2):
|
|
|
|
|
r1 = DopplerCentroidCoefficients[1];
|
|
|
|
|
case(1):
|
|
|
|
|
r0 = DopplerCentroidCoefficients[0];
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>
|
|
|
|
|
long GPUMemoryline = floor((Memory1MB * 2.0 / 8.0/3.0 / demimg.width*1000));//2GB
|
|
|
|
|
GPUMemoryline = GPUMemoryline < 1 ? 1 : GPUMemoryline;
|
|
|
|
|
|
|
|
|
|
// <20>ڴ<EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
std::shared_ptr<float> host_Rid((float*)mallocCUDAHost(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDAHost);
|
|
|
|
|
std::shared_ptr<float> host_Cid((float*)mallocCUDAHost(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDAHost);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<float> device_Rid((float*)mallocCUDADevice(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDADevice);
|
|
|
|
|
std::shared_ptr<float> device_Cid((float*)mallocCUDADevice(sizeof(float) * GPUMemoryline * demimg.width), FreeCUDADevice);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
std::shared_ptr<double> host_demX((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
|
|
|
|
|
std::shared_ptr<double> host_demY((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
|
|
|
|
|
std::shared_ptr<double> host_demZ((double*)mallocCUDAHost(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDAHost);
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<double> device_demX((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
|
|
|
|
|
std::shared_ptr<double> device_demY((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
|
|
|
|
|
std::shared_ptr<double> device_demZ((double*)mallocCUDADevice(sizeof(double) * GPUMemoryline * demimg.width), FreeCUDADevice);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>
|
|
|
|
|
|
2025-02-19 06:19:32 +00:00
|
|
|
|
long rowcount = 0;
|
|
|
|
|
long colcount = 0;
|
2025-02-19 04:29:15 +00:00
|
|
|
|
double fact_lamda = 1 / lamda;
|
2025-02-19 02:06:45 +00:00
|
|
|
|
for (long rid = 0; rid < demimg.height; rid = rid + GPUMemoryline) {
|
|
|
|
|
rowcount = GPUMemoryline;
|
|
|
|
|
colcount = demimg.width;
|
|
|
|
|
std::shared_ptr<double> demX = readDataArr<double>(demimg, rid, 0, rowcount, colcount, 1,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::shared_ptr<double> demY = readDataArr<double>(demimg, rid, 0, rowcount, colcount, 2,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);
|
|
|
|
|
std::shared_ptr<double> demZ = readDataArr<double>(demimg, rid, 0, rowcount, colcount, 3,GDALREADARRCOPYMETHOD::MEMCPYMETHOD);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ݸ<EFBFBD><DDB8><EFBFBD>
|
|
|
|
|
memcpy(host_demX.get(), demX.get(), sizeof(double)* rowcount* colcount);
|
|
|
|
|
memcpy(host_demY.get(), demY.get(), sizeof(double)* rowcount* colcount);
|
|
|
|
|
memcpy(host_demZ.get(), demZ.get(), sizeof(double)* rowcount* colcount);
|
2025-02-17 09:13:18 +00:00
|
|
|
|
|
2025-02-19 02:06:45 +00:00
|
|
|
|
//<2F>ڴ<EFBFBD>->GPU
|
|
|
|
|
HostToDevice(host_demX.get(), device_demX.get(), sizeof(double)* GPUMemoryline* demimg.width);
|
|
|
|
|
HostToDevice(host_demY.get(), device_demY.get(), sizeof(double)* GPUMemoryline* demimg.width);
|
|
|
|
|
HostToDevice(host_demZ.get(), device_demZ.get(), sizeof(double)* GPUMemoryline* demimg.width);
|
|
|
|
|
|
|
|
|
|
|
2025-02-19 04:29:15 +00:00
|
|
|
|
RDProcess_dopplerGPU(
|
|
|
|
|
device_demX.get(), device_demY.get(), device_demZ.get(),
|
|
|
|
|
device_Rid.get(), device_Cid.get(),
|
|
|
|
|
rowcount, colcount,
|
2025-02-19 06:19:32 +00:00
|
|
|
|
starttime, nearRange, farRange,
|
|
|
|
|
PRF, Fs,
|
|
|
|
|
fact_lamda,
|
2025-02-19 04:29:15 +00:00
|
|
|
|
Xp0, Yp0, Zp0, Xv0, Yv0, Zv0,
|
|
|
|
|
Xp1, Yp1, Zp1, Xv1, Yv1, Zv1,
|
|
|
|
|
Xp2, Yp2, Zp2, Xv2, Yv2, Zv2,
|
|
|
|
|
Xp3, Yp3, Zp3, Xv3, Yv3, Zv3,
|
|
|
|
|
Xp4, Yp4, Zp4, Xv4, Yv4, Zv4,
|
|
|
|
|
Xp5, Yp5, Zp5, Xv5, Yv5, Zv5,
|
2025-02-19 06:19:32 +00:00
|
|
|
|
dopplerRefrenceTime, r0, r1, r2, r3, r4);
|
2025-02-19 02:06:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GPU -> <20>ڴ<EFBFBD>
|
|
|
|
|
DeviceToHost(host_Rid.get(), device_Rid.get(), sizeof(float)* GPUMemoryline* demimg.width);
|
|
|
|
|
DeviceToHost(host_Cid.get(), device_Cid.get(), sizeof(float)* GPUMemoryline* demimg.width);
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ݴ洢
|
|
|
|
|
outLookTable.saveImage(host_Rid, rid, 0, rowcount, colcount,1);
|
|
|
|
|
outLookTable.saveImage(host_Cid, rid, 0, rowcount, colcount,2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
qDebug() << "look table computed finished!!!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LocalIncidenceAngleSimulationCompter(QString DEMPath, QString LookTablePath, QString outIncPath, long double OribtStartTime, std::vector<double> PolyfitPx, std::vector<double> PolyfitPy, std::vector<double> PolyfitPz, std::vector<double> PolyfitVx, std::vector<double> PolyfitVy, std::vector<double> PolyfitVz, double starttime, double endtime, double nearRange, double farRange, double PRF, double Fs)
|
|
|
|
|
{
|
|
|
|
|
//gdalImage outInc = CreategdalImageDouble(
|
|
|
|
|
// outIncPath,
|
|
|
|
|
// demimg.height, demimg.width, 1,
|
|
|
|
|
// demimg.gt,
|
|
|
|
|
// demimg.projection,
|
|
|
|
|
// true,
|
|
|
|
|
// true,
|
|
|
|
|
// true
|
|
|
|
|
//);
|
2025-02-17 09:13:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|