/** * Get the range and azimuth spacings (in meter). */ void getSrcImagePixelSpacings() { srcRangeSpacing = (float) absRoot.getAttributeDouble(AbstractMetadata.range_spacing); //System.out.println("Range spacing is " + srcRangeSpacing); srcAzimuthSpacing = (float) absRoot.getAttributeDouble(AbstractMetadata.azimuth_spacing); //System.out.println("Azimuth spacing is " + srcAzimuthSpacing); }
private static double[] getLatCorners(final MetadataElement absRoot) { final double latUL = absRoot.getAttributeDouble(AbstractMetadata.first_near_lat); final double latUR = absRoot.getAttributeDouble(AbstractMetadata.first_far_lat); final double latLL = absRoot.getAttributeDouble(AbstractMetadata.last_near_lat); final double latLR = absRoot.getAttributeDouble(AbstractMetadata.last_far_lat); return new double[]{latUL, latUR, latLL, latLR}; }
/** * Get line time interval from the abstracted metadata (in days). */ private void getLineTimeInterval() { lineTimeInterval = absRoot.getAttributeDouble(AbstractMetadata.line_time_interval) / Constants.secondsInDay; // s to day }
private static double[] getLonCorners(final MetadataElement absRoot) { final double lonUL = absRoot.getAttributeDouble(AbstractMetadata.first_near_long); final double lonUR = absRoot.getAttributeDouble(AbstractMetadata.first_far_long); final double lonLL = absRoot.getAttributeDouble(AbstractMetadata.last_near_long); final double lonLR = absRoot.getAttributeDouble(AbstractMetadata.last_far_long); return new double[]{lonUL, lonUR, lonLL, lonLR}; }
/** * Get calibration factors from Metadata for each band in the product. * Here it is assumed that the calibration factor values do not change in case that there are * multiple records in the Main Processing Parameters data set. */ private void getCalibrationFactorFromMetadata() { newCalibrationConstant[0] = absRoot.getAttributeDouble(AbstractMetadata.calibration_factor); if(productType.startsWith("ASA_AP")) { newCalibrationConstant[1] = absRoot.getAttributeDouble(AbstractMetadata.calibration_factor+".2"); } }
/** * Get information from the metadata. */ private void readMetadata() { srcRangeSpacing = (float) abs.getAttributeDouble(AbstractMetadata.range_spacing); srcAzimuthSpacing = (float) abs.getAttributeDouble(AbstractMetadata.azimuth_spacing); final String sampleType = abs.getAttributeString(AbstractMetadata.SAMPLE_TYPE); isDetectedSampleType = sampleType.contains("DETECTED"); prf = abs.getAttributeDouble(AbstractMetadata.pulse_repetition_frequency); if (prf == 0) { SystemUtils.LOG.warning("PRF is 0"); prf = 100; } }
/** * Get calibration factor. */ private void getCalibrationFactor() { calibrationFactor = absRoot.getAttributeDouble(AbstractMetadata.calibration_factor); if (isComplex) { calibrationFactor -= 32.0; // calibration factor offset is 32 dB } calibrationFactor = FastMath.pow(10.0, calibrationFactor / 10.0); // dB to linear scale //System.out.println("Calibration factor is " + calibrationFactor); }
/** * Get the replica pulse power for PGS ENVISAT product. * * @return The replica pulse power. */ private double getReplicaPulsePowerForENVISAT() { double replicaPulsePower = absRoot.getAttributeDouble(AbstractMetadata.chirp_power); // in dB replicaPulsePower = FastMath.pow(10.0, replicaPulsePower / 10.0); // convert to linear scale //System.out.println("Replica pulse power is " + replicaPulsePower); return replicaPulsePower; }
/** * Compute distance from satellite to the Earth center using satellite corrodinate in Metadata. * * @return The distance. */ private double getSatelliteToEarthCenterDistanceForENVISAT() { final MetadataElement orbit_state_vectors = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement orbit_vector = orbit_state_vectors.getElement(AbstractMetadata.orbit_vector + 3); final float xpos = (float)orbit_vector.getAttributeDouble("x_pos"); final float ypos = (float)orbit_vector.getAttributeDouble("y_pos"); final float zpos = (float)orbit_vector.getAttributeDouble("z_pos"); final double rSat = Math.sqrt(xpos * xpos + ypos * ypos + zpos * zpos); // in m if (Double.compare(rSat, 0.0) == 0) { throw new OperatorException("x, y and z positions in orbit_state_vectors are all zeros"); } return rSat; }
private String createMetadataDouble(final String name, final MetadataElement recElem, final String elemName, String unit) { final MetadataElement elem = recElem.getElement(elemName); final double value = elem.getElement("Values").getAttributeDouble("data", 0); String valueStr = String.valueOf(value); if (value - (int) value != 0) valueStr = frmt.format(value); if (unit == null) { unit = elem.getAttributeString("units"); } return name + ": " + valueStr + " " + unit; }
/** * Get calibration factor. */ private void getCalibrationFactor() { final MetadataElement[] elements = origMetadataRoot.getElements(); for (MetadataElement elem : elements) { final String elemName = elem.getName(); if (!elemName.equals("ProductMetadata")) { final String pol = elemName.substring(0, elemName.indexOf("_Metadata")); final MetadataElement leader = elem.getElement("Leader"); final MetadataElement radiometric = leader.getElement("Radiometric"); final double factorDB = radiometric.getAttributeDouble("Calibration_constant"); final double factor = Math.pow(10.0, factorDB/10.0); calibrationFactor.put(pol, factor); } } }
private double getBandTerrainHeight(final MetadataElement prodElem) { final MetadataElement generalAnnotation = prodElem.getElement("generalAnnotation"); final MetadataElement terrainHeightList = generalAnnotation.getElement("terrainHeightList"); double heightSum = 0.0; final MetadataElement[] heightList = terrainHeightList.getElements(); int cnt = 0; for (MetadataElement terrainHeight : heightList) { heightSum += terrainHeight.getAttributeDouble("value"); ++cnt; } return heightSum / cnt; }
private void getMetadata() { firstLineUTC = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // in days lineTimeInterval = absRoot.getAttributeDouble(AbstractMetadata.line_time_interval) / Constants.secondsInDay; // s to day if (lineTimeInterval == 0.0) { throw new OperatorException("Invalid input for Line Time Interval: " + lineTimeInterval); } }
/** * Get calibration constant from product original metadata. */ private void getCalibrationConstant() { final MetadataElement auxElem = origMetadataRoot.getElement("Auxiliary"); final MetadataElement rootElem = auxElem.getElement("Root"); final MetadataElement subSwathsElem = rootElem.getElement("SubSwaths"); final MetadataElement subSwathElem = subSwathsElem.getElement("SubSwath"); calibrationConstant = subSwathElem.getAttributeDouble("CalibrationConstant"); }
private void addSlantRangeToFirstPixel() { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); final MetadataElement bandElem = getBandElement(product.getBandAt(0)); if (bandElem != null) { final double slantRangeTime = bandElem.getAttributeDouble("Zero_Doppler_Range_First_Time", 0); //s AbstractMetadata.setAttribute(absRoot, AbstractMetadata.slant_range_to_first_pixel, slantRangeTime * Constants.halfLightSpeed); } }
private void addSlantRangeToFirstPixel() { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); final MetadataElement bandElem = getBandElement(product.getBandAt(0)); if (bandElem != null) { final double slantRangeTime = bandElem.getAttributeDouble("Zero_Doppler_Range_First_Time", 0); //s AbstractMetadata.setAttribute(absRoot, AbstractMetadata.slant_range_to_first_pixel, slantRangeTime * Constants.halfLightSpeed); } }
/** * For SAR products check that geocoding has been performed */ private void validateSARProduct() { final MetadataElement root = sourceProduct.getMetadataRoot(); if(root != null) { final MetadataElement absRoot = root.getElement("Abstracted_Metadata"); if(absRoot != null) { boolean isRadar = absRoot.getAttributeDouble("radar_frequency", 99999) != 99999; if(isRadar && !(sourceProduct.getSceneGeoCoding() instanceof CrsGeoCoding)) { throw new OperatorException("SAR products should be terrain corrected or ellipsoid corrected"); } } } }
private void updateTargetProductMetadata() { final MetadataElement absTgt = AbstractMetadata.getAbstractedMetadata(targetProduct); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.azimuth_spacing, azimuthSpacing); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.range_spacing, rangeSpacing); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.num_samples_per_line, targetImageWidth); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.num_output_lines, targetImageHeight); final float oldLineTimeInterval = (float) absTgt.getAttributeDouble(AbstractMetadata.line_time_interval); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.line_time_interval, oldLineTimeInterval / heightRatio); }
private void updateTargetProductMetadata(int subSamplingX, int subSamplingY) { getSrcImagePixelSpacings(); targetImageWidth = (sourceImageWidth - 1) / subSamplingX + 1; targetImageHeight = (sourceImageHeight - 1) / subSamplingY + 1; rangeSpacing = srcRangeSpacing * sourceImageWidth / targetImageWidth; azimuthSpacing = srcAzimuthSpacing * sourceImageHeight / targetImageHeight; final MetadataElement absTgt = AbstractMetadata.getAbstractedMetadata(targetProduct); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.azimuth_spacing, azimuthSpacing); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.range_spacing, rangeSpacing); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.num_samples_per_line, targetImageWidth); AbstractMetadata.setAttribute(absTgt, AbstractMetadata.num_output_lines, targetImageHeight); final float oldLineTimeInterval = (float) absTgt.getAttributeDouble(AbstractMetadata.line_time_interval); AbstractMetadata.setAttribute( absTgt, AbstractMetadata.line_time_interval, oldLineTimeInterval * (float) subSamplingY); }
/** * Get antenna pattern gain array from metadata. */ private void getLUT() { final MetadataElement origProdRoot = AbstractMetadata.getOriginalProductMetadata(sourceProduct); final MetadataElement lutSigmaElem = origProdRoot.getElement(lutsigma); if (lutSigmaElem != null) { offset = lutSigmaElem.getAttributeDouble("offset", 0); final MetadataAttribute gainsAttrib = lutSigmaElem.getAttribute("gains"); if (gainsAttrib != null) { gains = (double[]) gainsAttrib.getData().getElems(); } } else { throw new OperatorException(lutsigma + " not found. Please ensure the look up table " + lutsigma + ".xml is in the same folder as the original product"); } if (gains.length < sourceProduct.getSceneRasterWidth()) { throw new OperatorException("Calibration LUT is smaller than source product width"); } }