Commit 52fac90e authored by Julien Osman's avatar Julien Osman

ENH: Separate Calib data from SARParam. Add CheckFetch methods.

parent c69384d8
Pipeline #7328 failed with stages
in 102 minutes and 32 seconds
......@@ -238,12 +238,16 @@ public:
static void PrintMetadata(std::ostream& os, itk::Indent indent, const MetaDataDictionaryType& dict);
const std::string& Fetch(MDStr key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
void CheckFetch(MDStr key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
const double& Fetch(MDNum key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
void CheckFetch(MDNum key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
const MetaData::Time& Fetch(MDTime key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
void CheckFetch(MDTime key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
const std::string& Fetch(std::string key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
void CheckFetch(std::string key, const MetadataSupplierInterface & mds, const char *path, int band=-1);
const boost::any& FetchRPC(const MetadataSupplierInterface & mds, const double lineOffset = 0.0, const double sampleOffset = 0.0);
......
......@@ -212,6 +212,7 @@ enum class MDGeom
ProjectionProj, // -> string
RPC, // -> RPCParam
SAR, // -> SARParam
SARCalib, // -> SARCalib
SensorGeometry, // -> boost::any
GCP, // -> GCPParam
Adjustment, // -> ?
......
......@@ -96,7 +96,7 @@ public:
double GetCenterIncidenceAngle() const override;
/*get lookup data for calculating backscatter */
void CreateCalibrationLookupData(const short type) override;
const LookupDataPointerType CreateCalibrationLookupData(const short type) const override;
Please register or sign in to reply
void ParseGdal(const MetadataSupplierInterface &) override;
......
......@@ -123,11 +123,7 @@ struct OTBMetadata_EXPORT Orbit
* \ingroup OTBMetadata
*/
struct OTBMetadata_EXPORT SARParam
{
using PointSetType = itk::PointSet<double, 2>;
using ArrayType = std::array<int, 2>;
using LookupDataType = SarCalibrationLookupData;
{
/** Azimuth Frequency Modulation (FM) rate list.
* contains an entry for each azimuth FM rate update made along azimuth.
*/
......@@ -139,7 +135,28 @@ struct OTBMetadata_EXPORT SARParam
MetaData::Time calibrationStartTime;
MetaData::Time calibrationStopTime;
/** Radiometric Calibration */
/** Doppler centroid estimates */
std::vector<DopplerCentroid> dopplerCentroids;
/** Noise look up tables */
std::vector<SARNoise> noiseVector;
/** List of orbit information */
std::vector<Orbit> orbits;
};
/** \struct SARCalib
*
* \brief SAR calibration LUTs
*
* \ingroup OTBMetadata
*/
struct OTBMetadata_EXPORT SARCalib
{
using PointSetType = itk::PointSet<double, 2>;
using ArrayType = std::array<int, 2>;
using LookupDataType = SarCalibrationLookupData;
bool calibrationLookupFlag;
double rescalingFactor;
ArrayType radiometricCalibrationNoisePolynomialDegree;
......@@ -153,15 +170,6 @@ struct OTBMetadata_EXPORT SARParam
PointSetType::Pointer radiometricCalibrationIncidenceAngle;
PointSetType::Pointer radiometricCalibrationRangeSpreadLoss;
std::unordered_map<short, LookupDataType::Pointer> calibrationLookupData;
/** Doppler centroid estimates */
std::vector<DopplerCentroid> dopplerCentroids;
/** Noise look up tables */
std::vector<SARNoise> noiseVector;
/** List of orbit information */
std::vector<Orbit> orbits;
};
} // end namespace otb
......
......@@ -66,17 +66,12 @@ public:
typedef SarCalibrationLookupData LookupDataType;
typedef LookupDataType::Pointer LookupDataPointerType;
virtual void CreateCalibrationLookupData(const short t);
virtual const LookupDataPointerType CreateCalibrationLookupData(const short t) const;
const LookupDataPointerType GetCalibrationLookupData(const short type);
const LookupDataPointerType GetCalibrationLookupData(const short type) const;
bool HasCalibrationLookupDataFlag() const;
void SetCalibrationLookupData(LookupDataType* lut)
{
m_SarLut = lut;
}
virtual RealType GetRadiometricCalibrationScale() const;
virtual PointSetPointer GetRadiometricCalibrationAntennaPatternNewGain() const;
......@@ -125,7 +120,7 @@ public:
std::vector<CalibrationVector> GetCalibrationVectorGeom(const MetadataSupplierInterface &) const;
std::vector<SARNoise> GetNoiseVectorGeom(const MetadataSupplierInterface &) const;
void LoadRadiometricCalibrationData(SARParam &);
void LoadRadiometricCalibrationData(SARCalib &) const;
protected:
SarImageMetadataInterface();
......@@ -138,9 +133,6 @@ protected:
void PrintSelf(std::ostream& os, itk::Indent indent) const override;
LookupDataPointerType m_SarLut;
private:
SarImageMetadataInterface(const Self&) = delete;
void operator=(const Self&) = delete;
......
......@@ -97,7 +97,7 @@ public:
double GetCenterIncidenceAngle() const override;
/*get lookup data for calculating backscatter */
void CreateCalibrationLookupData(const short type) override;
const LookupDataPointerType CreateCalibrationLookupData(const short type) const override;
void ParseGdal(const MetadataSupplierInterface &) override;
......
......@@ -408,9 +408,11 @@ void CosmoImageMetadataInterface::ParseGdal(const MetadataSupplierInterface & md
//SAR Parameters
SARParam sarParam;
sarParam.orbits = this->getOrbits(mds, reference_UTC);
LoadRadiometricCalibrationData(sarParam);
m_Imd.Bands[0].Add(MDGeom::SAR, sarParam);
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void CosmoImageMetadataInterface::ParseGeom(const MetadataSupplierInterface & mds)
......@@ -444,8 +446,11 @@ void CosmoImageMetadataInterface::ParseGeom(const MetadataSupplierInterface & md
//SAR Parameters
SARParam sarParam;
sarParam.orbits = this->GetOrbitsGeom(mds);
LoadRadiometricCalibrationData(sarParam);
m_Imd.Bands[0].Add(MDGeom::SAR, sarParam);
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void CosmoImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
......
......@@ -637,6 +637,17 @@ ImageMetadataInterfaceBase::Fetch(
return m_Imd[key];
}
void
ImageMetadataInterfaceBase::CheckFetch(
MDStr key,
const MetadataSupplierInterface & mds,
const char *path,
int band)
{
if (mds.HasValue(path, band))
Fetch(key, mds, path, band);
}
const double&
ImageMetadataInterfaceBase::Fetch(
MDNum key,
......@@ -654,6 +665,17 @@ ImageMetadataInterfaceBase::Fetch(
return m_Imd[key];
}
void
ImageMetadataInterfaceBase::CheckFetch(
MDNum key,
const MetadataSupplierInterface & mds,
const char *path,
int band)
{
if (mds.HasValue(path, band))
Fetch(key, mds, path, band);
}
const MetaData::Time&
ImageMetadataInterfaceBase::Fetch(
MDTime key,
......@@ -672,6 +694,17 @@ ImageMetadataInterfaceBase::Fetch(
return m_Imd[key];
}
void
ImageMetadataInterfaceBase::CheckFetch(
MDTime key,
const MetadataSupplierInterface & mds,
const char *path,
int band)
{
if (mds.HasValue(path, band))
Fetch(key, mds, path, band);
}
const std::string&
ImageMetadataInterfaceBase::Fetch(
std::string key,
......@@ -689,6 +722,17 @@ ImageMetadataInterfaceBase::Fetch(
return m_Imd[key];
}
void
ImageMetadataInterfaceBase::CheckFetch(
std::string key,
const MetadataSupplierInterface & mds,
const char *path,
int band)
{
if (mds.HasValue(path, band))
Fetch(key, mds, path, band);
}
const boost::any& ImageMetadataInterfaceBase::FetchRPC(const MetadataSupplierInterface & mds,
const double lineOffset, const double sampleOffset)
{
......
......@@ -423,6 +423,7 @@ MDGeomBmType MDGeomNames = bimapGenerator<MDGeom>(std::map<MDGeom, std::string>
{MDGeom::ProjectionProj, "ProjectionProj"},
{MDGeom::RPC, "RPC"},
{MDGeom::SAR, "SAR"},
{MDGeom::SARCalib, "SARCalib"},
{MDGeom::SensorGeometry, "SensorGeometry"},
{MDGeom::GCP, "GCP"},
{MDGeom::Adjustment, "Adjustment"}
......
......@@ -52,7 +52,7 @@ bool Radarsat2ImageMetadataInterface::CanRead() const
}
void Radarsat2ImageMetadataInterface::CreateCalibrationLookupData(const short type)
const Radarsat2ImageMetadataInterface::LookupDataPointerType Radarsat2ImageMetadataInterface::CreateCalibrationLookupData(const short type) const
{
std::string lut = "SigmaNought";
......@@ -97,7 +97,7 @@ void Radarsat2ImageMetadataInterface::CreateCalibrationLookupData(const short ty
Radarsat2CalibrationLookupData::Pointer sarLut;
sarLut = Radarsat2CalibrationLookupData::New();
sarLut->InitParameters(type, offset, glist);
this->SetCalibrationLookupData(sarLut);
return static_cast<Radarsat2ImageMetadataInterface::LookupDataPointerType> (sarLut);
}
void Radarsat2ImageMetadataInterface::ParseDateTime(const char* key, std::vector<int>& dateFields) const
......@@ -265,7 +265,7 @@ void Radarsat2ImageMetadataInterface::ParseGdal(const MetadataSupplierInterface
// Product file
std::string ProductFilePath = mds.GetResourceFile("product.xml");
if (!ProductFilePath.empty())
{
{
XMLMetadataSupplier ProductMS(ProductFilePath);
m_Imd.Add(MDStr::Mission, ProductMS.GetAs<std::string>("product.sourceAttributes.satellite"));
......@@ -286,13 +286,15 @@ void Radarsat2ImageMetadataInterface::ParseGdal(const MetadataSupplierInterface
assert(mds.GetNbBands() == this->m_Imd.Bands.size());
SARParam sarParam;
LoadRadiometricCalibrationData(sarParam);
for (int bandId = 0 ; bandId < mds.GetNbBands() ; ++bandId)
{
{
Fetch(MDStr::Polarization, mds, "POLARIMETRIC_INTERP", bandId);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
}
}
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void Radarsat2ImageMetadataInterface::ParseGeom(const MetadataSupplierInterface & mds)
......@@ -328,13 +330,15 @@ void Radarsat2ImageMetadataInterface::ParseGeom(const MetadataSupplierInterface
auto polarizations = ProductMS.GetAsVector<std::string>("product.sourceAttributes.radarParameters.polarizations");
assert(polarizations.size() == m_Imd.Bands.size());
SARParam sarParam;
LoadRadiometricCalibrationData(sarParam);
for (int bandId = 0 ; bandId < polarizations.size() ; ++bandId)
{
m_Imd.Bands[bandId].Add(MDStr::Polarization, polarizations[bandId]);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
}
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void Radarsat2ImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
......
......@@ -79,18 +79,19 @@ const std::string SarImageMetadataInterface::GetAcquisitionMode() const
return "";
}
void SarImageMetadataInterface::CreateCalibrationLookupData(const short itkNotUsed(t))
const SarImageMetadataInterface::LookupDataPointerType SarImageMetadataInterface::CreateCalibrationLookupData(const short itkNotUsed(t)) const
{
return SarCalibrationLookupData::New();
}
const SarImageMetadataInterface::LookupDataPointerType SarImageMetadataInterface::GetCalibrationLookupData(const short type)
const SarImageMetadataInterface::LookupDataPointerType SarImageMetadataInterface::GetCalibrationLookupData(const short type) const
{
if (HasCalibrationLookupDataFlag())
{
CreateCalibrationLookupData(type);
return CreateCalibrationLookupData(type);
}
return m_SarLut;
return SarCalibrationLookupData::New();
}
bool SarImageMetadataInterface::HasCalibrationLookupDataFlag() const
......@@ -348,24 +349,29 @@ bool SarImageMetadataInterface::GetSAR(const MetadataSupplierInterface & mds, SA
return true;
}
void SarImageMetadataInterface::LoadRadiometricCalibrationData(SARParam &sarParam)
void SarImageMetadataInterface::LoadRadiometricCalibrationData(SARCalib &sarCalib) const
{
sarParam.calibrationLookupFlag = HasCalibrationLookupDataFlag();
sarParam.rescalingFactor = GetRescalingFactor();
sarParam.radiometricCalibrationNoisePolynomialDegree = GetRadiometricCalibrationNoisePolynomialDegree();
sarParam.radiometricCalibrationAntennaPatternNewGainPolynomialDegree = GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree();
sarParam.radiometricCalibrationAntennaPatternOldGainPolynomialDegree = GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree();
sarParam.radiometricCalibrationIncidenceAnglePolynomialDegree = GetRadiometricCalibrationIncidenceAnglePolynomialDegree();
sarParam.radiometricCalibrationRangeSpreadLossPolynomialDegree = GetRadiometricCalibrationRangeSpreadLossPolynomialDegree();
sarParam.radiometricCalibrationNoise = GetRadiometricCalibrationNoise();
sarParam.radiometricCalibrationAntennaPatternNewGain = GetRadiometricCalibrationAntennaPatternNewGain();
sarParam.radiometricCalibrationAntennaPatternOldGain = GetRadiometricCalibrationAntennaPatternOldGain();
sarParam.radiometricCalibrationIncidenceAngle = GetRadiometricCalibrationIncidenceAngle();
sarParam.radiometricCalibrationRangeSpreadLoss = GetRadiometricCalibrationRangeSpreadLoss();
sarParam.calibrationLookupData[SarCalibrationLookupData::SIGMA] = GetCalibrationLookupData(SarCalibrationLookupData::SIGMA);
sarParam.calibrationLookupData[SarCalibrationLookupData::BETA] = GetCalibrationLookupData(SarCalibrationLookupData::BETA);
sarParam.calibrationLookupData[SarCalibrationLookupData::GAMMA] = GetCalibrationLookupData(SarCalibrationLookupData::GAMMA);
sarParam.calibrationLookupData[SarCalibrationLookupData::DN] = GetCalibrationLookupData(SarCalibrationLookupData::DN);
sarCalib.calibrationLookupFlag = HasCalibrationLookupDataFlag();
sarCalib.rescalingFactor = GetRescalingFactor();
auto coeffs = GetRadiometricCalibrationNoisePolynomialDegree();
std::copy(coeffs.begin(), coeffs.end(), sarCalib.radiometricCalibrationNoisePolynomialDegree.begin());
coeffs = GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree();
std::copy(coeffs.begin(), coeffs.end(), sarCalib.radiometricCalibrationAntennaPatternNewGainPolynomialDegree.begin());
coeffs = GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree();
std::copy(coeffs.begin(), coeffs.end(), sarCalib.radiometricCalibrationAntennaPatternOldGainPolynomialDegree.begin());
coeffs = GetRadiometricCalibrationIncidenceAnglePolynomialDegree();
std::copy(coeffs.begin(), coeffs.end(), sarCalib.radiometricCalibrationIncidenceAnglePolynomialDegree.begin());
coeffs = GetRadiometricCalibrationRangeSpreadLossPolynomialDegree();
std::copy(coeffs.begin(), coeffs.end(), sarCalib.radiometricCalibrationRangeSpreadLossPolynomialDegree.begin());
sarCalib.radiometricCalibrationNoise = GetRadiometricCalibrationNoise();
sarCalib.radiometricCalibrationAntennaPatternNewGain = GetRadiometricCalibrationAntennaPatternNewGain();
sarCalib.radiometricCalibrationAntennaPatternOldGain = GetRadiometricCalibrationAntennaPatternOldGain();
sarCalib.radiometricCalibrationIncidenceAngle = GetRadiometricCalibrationIncidenceAngle();
sarCalib.radiometricCalibrationRangeSpreadLoss = GetRadiometricCalibrationRangeSpreadLoss();
sarCalib.calibrationLookupData[SarCalibrationLookupData::SIGMA] = GetCalibrationLookupData(SarCalibrationLookupData::SIGMA);
sarCalib.calibrationLookupData[SarCalibrationLookupData::BETA] = GetCalibrationLookupData(SarCalibrationLookupData::BETA);
sarCalib.calibrationLookupData[SarCalibrationLookupData::GAMMA] = GetCalibrationLookupData(SarCalibrationLookupData::GAMMA);
sarCalib.calibrationLookupData[SarCalibrationLookupData::DN] = GetCalibrationLookupData(SarCalibrationLookupData::DN);
}
void SarImageMetadataInterface::PrintSelf(std::ostream& os, itk::Indent indent) const
......
......@@ -54,7 +54,7 @@ bool Sentinel1ImageMetadataInterface::CanRead() const
return sensorID.find("SENTINEL-1") != std::string::npos;
}
void Sentinel1ImageMetadataInterface::CreateCalibrationLookupData(const short type)
const Sentinel1ImageMetadataInterface::LookupDataPointerType Sentinel1ImageMetadataInterface::CreateCalibrationLookupData(const short type) const
{
bool sigmaLut = false;
bool betaLut = false;
......@@ -168,7 +168,7 @@ void Sentinel1ImageMetadataInterface::CreateCalibrationLookupData(const short ty
Sentinel1CalibrationLookupData::Pointer sarLut = Sentinel1CalibrationLookupData::New();
sarLut->InitParameters(type, firstLineTime.as_day_frac(), lastLineTime.as_day_frac(), numOfLines, count, calibrationVectorList);
this->SetCalibrationLookupData(sarLut);
return static_cast<SarImageMetadataInterface::LookupDataPointerType> (sarLut);
}
void Sentinel1ImageMetadataInterface::ParseDateTime(const char* key, std::vector<int>& dateFields) const
......@@ -600,32 +600,24 @@ void Sentinel1ImageMetadataInterface::ParseGdal(const MetadataSupplierInterface
XMLMetadataSupplier NoiseMS(NoiseFilePath);
sarParam.noiseVector = this->GetNoiseVector(NoiseMS);
LoadRadiometricCalibrationData(sarParam);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void Sentinel1ImageMetadataInterface::ParseGeom(const MetadataSupplierInterface & mds)
{
Fetch(MDTime::AcquisitionStartTime, mds, "support_data.first_line_time");
Fetch(MDTime::AcquisitionStopTime, mds, "support_data.last_line_time");
Fetch(MDStr::BeamMode, mds, "manifest_data.acquisition_mode");
Fetch(MDStr::BeamSwath, mds, "manifest_data.swath");
Fetch(MDNum::LineSpacing, mds, "support_data.azimuth_spacing");
Fetch(MDStr::Mission, mds, "manifest_data.instrument");
Fetch(MDStr::OrbitDirection, mds, "manifest_data.orbit_pass");
Fetch(MDNum::OrbitNumber, mds, "manifest_data.abs_orbit");
Fetch(MDNum::PixelSpacing, mds, "support_data.range_spacing");
Fetch(MDStr::ProductType, mds, "manifest_data.product_type");
Fetch(MDTime::ProductionDate, mds, "manifest_data.date");
Fetch(MDTime::AcquisitionDate, mds, "manifest_data.image_date");
Fetch("FACILITY_IDENTIFIER", mds, "manifest_data.Processing_system_identifier");
m_Imd.Add(MDStr::SensorID, "SAR");
auto instrument = mds.GetAs<std::string>("sensor");
instrument.pop_back();
m_Imd.Add(MDStr::Instrument, instrument);
Fetch(MDStr::Mode, mds, "header.swath");
Fetch(MDStr::Swath, mds, "manifest_data.swath");
Fetch(MDNum::NumberOfLines, mds, "number_lines", 0);
Fetch(MDNum::NumberOfColumns, mds, "number_samples", 0);
Fetch(MDNum::AverageSceneHeight, mds, "support_data.avg_scene_height", 0);
......@@ -636,9 +628,23 @@ void Sentinel1ImageMetadataInterface::ParseGeom(const MetadataSupplierInterface
auto hasSAR = GetSAR(mds, sarParam);
if (hasSAR)
{
LoadRadiometricCalibrationData(sarParam);
m_Imd.Bands[0].Add(MDGeom::SAR, sarParam);
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
// Manifect data may not be present in geom file
CheckFetch(MDStr::BeamMode, mds, "manifest_data.acquisition_mode");
CheckFetch(MDStr::BeamSwath, mds, "manifest_data.swath");
CheckFetch(MDStr::Mission, mds, "manifest_data.instrument");
CheckFetch(MDStr::OrbitDirection, mds, "manifest_data.orbit_pass");
CheckFetch(MDNum::OrbitNumber, mds, "manifest_data.abs_orbit");
CheckFetch(MDStr::ProductType, mds, "manifest_data.product_type");
CheckFetch(MDTime::ProductionDate, mds, "manifest_data.date");
CheckFetch(MDTime::AcquisitionDate, mds, "manifest_data.image_date");
CheckFetch("FACILITY_IDENTIFIER", mds, "manifest_data.Processing_system_identifier");
CheckFetch(MDStr::Swath, mds, "manifest_data.swath");
}
void Sentinel1ImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
......
......@@ -1263,12 +1263,14 @@ void TerraSarImageMetadataInterface::ParseGdal(const MetadataSupplierInterface &
assert(mds.GetNbBands() == this->m_Imd.Bands.size());
SARParam sarParam;
LoadRadiometricCalibrationData(sarParam);
for (int bandId = 0 ; bandId < mds.GetNbBands() ; ++bandId)
{
Fetch(MDStr::Polarization, mds, "POLARIMETRIC_INTERP", bandId);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void TerraSarImageMetadataInterface::ParseGeom(const MetadataSupplierInterface & mds)
......@@ -1298,12 +1300,14 @@ void TerraSarImageMetadataInterface::ParseGeom(const MetadataSupplierInterface &
assert(mds.GetNbBands() == this->m_Imd.Bands.size());
SARParam sarParam;
LoadRadiometricCalibrationData(sarParam);
for (int bandId = 0 ; bandId < mds.GetNbBands() ; ++bandId)
{
Fetch(MDStr::Polarization, mds, ("acquisitionInfo.polarisationList[" + std::to_string(bandId) + "]").c_str(), bandId);
m_Imd.Bands[bandId].Add(MDGeom::SAR, sarParam);
}
SARCalib sarCalib;
LoadRadiometricCalibrationData(sarCalib);
m_Imd.Add(MDGeom::SARCalib, sarCalib);
}
void TerraSarImageMetadataInterface::Parse(const MetadataSupplierInterface & mds)
......
......@@ -45,31 +45,33 @@ void SarBrightnessToImageFilter<TInputImage, TOutputImage>::BeforeThreadedGenera
/** Retrieve the ImageMetadata */
auto imd = this->GetInput()->GetImageMetadata();
/** Fetch the SARModel */
auto sarParam = boost::any_cast<SARParam>(imd[MDGeom::SAR]);
/** Fetch the SARCalib */
if (!imd.Has(MDGeom::SARCalib))
throw std::runtime_error("otbSarBrightnessToImageFilter was not able to fetch the SARCalib metadata.");
auto sarCalib = boost::any_cast<SARCalib>(imd[MDGeom::SARCalib]);
FunctionPointer function = this->GetFunction();
function->SetScale(imd[MDNum::CalScale]);
ParametricFunctionPointer noise = function->GetNoise();
noise->SetPointSet(sarParam.radiometricCalibrationNoise);
noise->SetPolynomalSize(sarParam.radiometricCalibrationNoisePolynomialDegree);
noise->SetPointSet(sarCalib.radiometricCalibrationNoise);
noise->SetPolynomalSize(sarCalib.radiometricCalibrationNoisePolynomialDegree);
noise->EvaluateParametricCoefficient();
ParametricFunctionPointer antennaPatternNewGain = function->GetAntennaPatternNewGain();
antennaPatternNewGain->SetPointSet(sarParam.radiometricCalibrationAntennaPatternNewGain);
antennaPatternNewGain->SetPolynomalSize(sarParam.radiometricCalibrationAntennaPatternNewGainPolynomialDegree);
antennaPatternNewGain->SetPointSet(sarCalib.radiometricCalibrationAntennaPatternNewGain);
antennaPatternNewGain->SetPolynomalSize(sarCalib.radiometricCalibrationAntennaPatternNewGainPolynomialDegree);
antennaPatternNewGain->EvaluateParametricCoefficient();
ParametricFunctionPointer antennaPatternOldGain = function->GetAntennaPatternOldGain();
antennaPatternOldGain->SetPointSet(sarParam.radiometricCalibrationAntennaPatternOldGain);
antennaPatternOldGain->SetPolynomalSize(sarParam.radiometricCalibrationAntennaPatternOldGainPolynomialDegree);
antennaPatternOldGain->SetPointSet(sarCalib.radiometricCalibrationAntennaPatternOldGain);
antennaPatternOldGain->SetPolynomalSize(sarCalib.radiometricCalibrationAntennaPatternOldGainPolynomialDegree);
antennaPatternOldGain->EvaluateParametricCoefficient();
ParametricFunctionPointer rangeSpreadLoss = function->GetRangeSpreadLoss();
rangeSpreadLoss->SetPointSet(sarParam.radiometricCalibrationRangeSpreadLoss);
rangeSpreadLoss->SetPolynomalSize(sarParam.radiometricCalibrationRangeSpreadLossPolynomialDegree);
rangeSpreadLoss->SetPointSet(sarCalib.radiometricCalibrationRangeSpreadLoss);
rangeSpreadLoss->SetPolynomalSize(sarCalib.radiometricCalibrationRangeSpreadLossPolynomialDegree);
rangeSpreadLoss->EvaluateParametricCoefficient();
#if 0
......
......@@ -69,7 +69,9 @@ void SarRadiometricCalibrationToImageFilter<TInputImage, TOutputImage>::BeforeTh
/** Retrieve the ImageMetadata */
auto imd = this->GetInput()->GetImageMetadata();
/** Fetch the SARModel */
auto sarParam = boost::any_cast<SARParam>(imd[MDGeom::SAR]);
if (!imd.Has(MDGeom::SARCalib))
throw std::runtime_error("otbSarRadiometricCalibrationTiImageFilter was not able to fetch the SARCalib metadata.");
auto sarParam = boost::any_cast<SARCalib>(imd[MDGeom::SARCalib]);
/** Get the SarRadiometricCalibrationFunction function instance. */
FunctionPointer function = this->GetFunction();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment