Skip to content
Snippets Groups Projects
Commit 3ec03180 authored by Julien Osman's avatar Julien Osman
Browse files

WIP: Read more Sentinel1 metadata

parent f5cfce07
No related branches found
No related tags found
No related merge requests found
...@@ -91,10 +91,10 @@ struct OTBMetadata_EXPORT OTB_calibrationVector ...@@ -91,10 +91,10 @@ struct OTBMetadata_EXPORT OTB_calibrationVector
struct OTBMetadata_EXPORT OTB_dopplerCentroid struct OTBMetadata_EXPORT OTB_dopplerCentroid
{ {
MetaData::Time azimuthTime;
double t0;
std::vector<double> dopCoef; std::vector<double> dopCoef;
std::vector<double> geoDopCoef; std::vector<double> geoDopCoef;
MetaData::Time geoDopCoefTime;
double slantRangeTime;
}; };
struct OTBMetadata_EXPORT OTB_SARNoise struct OTBMetadata_EXPORT OTB_SARNoise
...@@ -104,6 +104,17 @@ struct OTBMetadata_EXPORT OTB_SARNoise ...@@ -104,6 +104,17 @@ struct OTBMetadata_EXPORT OTB_SARNoise
MetaData::LUT1D noiseLut; MetaData::LUT1D noiseLut;
}; };
struct OTBMetadata_EXPORT OTB_Orbit
{
MetaData::Time time;
double posX;
double posY;
double posZ;
double velX;
double velY;
double velZ;
};
namespace Projection namespace Projection
{ {
...@@ -212,6 +223,8 @@ struct OTBMetadata_EXPORT SARParam ...@@ -212,6 +223,8 @@ struct OTBMetadata_EXPORT SARParam
std::vector<OTB_dopplerCentroid> dopplerCentroid; std::vector<OTB_dopplerCentroid> dopplerCentroid;
std::vector<OTB_SARNoise> noiseVector; std::vector<OTB_SARNoise> noiseVector;
std::vector<OTB_Orbit> orbits;
}; };
} // end namespace Projection } // end namespace Projection
......
...@@ -132,6 +132,8 @@ enum class MDNum ...@@ -132,6 +132,8 @@ enum class MDNum
DataType, DataType,
NoData, NoData,
OrbitNumber, OrbitNumber,
NumberOfLines,
NumberOfColumns,
// optical section // optical section
PhysicalGain, PhysicalGain,
PhysicalBias, PhysicalBias,
......
...@@ -95,6 +95,10 @@ public: ...@@ -95,6 +95,10 @@ public:
std::vector<OTB_azimuthFmRate> GetAzimuthFmRate(XMLMetadataSupplier) const; std::vector<OTB_azimuthFmRate> GetAzimuthFmRate(XMLMetadataSupplier) const;
std::vector<OTB_dopplerCentroid> GetDopplerCentroid(XMLMetadataSupplier) const;
std::vector<OTB_Orbit> GetOrbits(XMLMetadataSupplier) const;
std::vector<OTB_calibrationVector> GetCalibrationVector(XMLMetadataSupplier) const; std::vector<OTB_calibrationVector> GetCalibrationVector(XMLMetadataSupplier) const;
/* fetch the noise LUTs */ /* fetch the noise LUTs */
......
...@@ -318,6 +318,8 @@ MDNumBmType MDNumNames = bimapGenerator<MDNum>(std::map<MDNum, std::string> { ...@@ -318,6 +318,8 @@ MDNumBmType MDNumNames = bimapGenerator<MDNum>(std::map<MDNum, std::string> {
{MDNum::TileHintY,"TileHintY"}, {MDNum::TileHintY,"TileHintY"},
{MDNum::DataType,"DataType"}, {MDNum::DataType,"DataType"},
{MDNum::NoData, "NoData"}, {MDNum::NoData, "NoData"},
{MDNum::NumberOfLines,"NumberOfLines"},
{MDNum::NumberOfColumns,"NumberOfColumns"},
{MDNum::OrbitNumber, "OrbitNumber"}, {MDNum::OrbitNumber, "OrbitNumber"},
{MDNum::PhysicalGain,"PhysicalGain"}, {MDNum::PhysicalGain,"PhysicalGain"},
{MDNum::PhysicalBias,"PhysicalBias"}, {MDNum::PhysicalBias,"PhysicalBias"},
......
...@@ -372,6 +372,51 @@ std::vector<OTB_azimuthFmRate> Sentinel1ImageMetadataInterface::GetAzimuthFmRate ...@@ -372,6 +372,51 @@ std::vector<OTB_azimuthFmRate> Sentinel1ImageMetadataInterface::GetAzimuthFmRate
return azimuthFmRateVector; return azimuthFmRateVector;
} }
std::vector<OTB_dopplerCentroid> Sentinel1ImageMetadataInterface::GetDopplerCentroid(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_dopplerCentroid> dopplerCentroidVector;
int listCount = xmlMS.GetAs<double>("product.dopplerCentroid.dcEstimateList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
oss.str("");
oss << listId;
std::string path_root = "product.dopplerCentroid.dcEstimateList.dcEstimate_" + oss.str();
OTB_dopplerCentroid dopplerCent;
std::istringstream(xmlMS.GetAs<std::string>(path_root + ".azimuthTime")) >> dopplerCent.azimuthTime;
dopplerCent.t0 = xmlMS.GetAs<double>(path_root + ".t0");
dopplerCent.dopCoef = xmlMS.GetAsVector<double>(path_root + ".dataDcPolynomial",
' ', xmlMS.GetAs<int>((path_root + ".dataDcPolynomial.count").c_str()));
dopplerCent.geoDopCoef = xmlMS.GetAsVector<double>(path_root + ".geometryDcPolynomial",
' ', xmlMS.GetAs<int>((path_root + ".geometryDcPolynomial.count").c_str()));
dopplerCentroidVector.push_back(dopplerCent);
}
return dopplerCentroidVector;
}
std::vector<OTB_Orbit> Sentinel1ImageMetadataInterface::GetOrbits(XMLMetadataSupplier xmlMS) const
{
std::vector<OTB_Orbit> orbitVector;
int listCount = xmlMS.GetAs<double>("product.generalAnnotation.orbitList.count");
std::ostringstream oss;
for (int listId = 1 ; listId <= listCount ; ++listId)
{
oss.str("");
oss << listId;
std::string path_root = "product.generalAnnotation.orbitList.orbit_" + oss.str();
OTB_Orbit orbit;
std::istringstream(xmlMS.GetAs<std::string>(path_root + ".time")) >> orbit.time;
orbit.posX = xmlMS.GetAs<double>(path_root + "1.position.x");
orbit.posY = xmlMS.GetAs<double>(path_root + "1.position.y");
orbit.posZ = xmlMS.GetAs<double>(path_root + "1.position.z");
orbit.velX = xmlMS.GetAs<double>(path_root + "1.velocity.x");
orbit.velY = xmlMS.GetAs<double>(path_root + "1.velocity.y");
orbit.velZ = xmlMS.GetAs<double>(path_root + "1.velocity.z");
orbitVector.push_back(orbit);
}
return orbitVector;
}
std::vector<OTB_calibrationVector> Sentinel1ImageMetadataInterface::GetCalibrationVector(XMLMetadataSupplier xmlMS) const std::vector<OTB_calibrationVector> Sentinel1ImageMetadataInterface::GetCalibrationVector(XMLMetadataSupplier xmlMS) const
{ {
std::vector<OTB_calibrationVector> calibrationVector; std::vector<OTB_calibrationVector> calibrationVector;
...@@ -489,29 +534,36 @@ void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds ...@@ -489,29 +534,36 @@ void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface *mds
std::string AnnotationFilePath = mds->GetResourceFile(std::string("annotation[/\\\\]s1[ab].*-") std::string AnnotationFilePath = mds->GetResourceFile(std::string("annotation[/\\\\]s1[ab].*-")
+ itksys::SystemTools::LowerCase(swath) + itksys::SystemTools::LowerCase(swath)
+ std::string("-.*\\.xml")); + std::string("-.*\\.xml"));
if (!AnnotationFilePath.empty()) if (AnnotationFilePath.empty())
{ otbGenericExceptionMacro(MissingMetadataException,<<"Missing Annotation file for band '"<<swath<<"'");
XMLMetadataSupplier AnnotationMS = XMLMetadataSupplier(AnnotationFilePath); XMLMetadataSupplier AnnotationMS = XMLMetadataSupplier(AnnotationFilePath);
sarParam.azimuthFmRate = this->GetAzimuthFmRate(AnnotationMS); sarParam.azimuthFmRate = this->GetAzimuthFmRate(AnnotationMS);
sarParam.dopplerCentroid = this->GetDopplerCentroid(AnnotationMS);
// Calibration file sarParam.orbits = this->GetOrbits(AnnotationMS);
std::string CalibrationFilePath = itksys::SystemTools::GetFilenamePath(AnnotationFilePath) m_Imd.Add(MDNum::NumberOfLines, AnnotationMS.GetAs<int>("product.imageAnnotation.imageInformation.numberOfLines"));
+ "/calibration/calibration-" m_Imd.Add(MDNum::NumberOfColumns, AnnotationMS.GetAs<int>("product.imageAnnotation.imageInformation.numberOfSamples"));
+ itksys::SystemTools::GetFilenameName(AnnotationFilePath);
XMLMetadataSupplier CalibrationMS = XMLMetadataSupplier(CalibrationFilePath); // Calibration file
sarParam.absoluteCalibrationConstant = CalibrationMS.GetAs<double>("calibration.calibrationInformation.absoluteCalibrationConstant"); std::string CalibrationFilePath = itksys::SystemTools::GetFilenamePath(AnnotationFilePath)
sarParam.calibrationVectors = this->GetCalibrationVector(CalibrationMS); + "/calibration/calibration-"
std::istringstream(CalibrationMS.GetAs<std::string>("calibration.adsHeader.startTime")) >> sarParam.startTime; + itksys::SystemTools::GetFilenameName(AnnotationFilePath);
std::istringstream(CalibrationMS.GetAs<std::string>("calibration.adsHeader.stopTime")) >> sarParam.stopTime; if (CalibrationFilePath.empty())
otbGenericExceptionMacro(MissingMetadataException,<<"Missing Calibration file for band '"<<swath<<"'");
// Noise file XMLMetadataSupplier CalibrationMS = XMLMetadataSupplier(CalibrationFilePath);
std::string NoiseFilePath = itksys::SystemTools::GetFilenamePath(AnnotationFilePath) sarParam.absoluteCalibrationConstant = CalibrationMS.GetAs<double>("calibration.calibrationInformation.absoluteCalibrationConstant");
+ "/calibration/noise-" sarParam.calibrationVectors = this->GetCalibrationVector(CalibrationMS);
+ itksys::SystemTools::GetFilenameName(AnnotationFilePath); std::istringstream(CalibrationMS.GetAs<std::string>("calibration.adsHeader.startTime")) >> sarParam.startTime;
XMLMetadataSupplier NoiseMS = XMLMetadataSupplier(NoiseFilePath); std::istringstream(CalibrationMS.GetAs<std::string>("calibration.adsHeader.stopTime")) >> sarParam.stopTime;
sarParam.noiseVector = this->GetNoiseVector(NoiseMS);
} // Noise file
std::string NoiseFilePath = itksys::SystemTools::GetFilenamePath(AnnotationFilePath)
+ "/calibration/noise-"
+ itksys::SystemTools::GetFilenameName(AnnotationFilePath);
if (NoiseFilePath.empty())
otbGenericExceptionMacro(MissingMetadataException,<<"Missing Noise file for band '"<<swath<<"'");
XMLMetadataSupplier NoiseMS = XMLMetadataSupplier(NoiseFilePath);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam); m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment