Illumination

  1# coding: utf-8
  2from Element import Element
  3
  4
  5class Atmosphere6S:
  6    def __init__(self):
  7        self.ats_profile = "MidlatitudeSummer"
  8        self.aot_550 = 0.375
  9        self.target_altitude = 0
 10        self.aero_profile = "Continental"
 11        self.month = 7
 12        self.day = 14
 13
 14    def init_from_json(self, json_object):
 15        self.ats_profile = json_object["ats_profile"]
 16        self.aot_550 = json_object["aot_550"]
 17        self.target_altitude = json_object["target_altitude"]
 18        self.aero_profile = json_object["aero_profile"]
 19        self.month = json_object["month"]
 20        self.day = json_object["day"]
 21
 22    def to_json(self):
 23        json_obj = {"ats_profile": self.ats_profile,
 24                    "aot_550": self.aot_550,
 25                    "target_altitude": self.target_altitude,
 26                    "aero_profile": self.aero_profile,
 27                    "month": self.month,
 28                    "day": self.day}
 29        return json_obj
 30
 31
 32class Illumination(Element):
 33    """
 34    Illumination of the scene.
 35    The solar zenith and azimuth must be set.
 36    There are mainly two ways to define the sun and sky irradiance spectrum:
 37    * 1: Manually set sun and sky spectrum, i.e., directly input the sun spectrum and sky spectrum
 38    * 2: Use an atmosphere model, two approaches are available
 39      * 2.1 SKY_TO_TOTAL: manual set the percentage of atmosphere irradiance (on horizontal plane), compared to the total irradiance
 40      * 2.2 ATMOSPHERE: currently, only 6S model is supported.
 41    """
 42
 43    def __init__(self):
 44        super().__init__()
 45        self.__atmosphere_percentage = "0.0,0.0"
 46        self.ats_type = "SKY_TO_TOTAL"
 47        self.__ats_model = "6S"
 48        self.__ats_model_parameter = Atmosphere6S()
 49
 50        self.__atmosphere_temperature = "T300"
 51
 52        self.sun_azimuth = 90
 53        """Solar azimuth angle in degree"""
 54        self.sun_zenith = 45
 55        """Solar zenith angle in degree"""
 56
 57        self.__sun_calculator = False
 58        self.__sun_calculator_params = None
 59
 60        self.__sun_spectrum = ""
 61        self.__sky_spectrum = ""
 62
 63    def set_ats_type(self, ats_type="SKY_TO_TOTAL"):
 64        self.ats_type = ats_type
 65
 66    def get_ats_type(self):
 67        return self.ats_type
 68
 69    def set_ats_percentage(self, ats_percentage: str):
 70        """
 71        Set atmosphere percentage
 72        :param ats_percentage: the incident atmosphere percentage (horizontal plane irradiance) for each band,
 73        e.g., "0.1,0.2"
 74        :return: None
 75        """
 76        self.__atmosphere_percentage = ats_percentage
 77
 78    def get_ats_percentage(self) -> str:
 79        """
 80        Get atmosphere percentage        :return:
 81        """
 82        return self.__atmosphere_percentage
 83
 84    def get_ats_temperature(self) -> str:
 85        """
 86        Get atmospohre temperature name
 87        :return:
 88        """
 89        return self.__atmosphere_temperature
 90
 91    def set_ats_temperature(self, temperature_name):
 92        """
 93        Set atmophere temperature
 94        :param temperature_name:
 95        :return:
 96        """
 97        self.__atmosphere_temperature = temperature_name
 98
 99    def set_sun_azimuth(self, azim: float):
100        """
101        Set solar azimuth angle in degree
102        :param azim: solar azimuth angle
103        :return:
104        """
105        self.sun_azimuth = azim
106
107    def set_sun_zenith(self, zenith: float):
108        """
109        Set solar zenith angle
110        :param zenith:
111        :return:
112        """
113        self.sun_zenith = zenith
114
115    def set_sun_spectrum(self, sun_spectrum: str):
116        """
117        Set solar spectral ($W/m^2/Sr/nm$)
118        :param sun_spectrum: e.g., "0.1,0.3"
119        :return:
120        """
121        self.__sun_spectrum = sun_spectrum
122
123    def get_sun_spectrum(self):
124        return self.__sun_spectrum
125
126    def set_sky_spectrum(self, sky_spectrum):
127        self.__sky_spectrum = sky_spectrum
128
129    def get_sky_spectrum(self):
130        return self.__sky_spectrum
131
132    def has_sun_sky_spectrum(self):
133        if self.__sun_spectrum != "" and self.__sky_spectrum != "":
134            return True
135        return False
136
137    def set_ats_model(self, ats_model="6S"):
138        self.__ats_model = ats_model
139
140    def get_ats_model(self):
141        return self.__ats_model
142
143    def set_ats_model_params(self, ats_model_params=Atmosphere6S()):
144        self.__ats_model_parameter = ats_model_params
145
146    def get_ats_model_params(self):
147        return self.__ats_model_parameter
148
149    def init_illumination_from_json(self, json_object):
150        self.sun_azimuth = json_object["illumination"]["sun"]["sun_azimuth"]
151        self.sun_zenith = json_object["illumination"]["sun"]["sun_zenith"]
152        self.ats_type = json_object["illumination"]["atmosphere"]["ats_type"]
153
154        if self.ats_type == "SKY_TO_TOTAL":
155            if "percentage" in json_object["illumination"]["atmosphere"]:
156                self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["percentage"]
157        elif self.ats_type == "ATMOSPHERE":
158            self.__ats_model = json_object["illumination"]["atmosphere"]["AtsParams"]["ats_model"]
159            if self.__ats_model == "6S":
160                sixs_model = Atmosphere6S()
161                sixs_model.init_from_json(json_object["illumination"]["atmosphere"]["AtsParams"]["modelParam"])
162                self.__ats_model_parameter = sixs_model
163        if "sun_spectrum" in json_object["illumination"]["sun"]:
164            self.__sun_spectrum = json_object["illumination"]["sun"]["sun_spectrum"]
165        if "sky_spectrum" in json_object["illumination"]["atmosphere"]:
166            self.__sky_spectrum = json_object["illumination"]["atmosphere"]["sky_spectrum"]
167        self.__sun_calculator = json_object["illumination"]["sun_calculator"]
168        if self.__sun_calculator:
169            self.__sun_calculator_params = json_object["illumination"]["calculator_params"]
170        if "AtsTemperature" in json_object["illumination"]["atmosphere"]:
171            self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["AtsTemperature"]
172        return self
173
174    def to_json_object(self):
175        json_object = {"atmosphere": {"ats_type": self.ats_type},
176                       "sun": {"sun_azimuth": self.sun_azimuth,
177                               "sun_zenith": self.sun_zenith},
178                       "sun_calculator": self.__sun_calculator}
179        if self.ats_type == "SKY_TO_TOTAL":
180            json_object["atmosphere"]["percentage"] = self.__atmosphere_percentage
181        elif self.ats_type == "ATMOSPHERE":
182            if self.__ats_model == "6S":
183                json_object["atmosphere"]["AtsParams"] = {}
184                json_object["atmosphere"]["AtsParams"]["ats_model"] = self.__ats_model
185                json_object["atmosphere"]["AtsParams"]["modelParam"] = self.__ats_model_parameter.to_json()
186        if self.get_sim().get_scene().get_sensor().thermal_radiation:
187            json_object["atmosphere"]["AtsTemperature"] = self.__atmosphere_temperature
188
189        if self.__sun_calculator and self.__sun_calculator_params is not None:
190            json_object["calculator_params"] = self.__sun_calculator_params
191        if self.has_sun_sky_spectrum():
192            json_object["atmosphere"]["sky_spectrum"] = self.__sky_spectrum
193            json_object["sun"]["sun_spectrum"] = self.__sun_spectrum
194
195        return json_object
class Atmosphere6S:
 6class Atmosphere6S:
 7    def __init__(self):
 8        self.ats_profile = "MidlatitudeSummer"
 9        self.aot_550 = 0.375
10        self.target_altitude = 0
11        self.aero_profile = "Continental"
12        self.month = 7
13        self.day = 14
14
15    def init_from_json(self, json_object):
16        self.ats_profile = json_object["ats_profile"]
17        self.aot_550 = json_object["aot_550"]
18        self.target_altitude = json_object["target_altitude"]
19        self.aero_profile = json_object["aero_profile"]
20        self.month = json_object["month"]
21        self.day = json_object["day"]
22
23    def to_json(self):
24        json_obj = {"ats_profile": self.ats_profile,
25                    "aot_550": self.aot_550,
26                    "target_altitude": self.target_altitude,
27                    "aero_profile": self.aero_profile,
28                    "month": self.month,
29                    "day": self.day}
30        return json_obj
ats_profile
aot_550
target_altitude
aero_profile
month
day
def init_from_json(self, json_object):
15    def init_from_json(self, json_object):
16        self.ats_profile = json_object["ats_profile"]
17        self.aot_550 = json_object["aot_550"]
18        self.target_altitude = json_object["target_altitude"]
19        self.aero_profile = json_object["aero_profile"]
20        self.month = json_object["month"]
21        self.day = json_object["day"]
def to_json(self):
23    def to_json(self):
24        json_obj = {"ats_profile": self.ats_profile,
25                    "aot_550": self.aot_550,
26                    "target_altitude": self.target_altitude,
27                    "aero_profile": self.aero_profile,
28                    "month": self.month,
29                    "day": self.day}
30        return json_obj
class Illumination(Element.Element):
 33class Illumination(Element):
 34    """
 35    Illumination of the scene.
 36    The solar zenith and azimuth must be set.
 37    There are mainly two ways to define the sun and sky irradiance spectrum:
 38    * 1: Manually set sun and sky spectrum, i.e., directly input the sun spectrum and sky spectrum
 39    * 2: Use an atmosphere model, two approaches are available
 40      * 2.1 SKY_TO_TOTAL: manual set the percentage of atmosphere irradiance (on horizontal plane), compared to the total irradiance
 41      * 2.2 ATMOSPHERE: currently, only 6S model is supported.
 42    """
 43
 44    def __init__(self):
 45        super().__init__()
 46        self.__atmosphere_percentage = "0.0,0.0"
 47        self.ats_type = "SKY_TO_TOTAL"
 48        self.__ats_model = "6S"
 49        self.__ats_model_parameter = Atmosphere6S()
 50
 51        self.__atmosphere_temperature = "T300"
 52
 53        self.sun_azimuth = 90
 54        """Solar azimuth angle in degree"""
 55        self.sun_zenith = 45
 56        """Solar zenith angle in degree"""
 57
 58        self.__sun_calculator = False
 59        self.__sun_calculator_params = None
 60
 61        self.__sun_spectrum = ""
 62        self.__sky_spectrum = ""
 63
 64    def set_ats_type(self, ats_type="SKY_TO_TOTAL"):
 65        self.ats_type = ats_type
 66
 67    def get_ats_type(self):
 68        return self.ats_type
 69
 70    def set_ats_percentage(self, ats_percentage: str):
 71        """
 72        Set atmosphere percentage
 73        :param ats_percentage: the incident atmosphere percentage (horizontal plane irradiance) for each band,
 74        e.g., "0.1,0.2"
 75        :return: None
 76        """
 77        self.__atmosphere_percentage = ats_percentage
 78
 79    def get_ats_percentage(self) -> str:
 80        """
 81        Get atmosphere percentage        :return:
 82        """
 83        return self.__atmosphere_percentage
 84
 85    def get_ats_temperature(self) -> str:
 86        """
 87        Get atmospohre temperature name
 88        :return:
 89        """
 90        return self.__atmosphere_temperature
 91
 92    def set_ats_temperature(self, temperature_name):
 93        """
 94        Set atmophere temperature
 95        :param temperature_name:
 96        :return:
 97        """
 98        self.__atmosphere_temperature = temperature_name
 99
100    def set_sun_azimuth(self, azim: float):
101        """
102        Set solar azimuth angle in degree
103        :param azim: solar azimuth angle
104        :return:
105        """
106        self.sun_azimuth = azim
107
108    def set_sun_zenith(self, zenith: float):
109        """
110        Set solar zenith angle
111        :param zenith:
112        :return:
113        """
114        self.sun_zenith = zenith
115
116    def set_sun_spectrum(self, sun_spectrum: str):
117        """
118        Set solar spectral ($W/m^2/Sr/nm$)
119        :param sun_spectrum: e.g., "0.1,0.3"
120        :return:
121        """
122        self.__sun_spectrum = sun_spectrum
123
124    def get_sun_spectrum(self):
125        return self.__sun_spectrum
126
127    def set_sky_spectrum(self, sky_spectrum):
128        self.__sky_spectrum = sky_spectrum
129
130    def get_sky_spectrum(self):
131        return self.__sky_spectrum
132
133    def has_sun_sky_spectrum(self):
134        if self.__sun_spectrum != "" and self.__sky_spectrum != "":
135            return True
136        return False
137
138    def set_ats_model(self, ats_model="6S"):
139        self.__ats_model = ats_model
140
141    def get_ats_model(self):
142        return self.__ats_model
143
144    def set_ats_model_params(self, ats_model_params=Atmosphere6S()):
145        self.__ats_model_parameter = ats_model_params
146
147    def get_ats_model_params(self):
148        return self.__ats_model_parameter
149
150    def init_illumination_from_json(self, json_object):
151        self.sun_azimuth = json_object["illumination"]["sun"]["sun_azimuth"]
152        self.sun_zenith = json_object["illumination"]["sun"]["sun_zenith"]
153        self.ats_type = json_object["illumination"]["atmosphere"]["ats_type"]
154
155        if self.ats_type == "SKY_TO_TOTAL":
156            if "percentage" in json_object["illumination"]["atmosphere"]:
157                self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["percentage"]
158        elif self.ats_type == "ATMOSPHERE":
159            self.__ats_model = json_object["illumination"]["atmosphere"]["AtsParams"]["ats_model"]
160            if self.__ats_model == "6S":
161                sixs_model = Atmosphere6S()
162                sixs_model.init_from_json(json_object["illumination"]["atmosphere"]["AtsParams"]["modelParam"])
163                self.__ats_model_parameter = sixs_model
164        if "sun_spectrum" in json_object["illumination"]["sun"]:
165            self.__sun_spectrum = json_object["illumination"]["sun"]["sun_spectrum"]
166        if "sky_spectrum" in json_object["illumination"]["atmosphere"]:
167            self.__sky_spectrum = json_object["illumination"]["atmosphere"]["sky_spectrum"]
168        self.__sun_calculator = json_object["illumination"]["sun_calculator"]
169        if self.__sun_calculator:
170            self.__sun_calculator_params = json_object["illumination"]["calculator_params"]
171        if "AtsTemperature" in json_object["illumination"]["atmosphere"]:
172            self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["AtsTemperature"]
173        return self
174
175    def to_json_object(self):
176        json_object = {"atmosphere": {"ats_type": self.ats_type},
177                       "sun": {"sun_azimuth": self.sun_azimuth,
178                               "sun_zenith": self.sun_zenith},
179                       "sun_calculator": self.__sun_calculator}
180        if self.ats_type == "SKY_TO_TOTAL":
181            json_object["atmosphere"]["percentage"] = self.__atmosphere_percentage
182        elif self.ats_type == "ATMOSPHERE":
183            if self.__ats_model == "6S":
184                json_object["atmosphere"]["AtsParams"] = {}
185                json_object["atmosphere"]["AtsParams"]["ats_model"] = self.__ats_model
186                json_object["atmosphere"]["AtsParams"]["modelParam"] = self.__ats_model_parameter.to_json()
187        if self.get_sim().get_scene().get_sensor().thermal_radiation:
188            json_object["atmosphere"]["AtsTemperature"] = self.__atmosphere_temperature
189
190        if self.__sun_calculator and self.__sun_calculator_params is not None:
191            json_object["calculator_params"] = self.__sun_calculator_params
192        if self.has_sun_sky_spectrum():
193            json_object["atmosphere"]["sky_spectrum"] = self.__sky_spectrum
194            json_object["sun"]["sun_spectrum"] = self.__sun_spectrum
195
196        return json_object

Illumination of the scene. The solar zenith and azimuth must be set. There are mainly two ways to define the sun and sky irradiance spectrum:

  • 1: Manually set sun and sky spectrum, i.e., directly input the sun spectrum and sky spectrum
  • 2: Use an atmosphere model, two approaches are available
    • 2.1 SKY_TO_TOTAL: manual set the percentage of atmosphere irradiance (on horizontal plane), compared to the total irradiance
    • 2.2 ATMOSPHERE: currently, only 6S model is supported.
ats_type
sun_azimuth

Solar azimuth angle in degree

sun_zenith

Solar zenith angle in degree

def set_ats_type(self, ats_type='SKY_TO_TOTAL'):
64    def set_ats_type(self, ats_type="SKY_TO_TOTAL"):
65        self.ats_type = ats_type
def get_ats_type(self):
67    def get_ats_type(self):
68        return self.ats_type
def set_ats_percentage(self, ats_percentage: str):
70    def set_ats_percentage(self, ats_percentage: str):
71        """
72        Set atmosphere percentage
73        :param ats_percentage: the incident atmosphere percentage (horizontal plane irradiance) for each band,
74        e.g., "0.1,0.2"
75        :return: None
76        """
77        self.__atmosphere_percentage = ats_percentage

Set atmosphere percentage

Parameters
  • ats_percentage: the incident atmosphere percentage (horizontal plane irradiance) for each band, e.g., "0.1,0.2"
Returns

None

def get_ats_percentage(self) -> str:
79    def get_ats_percentage(self) -> str:
80        """
81        Get atmosphere percentage        :return:
82        """
83        return self.__atmosphere_percentage

Get atmosphere percentage :return:

def get_ats_temperature(self) -> str:
85    def get_ats_temperature(self) -> str:
86        """
87        Get atmospohre temperature name
88        :return:
89        """
90        return self.__atmosphere_temperature

Get atmospohre temperature name

Returns
def set_ats_temperature(self, temperature_name):
92    def set_ats_temperature(self, temperature_name):
93        """
94        Set atmophere temperature
95        :param temperature_name:
96        :return:
97        """
98        self.__atmosphere_temperature = temperature_name

Set atmophere temperature

Parameters
  • temperature_name:
Returns
def set_sun_azimuth(self, azim: float):
100    def set_sun_azimuth(self, azim: float):
101        """
102        Set solar azimuth angle in degree
103        :param azim: solar azimuth angle
104        :return:
105        """
106        self.sun_azimuth = azim

Set solar azimuth angle in degree

Parameters
  • azim: solar azimuth angle
Returns
def set_sun_zenith(self, zenith: float):
108    def set_sun_zenith(self, zenith: float):
109        """
110        Set solar zenith angle
111        :param zenith:
112        :return:
113        """
114        self.sun_zenith = zenith

Set solar zenith angle

Parameters
  • zenith:
Returns
def set_sun_spectrum(self, sun_spectrum: str):
116    def set_sun_spectrum(self, sun_spectrum: str):
117        """
118        Set solar spectral ($W/m^2/Sr/nm$)
119        :param sun_spectrum: e.g., "0.1,0.3"
120        :return:
121        """
122        self.__sun_spectrum = sun_spectrum

Set solar spectral ($W/m^2/Sr/nm$)

Parameters
  • sun_spectrum: e.g., "0.1,0.3"
Returns
def get_sun_spectrum(self):
124    def get_sun_spectrum(self):
125        return self.__sun_spectrum
def set_sky_spectrum(self, sky_spectrum):
127    def set_sky_spectrum(self, sky_spectrum):
128        self.__sky_spectrum = sky_spectrum
def get_sky_spectrum(self):
130    def get_sky_spectrum(self):
131        return self.__sky_spectrum
def has_sun_sky_spectrum(self):
133    def has_sun_sky_spectrum(self):
134        if self.__sun_spectrum != "" and self.__sky_spectrum != "":
135            return True
136        return False
def set_ats_model(self, ats_model='6S'):
138    def set_ats_model(self, ats_model="6S"):
139        self.__ats_model = ats_model
def get_ats_model(self):
141    def get_ats_model(self):
142        return self.__ats_model
def set_ats_model_params(self, ats_model_params=<Illumination.Atmosphere6S object>):
144    def set_ats_model_params(self, ats_model_params=Atmosphere6S()):
145        self.__ats_model_parameter = ats_model_params
def get_ats_model_params(self):
147    def get_ats_model_params(self):
148        return self.__ats_model_parameter
def init_illumination_from_json(self, json_object):
150    def init_illumination_from_json(self, json_object):
151        self.sun_azimuth = json_object["illumination"]["sun"]["sun_azimuth"]
152        self.sun_zenith = json_object["illumination"]["sun"]["sun_zenith"]
153        self.ats_type = json_object["illumination"]["atmosphere"]["ats_type"]
154
155        if self.ats_type == "SKY_TO_TOTAL":
156            if "percentage" in json_object["illumination"]["atmosphere"]:
157                self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["percentage"]
158        elif self.ats_type == "ATMOSPHERE":
159            self.__ats_model = json_object["illumination"]["atmosphere"]["AtsParams"]["ats_model"]
160            if self.__ats_model == "6S":
161                sixs_model = Atmosphere6S()
162                sixs_model.init_from_json(json_object["illumination"]["atmosphere"]["AtsParams"]["modelParam"])
163                self.__ats_model_parameter = sixs_model
164        if "sun_spectrum" in json_object["illumination"]["sun"]:
165            self.__sun_spectrum = json_object["illumination"]["sun"]["sun_spectrum"]
166        if "sky_spectrum" in json_object["illumination"]["atmosphere"]:
167            self.__sky_spectrum = json_object["illumination"]["atmosphere"]["sky_spectrum"]
168        self.__sun_calculator = json_object["illumination"]["sun_calculator"]
169        if self.__sun_calculator:
170            self.__sun_calculator_params = json_object["illumination"]["calculator_params"]
171        if "AtsTemperature" in json_object["illumination"]["atmosphere"]:
172            self.__atmosphere_percentage = json_object["illumination"]["atmosphere"]["AtsTemperature"]
173        return self
def to_json_object(self):
175    def to_json_object(self):
176        json_object = {"atmosphere": {"ats_type": self.ats_type},
177                       "sun": {"sun_azimuth": self.sun_azimuth,
178                               "sun_zenith": self.sun_zenith},
179                       "sun_calculator": self.__sun_calculator}
180        if self.ats_type == "SKY_TO_TOTAL":
181            json_object["atmosphere"]["percentage"] = self.__atmosphere_percentage
182        elif self.ats_type == "ATMOSPHERE":
183            if self.__ats_model == "6S":
184                json_object["atmosphere"]["AtsParams"] = {}
185                json_object["atmosphere"]["AtsParams"]["ats_model"] = self.__ats_model
186                json_object["atmosphere"]["AtsParams"]["modelParam"] = self.__ats_model_parameter.to_json()
187        if self.get_sim().get_scene().get_sensor().thermal_radiation:
188            json_object["atmosphere"]["AtsTemperature"] = self.__atmosphere_temperature
189
190        if self.__sun_calculator and self.__sun_calculator_params is not None:
191            json_object["calculator_params"] = self.__sun_calculator_params
192        if self.has_sun_sky_spectrum():
193            json_object["atmosphere"]["sky_spectrum"] = self.__sky_spectrum
194            json_object["sun"]["sun_spectrum"] = self.__sun_spectrum
195
196        return json_object
Inherited Members
Element.Element
set_sim
get_sim