Example #1
0
  @Test
  public void testAssign_MERIS_twoBands_justInput() {
    final ResultMapper mapper = new ResultMapper("MERIS", new int[] {413, 443});

    final VectorImpl postVector = createVector(2);
    final double[] rrs_shifted = new double[] {-1.0, -1.0};
    final double[] rrs_in = new double[] {0.5, 0.6};

    mapper.assign(rrs_in, rrs_shifted, postVector);

    assertEquals(0.5, postVector.get(0), 1e-7);
    assertEquals(0.6, postVector.get(1), 1e-7);
  }
Example #2
0
  @Test
  public void testAssign_SeaWifs_threeBands_justShifted() {
    final ResultMapper mapper = new ResultMapper("SEAWIFS", new int[] {413, 547, 560});

    final VectorImpl postVector = createVector(3);
    final double[] rrs_shifted = new double[] {0.6, 0.7, 0.8, 0.9, 1.0, 1.1};
    final double[] rrs_in = new double[] {-1.0, -1.0, -1.0};

    mapper.assign(rrs_in, rrs_shifted, postVector);

    assertEquals(0.6, postVector.get(0), 1e-7);
    assertEquals(0.9, postVector.get(1), 1e-7);
    assertEquals(1.0, postVector.get(2), 1e-7);
  }
Example #3
0
  @Test
  public void testAssign_MODIS_noBands() {
    final ResultMapper mapper = new ResultMapper("MODISA", new int[0]);

    final VectorImpl postVector = createVector(2);
    final double[] rrs_shifted = new double[] {-1.0, -1.0};
    final double[] rrs_in = new double[0];

    mapper.assign(rrs_in, rrs_shifted, postVector);

    // check nothing happened
    assertEquals(-1.0, postVector.get(0), 1e-7);
    assertEquals(-1.0, postVector.get(1), 1e-7);
  }
Example #4
0
  @Test
  public void testAssign_MODIS_fourBands_mixedInAndOut() {
    final ResultMapper mapper = new ResultMapper("MODISA", new int[] {412, 413, 547, 555});

    final VectorImpl postVector = createVector(4);
    final double[] rrs_shifted = new double[] {0.6, 0.7, 0.8, 0.9, 1.0, 1.1};
    final double[] rrs_in = new double[] {1.2, 1.3, 1.4, 1.5, 1.6};

    mapper.assign(rrs_in, rrs_shifted, postVector);

    assertEquals(1.2, postVector.get(0), 1e-7);
    assertEquals(0.6, postVector.get(1), 1e-7);
    assertEquals(1.6, postVector.get(2), 1e-7);
    assertEquals(1.0, postVector.get(3), 1e-7);
  }
Example #5
0
  @Test
  public void testAggregatorOnMaxSet() {
    AggregatorOnMaxSet agg =
        new AggregatorOnMaxSet(new MyVariableContext("a", "b", "c"), "c", "a", "b");

    VectorImpl svec = vec(NaN, NaN, NaN, NaN);
    VectorImpl tvec = vec(NaN, NaN, NaN, NaN);
    VectorImpl out = vec(NaN, NaN, NaN, NaN);

    agg.initSpatial(ctx, svec);
    assertEquals(Float.NEGATIVE_INFINITY, svec.get(0), 0.0f);
    assertEquals(NaN, svec.get(1), 0.0f);
    assertEquals(NaN, svec.get(2), 0.0f);
    assertEquals(NaN, svec.get(3), 0.0f);

    agg.aggregateSpatial(ctx, obs(4, 7.3f, 0.5f, 1.1f), svec);
    agg.aggregateSpatial(ctx, obs(5, 0.1f, 2.5f, 1.5f), svec);
    agg.aggregateSpatial(ctx, obs(6, 5.5f, 4.9f, 1.4f), svec);
    assertEquals(1.5f, svec.get(0), 1e-5f);
    assertEquals(5f, svec.get(1), 1e-5f);
    assertEquals(0.1f, svec.get(2), 1e-5f);
    assertEquals(2.5f, svec.get(3), 1e-5f);

    agg.completeSpatial(ctx, 3, svec);
    assertEquals(1.5f, svec.get(0), 1e-5f);
    assertEquals(5f, svec.get(1), 1e-5f);
    assertEquals(0.1f, svec.get(2), 1e-5f);
    assertEquals(2.5f, svec.get(3), 1e-5f);

    agg.initTemporal(ctx, tvec);
    assertEquals(Float.NEGATIVE_INFINITY, tvec.get(0), 0.0f);
    assertEquals(NaN, tvec.get(1), 0.0f);
    assertEquals(NaN, tvec.get(2), 0.0f);
    assertEquals(NaN, tvec.get(3), 0.0f);

    agg.aggregateTemporal(ctx, vec(0.3f, 4, 0.2f, 9.7f), 3, tvec);
    agg.aggregateTemporal(ctx, vec(1.1f, 5, 0.1f, 0.3f), 3, tvec);
    agg.aggregateTemporal(ctx, vec(4.7f, 6, 0.6f, 7.1f), 3, tvec);
    assertEquals(4.7f, tvec.get(0), 1e-5f);
    assertEquals(6f, tvec.get(1), 1e-5f);
    assertEquals(0.6f, tvec.get(2), 1e-5f);
    assertEquals(7.1f, tvec.get(3), 1e-5f);

    agg.computeOutput(tvec, out);
    assertEquals(4.7f, out.get(0), 1e-5f);
    assertEquals(6f, out.get(1), 1e-5f);
    assertEquals(0.6f, out.get(2), 1e-5f);
    assertEquals(7.1f, out.get(3), 1e-5f);
  }