/** * Computes the median (average) of two <code>ProductData.UTC</code> data structures. * * @param startDate The first date * @param endDate The second date * @return The date between the two input dates */ public static ProductData.UTC average(ProductData.UTC startDate, ProductData.UTC endDate) { ProductData.UTC average = null; if (startDate != null && endDate != null) { BigInteger averageMillis = BigInteger.valueOf(startDate.getAsDate().getTime()).add(BigInteger.valueOf(endDate.getAsDate().getTime())).divide(BigInteger.valueOf(2L)); Date averageDate = new Date(averageMillis.longValue()); average = ProductData.UTC.create(averageDate, 0L); } return average; }
private String convertFormat(String rawDate) { try { final ProductData.UTC utc = ProductData.UTC.parse(rawDate, rawDateFormat); final String date = dateFormat.format(utc.getAsDate()); //System.out.println("rawdate = " + rawDate + " date = " + date); return date; } catch (Exception e) { SystemUtils.LOG.severe("failed to convert date" + e.getMessage()); return rawDate; } }
private void getNewXCAFile() throws Exception { if (auxFile != null && auxFile.contains(CalibrationOp.EXTERNAL_AUX)) { if (externalAuxFile != null && externalAuxFile.exists()) { if (!externalAuxFile.getName().contains("ASA_XCA")) { throw new OperatorException("Invalid XCA file for ASAR product"); } newXCAFileName = externalAuxFile.getName(); newXCAFilePath = externalAuxFile.getAbsolutePath(); } else { throw new OperatorException("No external auxiliary file is specified."); } } else { final Date startDate = sourceProduct.getStartTime().getAsDate(); final Date endDate = sourceProduct.getEndTime().getAsDate(); final File localFolder = SystemUtils.getAuxDataPath().resolve("AuxCal").resolve("ENVISAT").toFile(); newXCAFileName = findXCAFile(localFolder, startDate, endDate); if(newXCAFileName == null) { final URL remotePath = new URL(Settings.getPath("AuxCal.ENVISAT.remotePath")); final File localFile = new File(localFolder, "ENVISAT_XCA.zip"); final DownloadableArchive archive = new DownloadableArchive(localFile, remotePath); archive.getContentFiles(); newXCAFileName = findXCAFile(localFolder, startDate, endDate); } newXCAFilePath = localFolder.toString() + File.separator + newXCAFileName; } }
final Date date = startTime.getAsDate(); final String dateString = dateFormat.format(date);
final Date date = startTime.getAsDate(); final String dateString = dateFormat.format(date);
: "(" + entry.getFileSizeString() + ")"; final String dateString = dateFormat.format(entry.getFirstLineTime().getAsDate());
for(int i=0; i < stackOverview.length; ++i) { double mstMJD = stackOverview[i].getMasterSlave()[0].getMasterMetadata().getMjd(); final String mstDate = dateFormat.format(new ProductData.UTC(mstMJD).getAsDate()); for(int j=0; j< stackOverview[i].getMasterSlave().length; ++j) { double slvMJD = stackOverview[i].getMasterSlave()[j].getSlaveMetadata().getMjd(); final String slvDate = dateFormat.format(new ProductData.UTC(slvMJD).getAsDate());
final Date startDate = sourceProduct.getStartTime().getAsDate(); orbitFile = FindDorisOrbitFile(dorisReader, localPath, startDate, absOrbit); if (orbitFile == null) {
public int compare(final Object o1, final Object o2) { if (o1 == null && o2 == null) { return 0; } else if (o1 == null) { return -1; } else if (o2 == null) { return 1; } else if (o1 instanceof ProductEntry && o2 instanceof ProductEntry) { final ProductEntry e1 = (ProductEntry) o1; final ProductEntry e2 = (ProductEntry) o2; if (sortBy.equals(SORT_BY.NAME)) { return e1.getName().compareTo(e2.getName()); } else if (sortBy.equals(SORT_BY.TYPE)) { return e1.getProductType().compareTo(e2.getProductType()); } else if (sortBy.equals(SORT_BY.MISSON)) { return e1.getMission().compareTo(e2.getMission()); } else if (sortBy.equals(SORT_BY.DATE)) { return e1.getFirstLineTime().getAsDate().compareTo(e2.getFirstLineTime().getAsDate()); } else if (sortBy.equals(SORT_BY.FILESIZE)) { final Long size1 = e1.getFileSize(); final Long size2 = e2.getFileSize(); return size1.compareTo(size2); } } return o1.toString().compareTo(o2.toString()); } };
public String[] createTickmarkTexts() { final ArrayList<String> tickNames = new ArrayList<>(times.length()); setName("Acquisition Date"); int numTicks = getNumMajorTicks(); double min = getMinValue(); double dist = getMajorTickMarkDistance(); for (int i = 0; i < numTicks; ++i) { final double mjd = min + (i * dist); final ProductData.UTC newTime = new ProductData.UTC(mjd); final String tickStr = dateFormat.format(newTime.getAsDate()); tickNames.add(tickStr); } return tickNames.toArray(new String[tickNames.size()]); } }
public File retrieveOrbitFile(final String orbitType) throws Exception { delftReader = OrbitalDataRecordReader.getInstance(); // get product start time final Date startDate = sourceProduct.getStartTime().getAsDate(); // find orbit file in the folder orbitFile = FindDelftOrbitFile(delftReader, startDate); if (orbitFile == null) { throw new IOException("Unable to find suitable orbit file.\n" + "Please refer to http://www.deos.tudelft.nl/ers/precorbs/orbits/ \n" + "ERS1 orbits are available until 1996\n" + "ERS2 orbits are available until 2003\n" + "ENVISAT orbits are available until 2008"); } return orbitFile; }
private double getDataAsDouble(ProductData data) { if (data instanceof ProductData.UTC) { return ((ProductData.UTC) data).getAsDate().getTime(); } else { return data.getElemDouble(); } }
public DateTimePickerCellEditor(DateFormat dateFormat, DateFormat timeFormat) { super(null); Date asDate = ProductData.UTC.create(new Date(), 0).getAsDate(); DateTimePicker dateTimePicker = new DateTimePicker(asDate, Locale.getDefault(), dateFormat, timeFormat); //---- this duplicates the code in the parent constructor ------------- dateTimePicker.getEditor().setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1)); dateTimePicker.addActionListener(getPickerActionListener()); datePicker = dateTimePicker; //--------------------------------------------------------------------- }
/** * Get the product acquisition time (in second). */ private void getProductAcquisitionTime() { try { final ProductData.UTC acqTimeUTC = AbstractMetadata.parseUTC(absRoot.getAttributeString(AbstractMetadata.first_line_time)); acquisitionTime = acqTimeUTC.getAsDate(); //System.out.println("The acquisition time is " + acquisitionTime); } catch (Exception e) { throw new OperatorException(e.getMessage()); } }
private String toDate(double time) { final ProductData.UTC newTime = new ProductData.UTC(time); return dateFormat.format(newTime.getAsDate()); }
/** * Get the processing time (in second). */ private void getProcessingTime() { try { final ProductData.UTC procTimeUTC = AbstractMetadata.parseUTC(absRoot.getAttributeString(AbstractMetadata.PROC_TIME)); processingTime = procTimeUTC.getAsDate(); //System.out.println("The processing time is " + processingTime); } catch (Exception e) { throw new OperatorException(e.getMessage()); } }