def test_chla_values_ES2_105(self): productcode = "modis-chla" subproductcode = "chla-day" version = "v2013.1" mapsetcode = "MODIS-Africa-4km" from_date = date(2015, 01, 01) to_date = date(2015, 01, 11) # Type can be 'none' -> average # 'count' -> number of pixels in min-max range # 'percent' -> (number of pixels in min-max range) / (number of valid pixels) * 100 aggregate = { 'aggregation_type': 'mean', 'aggregation_min': 0.0, 'aggregation_max': 40.0 } list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_test_ES2_105, from_date, to_date, aggregate) print list_values self.assertEquals(len(list_values), 36)
def test_point_line_poly_vgt_ndvi_ndv(self): productcode = "vgt-ndvi" subproductcode = "ndv" version = "sv2-pv2.1" mapsetcode = "SPOTV-Africa-1km" from_date = date(2016, 01, 01) to_date = date(2016, 12, 31) date_format = 'YYYYMMDD' list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_test_polygon, from_date, to_date, self.aggregate) print list_values list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_test_polygon, from_date, to_date, self.aggregate) # list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_test_point, from_date, to_date, self.aggregate) print list_values self.assertEquals(len(list_values), 36)
def test_values_rfe_10d(self): productcode = "fewsnet-rfe" subproductcode = "10d" version = "2.0" mapsetcode = "FEWSNET-Africa-8km" from_date = date(2013, 01, 01) to_date = date(2015, 12, 21) list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_Congo, from_date, to_date) self.assertEquals(len(list_values), 75)
def test_files_vgt_ndvi_ndv(self): # productcode="fewsnet-rfe" # subproductcode="10d" # version="2.0" # mapsetcode="FEWSNET-Africa-8km" productcode = "vgt-ndvi" subproductcode = "ndv" version = "spot-v1" mapsetcode = "SPOTV-Africa-1km" from_date = date(2002, 01, 01) to_date = date(2002, 12, 31) date_format = 'YYYYMMDD' list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt, from_date, to_date) # [list_files, dates_list] = getFilesList(productcode, subproductcode, version, mapsetcode, date_format, from_date, to_date) self.assertEquals(len(list_values), 36)
def test_values_sst(self): productcode = "modis-sst" subproductcode = "monavg" version = "v2013.1" mapsetcode = "MODIS-Africa-4km" from_date = date(2015, 01, 01) to_date = date(2015, 02, 11) aggregate = { 'aggregation_type': 'mean', 'aggregation_min': None, 'aggregation_max': None } list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_fish, from_date, to_date, aggregate) print list_values self.assertEquals(len(list_values), 108)
def test_values_rfe_10davg(self): productcode = "fewsnet-rfe" subproductcode = "10davg" version = "2.0" mapsetcode = "FEWSNET-Africa-8km" from_date = date(2015, 01, 01) to_date = date(2015, 01, 11) aggregate = { 'aggregation_type': 'mean', 'aggregation_min': None, 'aggregation_max': None } list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_Congo, from_date, to_date, aggregate) print list_values self.assertEquals(len(list_values), 108)
def test_values_wd_gee(self): productcode = "wd-gee" subproductcode = "occurr" version = "1.0" mapsetcode = "WD-GEE-ECOWAS-AVG" from_date = date(2018, 01, 01) to_date = date(2018, 01, 01) aggregate = { 'aggregation_type': 'surface', 'aggregation_min': 1, 'aggregation_max': 100 } list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt, from_date, to_date, aggregate) print(list_values) self.assertEquals(len(list_values), 12)
def test_wkt_rectangle(self): productcode = "tamsat-rfe" subproductcode = "10d" version = "3.0" mapsetcode = "TAMSAT-Africa-4km" from_date = date(2019, 1, 1) to_date = date(2019, 12, 31) list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_poly, from_date, to_date, self.aggregate) print(list_values) # Check number of values self.assertEqual(len(list_values), 36) # Check value for 2019.01.01 first_value = list_values[0] self.assertAlmostEqual(85.7455916064186, first_value['meanvalue'])
def test_product_new_dir_structure(self): productcode = "era5-hourly-2mt" subproductcode = "2mt" version = "1.0" mapsetcode = "CDS-Africa-25km" from_date = date(2021, 1, 1) to_date = date(2021, 12, 31) list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_poly, from_date, to_date, self.aggregate) print(list_values) # Check number of values self.assertEqual(len(list_values), 36) # Check value for 2019.01.01 first_value = list_values[0] self.assertAlmostEqual(85.7455916064186, first_value['meanvalue'])
def test_tamsat_10davg_case2(self): productcode = "tamsat-rfe" subproductcode = "10davg" version = "3.0" mapsetcode = "TAMSAT-Africa-4km" from_date = date(2012, 9, 1) to_date = date(2015, 6, 21) list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_poly, from_date, to_date, self.aggregate) # Check number of values self.assertEqual(len(list_values), 102) # Check first value first_value = list_values[0] self.assertAlmostEqual(0.08217245635690354, first_value['meanvalue'])
def test_tamsat_10davg_case1(self): productcode = "tamsat-rfe" subproductcode = "10davg" version = "3.0" mapsetcode = "TAMSAT-Africa-4km" from_date = date(2014, 1, 1) to_date = date(2014, 12, 31) date_format = 'MMDD' list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_poly, from_date, to_date, self.aggregate) # Check number of values self.assertEqual(len(list_values), 36) # Check value for 2014.01.01 first_value = list_values[0] self.assertAlmostEqual(70.203138776, first_value['meanvalue'])
def test_tamsat_10davg_es105(self): productcode = "tamsat-rfe" subproductcode = "10d" version = "3.0" mapsetcode = "TAMSAT-Africa-4km" from_date = date(2019, 1, 1) to_date = date(2019, 1, 11) try: failed = False list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_out_of_mapset, from_date, to_date, self.aggregate) except: failed = True # Check does not stop self.assertEqual(failed, False) # Check list empty self.assertEqual(len(list_values), 0)
def test_wkt_line(self): productcode = "tamsat-rfe" subproductcode = "10d" version = "3.0" mapsetcode = "TAMSAT-Africa-4km" from_date = date(2019, 1, 1) to_date = date(2019, 12, 31) date_format = 'YYYYMMDD' list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_line, from_date, to_date, self.aggregate) print(list_values) # Check number of values self.assertEqual(len(list_values), 36) # Check value for 2019.01.01 - quickly looked at in QGIS first_value = list_values[0] self.assertAlmostEqual(100.333333333, first_value['meanvalue'])
def test_values_chirps_10d(self): productcode = "chirps-dekad" subproductcode = "10d" version = "2.0" mapsetcode = "CHIRP-Africa-5km" from_date = date(2015, 01, 01) to_date = date(2015, 02, 21) # Type can be 'none' -> average # 'count' -> number of pixels in min-max range # 'percent' -> (number of pixels in min-max range) / (number of valid pixels) * 100 aggregate = { 'aggregation_type': 'mean', 'aggregation_min': 20.0, 'aggregation_max': 40.0 } list_values = getTimeseries(productcode, subproductcode, version, mapsetcode, self.wkt_sa, from_date, to_date, aggregate) print list_values self.assertEquals(len(list_values), 36)