Commit 9e6d6b18 authored by Julien Osman's avatar Julien Osman
Browse files

BUG: Read the correct LUTs for Radarsat2

parent 0472472b
Pipeline #7730 failed with stages
in 88 minutes and 59 seconds
......@@ -63,53 +63,54 @@ bool Radarsat2ImageMetadataInterface::CreateCalibrationLookupData(SARCalib& sarC
const MetadataSupplierInterface& mds,
const bool geom) const
{
if(SarImageMetadataInterface::CreateCalibrationLookupData(sarCalib, imd, mds, geom))
return true;
int offset = 0;
std::ostringstream ossSigma;
std::ostringstream ossBeta;
std::ostringstream ossGamma;
Radarsat2CalibrationLookupData::Pointer sigmaSarLut = Radarsat2CalibrationLookupData::New();
Radarsat2CalibrationLookupData::Pointer betaSarLut = Radarsat2CalibrationLookupData::New();
Radarsat2CalibrationLookupData::Pointer gammaSarLut = Radarsat2CalibrationLookupData::New();
Radarsat2CalibrationLookupData::Pointer dnSarLut = Radarsat2CalibrationLookupData::New();
if(geom)
{
ossSigma << "referenceNoiseLevel[SigmaNought].gain";
ossBeta << "referenceNoiseLevel[BetaNought].gain";
ossGamma << "referenceNoiseLevel[GammaNought].gain";
std::string path = "referenceNoiseLevel[SigmaNought].gain";
auto glist = mds.GetAsVector<float>(path);
sigmaSarLut->InitParameters(SarCalibrationLookupData::SIGMA, offset, glist);
path = "referenceNoiseLevel[BetaNought].gain";
glist = mds.GetAsVector<float>(path);
betaSarLut->InitParameters(SarCalibrationLookupData::BETA, offset, glist);
path = "referenceNoiseLevel[GammaNought].gain";
glist = mds.GetAsVector<float>(path);
gammaSarLut->InitParameters(SarCalibrationLookupData::GAMMA, offset, glist);
}
else
{
ossSigma << "product.sourceAttributes.radarParameters.referenceNoiseLevel_"
<< mds.GetAttributId("product.sourceAttributes.radarParameters.referenceNoiseLevel_#.incidenceAngleCorrection",
"Sigma Nought")
<< ".noiseLevelValues";
ossBeta << "product.sourceAttributes.radarParameters.referenceNoiseLevel_"
<< mds.GetAttributId("product.sourceAttributes.radarParameters.referenceNoiseLevel_#.incidenceAngleCorrection",
"Beta Nought")
<< ".noiseLevelValues";
ossGamma << "product.sourceAttributes.radarParameters.referenceNoiseLevel_"
<< mds.GetAttributId("product.sourceAttributes.radarParameters.referenceNoiseLevel_#.incidenceAngleCorrection",
"gamma")
<< ".noiseLevelValues";
std::string pathGains = "lut.gains";
auto productPath = boost::filesystem::path(mds.GetResourceFile()); // TODO C++ 2017 use std::filesystem
productPath = productPath.remove_filename() /= "lutSigma.xml";
XMLMetadataSupplier sigmaLutSupplier(productPath.string());
auto glist = sigmaLutSupplier.GetAsVector<float>(pathGains);
sigmaSarLut->InitParameters(SarCalibrationLookupData::SIGMA, offset, glist);
productPath = productPath.remove_filename() /= "lutBeta.xml";
XMLMetadataSupplier betaLutSupplier(productPath.string());
glist = betaLutSupplier.GetAsVector<float>(pathGains);
betaSarLut->InitParameters(SarCalibrationLookupData::BETA, offset, glist);
productPath = productPath.remove_filename() /= "lutGamma.xml";
XMLMetadataSupplier gammaLutSupplier(productPath.string());
glist = gammaLutSupplier.GetAsVector<float>(pathGains);
gammaSarLut->InitParameters(SarCalibrationLookupData::GAMMA, offset, glist);
}
Radarsat2CalibrationLookupData::Pointer sigmaSarLut = Radarsat2CalibrationLookupData::New();
auto glist = mds.GetAsVector<float>(ossSigma.str());
sigmaSarLut->InitParameters(SarCalibrationLookupData::SIGMA, offset, glist);
sarCalib.calibrationLookupData[SarCalibrationLookupData::SIGMA] = std::move(sigmaSarLut);
Radarsat2CalibrationLookupData::Pointer betaSarLut = Radarsat2CalibrationLookupData::New();
glist = mds.GetAsVector<float>(ossSigma.str());
betaSarLut->InitParameters(SarCalibrationLookupData::BETA, offset, glist);
sarCalib.calibrationLookupData[SarCalibrationLookupData::BETA] = std::move(betaSarLut);
Radarsat2CalibrationLookupData::Pointer gammaSarLut = Radarsat2CalibrationLookupData::New();
glist = mds.GetAsVector<float>(ossSigma.str());
gammaSarLut->InitParameters(SarCalibrationLookupData::GAMMA, offset, glist);
sarCalib.calibrationLookupData[SarCalibrationLookupData::GAMMA] = std::move(gammaSarLut);
Radarsat2CalibrationLookupData::Pointer dnSarLut = Radarsat2CalibrationLookupData::New();
sarCalib.calibrationLookupData[SarCalibrationLookupData::DN] = std::move(dnSarLut);
return true;
......@@ -336,6 +337,7 @@ void Radarsat2ImageMetadataInterface::ParseGdal(ImageMetadata & imd)
imd.Add(MDNum::PRF, this->GetPRF());
imd.Add(MDNum::RSF, this->GetRSF());
imd.Add(MDNum::CenterIncidenceAngle, this->GetCenterIncidenceAngle(ProductMS));
imd.Add(MDNum::CalScale, 1.0);
SARParam sarParam;
// Fetch the GCP
......@@ -355,6 +357,7 @@ void Radarsat2ImageMetadataInterface::ParseGeom(ImageMetadata & imd)
Fetch(MDNum::PixelSpacing, imd, "meters_per_pixel_x");
Fetch(MDStr::Instrument, imd, "sensor");
imd.Add(MDStr::SensorID, "SAR");
imd.Add(MDNum::CalScale, 1.0);
// Product file
auto ProductFilePath = boost::filesystem::path(m_MetadataSupplierInterface->GetResourceFile("geom")); // TODO C++ 2017 use std::filesystem
......
......@@ -103,9 +103,9 @@ SarRadiometricCalibrationFunction<TInputImage, TCoordRep>::EvaluateAtIndex(const
this->GetInputImage()->TransformIndexToPhysicalPoint(index, point);
/** digitalNumber:
* For complex pixel type, std::abs() returns the modulus. which is
* For complex pixel type, std::abs() returns the modulus, which is
* sqrt((I*I) + (Q*Q)). Where I and Q are real and imaginary part of the
* complex pixel. So to to get (I*I) + (Q*Q) in our calculation, the output
* complex pixel. So to get (I*I) + (Q*Q) in our calculation, the output
* of std::abs() is squared. See below (digitalNumber * digitalNumber) where
* digitalNumber is the output of std::abs() which is sqrt((I*I) + (Q*Q)). For
* non-complex pixel types, std::abs() simply returns absolute value.
......
......@@ -30,13 +30,12 @@ namespace otb
/** \class SarRadiometricCalibrationToImageFilter
* \brief Evaluates the SarRadiometricCalibrationFunction onto a source image
* The BeforeThreadedGenerateData create a SarImageMetadataInterface based on
* input metadata dictionary. The nature of product(TerrSARX, Sentinel1, etc..)
* are thus detected automatically from this. The filter then reads necessary
* The nature of product(TerrSARX, Sentinel1, etc..)
* are thus detected automatically from the metadata. The filter then reads necessary
* parameters required to perform SarCalibration in a generic way.
*
* BeforeThreadedGenerateData() instantiate a SarRadiometricCalibrationFunction
* and pass the values taken from SarImageMetadataInterface instance to it. This
* and pass the values taken from ImageMetadata instance to it. This
* is where the actual computation of sigma (backscatter) occurs.
*
* Noise, Antenna pattern gain (old && new), range spread loss, incidence angle
......
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