def test_ndvi(): collection = col.map(lambda img: img.addBands(indices.ndvi(img, 'B8','B4'))) image = ee.Image(collection.first()) values = getValue(image, p, 10, side='client') NIR = float(values['B8']) RED = float(values['B4']) index = (NIR-RED)/(NIR+RED) index_from_i = getValue(image, p, 10, 'client')['ndvi'] assert index == index_from_i
def test_nbr2(): collection = col.map(lambda img: img.addBands(indices.nbr2(img, 'B11', 'B12'))) image = ee.Image(collection.first()) values = getValue(image, p, 10, side='client') SWIR1 = float(values['B11']) SWIR2 = float(values['B12']) index = (SWIR1-SWIR2)/(SWIR1+SWIR2) index_from_i = getValue(image, p, 10, 'client')['nbr2'] assert index == index_from_i
def test_evi(): collection = col.map(lambda img: img.addBands(indices.evi(img, 'B8', 'B4', 'B2'))) image = ee.Image(collection.first()) values = getValue(image, p, 10, side='client') NIR = float(values['B8']) RED = float(values['B4']) BLUE = float(values['B2']) index = (2.5)*((NIR-RED)/(NIR+(6*RED)-((7.5)*BLUE)+1)) index_from_i = getValue(image, p, 10, 'client')['evi'] assert index == index_from_i
def test_expressions(): from geetools import expressions generator = expressions.Expression() exp_max = generator.max("b('B1')", "b('B2')") exp_min = generator.min("b('B1')", "b('B2')") img_max = l8SR.expression(exp_max).select([0], ["max"]) img_min = l8SR.expression(exp_min).select([0], ["min"]) vals_max = getValue(img_max, p_l8SR_no_cloud, 30, 'client') vals_min = getValue(img_min, p_l8SR_no_cloud, 30, 'client') assert vals_max["max"] == 580 assert vals_min["min"] == 517
def test_snow(): masked = cloud_mask.applyHollstein(image, ['snow']) vals = getValue(masked, p_snow, 30) assert vals.get("B1").getInfo() == None
def test_cirrus(): masked = cloud_mask.applyHollstein(image, ['cirrus']) vals = getValue(masked, p_cirrus, 30) assert vals.get("B1").getInfo() == None
def test_cirrus(): masked = cloud_mask.sentinel2(['cirrus'])(image) vals = getValue(masked, p_cirrus, 30) assert vals.get("B1").getInfo() == None
def test_snow(): masked = cloud_mask.landsat457SRPixelQA(['snow'])(image) vals = getValue(masked, p_snow, 30) assert vals.get("B1").getInfo() == None
def test_shadows(): masked = cloud_mask.landsat457ToaBQA(['shadow'])(image) vals = getValue(masked, p_shadow, 30) assert vals.get("B1").getInfo() == None
def test_clouds(): masked = cloud_mask.landsat457ToaBQA(['cloud'])(image) vals = getValue(masked, p_cloud, 30) assert vals.get("B1").getInfo() == None