def setUpClass(cls): bbox = BBox(bbox=(47.94, -5.23, 48.17, -5.03), crs=CRS.WGS84) cls.request = OgcRequest(image_format=MimeType.TIFF_d32f, layer='ALL_BANDS', maxcc=1.0, data_folder='TestOutputs', bbox=bbox, time=('2017-10-01', '2017-10-31'), time_difference=datetime.timedelta(days=10), source=DataSource.WMS, instance_id=INSTANCE_ID)
def setUpClass(cls): wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84) wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84) wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84) pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB) geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \ '1301479.5 5214191.0, 1292344.0 5205055.5))' geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))' img_width = 100 img_height = 100 resx = '53m' resy = '78m' expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S') cls.test_cases = [ cls.OgcTestCase('generalWmsTest', OgcRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height, time=(datetime.date(year=2017, month=1, day=5), datetime.date(year=2017, month=12, day=16)), service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)), result_len=14, img_min=0.0, img_max=1.5964, img_mean=0.1810, img_median=0.1140, tile_num=29, save_data=True, data_filter=[0, -2, 0]), cls.OgcTestCase('generalWcsTest', OgcRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy, time=(datetime.datetime(year=2017, month=10, day=7, hour=1), datetime.datetime(year=2017, month=12, day=11)), service_type=ServiceType.WCS, time_difference=datetime.timedelta(hours=1)), result_len=4, img_min=0.0002, img_max=0.5266, img_mean=0.1038, img_median=0.0948, tile_num=6, date_check=expected_date, save_data=True, data_filter=[0, -1]), # CustomUrlParam tests: cls.OgcTestCase('customUrlAtmcorQualitySampling', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.ATMFILTER: 'ATMCOR', CustomUrlParam.QUALITY: 100, CustomUrlParam.DOWNSAMPLING: 'BICUBIC', CustomUrlParam.UPSAMPLING: 'BICUBIC' }), result_len=1, img_min=11, img_max=255, img_mean=193.796, img_median=206, tile_num=2, data_filter=[0, -1]), cls.OgcTestCase('customUrlPreview', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.PREVIEW: 2 }), result_len=1, img_min=27, img_max=253, img_mean=176.732, img_median=177, tile_num=2), cls.OgcTestCase( 'customUrlEvalscripturl', WcsRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.EVALSCRIPTURL: 'https://raw.githubusercontent.com/sentinel-hub/' 'customScripts/master/sentinel-2/false_color_infrared/' 'script.js' }), result_len=1, img_min=41, img_max=255, img_mean=230.568, img_median=255, tile_num=3), cls.OgcTestCase('customUrlEvalscript,Transparent,Geometry', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.TRANSPARENT: True, CustomUrlParam.EVALSCRIPT: 'return [B10,B8A, B03 ]', CustomUrlParam.GEOMETRY: geometry_wkt_wgs84 }), result_len=1, img_min=0, img_max=255, img_mean=53.71428, img_median=1.0, tile_num=2), cls.OgcTestCase('FalseLogo,BgColor,Geometry', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: False, CustomUrlParam.BGCOLOR: "F4F86A", CustomUrlParam.GEOMETRY: geometry_wkt_pop_web }), result_len=1, img_min=63, img_max=255, img_mean=213.3590, img_median=242.0, tile_num=3), # DataSource tests: cls.OgcTestCase('S2 L1C Test', WmsRequest(data_source=DataSource.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d8, layer='BANDS-S2-L1C', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0, img_max=160, img_mean=59.9996, img_median=63.0, tile_num=2), cls.OgcTestCase('S2 L2A Test', WmsRequest(data_source=DataSource.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S2-L2A', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0.0, img_max=65535, img_mean=22743.5164, img_median=21390.0, tile_num=2), cls.OgcTestCase('L8 Test', WmsRequest( data_source=DataSource.LANDSAT8, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-L8', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0011, img_max=285.72415, img_mean=52.06075, img_median=0.5192, tile_num=2), cls.OgcTestCase('DEM Test', WmsRequest(data_source=DataSource.DEM, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='DEM', width=img_width, height=img_height, bbox=wgs84_bbox), result_len=1, img_min=-108.0, img_max=-18.0, img_mean=-72.1819, img_median=-72.0), cls.OgcTestCase('MODIS Test', WmsRequest(data_source=DataSource.MODIS, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-MODIS', width=img_width, height=img_height, bbox=wgs84_bbox, time='2017-10-01'), result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.136408, img_median=0.00240, tile_num=1), cls.OgcTestCase('S1 IW Test', WmsRequest( data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=1.0, img_mean=0.104584, img_median=0.06160, tile_num=2), cls.OgcTestCase('S1 EW Test', WmsRequest( data_source=DataSource.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=2, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=3), cls.OgcTestCase( 'S1 EW SH Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_SH, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_3, custom_url_params={CustomUrlParam.SHOWLOGO: True}, time=('2018-2-6', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=465, img_max=59287, img_mean=5323.0523, img_median=943.0, tile_num=1) ] """ # Test case for eocloud data source cls.test_cases.extend([ cls.OgcTestCase('EOCloud S1 IW Test', WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS_S1_IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=0.49706, img_mean=0.04082, img_median=0.00607, tile_num=2), ]) """ for test_case in cls.test_cases: test_case.collect_data()
def setUpClass(cls): super().setUpClass() wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84) wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84) wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84) wgs84_bbox_4 = BBox(bbox=(-72.0, -66.4, -71.8, -66.2), crs=CRS.WGS84) wgs84_bbox_byoc = BBox(bbox=(13.82387, 45.85221, 13.83313, 45.85901), crs=CRS.WGS84) pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB) geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \ '1301479.5 5214191.0, 1292344.0 5205055.5))' geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))' img_width = 100 img_height = 100 resx = '53m' resy = '78m' expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S') cls.test_cases = [ cls.OgcTestCase('generalWmsTest', OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height, time=(datetime.date(year=2017, month=1, day=5), datetime.date(year=2017, month=12, day=16)), service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)), result_len=14, img_min=0.0, img_max=1.5964, img_mean=0.1810, img_median=0.1140, tile_num=29, save_data=True, data_filter=[0, -2, 0]), cls.OgcTestCase('generalWcsTest', OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy, time=(datetime.datetime(year=2017, month=10, day=7, hour=1), datetime.datetime(year=2017, month=12, day=11)), service_type=ServiceType.WCS, time_difference=datetime.timedelta(hours=1)), result_len=4, img_min=0.0002, img_max=0.5266, img_mean=0.1038, img_median=0.0948, tile_num=6, date_check=expected_date, save_data=True, data_filter=[0, -1]), # CustomUrlParam tests: cls.OgcTestCase('customUrlLogoQualitySampling', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.SHOWLOGO: True, CustomUrlParam.QUALITY: 100, CustomUrlParam.DOWNSAMPLING: 'BICUBIC', CustomUrlParam.UPSAMPLING: 'BICUBIC'}), result_len=1, img_min=29, img_max=255, img_mean=179.833917, img_median=181, tile_num=2, data_filter=[0, -1]), cls.OgcTestCase('customUrlPreview', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.PREVIEW: 2}), result_len=1, img_min=27, img_max=244, img_mean=175.51357, img_median=177, tile_num=2), cls.OgcTestCase('customUrlEvalscripturl', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.EVALSCRIPTURL: 'https://raw.githubusercontent.com/sentinel-hub/' 'customScripts/master/sentinel-2/false_color_infrared/' 'script.js'}), result_len=1, img_min=46, img_max=255, img_mean=231.051154, img_median=255, tile_num=3), cls.OgcTestCase('customUrlEvalscript,Transparent,Geometry', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.TRANSPARENT: True, CustomUrlParam.EVALSCRIPT: 'return [B10,B8A, B03 ]', CustomUrlParam.GEOMETRY: geometry_wkt_wgs84}), result_len=1, img_min=0, img_max=255, img_mean=50.726361, img_median=1.0, tile_num=2), cls.OgcTestCase('FalseLogo,BgColor,Geometry', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.SHOWLOGO: False, CustomUrlParam.BGCOLOR: "F4F86A", CustomUrlParam.GEOMETRY: geometry_wkt_pop_web}), result_len=1, img_min=64, img_max=MimeType.PNG.get_expected_max_value(), img_mean=213.6124, img_median=242.0, tile_num=3), # DataSource tests: cls.OgcTestCase('S2 L1C Test', WmsRequest(data_source=DataSource.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d8, layer='BANDS-S2-L1C', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0, img_max=160, img_mean=60.50514, img_median=63.0, tile_num=2), cls.OgcTestCase('S2 L2A Test', WmsRequest(data_source=DataSource.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S2-L2A', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0.0, img_max=MimeType.TIFF.get_expected_max_value(), img_mean=22744.01498, img_median=21391.0, tile_num=2), cls.OgcTestCase('L8 Test', WmsRequest(data_source=DataSource.LANDSAT8, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-L8', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0012, img_max=285.78003, img_mean=52.06088, img_median=0.5192, tile_num=2), cls.OgcTestCase('DEM Test', WmsRequest(data_source=DataSource.DEM, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='DEM', width=img_width, height=img_height, bbox=wgs84_bbox), result_len=1, img_min=-108.0, img_max=-18.0, img_mean=-72.2097, img_median=-72.0), cls.OgcTestCase('MODIS Test', WmsRequest(data_source=DataSource.MODIS, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-MODIS', width=img_width, height=img_height, bbox=wgs84_bbox, time='2017-10-01'), result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.136548, img_median=0.00240, tile_num=1), cls.OgcTestCase('S1 IW Test', WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.00150, img_max=MimeType.TIFF_d32f.get_expected_max_value(), img_mean=0.1135815, img_median=0.06210, tile_num=2), cls.OgcTestCase('S1 EW Test', WmsRequest(data_source=DataSource.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=2, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=3), cls.OgcTestCase('S1 EW SH Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_SH, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_3, time=('2018-2-6', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=472, img_max=3538, img_mean=926.8818, img_median=894.0, tile_num=1), cls.OgcTestCase('S1 IW ASC Test', WmsRequest(data_source=DataSource.SENTINEL1_IW_ASC, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-03'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.00150, img_max=MimeType.TIFF_d32f.get_expected_max_value(), img_mean=0.1135815, img_median=0.0621000, tile_num=2), cls.OgcTestCase('S1 EW ASC Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_ASC, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0003, img_max=0.2322, img_mean=0.02199, img_median=0.0102, tile_num=2), cls.OgcTestCase('S1 EW SH ASC Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_SH_ASC, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_3, time=('2018-2-6', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=472, img_max=3538, img_mean=926.8818, img_median=894.0, tile_num=1), cls.OgcTestCase('S1 IW DES Test', WmsRequest(data_source=DataSource.SENTINEL1_IW_DES, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-05'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=0.07700, img_mean=0.0210801, img_median=0.0132, tile_num=1), cls.OgcTestCase('S1 EW DES Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_DES, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=1), cls.OgcTestCase('S1 EW SH DES Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_SH_DES, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_4, time=('2018-2-5', '2018-2-6'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=3975, img_max=37973, img_mean=15061.2035, img_median=14769.0, tile_num=1), # cls.OgcTestCase('BYOC Test', # WmsRequest(data_source=DataSource('31df1de4-8bd4-43e0-8c3f-b04262d111b6'), # data_folder=cls.OUTPUT_FOLDER, # image_format=MimeType.TIFF_d16, layer='DEMO_BYOC_LAYER', # width=img_width, height=img_height, bbox=wgs84_bbox_byoc, # custom_url_params={CustomUrlParam.SHOWLOGO: False}), # result_len=1, img_min=0, img_max=65535, img_mean=17158.8938, img_median=15728.0, # tile_num=1) ] """ # Test case for eocloud data source cls.test_cases.extend([ cls.OgcTestCase('EOCloud S1 IW Test', WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS_S1_IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=0.49706, img_mean=0.04082, img_median=0.00607, tile_num=2), ]) """ for test_case in cls.test_cases: test_case.collect_data()
def setUpClass(cls): wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84) wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84) wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84) pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB) img_width = 100 img_height = 100 resx = '53m' resy = '78m' expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S') cls.test_cases = [ cls.OgcTestCase('generalWmsTest', OgcRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height, time=('2017-10-01', '2018-01-01'), instance_id=cls.INSTANCE_ID, service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)), result_len=3, img_min=0.0, img_max=0.4544, img_mean=0.1038, img_median=0.0945, tile_num=7, date_check=expected_date, save_data=True), cls.OgcTestCase('generalWcsTest', OgcRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox, layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy, time=('2017-10-01', '2018-01-01'), instance_id=cls.INSTANCE_ID, service_type=ServiceType.WCS, time_difference=datetime.timedelta(days=5)), result_len=5, img_min=0.0002, img_max=0.5266, img_mean=0.1038, img_median=0.0948, tile_num=9, date_check=expected_date, save_data=True), # CustomUrlParam tests: cls.OgcTestCase('customUrlAtmcorQualitySampling', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.ATMFILTER: 'ATMCOR', CustomUrlParam.QUALITY: 100, CustomUrlParam.DOWNSAMPLING: 'BICUBIC', CustomUrlParam.UPSAMPLING: 'BICUBIC' }), result_len=1, img_min=11, img_max=255, img_mean=193.796, img_median=206, tile_num=2), cls.OgcTestCase('customUrlPreview', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.PREVIEW: 2 }), result_len=1, img_min=27, img_max=253, img_mean=176.732, img_median=177, tile_num=2), cls.OgcTestCase( 'customUrlEvalscripturl', WcsRequest( data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.EVALSCRIPTURL: 'https://raw.githubusercontent.com/sentinel-hub/' 'customScripts/master/sentinel-2/false_color_infrared/' 'script.js' }), result_len=1, img_min=41, img_max=255, img_mean=230.568, img_median=255, tile_num=3), cls.OgcTestCase('customUrlEvalscript', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: True, CustomUrlParam.EVALSCRIPT: 'return [B10,B8A, B03 ]' }), result_len=1, img_min=0, img_max=235, img_mean=48.539, img_median=55, tile_num=2), cls.OgcTestCase('TransparentFalseLogo', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), custom_url_params={ CustomUrlParam.SHOWLOGO: False, CustomUrlParam.TRANSPARENT: True }), result_len=1, img_min=48, img_max=255, img_mean=230.9804, img_median=242.0, tile_num=3), # DataSource tests: cls.OgcTestCase('S2 L1C Test', WmsRequest(data_source=DataSource.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d8, layer='BANDS-S2-L1C', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=38, img_max=152, img_mean=84.6465, img_median=84.0, tile_num=2), cls.OgcTestCase('S2 L2A Test', WmsRequest(data_source=DataSource.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S2-L2A', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0.0, img_max=65535, img_mean=22743.5164, img_median=21390.0, tile_num=2), cls.OgcTestCase('L8 Test', WmsRequest( data_source=DataSource.LANDSAT8, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-L8', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0011, img_max=285.72415, img_mean=52.06075, img_median=0.5192, tile_num=2), cls.OgcTestCase('DEM Test', WmsRequest(data_source=DataSource.DEM, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='DEM', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID), result_len=1, img_min=-108.0, img_max=-18.0, img_mean=-72.1819, img_median=-72.0), cls.OgcTestCase('MODIS Test', WmsRequest(data_source=DataSource.MODIS, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-MODIS', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time='2017-10-01'), result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.136408, img_median=0.00240, tile_num=1), cls.OgcTestCase('S1 IW Test', WmsRequest( data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, instance_id=cls.INSTANCE_ID, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=1.0, img_mean=0.104584, img_median=0.06160, tile_num=2), cls.OgcTestCase('S1 EW Test', WmsRequest( data_source=DataSource.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, instance_id=cls.INSTANCE_ID, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=2, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=3), cls.OgcTestCase( 'S1 EW SH Test', WmsRequest(data_source=DataSource.SENTINEL1_EW_SH, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_3, custom_url_params={CustomUrlParam.SHOWLOGO: True}, instance_id=cls.INSTANCE_ID, time=('2018-2-6', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=465, img_max=59287, img_mean=5323.0523, img_median=943.0, tile_num=1) ] for test_case in cls.test_cases: test_case.collect_data()
def setUpClass(cls): super().setUpClass() wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84) wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84) wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84) wgs84_bbox_4 = BBox(bbox=(-72.0, -66.4, -71.8, -66.2), crs=CRS.WGS84) pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB) geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \ '1301479.5 5214191.0, 1292344.0 5205055.5))' geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))' img_width = 100 img_height = 100 resx = '53m' resy = '78m' expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S') cls.test_cases = [ cls.OgcTestCase('generalWmsTest', OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, bbox=wgs84_bbox, data_collection=DataCollection.SENTINEL2_L1C, layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height, time=(datetime.date(year=2017, month=1, day=5), datetime.date(year=2017, month=12, day=16)), service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)), result_len=14, img_min=0.0, img_max=1.5964, img_mean=0.2395, img_median=0.1349, tile_num=29, save_data=True, data_filter=[0, -2, 0]), cls.OgcTestCase('generalWcsTest', OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, bbox=wgs84_bbox, data_collection=DataCollection.SENTINEL2_L1C, layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy, time=(datetime.datetime(year=2017, month=10, day=7, hour=1), datetime.datetime(year=2017, month=12, day=11)), service_type=ServiceType.WCS, time_difference=datetime.timedelta(hours=1)), result_len=4, img_min=0.0002, img_max=1.0, img_mean=0.16779, img_median=0.1023, tile_num=6, date_check=expected_date, save_data=True, data_filter=[0, -1]), # CustomUrlParam tests: cls.OgcTestCase('customUrlLogoQualitySampling', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, data_collection=DataCollection.SENTINEL2_L1C, layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.SHOWLOGO: True, CustomUrlParam.QUALITY: 100, CustomUrlParam.DOWNSAMPLING: 'BICUBIC', CustomUrlParam.UPSAMPLING: 'BICUBIC'}), result_len=1, img_min=29, img_max=255, img_mean=198.6254375, img_median=206, tile_num=2, data_filter=[0, -1]), cls.OgcTestCase('customUrlPreview', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, data_collection=DataCollection.SENTINEL2_L1C, layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.PREVIEW: 2}), result_len=1, img_min=27, img_max=255, img_mean=195.385181, img_median=199, tile_num=2), cls.OgcTestCase('customUrlEvalscripturl', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, data_collection=DataCollection.SENTINEL2_L1C, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.EVALSCRIPTURL: 'https://raw.githubusercontent.com/sentinel-hub/' 'customScripts/master/sentinel-2/false_color_infrared/' 'script.js'}), result_len=1, img_min=46, img_max=255, img_mean=231.051154, img_median=255, tile_num=3), cls.OgcTestCase('customUrlEvalscript,Geometry', WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, data_collection=DataCollection.SENTINEL2_L1C, layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.EVALSCRIPT: 'return [B10, B8A, B03]', CustomUrlParam.GEOMETRY: geometry_wkt_wgs84}), result_len=1, img_min=0, img_max=152, img_mean=24.5405, img_median=1.0, tile_num=2), cls.OgcTestCase('FalseLogo,Geometry', WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG, data_collection=DataCollection.SENTINEL2_L1C, layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox, time=('2017-10-01', '2017-10-02'), custom_url_params={CustomUrlParam.SHOWLOGO: False, CustomUrlParam.GEOMETRY: geometry_wkt_pop_web}), result_len=1, img_min=0, img_max=MimeType.PNG.get_expected_max_value(), img_mean=119.4666, img_median=123, tile_num=3), # DataCollection tests: cls.OgcTestCase('S2 L1C Test', WmsRequest(data_collection=DataCollection.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S2-L1C', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0.0009, img_max=1.0, img_mean=0.2917, img_median=0.2572, tile_num=2), cls.OgcTestCase('S2 L2A Test', WmsRequest(data_collection=DataCollection.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S2-L2A', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02')), result_len=1, img_min=0.0, img_max=1.6720, img_mean=0.39766, img_median=0.3393, tile_num=2), cls.OgcTestCase('L8 Test', WmsRequest(data_collection=DataCollection.LANDSAT8, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-L8', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0011, img_max=285.72681, img_mean=47.80554, img_median=0.53305, tile_num=2), cls.OgcTestCase('DEM Test', WmsRequest(data_collection=DataCollection.DEM, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='DEM', width=img_width, height=img_height, bbox=wgs84_bbox), result_len=1, img_min=-108.0, img_max=1, img_mean=-35.6049, img_median=-8.5), cls.OgcTestCase('MODIS Test', WmsRequest(data_collection=DataCollection.MODIS, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-MODIS', width=img_width, height=img_height, bbox=wgs84_bbox, time='2017-10-01'), result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.2445, img_median=0.0030, tile_num=1), cls.OgcTestCase('S1 IW Test', WmsRequest(data_collection=DataCollection.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-02'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=1.0, img_mean=0.3508, img_median=0.07607, tile_num=2), cls.OgcTestCase('S1 EW Test', WmsRequest(data_collection=DataCollection.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=2, img_min=0.0, img_max=1.0, img_mean=0.24709, img_median=0.00322, tile_num=3), cls.OgcTestCase('S1 EW SH Test', WmsRequest(data_collection=DataCollection.SENTINEL1_EW_SH, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S1-EW-SH', width=img_width, height=img_height, bbox=wgs84_bbox_3, time=('2018-2-6', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.00697, img_max=1.0, img_mean=0.5071, img_median=0.5276, tile_num=1), cls.OgcTestCase('S1 EW ASC Test', WmsRequest(data_collection=DataCollection.SENTINEL1_EW_ASC, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S1-EW', width=img_width, height=img_height, bbox=wgs84_bbox_2, time=('2018-2-7', '2018-2-8'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=1.0, img_mean=0.34803, img_median=0.02383, tile_num=2), cls.OgcTestCase('S1 IW DES Test', WmsRequest(data_collection=DataCollection.SENTINEL1_IW_DES, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='BANDS-S1-IW', width=img_width, height=img_height, bbox=wgs84_bbox, time=('2017-10-01', '2017-10-05'), time_difference=datetime.timedelta(hours=1)), result_len=1, img_min=0.0, img_max=1.0, img_mean=0.3474, img_median=0.04069, tile_num=1), cls.OgcTestCase('S3 OLCI Test', WmsRequest(data_collection=DataCollection.SENTINEL3_OLCI, data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, layer='TRUE-COLOR-S3-OLCI', width=img_width, height=img_height, bbox=wgs84_bbox_4, time=('2020-2-5', '2020-2-10'), time_difference=datetime.timedelta(hours=1)), result_len=11, img_min=243, img_max=255, img_mean=248.80765, img_median=248.0, tile_num=17), ] for test_case in cls.test_cases: test_case.collect_data()