|
| 1 | +/* |
| 2 | + * Copyright (C) 2016 Brockmann Consult GmbH |
| 3 | + * This code was developed for the EC project "Fidelity and Uncertainty in |
| 4 | + * Climate Data Records from Earth Observations (FIDUCEO)". |
| 5 | + * Grant Agreement: 638822 |
| 6 | + * |
| 7 | + * This program is free software; you can redistribute it and/or modify it |
| 8 | + * under the terms of the GNU General Public License as published by the Free |
| 9 | + * Software Foundation; either version 3 of the License, or (at your option) |
| 10 | + * any later version. |
| 11 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | + * more details. |
| 15 | + * |
| 16 | + * A copy of the GNU General Public License should have been supplied along |
| 17 | + * with this program; if not, see http://www.gnu.org/licenses/ |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +package com.bc.fiduceo.matchup; |
| 22 | + |
| 23 | +import com.bc.fiduceo.FiduceoConstants; |
| 24 | +import com.bc.fiduceo.NCTestUtils; |
| 25 | +import com.bc.fiduceo.TestUtil; |
| 26 | +import com.bc.fiduceo.core.SatelliteObservation; |
| 27 | +import com.bc.fiduceo.core.Sensor; |
| 28 | +import com.bc.fiduceo.core.UseCaseConfig; |
| 29 | +import com.bc.fiduceo.db.DbAndIOTestRunner; |
| 30 | +import com.bc.fiduceo.util.NetCDFUtils; |
| 31 | +import org.apache.commons.cli.ParseException; |
| 32 | +import org.junit.Test; |
| 33 | +import org.junit.runner.RunWith; |
| 34 | +import ucar.ma2.InvalidRangeException; |
| 35 | +import ucar.nc2.NetcdfFile; |
| 36 | + |
| 37 | +import java.io.File; |
| 38 | +import java.io.IOException; |
| 39 | +import java.sql.SQLException; |
| 40 | +import java.util.ArrayList; |
| 41 | +import java.util.List; |
| 42 | + |
| 43 | +import static org.junit.Assert.assertEquals; |
| 44 | +import static org.junit.Assert.assertTrue; |
| 45 | + |
| 46 | +@RunWith(DbAndIOTestRunner.class) |
| 47 | +public class MatchupToolIntegrationTest_AVHRR_SLSTR extends AbstractUsecaseIntegrationTest { |
| 48 | + |
| 49 | + @Test |
| 50 | + public void testMatchup_AVHRR_SLSTR_UOR() throws IOException, ParseException, SQLException, InvalidRangeException { |
| 51 | + final UseCaseConfig useCaseConfig = createUseCaseConfigBuilder() |
| 52 | + .withTimeDeltaSeconds(60000, null) |
| 53 | + .withMaxPixelDistanceKm(0.1f, null) |
| 54 | + .createConfig(); |
| 55 | + final File useCaseConfigFile = storeUseCaseConfig(useCaseConfig, "usecase-avhrr-slstr.xml"); |
| 56 | + |
| 57 | + insert_AVHRR_FRAC_MA(); |
| 58 | + insert_SLSTR_UOR(); |
| 59 | + |
| 60 | + final String[] args = new String[]{"-c", configDir.getAbsolutePath(), "-u", useCaseConfigFile.getName(), "-start", "2020-142", "-end", "2020-143"}; |
| 61 | + MatchupToolMain.main(args); |
| 62 | + |
| 63 | + final File mmdFile = getMmdFilePath(useCaseConfig, "2020-142", "2020-143"); |
| 64 | + assertTrue(mmdFile.isFile()); |
| 65 | + |
| 66 | + try (NetcdfFile mmd = NetcdfFile.open(mmdFile.getAbsolutePath())) { |
| 67 | + final int matchupCount = NetCDFUtils.getDimensionLength(FiduceoConstants.MATCHUP_COUNT, mmd); |
| 68 | + assertEquals(1380, matchupCount); |
| 69 | + |
| 70 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_S1_radiance_in", 0, 0, 0, -32768, mmd); |
| 71 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_S7_BT_in", 1, 0, 24, 854, mmd); |
| 72 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_acquisition_time", 2, 0, 25, 1590189249, mmd); |
| 73 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_S8_exception_in", 0, 1, 30, 2, mmd); |
| 74 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_cloud_io", 1, 1, 31, 32769, mmd); |
| 75 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_detector_io", 2, 1, 32, 255, mmd); |
| 76 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_latitude_in", 0, 2, 33, -19847056, mmd); |
| 77 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_longitude_in", 1, 2, 34, -5812828, mmd); |
| 78 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_solar_azimuth_tn", 2, 2, 35, 275.6034547080558, mmd); |
| 79 | + NCTestUtils.assert3DVariable("slstr-s3a-uor_solar_azimuth_to", 0, 0, 36, Float.NaN, mmd); |
| 80 | + |
| 81 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_acquisition_time", 0, 0, 1, 1590137472, mmd); |
| 82 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_cloudFlag", 1, 0, 2, 0, mmd); |
| 83 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_delta_azimuth", 2, 0, 3, 52.04375076293945, mmd); |
| 84 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_flags", 0, 1, 4, -1, mmd); |
| 85 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_latitude", 1, 1, 5, -19.104799270629883, mmd); |
| 86 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_longitude", 2, 1, 6, -5.870356559753418, mmd); |
| 87 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_radiance_1", 0, 2, 7, 87.23554992675781, mmd); |
| 88 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_radiance_2", 1, 2, 8, 64.54716491699219, mmd); |
| 89 | + NCTestUtils.assert3DVariable("avhrr-frac-mc_radiance_3a", 2, 2, 9, 11.970253944396973, mmd); |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + private void insert_SLSTR_UOR() throws IOException, SQLException { |
| 94 | + final String sensorKey = "slstr-s3a-uor"; |
| 95 | + final String relativeArchivePath = TestUtil.assembleFileSystemPath(new String[]{sensorKey, "1.0", "2020", "05", "22", "S3A_SL_1_RBT____20200522T231202_20200522T231502_20200524T053503_0179_058_286_5580_LN2_O_NT_004.SEN3"}, true); |
| 96 | + |
| 97 | + final SatelliteObservation satelliteObservation = readSatelliteObservation(sensorKey, relativeArchivePath, "1.0"); |
| 98 | + storage.insert(satelliteObservation); |
| 99 | + } |
| 100 | + |
| 101 | + private void insert_AVHRR_FRAC_MA() throws IOException, SQLException { |
| 102 | + final String sensorKey = "avhrr-frac-mc"; |
| 103 | + final String relativeArchivePath = TestUtil.assembleFileSystemPath(new String[]{sensorKey, "v1", "2020", "05", "22", "NSS.FRAC.M3.D20143.S0824.E1005.B0798990.SV"}, true); |
| 104 | + |
| 105 | + final SatelliteObservation satelliteObservation = readSatelliteObservation(sensorKey, relativeArchivePath, "v1"); |
| 106 | + storage.insert(satelliteObservation); |
| 107 | + } |
| 108 | + |
| 109 | + private MatchupToolTestUseCaseConfigBuilder createUseCaseConfigBuilder() { |
| 110 | + final List<Sensor> sensorList = new ArrayList<>(); |
| 111 | + final Sensor primary = new Sensor("avhrr-frac-mc"); |
| 112 | + primary.setPrimary(true); |
| 113 | + sensorList.add(primary); |
| 114 | + sensorList.add(new Sensor("slstr-s3a-uor")); |
| 115 | + |
| 116 | + final List<com.bc.fiduceo.core.Dimension> dimensions = new ArrayList<>(); |
| 117 | + dimensions.add(new com.bc.fiduceo.core.Dimension("avhrr-frac-mc", 3, 3)); |
| 118 | + dimensions.add(new com.bc.fiduceo.core.Dimension("slstr-s3a-uor", 3, 3)); |
| 119 | + |
| 120 | + return (MatchupToolTestUseCaseConfigBuilder) new MatchupToolTestUseCaseConfigBuilder("coo30") |
| 121 | + .withSensors(sensorList) |
| 122 | + .withOutputPath(new File(TestUtil.getTestDir().getPath(), "coo30-avhrr-slstr").getPath()) |
| 123 | + .withDimensions(dimensions); |
| 124 | + } |
| 125 | +} |
0 commit comments