Terrain

  1# coding: utf-8
  2from Element import Element
  3import sys
  4import os
  5import shutil
  6
  7
  8class TERRAIN_BRDF_TYPE:
  9    LAMBERTIAN = "Lambertian"
 10    LAND_ALBEDO_MAP = "Land Albedo Map"
 11    SOILSPECT = "Soilspect"
 12    RPV = "RPV"
 13    ART = "ART"
 14
 15
 16class TERRAIN_TYPE:
 17    PLANE = "PLANE"
 18    RASTER = "RASTER"
 19    MESH = "MESH"
 20
 21
 22class Terrain(Element):
 23
 24    def __init__(self):
 25        super().__init__()
 26        # terrain
 27        self.terr_BRDF_Type = TERRAIN_BRDF_TYPE.LAMBERTIAN
 28        self.optical_scale = 1
 29        self.extent_height = 100
 30        self.extent_width = 100
 31        self.terr_file = ""
 32        self.terrain_type = TERRAIN_TYPE.PLANE
 33        self.temperature = "T300"
 34
 35        # conditional properties
 36        self.optical = "dark_soil_mollisol"
 37        self.landalbedo = ""
 38        self.soilSpectParams = dict()
 39        self.rpvParams = dict()
 40        self.artParams = dict()
 41
 42    def set_extent_width(self, width):
 43        self.extent_width = width
 44
 45    def set_extent_height(self, height):
 46        self.extent_height = height
 47
 48    def get_extent_width(self):
 49        return self.extent_width
 50
 51    def get_extent_height(self):
 52        return self.extent_height
 53
 54    def set_terrain_type(self, terrain_type):
 55        self.terrain_type = terrain_type
 56
 57    def set_terrain_file(self, terrain_file):
 58        filename = os.path.basename(terrain_file)
 59        dist_dem_file = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
 60        if dist_dem_file != terrain_file:
 61            shutil.copy(terrain_file, dist_dem_file)
 62            hdr_file = os.path.join(terrain_file+".hdr")
 63            if os.path.exists(hdr_file):
 64                shutil.copy(hdr_file, os.path.join(dist_dem_file+".hdr"))
 65        self.terr_file = filename
 66
 67    def set_terr_brdf_type(self, brdf_type):
 68        self.terr_BRDF_Type = brdf_type
 69
 70    def get_terr_brdf_type(self):
 71        return self.terr_BRDF_Type
 72
 73    def get_optical(self):
 74        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
 75            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
 76            sys.exit()
 77        return self.optical
 78
 79    def set_optical(self, optical_name):
 80        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
 81            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
 82            sys.exit()
 83        self.optical = optical_name
 84
 85    def get_landalbedo_file(self):
 86        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
 87            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
 88            sys.exit()
 89        return self.landalbedo
 90
 91    def set_landalbedo_file(self, landalbedo_file):  # 需要复制文件
 92        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
 93            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
 94            sys.exit()
 95        filename = os.path.basename(landalbedo_file)
 96        dist_albedomap = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
 97        if dist_albedomap != landalbedo_file:
 98            shutil.copy(landalbedo_file, dist_albedomap)
 99        landalbedo_file_header = landalbedo_file + ".hdr"
100        dist_albedomap_header = dist_albedomap+".hdr"
101        if os.path.exists(landalbedo_file_header) and landalbedo_file_header != dist_albedomap_header:
102            shutil.copy(landalbedo_file_header, dist_albedomap+".hdr")
103        self.landalbedo = filename
104
105    def init_terrain_from_json(self, json_object):
106        self.terr_BRDF_Type = json_object["scene"]["terrain"]["terrBRDFType"]
107        self.optical_scale = json_object["scene"]["terrain"]["optical_scale"]
108        self.extent_height = json_object["scene"]["terrain"]["extent_height"]
109        self.extent_width = json_object["scene"]["terrain"]["extent_width"]
110        self.terr_file = json_object["scene"]["terrain"]["terr_file"]
111        self.terrain_type = json_object["scene"]["terrain"]["terrain_type"]
112
113        if self.terr_BRDF_Type == "Lambertian":
114            if "optical" in json_object["scene"]["terrain"]:
115                self.optical = json_object["scene"]["terrain"]["optical"]
116        elif self.terr_BRDF_Type == "Land Albedo Map":
117            if "landalbedo" in json_object["scene"]["terrain"]:
118                self.landalbedo = json_object["scene"]["terrain"]["landalbedo"]
119        elif self.terr_BRDF_Type == "Soilspect":
120            if "soilSpectParams" in json_object["scene"]["terrain"]:
121                if "c3" in json_object["scene"]["terrain"]["soilSpectParams"]:
122                    self.soilSpectParams["c3"] = json_object["scene"]["terrain"]["soilSpectParams"]["c3"]
123                if "c4" in json_object["scene"]["terrain"]["soilSpectParams"]:
124                    self.soilSpectParams["c4"] = json_object["scene"]["terrain"]["soilSpectParams"]["c4"]
125                if "h1" in json_object["scene"]["terrain"]["soilSpectParams"]:
126                    self.soilSpectParams["h1"] = json_object["scene"]["terrain"]["soilSpectParams"]["h1"]
127                if "h2" in json_object["scene"]["terrain"]["soilSpectParams"]:
128                    self.soilSpectParams["h2"] = json_object["scene"]["terrain"]["soilSpectParams"]["h2"]
129                if "c1" in json_object["scene"]["terrain"]["soilSpectParams"]:
130                    self.soilSpectParams["c1"] = json_object["scene"]["terrain"]["soilSpectParams"]["c1"]
131                if "albedo" in json_object["scene"]["terrain"]["soilSpectParams"]:
132                    self.soilSpectParams["albedo"] = json_object["scene"]["terrain"]["soilSpectParams"]["albedo"]
133                if "c2" in json_object["scene"]["terrain"]["soilSpectParams"]:
134                    self.soilSpectParams["c2"] = json_object["scene"]["terrain"]["soilSpectParams"]["c2"]
135        elif self.terr_BRDF_Type == "RPV":
136            if "rpvParams" in json_object["scene"]["terrain"]:
137                if "rho0" in json_object["scene"]["terrain"]["rpvParams"]:
138                    self.rpvParams["rho0"] = json_object["scene"]["terrain"]["rpvParams"]["rho0"]
139                if "k" in json_object["scene"]["terrain"]["rpvParams"]:
140                    self.rpvParams["k"] = json_object["scene"]["terrain"]["rpvParams"]["k"]
141                if "THETA" in json_object["scene"]["terrain"]["rpvParams"]:
142                    self.rpvParams["THETA"] = json_object["scene"]["terrain"]["rpvParams"]["THETA"]
143                if "rhoc" in json_object["scene"]["terrain"]["rpvParams"]:
144                    self.rpvParams["rhoc"] = json_object["scene"]["terrain"]["rpvParams"]["rhoc"]
145        elif self.terr_BRDF_Type == "ART":
146            if "artParams" in json_object["scene"]["terrain"]:
147                if "snow_particle_size" in json_object["scene"]["terrain"]["artParams"]:
148                    self.artParams["snow_particle_size"] = json_object["scene"]["terrain"]["artParams"]["snow_particle_size"]
149                if "snow_pollution_content" in json_object["scene"]["terrain"]["artParams"]:
150                    self.artParams["snow_pollution_content"] = json_object["scene"]["terrain"]["artParams"]["snow_pollution_content"]
151
152        return self
153
154    def to_json_object(self):
155        json_obj = ""
156        if not self.get_sim().get_scene().get_sensor().thermal_radiation:
157            if self.terr_BRDF_Type == "Lambertian":
158                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
159                            "optical_scale": self.optical_scale,
160                            "extent_height": self.extent_height,
161                            "terr_file": self.terr_file,
162                            "terrain_type": self.terrain_type,
163                            "optical": self.optical,
164                            "extent_width": self.extent_width}
165            elif self.terr_BRDF_Type == "Land Albedo Map":
166                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
167                            "optical_scale": self.optical_scale,
168                            "extent_height": self.extent_height,
169                            "terr_file": self.terr_file,
170                            "terrain_type": self.terrain_type,
171                            "landalbedo": self.landalbedo,
172                            "extent_width": self.extent_width}
173            elif self.terr_BRDF_Type == "Soilspect":
174                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
175                            "optical_scale": self.optical_scale,
176                            "extent_height": self.extent_height,
177                            "terr_file": self.terr_file,
178                            "terrain_type": self.terrain_type,
179                            "soilSpectParams": self.soilSpectParams,
180                            "extent_width": self.extent_width}
181            elif self.terr_BRDF_Type == "RPV":
182                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
183                            "optical_scale": self.optical_scale,
184                            "extent_height": self.extent_height,
185                            "terr_file": self.terr_file,
186                            "terrain_type": self.terrain_type,
187                            "rpvParams": self.rpvParams,
188                            "extent_width": self.extent_width}
189            elif self.terr_BRDF_Type == "ART":
190                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
191                            "optical_scale": self.optical_scale,
192                            "extent_height": self.extent_height,
193                            "terr_file": self.terr_file,
194                            "terrain_type": self.terrain_type,
195                            "artParams": self.artParams,
196                            "extent_width": self.extent_width}
197        else:
198            json_obj = {"terrBRDFType": self.terr_BRDF_Type,
199                        "optical_scale": self.optical_scale,
200                        "extent_height": self.extent_height,
201                        "terr_file": self.terr_file,
202                        "temperature": self.temperature,
203                        "terrain_type": self.terrain_type,
204                        "optical": self.optical,
205                        "extent_width": self.extent_width}
206        return json_obj
class TERRAIN_BRDF_TYPE:
 9class TERRAIN_BRDF_TYPE:
10    LAMBERTIAN = "Lambertian"
11    LAND_ALBEDO_MAP = "Land Albedo Map"
12    SOILSPECT = "Soilspect"
13    RPV = "RPV"
14    ART = "ART"
LAMBERTIAN = 'Lambertian'
LAND_ALBEDO_MAP = 'Land Albedo Map'
SOILSPECT = 'Soilspect'
RPV = 'RPV'
ART = 'ART'
class TERRAIN_TYPE:
17class TERRAIN_TYPE:
18    PLANE = "PLANE"
19    RASTER = "RASTER"
20    MESH = "MESH"
PLANE = 'PLANE'
RASTER = 'RASTER'
MESH = 'MESH'
class Terrain(Element.Element):
 23class Terrain(Element):
 24
 25    def __init__(self):
 26        super().__init__()
 27        # terrain
 28        self.terr_BRDF_Type = TERRAIN_BRDF_TYPE.LAMBERTIAN
 29        self.optical_scale = 1
 30        self.extent_height = 100
 31        self.extent_width = 100
 32        self.terr_file = ""
 33        self.terrain_type = TERRAIN_TYPE.PLANE
 34        self.temperature = "T300"
 35
 36        # conditional properties
 37        self.optical = "dark_soil_mollisol"
 38        self.landalbedo = ""
 39        self.soilSpectParams = dict()
 40        self.rpvParams = dict()
 41        self.artParams = dict()
 42
 43    def set_extent_width(self, width):
 44        self.extent_width = width
 45
 46    def set_extent_height(self, height):
 47        self.extent_height = height
 48
 49    def get_extent_width(self):
 50        return self.extent_width
 51
 52    def get_extent_height(self):
 53        return self.extent_height
 54
 55    def set_terrain_type(self, terrain_type):
 56        self.terrain_type = terrain_type
 57
 58    def set_terrain_file(self, terrain_file):
 59        filename = os.path.basename(terrain_file)
 60        dist_dem_file = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
 61        if dist_dem_file != terrain_file:
 62            shutil.copy(terrain_file, dist_dem_file)
 63            hdr_file = os.path.join(terrain_file+".hdr")
 64            if os.path.exists(hdr_file):
 65                shutil.copy(hdr_file, os.path.join(dist_dem_file+".hdr"))
 66        self.terr_file = filename
 67
 68    def set_terr_brdf_type(self, brdf_type):
 69        self.terr_BRDF_Type = brdf_type
 70
 71    def get_terr_brdf_type(self):
 72        return self.terr_BRDF_Type
 73
 74    def get_optical(self):
 75        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
 76            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
 77            sys.exit()
 78        return self.optical
 79
 80    def set_optical(self, optical_name):
 81        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
 82            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
 83            sys.exit()
 84        self.optical = optical_name
 85
 86    def get_landalbedo_file(self):
 87        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
 88            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
 89            sys.exit()
 90        return self.landalbedo
 91
 92    def set_landalbedo_file(self, landalbedo_file):  # 需要复制文件
 93        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
 94            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
 95            sys.exit()
 96        filename = os.path.basename(landalbedo_file)
 97        dist_albedomap = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
 98        if dist_albedomap != landalbedo_file:
 99            shutil.copy(landalbedo_file, dist_albedomap)
100        landalbedo_file_header = landalbedo_file + ".hdr"
101        dist_albedomap_header = dist_albedomap+".hdr"
102        if os.path.exists(landalbedo_file_header) and landalbedo_file_header != dist_albedomap_header:
103            shutil.copy(landalbedo_file_header, dist_albedomap+".hdr")
104        self.landalbedo = filename
105
106    def init_terrain_from_json(self, json_object):
107        self.terr_BRDF_Type = json_object["scene"]["terrain"]["terrBRDFType"]
108        self.optical_scale = json_object["scene"]["terrain"]["optical_scale"]
109        self.extent_height = json_object["scene"]["terrain"]["extent_height"]
110        self.extent_width = json_object["scene"]["terrain"]["extent_width"]
111        self.terr_file = json_object["scene"]["terrain"]["terr_file"]
112        self.terrain_type = json_object["scene"]["terrain"]["terrain_type"]
113
114        if self.terr_BRDF_Type == "Lambertian":
115            if "optical" in json_object["scene"]["terrain"]:
116                self.optical = json_object["scene"]["terrain"]["optical"]
117        elif self.terr_BRDF_Type == "Land Albedo Map":
118            if "landalbedo" in json_object["scene"]["terrain"]:
119                self.landalbedo = json_object["scene"]["terrain"]["landalbedo"]
120        elif self.terr_BRDF_Type == "Soilspect":
121            if "soilSpectParams" in json_object["scene"]["terrain"]:
122                if "c3" in json_object["scene"]["terrain"]["soilSpectParams"]:
123                    self.soilSpectParams["c3"] = json_object["scene"]["terrain"]["soilSpectParams"]["c3"]
124                if "c4" in json_object["scene"]["terrain"]["soilSpectParams"]:
125                    self.soilSpectParams["c4"] = json_object["scene"]["terrain"]["soilSpectParams"]["c4"]
126                if "h1" in json_object["scene"]["terrain"]["soilSpectParams"]:
127                    self.soilSpectParams["h1"] = json_object["scene"]["terrain"]["soilSpectParams"]["h1"]
128                if "h2" in json_object["scene"]["terrain"]["soilSpectParams"]:
129                    self.soilSpectParams["h2"] = json_object["scene"]["terrain"]["soilSpectParams"]["h2"]
130                if "c1" in json_object["scene"]["terrain"]["soilSpectParams"]:
131                    self.soilSpectParams["c1"] = json_object["scene"]["terrain"]["soilSpectParams"]["c1"]
132                if "albedo" in json_object["scene"]["terrain"]["soilSpectParams"]:
133                    self.soilSpectParams["albedo"] = json_object["scene"]["terrain"]["soilSpectParams"]["albedo"]
134                if "c2" in json_object["scene"]["terrain"]["soilSpectParams"]:
135                    self.soilSpectParams["c2"] = json_object["scene"]["terrain"]["soilSpectParams"]["c2"]
136        elif self.terr_BRDF_Type == "RPV":
137            if "rpvParams" in json_object["scene"]["terrain"]:
138                if "rho0" in json_object["scene"]["terrain"]["rpvParams"]:
139                    self.rpvParams["rho0"] = json_object["scene"]["terrain"]["rpvParams"]["rho0"]
140                if "k" in json_object["scene"]["terrain"]["rpvParams"]:
141                    self.rpvParams["k"] = json_object["scene"]["terrain"]["rpvParams"]["k"]
142                if "THETA" in json_object["scene"]["terrain"]["rpvParams"]:
143                    self.rpvParams["THETA"] = json_object["scene"]["terrain"]["rpvParams"]["THETA"]
144                if "rhoc" in json_object["scene"]["terrain"]["rpvParams"]:
145                    self.rpvParams["rhoc"] = json_object["scene"]["terrain"]["rpvParams"]["rhoc"]
146        elif self.terr_BRDF_Type == "ART":
147            if "artParams" in json_object["scene"]["terrain"]:
148                if "snow_particle_size" in json_object["scene"]["terrain"]["artParams"]:
149                    self.artParams["snow_particle_size"] = json_object["scene"]["terrain"]["artParams"]["snow_particle_size"]
150                if "snow_pollution_content" in json_object["scene"]["terrain"]["artParams"]:
151                    self.artParams["snow_pollution_content"] = json_object["scene"]["terrain"]["artParams"]["snow_pollution_content"]
152
153        return self
154
155    def to_json_object(self):
156        json_obj = ""
157        if not self.get_sim().get_scene().get_sensor().thermal_radiation:
158            if self.terr_BRDF_Type == "Lambertian":
159                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
160                            "optical_scale": self.optical_scale,
161                            "extent_height": self.extent_height,
162                            "terr_file": self.terr_file,
163                            "terrain_type": self.terrain_type,
164                            "optical": self.optical,
165                            "extent_width": self.extent_width}
166            elif self.terr_BRDF_Type == "Land Albedo Map":
167                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
168                            "optical_scale": self.optical_scale,
169                            "extent_height": self.extent_height,
170                            "terr_file": self.terr_file,
171                            "terrain_type": self.terrain_type,
172                            "landalbedo": self.landalbedo,
173                            "extent_width": self.extent_width}
174            elif self.terr_BRDF_Type == "Soilspect":
175                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
176                            "optical_scale": self.optical_scale,
177                            "extent_height": self.extent_height,
178                            "terr_file": self.terr_file,
179                            "terrain_type": self.terrain_type,
180                            "soilSpectParams": self.soilSpectParams,
181                            "extent_width": self.extent_width}
182            elif self.terr_BRDF_Type == "RPV":
183                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
184                            "optical_scale": self.optical_scale,
185                            "extent_height": self.extent_height,
186                            "terr_file": self.terr_file,
187                            "terrain_type": self.terrain_type,
188                            "rpvParams": self.rpvParams,
189                            "extent_width": self.extent_width}
190            elif self.terr_BRDF_Type == "ART":
191                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
192                            "optical_scale": self.optical_scale,
193                            "extent_height": self.extent_height,
194                            "terr_file": self.terr_file,
195                            "terrain_type": self.terrain_type,
196                            "artParams": self.artParams,
197                            "extent_width": self.extent_width}
198        else:
199            json_obj = {"terrBRDFType": self.terr_BRDF_Type,
200                        "optical_scale": self.optical_scale,
201                        "extent_height": self.extent_height,
202                        "terr_file": self.terr_file,
203                        "temperature": self.temperature,
204                        "terrain_type": self.terrain_type,
205                        "optical": self.optical,
206                        "extent_width": self.extent_width}
207        return json_obj
terr_BRDF_Type
optical_scale
extent_height
extent_width
terr_file
terrain_type
temperature
optical
landalbedo
soilSpectParams
rpvParams
artParams
def set_extent_width(self, width):
43    def set_extent_width(self, width):
44        self.extent_width = width
def set_extent_height(self, height):
46    def set_extent_height(self, height):
47        self.extent_height = height
def get_extent_width(self):
49    def get_extent_width(self):
50        return self.extent_width
def get_extent_height(self):
52    def get_extent_height(self):
53        return self.extent_height
def set_terrain_type(self, terrain_type):
55    def set_terrain_type(self, terrain_type):
56        self.terrain_type = terrain_type
def set_terrain_file(self, terrain_file):
58    def set_terrain_file(self, terrain_file):
59        filename = os.path.basename(terrain_file)
60        dist_dem_file = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
61        if dist_dem_file != terrain_file:
62            shutil.copy(terrain_file, dist_dem_file)
63            hdr_file = os.path.join(terrain_file+".hdr")
64            if os.path.exists(hdr_file):
65                shutil.copy(hdr_file, os.path.join(dist_dem_file+".hdr"))
66        self.terr_file = filename
def set_terr_brdf_type(self, brdf_type):
68    def set_terr_brdf_type(self, brdf_type):
69        self.terr_BRDF_Type = brdf_type
def get_terr_brdf_type(self):
71    def get_terr_brdf_type(self):
72        return self.terr_BRDF_Type
def get_optical(self):
74    def get_optical(self):
75        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
76            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
77            sys.exit()
78        return self.optical
def set_optical(self, optical_name):
80    def set_optical(self, optical_name):
81        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAMBERTIAN:
82            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"optical\"")
83            sys.exit()
84        self.optical = optical_name
def get_landalbedo_file(self):
86    def get_landalbedo_file(self):
87        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
88            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
89            sys.exit()
90        return self.landalbedo
def set_landalbedo_file(self, landalbedo_file):
 92    def set_landalbedo_file(self, landalbedo_file):  # 需要复制文件
 93        if self.terr_BRDF_Type != TERRAIN_BRDF_TYPE.LAND_ALBEDO_MAP:
 94            print("Terrain Type: ", self.terr_BRDF_Type, "does not have property \"Land Albedo Map\"")
 95            sys.exit()
 96        filename = os.path.basename(landalbedo_file)
 97        dist_albedomap = os.path.join(self.get_sim().get_sim_dir(), "Parameters", filename)
 98        if dist_albedomap != landalbedo_file:
 99            shutil.copy(landalbedo_file, dist_albedomap)
100        landalbedo_file_header = landalbedo_file + ".hdr"
101        dist_albedomap_header = dist_albedomap+".hdr"
102        if os.path.exists(landalbedo_file_header) and landalbedo_file_header != dist_albedomap_header:
103            shutil.copy(landalbedo_file_header, dist_albedomap+".hdr")
104        self.landalbedo = filename
def init_terrain_from_json(self, json_object):
106    def init_terrain_from_json(self, json_object):
107        self.terr_BRDF_Type = json_object["scene"]["terrain"]["terrBRDFType"]
108        self.optical_scale = json_object["scene"]["terrain"]["optical_scale"]
109        self.extent_height = json_object["scene"]["terrain"]["extent_height"]
110        self.extent_width = json_object["scene"]["terrain"]["extent_width"]
111        self.terr_file = json_object["scene"]["terrain"]["terr_file"]
112        self.terrain_type = json_object["scene"]["terrain"]["terrain_type"]
113
114        if self.terr_BRDF_Type == "Lambertian":
115            if "optical" in json_object["scene"]["terrain"]:
116                self.optical = json_object["scene"]["terrain"]["optical"]
117        elif self.terr_BRDF_Type == "Land Albedo Map":
118            if "landalbedo" in json_object["scene"]["terrain"]:
119                self.landalbedo = json_object["scene"]["terrain"]["landalbedo"]
120        elif self.terr_BRDF_Type == "Soilspect":
121            if "soilSpectParams" in json_object["scene"]["terrain"]:
122                if "c3" in json_object["scene"]["terrain"]["soilSpectParams"]:
123                    self.soilSpectParams["c3"] = json_object["scene"]["terrain"]["soilSpectParams"]["c3"]
124                if "c4" in json_object["scene"]["terrain"]["soilSpectParams"]:
125                    self.soilSpectParams["c4"] = json_object["scene"]["terrain"]["soilSpectParams"]["c4"]
126                if "h1" in json_object["scene"]["terrain"]["soilSpectParams"]:
127                    self.soilSpectParams["h1"] = json_object["scene"]["terrain"]["soilSpectParams"]["h1"]
128                if "h2" in json_object["scene"]["terrain"]["soilSpectParams"]:
129                    self.soilSpectParams["h2"] = json_object["scene"]["terrain"]["soilSpectParams"]["h2"]
130                if "c1" in json_object["scene"]["terrain"]["soilSpectParams"]:
131                    self.soilSpectParams["c1"] = json_object["scene"]["terrain"]["soilSpectParams"]["c1"]
132                if "albedo" in json_object["scene"]["terrain"]["soilSpectParams"]:
133                    self.soilSpectParams["albedo"] = json_object["scene"]["terrain"]["soilSpectParams"]["albedo"]
134                if "c2" in json_object["scene"]["terrain"]["soilSpectParams"]:
135                    self.soilSpectParams["c2"] = json_object["scene"]["terrain"]["soilSpectParams"]["c2"]
136        elif self.terr_BRDF_Type == "RPV":
137            if "rpvParams" in json_object["scene"]["terrain"]:
138                if "rho0" in json_object["scene"]["terrain"]["rpvParams"]:
139                    self.rpvParams["rho0"] = json_object["scene"]["terrain"]["rpvParams"]["rho0"]
140                if "k" in json_object["scene"]["terrain"]["rpvParams"]:
141                    self.rpvParams["k"] = json_object["scene"]["terrain"]["rpvParams"]["k"]
142                if "THETA" in json_object["scene"]["terrain"]["rpvParams"]:
143                    self.rpvParams["THETA"] = json_object["scene"]["terrain"]["rpvParams"]["THETA"]
144                if "rhoc" in json_object["scene"]["terrain"]["rpvParams"]:
145                    self.rpvParams["rhoc"] = json_object["scene"]["terrain"]["rpvParams"]["rhoc"]
146        elif self.terr_BRDF_Type == "ART":
147            if "artParams" in json_object["scene"]["terrain"]:
148                if "snow_particle_size" in json_object["scene"]["terrain"]["artParams"]:
149                    self.artParams["snow_particle_size"] = json_object["scene"]["terrain"]["artParams"]["snow_particle_size"]
150                if "snow_pollution_content" in json_object["scene"]["terrain"]["artParams"]:
151                    self.artParams["snow_pollution_content"] = json_object["scene"]["terrain"]["artParams"]["snow_pollution_content"]
152
153        return self
def to_json_object(self):
155    def to_json_object(self):
156        json_obj = ""
157        if not self.get_sim().get_scene().get_sensor().thermal_radiation:
158            if self.terr_BRDF_Type == "Lambertian":
159                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
160                            "optical_scale": self.optical_scale,
161                            "extent_height": self.extent_height,
162                            "terr_file": self.terr_file,
163                            "terrain_type": self.terrain_type,
164                            "optical": self.optical,
165                            "extent_width": self.extent_width}
166            elif self.terr_BRDF_Type == "Land Albedo Map":
167                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
168                            "optical_scale": self.optical_scale,
169                            "extent_height": self.extent_height,
170                            "terr_file": self.terr_file,
171                            "terrain_type": self.terrain_type,
172                            "landalbedo": self.landalbedo,
173                            "extent_width": self.extent_width}
174            elif self.terr_BRDF_Type == "Soilspect":
175                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
176                            "optical_scale": self.optical_scale,
177                            "extent_height": self.extent_height,
178                            "terr_file": self.terr_file,
179                            "terrain_type": self.terrain_type,
180                            "soilSpectParams": self.soilSpectParams,
181                            "extent_width": self.extent_width}
182            elif self.terr_BRDF_Type == "RPV":
183                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
184                            "optical_scale": self.optical_scale,
185                            "extent_height": self.extent_height,
186                            "terr_file": self.terr_file,
187                            "terrain_type": self.terrain_type,
188                            "rpvParams": self.rpvParams,
189                            "extent_width": self.extent_width}
190            elif self.terr_BRDF_Type == "ART":
191                json_obj = {"terrBRDFType": self.terr_BRDF_Type,
192                            "optical_scale": self.optical_scale,
193                            "extent_height": self.extent_height,
194                            "terr_file": self.terr_file,
195                            "terrain_type": self.terrain_type,
196                            "artParams": self.artParams,
197                            "extent_width": self.extent_width}
198        else:
199            json_obj = {"terrBRDFType": self.terr_BRDF_Type,
200                        "optical_scale": self.optical_scale,
201                        "extent_height": self.extent_height,
202                        "terr_file": self.terr_file,
203                        "temperature": self.temperature,
204                        "terrain_type": self.terrain_type,
205                        "optical": self.optical,
206                        "extent_width": self.extent_width}
207        return json_obj
Inherited Members
Element.Element
set_sim
get_sim