Commit 844faddc authored by Remi Cresson's avatar Remi Cresson
Browse files

REFAC: STAC, theia-picker, pyotb

1 merge request!50Support de STAC
Pipeline #45544 failed with stages
in 3 minutes and 35 seconds
Showing with 16 additions and 15 deletions
+16 -15
......@@ -490,7 +490,7 @@ class Scene(ABC):
return get_
def get_assets_paths(self, key: str) -> str:
def get_asset_path(self, key: str) -> str:
"""
Get asset path.
......
......@@ -5,7 +5,10 @@ import scenes
import tests_data
import tempfile
sc_spot67 = scenes.spot.get_local_spot67drs_scene(dimap_xs=tests_data.DIMAP1_XS, dimap_pan=tests_data.DIMAP1_P)
sc_spot67 = scenes.spot.get_local_spot67drs_scene(
dimap_xs=tests_data.DIMAP1_XS,
dimap_pan=tests_data.DIMAP1_P
)
sc_s2a = scenes.sentinel.Sentinel22AScene(archive=tests_data.ARCHIVE1)
sc_s3a = scenes.sentinel.Sentinel23AScene(archive=tests_data.ARCHIVE2)
scs = [sc_spot67, sc_s2a, sc_s3a]
......@@ -13,19 +16,15 @@ scs = [sc_spot67, sc_s2a, sc_s3a]
class SerializationTest(ScenesTestBase):
def compare_scenes(self, sc1, sc2):
for member in ["metadata", "assets_paths_func"]:
m1 = getattr(sc1, member)
m2 = getattr(sc2, member)
print(f"\nAttribute {member} of sc1: {m1}")
print(f"\nAttribute {member} of sc2: {m2}")
assert m1 == m2, f"Member {member} differ in compared scenes."
assert sc1.metadata == sc2.metadata
def test_serialize(self):
for sc in scs:
with tempfile.NamedTemporaryFile() as tmp:
pickle_file = tmp.name
scenes.save_scenes(scenes_list=[sc], pickle_file=pickle_file)
assert os.path.isfile(pickle_file), f"File {pickle_file} not found!"
assert os.path.isfile(pickle_file), \
f"File {pickle_file} not found!"
def test_deserialize(self):
for sc in scs:
......@@ -33,7 +32,9 @@ class SerializationTest(ScenesTestBase):
pickle_file = tmp.name
scenes.save_scenes(scenes_list=[sc], pickle_file=pickle_file)
loaded_scs = scenes.load_scenes(pickle_file=pickle_file)
assert len(loaded_scs)==1, f"There is {len(loaded_scs)} scenes in {pickle_file}! (expected 1)"
assert len(loaded_scs)==1, \
f"There is {len(loaded_scs)} scenes " \
f"in {pickle_file}! (expected 1)"
self.compare_scenes(sc1=loaded_scs[0], sc2=sc)
......
......@@ -15,11 +15,11 @@ class Spot67ImageryTest(ScenesTestBase):
self.compare_images(inp, actual_ref)
def xs_imagery(self, reflectance="dn"):
xs = sc.get_xs(reflectance=reflectance)
xs = sc.get_xs().reflectance(level=reflectance)
self.compare(xs, tests_data.DIMAP1_XS, reflectance)
def pan_imagery(self, reflectance="dn"):
pan = sc.get_pan(reflectance=reflectance)
pan = sc.get_pan().reflectance(level=reflectance)
self.compare(pan, tests_data.DIMAP1_P, reflectance)
def test_instanciate_sc(self):
......@@ -46,16 +46,16 @@ class Spot67ImageryTest(ScenesTestBase):
self.compare_images(pxs, pxs_baseline, roi=[2500, 2500, 500, 500])
def pxs_imagery(self, reflectance="dn"):
pxs = sc.get_pxs(reflectance=reflectance)
pxs = sc.get_pxs().reflectance(level=reflectance)
self.pxs_compare(pxs, reflectance)
def pxs_imagery_cld_msk_drilled(self, reflectance="dn"):
pxs = sc.get_pxs(reflectance=reflectance)
pxs = sc.get_pxs().reflectance(level=reflectance)
pxs_drilled = pxs.cld_msk_drilled()
self.pxs_compare(pxs_drilled, reflectance)
def pxs_imagery_cld_msk_drilled_cached(self, reflectance="dn"):
pxs = sc.get_pxs(reflectance=reflectance)
pxs = sc.get_pxs().reflectance(level=reflectance)
pxs_drilled = pxs.cld_msk_drilled()
pxs_cached = pxs_drilled.cached()
self.pxs_compare(pxs_cached, reflectance)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment