use of org.esa.s1tbx.commons.Sentinel1Utils in project s1tbx by senbox-org.
the class TOPSARMergeOp method getSubSwathParameters.
private void getSubSwathParameters() {
try {
su = new Sentinel1Utils[numOfSubSwath];
subSwath = new Sentinel1Utils.SubSwathInfo[numOfSubSwath];
for (int p = 0; p < numOfSubSwath; p++) {
final int s = sourceProductIndexToSubSwathIndexMap.get(p) - refSubSwathIndex;
su[s] = new Sentinel1Utils(sourceProduct[p]);
subSwath[s] = su[s].getSubSwath()[0];
if (selectedPolarisations == null || selectedPolarisations.length == 0) {
selectedPolarisations = su[s].getPolarizations();
}
final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(sourceProduct[p]);
subSwath[s].firstValidPixel = AbstractMetadata.getAttributeInt(absRoot, "firstValidPixel");
subSwath[s].lastValidPixel = AbstractMetadata.getAttributeInt(absRoot, "lastValidPixel");
subSwath[s].slrTimeToFirstValidPixel = AbstractMetadata.getAttributeDouble(absRoot, "slrTimeToFirstValidPixel");
subSwath[s].slrTimeToLastValidPixel = AbstractMetadata.getAttributeDouble(absRoot, "slrTimeToLastValidPixel");
subSwath[s].firstValidLineTime = AbstractMetadata.getAttributeDouble(absRoot, "firstValidLineTime");
subSwath[s].lastValidLineTime = AbstractMetadata.getAttributeDouble(absRoot, "lastValidLineTime");
}
} catch (Throwable e) {
throw new OperatorException(e.getMessage());
}
}
use of org.esa.s1tbx.commons.Sentinel1Utils in project s1tbx by senbox-org.
the class InterferogramOp method checkUserInput.
private void checkUserInput() {
try {
final InputProductValidator validator = new InputProductValidator(sourceProduct);
validator.checkIfSARProduct();
validator.checkIfCoregisteredStack();
validator.checkIfSLC();
isTOPSARBurstProduct = validator.isTOPSARProduct() && !validator.isDebursted();
if (isTOPSARBurstProduct) {
final String mProcSysId = mstRoot.getAttributeString(AbstractMetadata.ProcessingSystemIdentifier);
final float mVersion = Float.parseFloat(mProcSysId.substring(mProcSysId.lastIndexOf(' ')));
MetadataElement slaveElem = sourceProduct.getMetadataRoot().getElement(AbstractMetadata.SLAVE_METADATA_ROOT);
if (slaveElem == null) {
slaveElem = sourceProduct.getMetadataRoot().getElement("Slave Metadata");
}
MetadataElement[] slaveRoot = slaveElem.getElements();
for (MetadataElement slvRoot : slaveRoot) {
final String sProcSysId = slvRoot.getAttributeString(AbstractMetadata.ProcessingSystemIdentifier);
final float sVersion = Float.parseFloat(sProcSysId.substring(sProcSysId.lastIndexOf(' ')));
if ((mVersion < 2.43 && sVersion >= 2.43 && mstRoot.getAttribute("EAP Correction") == null) || (sVersion < 2.43 && mVersion >= 2.43 && slvRoot.getAttribute("EAP Correction") == null)) {
throw new OperatorException("Source products cannot be InSAR pairs: one is EAP phase corrected" + " and the other is not. Apply EAP Correction.");
}
}
su = new Sentinel1Utils(sourceProduct);
subswaths = su.getSubSwathNames();
subSwath = su.getSubSwath();
numSubSwaths = su.getNumOfSubSwath();
// subSwathIndex is always 1 because of split product
subSwathIndex = 1;
}
final String[] polarisationsInBandNames = OperatorUtils.getPolarisations(sourceProduct);
polarisations = getPolsSharedByMstSlv(sourceProduct, polarisationsInBandNames);
sourceImageWidth = sourceProduct.getSceneRasterWidth();
sourceImageHeight = sourceProduct.getSceneRasterHeight();
} catch (Exception e) {
throw new OperatorException(e);
}
}
use of org.esa.s1tbx.commons.Sentinel1Utils in project s1tbx by senbox-org.
the class AzimuthShiftEstimationUsingESDOp method initialize.
/**
* Initializes this operator and sets the one and only target product.
* <p>The target product can be either defined by a field of type {@link Product} annotated with the
* {@link TargetProduct TargetProduct} annotation or
* by calling {@link #setTargetProduct} method.</p>
* <p>The framework calls this method after it has created this operator.
* Any client code that must be performed before computation of tile data
* should be placed here.</p>
*
* @throws OperatorException If an error occurs during operator initialisation.
* @see #getTargetProduct()
*/
@Override
public void initialize() throws OperatorException {
try {
final InputProductValidator validator = new InputProductValidator(sourceProduct);
validator.checkIfSARProduct();
validator.checkIfSentinel1Product();
su = new Sentinel1Utils(sourceProduct);
su.computeDopplerRate();
su.computeReferenceTime();
subSwath = su.getSubSwath();
polarizations = su.getPolarizations();
subSwathNames = su.getSubSwathNames();
if (subSwathNames.length != 1) {
throw new OperatorException("Split product is expected");
} else {
// subSwathIndex is always 1 because of split product
subSwathIndex = 1;
}
constructSourceMetadata();
constructTargetMetadata();
createTargetProduct();
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
}
}
use of org.esa.s1tbx.commons.Sentinel1Utils in project s1tbx by senbox-org.
the class AzimuthShiftOp method initialize.
/**
* Initializes this operator and sets the one and only target product.
* <p>The target product can be either defined by a field of type {@link Product} annotated with the
* {@link TargetProduct TargetProduct} annotation or
* by calling {@link #setTargetProduct} method.</p>
* <p>The framework calls this method after it has created this operator.
* Any client code that must be performed before computation of tile data
* should be placed here.</p>
*
* @throws OperatorException If an error occurs during operator initialisation.
* @see #getTargetProduct()
*/
@Override
public void initialize() throws OperatorException {
try {
final InputProductValidator validator = new InputProductValidator(sourceProduct);
validator.checkIfSARProduct();
validator.checkIfSentinel1Product();
checkDerampDemodPhaseBand();
final Sentinel1Utils su = new Sentinel1Utils(sourceProduct);
su.computeDopplerRate();
subSwath = su.getSubSwath();
subSwathNames = su.getSubSwathNames();
if (subSwathNames.length != 1) {
throw new OperatorException("Split product is expected.");
} else {
// Integer.parseInt(subSwathNames[0].substring(subSwathNames[0].length()-1));
subSwathIndex = 1;
swathIndexStr = subSwathNames[0].substring(2);
}
polarizations = su.getPolarizations();
createTargetProduct();
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
}
}
use of org.esa.s1tbx.commons.Sentinel1Utils in project s1tbx by senbox-org.
the class BackGeocodingOp method initialize.
/**
* Initializes this operator and sets the one and only target product.
* <p>The target product can be either defined by a field of type {@link Product} annotated with the
* {@link TargetProduct TargetProduct} annotation or
* by calling {@link #setTargetProduct} method.</p>
* <p>The framework calls this method after it has created this operator.
* Any client code that must be performed before computation of tile data
* should be placed here.</p>
*
* @throws OperatorException If an error occurs during operator initialisation.
* @see #getTargetProduct()
*/
@Override
public void initialize() throws OperatorException {
try {
if (sourceProduct == null) {
return;
}
checkSourceProductValidity();
masterProduct = sourceProduct[0];
mSU = new Sentinel1Utils(masterProduct);
mSubSwath = mSU.getSubSwath();
mSU.computeDopplerRate();
mSU.computeReferenceTime();
for (Product product : sourceProduct) {
if (product.equals(masterProduct))
continue;
slaveDataList.add(new SlaveData(product));
}
/*
outputToFile("c:\\output\\mSensorPosition.dat", mSU.getOrbit().sensorPosition);
outputToFile("c:\\output\\mSensorVelocity.dat", mSU.getOrbit().sensorVelocity);
outputToFile("c:\\output\\sSensorPosition.dat", sSU.getOrbit().sensorPosition);
outputToFile("c:\\output\\sSensorVelocity.dat", sSU.getOrbit().sensorVelocity);
*/
final String[] mSubSwathNames = mSU.getSubSwathNames();
final String[] mPolarizations = mSU.getPolarizations();
for (SlaveData slaveData : slaveDataList) {
final String[] sSubSwathNames = slaveData.sSU.getSubSwathNames();
if (mSubSwathNames.length != 1 || sSubSwathNames.length != 1) {
throw new OperatorException("Split product is expected.");
}
if (!mSubSwathNames[0].equals(sSubSwathNames[0])) {
throw new OperatorException("Same sub-swath is expected.");
}
final String[] sPolarizations = slaveData.sSU.getPolarizations();
if (!StringUtils.containsIgnoreCase(sPolarizations, mPolarizations[0])) {
throw new OperatorException("Same polarization is expected.");
}
}
// subSwathIndex is always 1 because of split product
subSwathIndex = 1;
swathIndexStr = mSubSwathNames[0].substring(2);
if (externalDEMFile == null) {
DEMFactory.checkIfDEMInstalled(demName);
}
DEMFactory.validateDEM(demName, masterProduct);
selectedResampling = ResamplingFactory.createResampling(resamplingType);
if (selectedResampling == null) {
throw new OperatorException("Resampling method " + resamplingType + " is invalid");
}
createTargetProduct();
final List<String> masterProductBands = new ArrayList<>();
for (String bandName : masterProduct.getBandNames()) {
if (masterProduct.getBand(bandName) instanceof VirtualBand) {
continue;
}
masterProductBands.add(bandName + mstSuffix);
}
StackUtils.saveMasterProductBandNames(targetProduct, masterProductBands.toArray(new String[masterProductBands.size()]));
StackUtils.saveSlaveProductNames(sourceProduct, targetProduct, masterProduct, targetBandToSlaveBandMap);
updateTargetProductMetadata();
final Band masterBandI = getBand(masterProduct, "i_", swathIndexStr, mSU.getPolarizations()[0]);
if (masterBandI != null && masterBandI.isNoDataValueUsed()) {
noDataValue = masterBandI.getNoDataValue();
}
} catch (Throwable e) {
OperatorUtils.catchOperatorException(getId(), e);
}
}
Aggregations