CellL3ProcessorMapper extends Mapper<LongWritable, L3TemporalBin, LongWritable, L3SpatialBin> { static double getMeanMJD(Configuration conf) { double min = getMJD(conf.get(JobConfigNames.CALVALUS_MIN_DATE)); double max = getMJD(conf.get(JobConfigNames.CALVALUS_MAX_DATE)); if (min == 0.0 || max == 0.0) { return 0.0; } return ((max + 1.0 - min) / 2.0) + min; }    }
@Test public void testGetMeanMJD() throws Exception { Configuration conf = new Configuration(); conf.set(JobConfigNames.CALVALUS_MIN_DATE, "2005-04-10"); conf.set(JobConfigNames.CALVALUS_MAX_DATE, "2005-04-20"); assertEquals(1931.5, CellL3ProcessorMapper.getMeanMJD(conf), 1e-6); conf = new Configuration(); conf.set(JobConfigNames.CALVALUS_MIN_DATE, "2005-04-20"); conf.set(JobConfigNames.CALVALUS_MAX_DATE, "2005-04-20"); assertEquals(1936.5, CellL3ProcessorMapper.getMeanMJD(conf), 1e-6); conf = new Configuration(); assertEquals(0.0, CellL3ProcessorMapper.getMeanMJD(conf), 1e-6); conf.set(JobConfigNames.CALVALUS_MIN_DATE, "2005-04-20"); assertEquals(0.0, CellL3ProcessorMapper.getMeanMJD(conf), 1e-6); }