Skip to content

Commit

Permalink
fix(unitest)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasK committed Dec 15, 2023
1 parent a76bef8 commit 920cc56
Showing 1 changed file with 4 additions and 41 deletions.
45 changes: 4 additions & 41 deletions tests/test_simple_datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,7 @@ class TestEarthDataStore(unittest.TestCase):
def setUp(self):
self.eds = earthdaily.earthdatastore.Auth()
self.pivot = earthdaily.datasets.load_pivot()

def test_rescale_on_venus(self):
collection = "venus-l2a"
theia_location = "MEAD"
max_cloud_cover = 20

query = {
"theia:location": {"eq": theia_location},
"eo:cloud_cover": {"lt": max_cloud_cover},
}

items = self.eds.search(collection, query=query, max_items=1)
crs = items[0].properties["proj:epsg"]
gsd = items[0].properties["gsd"]

bands_info = (
items[0].assets["image_file_SRE_B3"].extra_fields["raster:bands"][0]
)
scale, offset = bands_info["scale"], bands_info["offset"]
for rescale in True, False:
datacube = self.eds.datacube(
collection,
assets=["image_file_SRE_B3"],
rescale=rescale,
search_kwargs=dict(query=query, max_items=1),
resolution=gsd,
crs=crs,
)

# self.assertEqual(datacube.rio.width,9374)
# self.assertEqual(datacube.rio.height,10161)
self.assertEqual(datacube.time.size, 1)
blue = (
datacube["image_file_SRE_B3"]
.isel(x=4000, y=4000, time=0)
.data.load()
)
if rescale is False:
blue = blue * scale + offset
self.assertAlmostEqual(blue, 0.136)
self.pivot_corumba = earthdaily.datasets.load_pivot_corumba()

def test_sentinel1(self):
collection = "sentinel-1-rtc"
Expand All @@ -66,7 +27,9 @@ def test_sentinel2(self):
intersects=self.pivot,
datetime="2023-07-01",
)
self.assertEqual(list(datacube.data_vars.keys()), ["blue", "green", "red"])
self.assertEqual(
list(datacube.data_vars.keys()), ["blue", "green", "red"]
)


if __name__ == "__main__":
Expand Down

0 comments on commit 920cc56

Please sign in to comment.