@Override public double evalD(EvalEnv env) throws EvalException { int pixelY = ((RasterDataEvalEnv) env).getPixelY(); ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, pixelY); if (scanLineTime != null) { return scanLineTime.getMJD(); } return Double.NaN; } }
private void updateScanLineValues() { final ProductData.UTC utcStartTime = currentProduct.getStartTime(); final ProductData.UTC utcEndTime = currentProduct.getEndTime(); if (utcStartTime == null || utcEndTime == null || !isSampleValueAvailable(0, levelZeroY, true)) { scanlineModel.updateValue("No date information", 0); scanlineModel.updateValue("No time information", 1); } else { final float pY = levelZeroY + pixelInfoView.getPixelOffsetY(); final ProductData.UTC utcCurrentLine = ProductUtils.getScanLineTime(currentProduct, pY); final Calendar currentLineTime = utcCurrentLine.getAsCalendar(); final String dateString = String.format("%1$tF", currentLineTime); final String timeString = String.format("%1$tI:%1$tM:%1$tS:%1$tL %1$Tp", currentLineTime); scanlineModel.updateValue(dateString, 0); scanlineModel.updateValue(timeString, 1); } }
protected static Measurement createMeasurement(Product product, long productId, int coordinateID, String coordinateName, Number[] values, boolean isValid, int x, int y) { final PixelPos pixelPos = new PixelPos(x + 0.5f, y + 0.5f); final GeoCoding geoCoding = product.getGeoCoding(); final GeoPos currentGeoPos; if (geoCoding != null) { currentGeoPos = geoCoding.getGeoPos(pixelPos, null); } else { currentGeoPos = new GeoPos(); } final ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, pixelPos.y); return new Measurement(coordinateID, coordinateName, productId, pixelPos.x, pixelPos.y, scanLineTime, currentGeoPos, values, isValid); }
@Test public void testGetScanLineTime_1_pixel() throws Exception { Product product = new Product("name", "type", 1, 1); ProductData.UTC startTime = ProductData.UTC.parse("01-01-2010", "dd-MM-yyyy"); ProductData.UTC endTime = ProductData.UTC.parse("02-01-2010", "dd-MM-yyyy"); product.setStartTime(startTime); product.setEndTime(endTime); double startTimeMJD = startTime.getMJD(); assertEquals(startTimeMJD, ProductUtils.getScanLineTime(product, 0).getMJD(), 1E-6); assertNotSame(startTime, ProductUtils.getScanLineTime(product, 0)); }
private boolean extractMeasurement(Product product, Coordinate coordinate, int coordinateID, RenderedImage validMaskImage) throws IOException { PixelPos centerPos = getPixelPosition(product, coordinate); if (!product.containsPixel(centerPos)) { return false; } if (considerTimeDifference(timeDifference) && coordinate.getDateTime() != null) { final ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, centerPos.y); if (scanLineTime == null || !isPixelInTimeSpan(coordinate, timeDelta, calendarField, scanLineTime)) { return false; } } int offset = MathUtils.floorInt(windowSize / 2); final int centerX = MathUtils.floorInt(centerPos.x); final int centerY = MathUtils.floorInt(centerPos.y); final int upperLeftX = centerX - offset; final int upperLeftY = centerY - offset; final Raster validData = validMaskImage.getData(new Rectangle(upperLeftX, upperLeftY, windowSize, windowSize)); boolean isAnyPixelValid = isAnyPixelInWindowValid(upperLeftX, upperLeftY, validData); if (isAnyPixelValid) { measurementWriter.writeMeasurements(centerX, centerY, coordinateID, coordinate.getName(), product, validData); return true; } return false; }
@Override protected boolean acceptForBinning(Product product) { GeoCoding geoCoding = product.getGeoCoding(); ProductData.UTC firstScanLineTime = ProductUtils.getScanLineTime(product, 0); ProductData.UTC lastScanLineTime = ProductUtils.getScanLineTime(product, product.getSceneRasterHeight() - 1); if (firstScanLineTime == null || lastScanLineTime == null) { String message = String.format("not accepting product '%s': missing time coding", product.getName());
@Test public void testGetScanLineTime() throws Exception { Product product = new Product("name", "type", 10, 10); ProductData.UTC startTime = ProductData.UTC.parse("01-01-2010", "dd-MM-yyyy"); ProductData.UTC endTime = ProductData.UTC.parse("02-01-2010", "dd-MM-yyyy"); product.setStartTime(startTime); product.setEndTime(endTime); double startTimeMJD = startTime.getMJD(); double endTimeMJD = endTime.getMJD(); assertEquals(startTimeMJD, ProductUtils.getScanLineTime(product, 0).getMJD(), 1E-6); assertEquals(endTimeMJD, ProductUtils.getScanLineTime(product, 9).getMJD(), 1E-6); }
static DataPeriod.Membership[] analyseBasic(DataPeriod dataPeriod, Product product) { GeoCoding geoCoding = product.getGeoCoding(); ProductData.UTC firstScanLineTime = ProductUtils.getScanLineTime(product, 0); float firstLon = geoCoding.getGeoPos(new PixelPos(0, 0), null).lon; DataPeriod.Membership fl = dataPeriod.getObservationMembership(firstLon, firstScanLineTime.getMJD()); float lastLon = geoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, 0), null).lon; DataPeriod.Membership fr = dataPeriod.getObservationMembership(lastLon, firstScanLineTime.getMJD()); ProductData.UTC lastScanLineTime = ProductUtils.getScanLineTime(product, product.getSceneRasterHeight() - 1); firstLon = geoCoding.getGeoPos(new PixelPos(0, product.getSceneRasterHeight() - 1), null).lon; DataPeriod.Membership ll = dataPeriod.getObservationMembership(firstLon, lastScanLineTime.getMJD()); lastLon = geoCoding.getGeoPos(new PixelPos(product.getSceneRasterWidth() - 1, product.getSceneRasterHeight() - 1), null).lon; DataPeriod.Membership lr = dataPeriod.getObservationMembership(lastLon, lastScanLineTime.getMJD()); return new DataPeriod.Membership[]{fl, fr, ll, lr}; }
protected Observation createObservation(int x, int y) { final SamplePointer pointer = getPointer(); final Point2D.Float superSamplingPoint = pointer.getSuperSamplingPoint(); final PixelPos pixelPos = new PixelPos(x + superSamplingPoint.x, y + superSamplingPoint.y); final GeoPos geoPos = getGeoPos(pixelPos); if (!acceptGeoPos(geoPos)) { return null; } double mjd = 0.0; if (productHasTime) { ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, y + 0.5); mjd = scanLineTime.getMJD(); if (dataPeriod != null && dataPeriod.getObservationMembership(geoPos.lon, mjd) != DataPeriod.Membership.CURRENT_PERIOD) { return null; } } if(maxDistanceOnEarth > 0) { PixelPos currentRefPP = new PixelPos(x + 0.5f, y + 0.5f); if(!currentRefPP.equals(lastRefPP)) { lastRefPP = currentRefPP; lastRefGP = getGeoPos(lastRefPP); } double distance = MathUtils.sphereDistanceDeg(earthRadius, geoPos.getLon(), geoPos.getLat(), lastRefGP.getLon(), lastRefGP.getLat()); if(distance > maxDistanceOnEarth) { return null; } } final float[] samples = pointer.createSamples(); return new ObservationImpl(geoPos.lat, geoPos.lon, mjd, samples); }
static int[] analysePrecise(DataPeriod dataPeriod, Product product) { int width = product.getSceneRasterWidth(); int height = product.getSceneRasterHeight(); GeoCoding geoCoding = product.getGeoCoding(); PixelPos pixelPos = new PixelPos(); GeoPos geoPos = new GeoPos(); int[] distribution = new int[DataPeriod.Membership.values().length]; for (int y = 0; y < height; y++) { ProductData.UTC scanLineTime = ProductUtils.getScanLineTime(product, y); double mjd = scanLineTime.getMJD(); for (int x = 0; x < width; x++) { pixelPos.setLocation(x, y); geoCoding.getGeoPos(pixelPos, geoPos); DataPeriod.Membership membership = dataPeriod.getObservationMembership(geoPos.lon, mjd); distribution[membership.ordinal()]++; } } return distribution; }