/** * Get first line time from the abstracted metadata (in days). */ private void getFirstLineTime() { firstLineUTC = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // in days }
public File retrieveOrbitFile(final String orbitType) throws Exception { final double stateVectorTime = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).getMJD(); final Calendar calendar = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).getAsCalendar(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; // zero based final int day = calendar.get(Calendar.DAY_OF_MONTH); orbitFile = findOrbitFile(orbitType, stateVectorTime, year, month); if (orbitFile == null) { String timeStr = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).format(); final File destFolder = getDestFolder(orbitType, year, month); throw new IOException("No valid orbit file found for " + timeStr + "\nOrbit files may be downloaded from " + remoteURL + "\nand placed in " + destFolder.getAbsolutePath()); } // read content of the orbit file osvList = readOrbitFile(orbitFile); return orbitFile; }
public static ProductData.UTC getSlaveTime(final Product sourceProduct, final Band slvBand) { final MetadataElement slaveMetadataRoot = sourceProduct.getMetadataRoot().getElement( AbstractMetadata.SLAVE_METADATA_ROOT); if (slaveMetadataRoot != null) { final String slvBandName = slvBand.getName(); final boolean isIntensity = slvBandName.startsWith("Intensity"); for (MetadataElement elem : slaveMetadataRoot.getElements()) { final String slvBandNames = elem.getAttributeString(AbstractMetadata.SLAVE_BANDS, ""); if (slvBandNames.contains(slvBandName)) return elem.getAttributeUTC(AbstractMetadata.first_line_time); if (isIntensity) { final String iName = slvBandName.replace("Intensity_", "i_"); if (slvBandNames.contains(iName)) return elem.getAttributeUTC(AbstractMetadata.first_line_time); } } } return null; }
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); } }
public File retrieveOrbitFile(final String orbitType) throws Exception { final double stateVectorTime = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).getMJD(); final Calendar calendar = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).getAsCalendar(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; // zero based final int day = calendar.get(Calendar.DAY_OF_MONTH); final String missionPrefix = getMissionPrefix(absRoot); orbitFile = findOrbitFile(missionPrefix, orbitType, stateVectorTime, year, month); if (orbitFile == null) { //orbitFile = downloadArchive(missionPrefix, orbitType, year, month, day, stateVectorTime); orbitFile = downloadFromStepAuxdata(missionPrefix, orbitType, year, month, day, stateVectorTime); } if (orbitFile == null) { orbitFile = downloadFromQCWebsite(missionPrefix, orbitType, year, month, day, stateVectorTime); } if (orbitFile == null) { String timeStr = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).format(); final File destFolder = getDestFolder(missionPrefix, orbitType, year, month); throw new IOException("No valid orbit file found for " + timeStr + "\nOrbit files may be downloaded from https://qc.sentinel1.eo.esa.int/" + "\nand placed in " + destFolder.getAbsolutePath()); } if (!orbitFile.exists()) { throw new IOException("SentinelPODOrbitFile: Unable to find POD orbit file"); } // read content of the orbit file readOrbitFile(); return orbitFile; }
protected static void updateProduct(final Product product, final MetadataElement newRoot) { final MetadataElement root = product.getMetadataRoot(); for(MetadataElement elem : newRoot.getElements()) { root.addElement(elem); } final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); product.setStartTime(absRoot.getAttributeUTC(AbstractMetadata.first_line_time)); product.setEndTime(absRoot.getAttributeUTC(AbstractMetadata.last_line_time)); product.setProductType(absRoot.getAttributeString(AbstractMetadata.PRODUCT_TYPE)); product.setDescription(absRoot.getAttributeString(AbstractMetadata.SPH_DESCRIPTOR)); }
/** * Check if product acquisition time is within the validity period of the orbit file. * * @throws Exception */ private void checkOrbitFileValidity() throws Exception { final double stateVectorTime = absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME).getMJD(); final String validityStartTimeStr = getValidityStartFromHeader(); final String validityStopTimeStr = getValidityStopFromHeader(); final double validityStartTimeMJD = SentinelPODOrbitFile.toUTC(validityStartTimeStr).getMJD(); final double validityStopTimeMJD = SentinelPODOrbitFile.toUTC(validityStopTimeStr).getMJD(); if (stateVectorTime < validityStartTimeMJD || stateVectorTime > validityStopTimeMJD) { throw new IOException("Product acquisition time is not within the validity period of the orbit"); } }
private void addOrbitStateVectors(final MetadataElement absRoot, final MetadataElement orbitInformation) { final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement[] stateVectorElems = orbitInformation.getElements(); for (int i = 1; i <= stateVectorElems.length; ++i) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVectorElems[i - 1], i); } // set state vector time if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(stateVectorElems[0], "timeStamp", standardDateFormat)); } }
protected void addOrbitStateVectors(final MetadataElement absRoot, final BinaryRecord platformPosRec) { if (platformPosRec == null) return; final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final int numPoints = platformPosRec.getAttributeInt("Number of data points"); for (int i = 1; i <= numPoints; ++i) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, platformPosRec, i); } if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, getOrbitTime(platformPosRec, 1)); } }
private void addOrbitStateVectors(MetadataElement absRoot, MetadataElement orbitInformation) { final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement[] stateVectorElems = orbitInformation.getElements(); for (int i = 1; i < stateVectorElems.length; ++i) { // first stateVectorElem is orbitHeader therefore skip it addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVectorElems[i], i); } // set state vector time if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(stateVectorElems[1], "timeUTC", standardDateFormat)); } }
private void addOrbitStateVectors(final MetadataElement absRoot, final MetadataElement orbitList) { final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement[] stateVectorElems = orbitList.getElements(); for (int i = 1; i <= stateVectorElems.length; ++i) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVectorElems[i - 1], i); } // set state vector time if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(stateVectorElems[0], "time", sentinelDateFormat)); } }
private void addOrbitStateVectors(final MetadataElement absRoot, final MetadataElement orbitInformation) { final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement[] stateVectorElems = orbitInformation.getElements(); for (int i = 1; i <= stateVectorElems.length; ++i) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVectorElems[i - 1], i); } // set state vector time if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(stateVectorElems[0], "timeStamp", standardDateFormat)); } }
private void addOrbitStateVectors(final MetadataElement absRoot, final MetadataElement orbitInformation) { final MetadataElement orbitVectorListElem = absRoot.getElement(AbstractMetadata.orbit_state_vectors); final MetadataElement[] stateVectorElems = orbitInformation.getElements(); for (int i = 1; i <= stateVectorElems.length; ++i) { addVector(AbstractMetadata.orbit_vector, orbitVectorListElem, stateVectorElems[i - 1], i); } // set state vector time if (absRoot.getAttributeUTC(AbstractMetadata.STATE_VECTOR_TIME, AbstractMetadata.NO_METADATA_UTC). equalElems(AbstractMetadata.NO_METADATA_UTC)) { AbstractMetadata.setAttribute(absRoot, AbstractMetadata.STATE_VECTOR_TIME, ReaderUtils.getTime(stateVectorElems[0], "timeStamp", standardDateFormat)); } }
private void getT0andDeltaTS(final String imageName) { // imageName is something like s1a-iw-grd-hh-... final MetadataElement annotationElem = origMetadataRoot.getElement("annotation"); final MetadataElement[] annotationDataSetListElem = annotationElem.getElements(); for (MetadataElement dataSetListElem : annotationDataSetListElem) { if (dataSetListElem.getName().equals(imageName)){ //System.out.println("getT0andDeltaTS: found " + imageName); MetadataElement productElem = dataSetListElem.getElement("product"); MetadataElement imageAnnotationElem = productElem.getElement("imageAnnotation"); MetadataElement imageInformationElem = imageAnnotationElem.getElement("imageInformation"); double t01 = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // just for comparison double t0 = Sentinel1Utils.getTime(imageInformationElem ,"productFirstLineUtcTime").getMJD(); t0Map.put(imageName, t0); double deltaTS1 = absRoot.getAttributeDouble(AbstractMetadata.line_time_interval) / Constants.secondsInDay; // just for comparison double deltaTS = imageInformationElem.getAttributeDouble("azimuthTimeInterval") / Constants.secondsInDay; // s to day deltaTsMap.put(imageName, deltaTS); //System.out.println("getT0andDeltaTS: " + imageName + ": t01 = " + t01 + " t0 = " + t0 + " deltaTS1 = " + deltaTS1 + " deltaTS = " + deltaTS); break; } } }
/** * Retrieve required data from Abstracted Metadata * * @throws Exception if metadata not found */ private void getMetadata() throws Exception { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(sourceProduct); final double wavelength = SARUtils.getRadarFrequency(absRoot); waveNumber = Constants.TWO_PI / wavelength; orbitStateVectors = AbstractMetadata.getOrbitStateVectors(absRoot); firstLineUTC = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // in days sourceImageWidth = sourceProduct.getSceneRasterWidth(); sourceImageHeight = sourceProduct.getSceneRasterHeight(); }
protected static void addDopplerCentroidCoefficients(final MetadataElement absRoot, final BinaryRecord sceneRec) { if (sceneRec == null) return; final MetadataElement dopCoefficientsElem = absRoot.getElement(AbstractMetadata.dop_coefficients); final MetadataElement dopListElem = new MetadataElement(AbstractMetadata.dop_coef_list); dopCoefficientsElem.addElement(dopListElem); final ProductData.UTC utcTime = absRoot.getAttributeUTC(AbstractMetadata.first_line_time, AbstractMetadata.NO_METADATA_UTC); dopListElem.setAttributeUTC(AbstractMetadata.dop_coef_time, utcTime); AbstractMetadata.addAbstractedAttribute(dopListElem, AbstractMetadata.slant_range_time, ProductData.TYPE_FLOAT64, "ns", "Slant Range Time"); AbstractMetadata.setAttribute(dopListElem, AbstractMetadata.slant_range_time, 0.0); addDopCoef(dopListElem, sceneRec, "Cross track Doppler frequency centroid constant term", 1); addDopCoef(dopListElem, sceneRec, "Cross track Doppler frequency centroid linear term", 2); addDopCoef(dopListElem, sceneRec, "Cross track Doppler frequency centroid quadratic term", 3); }
private void getAbstractedMetadata() throws Exception { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(sourceProduct); this.srgrFlag = AbstractMetadata.getAttributeBoolean(absRoot, AbstractMetadata.srgr_flag); this.wavelength = SARUtils.getRadarFrequency(absRoot); this.rangeSpacing = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.range_spacing); this.azimuthSpacing = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.azimuth_spacing); this.firstLineUTC = absRoot.getAttributeUTC(AbstractMetadata.first_line_time).getMJD(); // in days this.lastLineUTC = absRoot.getAttributeUTC(AbstractMetadata.last_line_time).getMJD(); // in days this.lineTimeInterval = absRoot.getAttributeDouble(AbstractMetadata.line_time_interval) / Constants.secondsInDay; // s to day //this.prf = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.pulse_repetition_frequency); //Hz //this.samplingRate = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.range_sampling_rate)* // 1000000; // MHz to Hz this.sourceImageWidth = sourceProduct.getSceneRasterWidth(); this.sourceImageHeight = sourceProduct.getSceneRasterHeight(); OrbitStateVector[] orbitStateVectors = AbstractMetadata.getOrbitStateVectors(absRoot); this.orbit = new OrbitStateVectors(orbitStateVectors, firstLineUTC, lineTimeInterval, sourceImageHeight); if (this.srgrFlag) { this.srgrConvParams = AbstractMetadata.getSRGRCoefficients(absRoot); } else { this.nearEdgeSlantRange = AbstractMetadata.getAttributeDouble(absRoot, AbstractMetadata.slant_range_to_first_pixel); } //final TiePointGrid incidenceAngle = OperatorUtils.getIncidenceAngle(sourceProduct); //this.nearRangeOnLeft = SARGeocoding.isNearRangeOnLeft(incidenceAngle, sourceImageWidth); }
protected static void addSRGRCoefficients(final MetadataElement absRoot, final BinaryRecord facilityRec) { if (facilityRec == null) return; final MetadataElement srgrCoefficientsElem = absRoot.getElement(AbstractMetadata.srgr_coefficients); final MetadataElement srgrListElem = new MetadataElement(AbstractMetadata.srgr_coef_list); srgrCoefficientsElem.addElement(srgrListElem); final ProductData.UTC utcTime = absRoot.getAttributeUTC(AbstractMetadata.first_line_time, AbstractMetadata.NO_METADATA_UTC); srgrListElem.setAttributeUTC(AbstractMetadata.srgr_coef_time, utcTime); AbstractMetadata.addAbstractedAttribute(srgrListElem, AbstractMetadata.ground_range_origin, ProductData.TYPE_FLOAT64, "m", "Ground Range Origin"); AbstractMetadata.setAttribute(srgrListElem, AbstractMetadata.ground_range_origin, 0.0); addSRGRCoef(srgrListElem, facilityRec, "coefficients of the ground range to slant range conversion polynomial 1", 1); addSRGRCoef(srgrListElem, facilityRec, "coefficients of the ground range to slant range conversion polynomial 2", 2); addSRGRCoef(srgrListElem, facilityRec, "coefficients of the ground range to slant range conversion polynomial 3", 3); addSRGRCoef(srgrListElem, facilityRec, "coefficients of the ground range to slant range conversion polynomial 4", 4); }
private static void addDopplerCentroidCoefficients(final Product product) { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); final MetadataElement root = AbstractMetadata.getOriginalProductMetadata(product); final MetadataElement globalElem = root.getElement(NetcdfConstants.GLOBAL_ATTRIBUTES_NAME); final MetadataElement dopplerCentroidCoefficientsElem = absRoot.getElement(AbstractMetadata.dop_coefficients); final MetadataElement dopplerListElem = new MetadataElement(AbstractMetadata.dop_coef_list + ".1"); dopplerCentroidCoefficientsElem.addElement(dopplerListElem); final ProductData.UTC utcTime = absRoot.getAttributeUTC(AbstractMetadata.first_line_time, AbstractMetadata.NO_METADATA_UTC); dopplerListElem.setAttributeUTC(AbstractMetadata.dop_coef_time, utcTime); AbstractMetadata.addAbstractedAttribute(dopplerListElem, AbstractMetadata.slant_range_time, ProductData.TYPE_FLOAT64, "ns", "Slant Range Time"); AbstractMetadata.setAttribute(dopplerListElem, AbstractMetadata.slant_range_time, 0.0); for (int i = 0; i < 6; i++) { final double coefValue = globalElem.getAttribute("Centroid_vs_Range_Time_Polynomial").getData().getElemDoubleAt(i); final MetadataElement coefElem = new MetadataElement(AbstractMetadata.coefficient + '.' + (i + 1)); dopplerListElem.addElement(coefElem); AbstractMetadata.addAbstractedAttribute(coefElem, AbstractMetadata.dop_coef, ProductData.TYPE_FLOAT64, "", "Doppler Centroid Coefficient"); AbstractMetadata.setAttribute(coefElem, AbstractMetadata.dop_coef, coefValue); } }
private void addDopplerCentroidCoefficients() { final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); final MetadataElement root = AbstractMetadata.getOriginalProductMetadata(product); final MetadataElement globalElem = root.getElement(NetcdfConstants.GLOBAL_ATTRIBUTES_NAME); final MetadataElement dopplerCentroidCoefficientsElem = absRoot.getElement(AbstractMetadata.dop_coefficients); final MetadataElement dopplerListElem = new MetadataElement(AbstractMetadata.dop_coef_list + ".1"); dopplerCentroidCoefficientsElem.addElement(dopplerListElem); final ProductData.UTC utcTime = absRoot.getAttributeUTC(AbstractMetadata.first_line_time, AbstractMetadata.NO_METADATA_UTC); dopplerListElem.setAttributeUTC(AbstractMetadata.dop_coef_time, utcTime); AbstractMetadata.addAbstractedAttribute(dopplerListElem, AbstractMetadata.slant_range_time, ProductData.TYPE_FLOAT64, "ns", "Slant Range Time"); AbstractMetadata.setAttribute(dopplerListElem, AbstractMetadata.slant_range_time, 0.0); for (int i = 0; i < 6; i++) { final double coefValue = globalElem.getAttribute("Centroid_vs_Range_Time_Polynomial").getData().getElemDoubleAt(i); final MetadataElement coefElem = new MetadataElement(AbstractMetadata.coefficient + '.' + (i + 1)); dopplerListElem.addElement(coefElem); AbstractMetadata.addAbstractedAttribute(coefElem, AbstractMetadata.dop_coef, ProductData.TYPE_FLOAT64, "", "Doppler Centroid Coefficient"); AbstractMetadata.setAttribute(coefElem, AbstractMetadata.dop_coef, coefValue); } }