From d08a0053bee812320e9749d0afb8b4e2ea949474 Mon Sep 17 00:00:00 2001 From: Vincent Delbar <vincent.delbar@latelescop.fr> Date: Fri, 22 Apr 2022 18:51:07 +0200 Subject: [PATCH] ENH: allow TOC calibration + clamp and milli param --- scenes/spot.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scenes/spot.py b/scenes/spot.py index 9765172..9bf40cd 100644 --- a/scenes/spot.py +++ b/scenes/spot.py @@ -192,13 +192,16 @@ class Spot67Imagery(Imagery): """ - def __init__(self, root_scene, reflectance): + def __init__(self, root_scene, reflectance="dn", clamp=False, milli=False): """ Args: - root_scene: The Scene of which the Imagery instance is attached - reflectance: optional level of reflectance (can be "dn", "toa") + root_scene: the Scene of which the Imagery instance is attached + reflectance: optional level of reflectance (can be "dn", "toa", "toc") + clamp: normalize reflectance values + milli: convert values to milli reflectance """ - assert reflectance.lower() == "toa" or reflectance.lower() == "dn", "reflectance can be 'dn' or 'toa'" + reflectance = reflectance.lower() + assert reflectance in ("dn", "toa", "toc"), "reflectance can be 'dn', 'toa' or 'toc'" super().__init__(root_scene=root_scene) # Base @@ -206,12 +209,13 @@ class Spot67Imagery(Imagery): self.pan = self.root_scene.dimap_file_pan # Radiometry correction - if reflectance.lower() == "toa": - def _toa(inp): - return pyotb.OpticalCalibration({"in": inp, "level": "toa"}) + if reflectance in ("toa", "toc"): + def _calib(inp): + params = {"in": inp, "level": reflectance, "clamp": clamp, "milli": milli} + return pyotb.OpticalCalibration(params) - self.xs = _toa(self.xs) - self.pan = _toa(self.pan) + self.xs = _calib(self.xs) + self.pan = _calib(self.pan) def get_xs(self): """ -- GitLab