Esempio n. 1
0
 def get_image_center_solar_angles(self):
     # vieAngles[0] = zenith vieAngles[1] = azimuth
     return (
         xml_tools.get_xml_float_value(
             self.root,
             "//Sun_Angles_List/Sun_Angles[@name='center']/ZENITH_ANGLE"),
         xml_tools.get_xml_float_value(
             self.root,
             "//Sun_Angles_List/Sun_Angles[@name='center']/AZIMUTH_ANGLE"))
 def get_upper_left_corner(self):
     # upperLeftCorner[0] = Long upperLeftCorner[1] = Lat
     return (xml_tools.get_xml_float_value(
         self.root,
         "//Geopositioning/Global_Geopositioning/Point[@name='upperLeft']/LON"
     ),
             xml_tools.get_xml_float_value(
                 self.root,
                 "//Geopositioning/Global_Geopositioning/Point[@name='upperLeft']/LAT"
             ))
 def get_lower_right_corner(self):
     # lowerRightCorner[0] = Long lowerRightCorner[1] = Lat
     return (xml_tools.get_xml_float_value(
         self.root,
         "//Geopositioning/Global_Geopositioning/Point[@name='lowerRight']/LON"
     ),
             xml_tools.get_xml_float_value(
                 self.root,
                 "//Geopositioning/Global_Geopositioning/Point[@name='lowerRight']/LAT"
             ))
Esempio n. 4
0
 def get_geopositioning_center(self):
     # lowerRightCorner[0] = Long lowerRightCorner[1] = Lat
     return (xml_tools.get_xml_float_value(
         self.root,
         "//Geoposition_Informations/Product_Geopositining/Point[@name='center']/LON"
     ),
             xml_tools.get_xml_float_value(
                 self.root,
                 "//Geoposition_Informations/Product_Geopositining/Point[@name='center']/LAT"
             ))
Esempio n. 5
0
 def get_image_center_viewing_angles(self, detector):
     # vieAngles[0] = zenith vieAngles[1] = azimuth
     return (
         xml_tools.get_xml_float_value(
             self.root,
             "//Viewing_Incidence_Angles_List[@detector_id='" + detector +
             "']/Viewing_Incidence_Angles[@name='center']/ZENITH_ANGLE"),
         xml_tools.get_xml_float_value(
             self.root,
             "//Viewing_Incidence_Angles_List[@detector_id='" + detector +
             "']/Viewing_Incidence_Angles[@name='center']/AZIMUTH_ANGLE"))
 def get_mean_viewing_angles(self):
     # vieAngles[0] = zenith vieAngles[1] = azimuth
     if xml_tools.get_only_value(
             self.root,
             "//Incidence_Angles/ZENITH_ANGLE[@unit='deg']",
             check=True) is not None:
         return (xml_tools.get_xml_float_value(
             self.root, "//Incidence_Angles/ZENITH_ANGLE[@unit='deg']"),
                 xml_tools.get_xml_float_value(
                     self.root,
                     "//Incidence_Angles/AZIMUTH_ANGLE[@unit='deg']"))
     else:
         return 0, 0
Esempio n. 7
0
 def get_reflectance_quantification_value(self):
     """
     GetReflectance_Quantification_Value
     :return: double
     """
     return xml_tools.get_xml_float_value(self.root,
                                          REFLECTANCE_QUANTIF_VALUE)
 def get_no_data_value_as_double(self):
     """
     GetResolution
     :return:
     """
     return xml_tools.get_xml_float_value(self.root, NO_DATA_VALUE)
 def get_vap_quantification_value(self):
     """
     GetVAPQuantificationValue
     :return:
     """
     return xml_tools.get_xml_float_value(self.root, VAP_QUANTIF_VALUE)
 def get_aot_quantification_value(self):
     """
     GetAOTQuantificationValue
     :return:
     """
     return xml_tools.get_xml_float_value(self.root, AOT_QUANTIF_VALUE)
Esempio n. 11
0
 def get_useful_image_center_view_angle_zenith(self, index):
     localpath = "/Earth_Explorer_Header/Variable_Header/Specific_Product_Header/Product_Information/" \
                 "List_of_Viewing_Angles/Viewing_Angles[@sn='" + str(index) + "']/Useful_Image/Image_Center/Zenith"
     return get_xml_float_value(self.root, localpath)
Esempio n. 12
0
 def get_useful_image_lower_right_corner_view_angle_azimuth(self, index):
     localpath = "/Earth_Explorer_Header/Variable_Header/Specific_Product_Header/Product_Information/" \
                 "List_of_Viewing_Angles/Viewing_Angles[@sn='" + str(index) + "']/Useful_Image/Lower_Right_Corner/Azimuth"
     return get_xml_float_value(self.root, localpath)
Esempio n. 13
0
 def get_useful_image_geo_coverage_center_corner_lat(self):
     localpath = "/Earth_Explorer_Header/Variable_Header/Specific_Product_Header/Product_Information/Useful_Image_Geo_Coverage/Center/Lat"
     return get_xml_float_value(self.root, localpath)
Esempio n. 14
0
 def get_useful_image_image_center_solar_angle_azimuth(self):
     localpath = "/Earth_Explorer_Header/Variable_Header/Specific_Product_Header/Product_Information/Solar_Angles/Useful_Image/Image_Center/Azimuth"
     return get_xml_float_value(self.root, localpath)
Esempio n. 15
0
 def get_product_lower_left_corner_view_angle_zenith(self, index):
     localpath = "/Earth_Explorer_Header/Variable_Header/Specific_Product_Header/Product_Information/" \
                 "List_of_Viewing_Angles/Viewing_Angles[@sn='" + str(index) + "']/Product/Lower_Left_Corner/Zenith"
     return get_xml_float_value(self.root, localpath)
 def get_mean_solar_angles(self):
     # solAngles[0] = zenith solAngles[1] = azimuth
     return (xml_tools.get_xml_float_value(
         self.root, "//Sun_Angles/ZENITH_ANGLE[@unit='deg']"),
             xml_tools.get_xml_float_value(
                 self.root, "//Sun_Angles/AZIMUTH_ANGLE[@unit='deg']"))
    def initialize(self, product_filename, validate=False, schema_path=None):
        LOGGER.info("Start Venus L1 Initialize on product " + product_filename)
        l_hdrfilename = os.path.splitext(product_filename)[0] + ".HDR"
        l_CanLoad = xml_tools.can_load_file(l_hdrfilename)
        if not l_CanLoad:
            return False

        rootNode = xml_tools.get_root_xml(l_hdrfilename, deannotate=True)
        self.Satellite = xml_tools.get_xml_string_value(rootNode, "//Mission")
        if not self._plugin.is_valid_with_satellite(self.Satellite):
            LOGGER.debug("The L1 product '" + product_filename + "' with satellite '" + self.Satellite + "' is not a VENUS product !")
        self.SatelliteID = self.Satellite.upper()
        self.PluginName = self._plugin.PluginName
        self.Prefix = "VE"
        l_File_Type = xml_tools.get_xml_string_value(rootNode, "//File_Type")
        filenamekey = l_File_Type.split("_")
        self.FileCategory = filenamekey[0]
        self.LevelType = filenamekey[1]
        self.FileClass = xml_tools.get_xml_string_value(rootNode, "//File_Class")
        self.Site = xml_tools.get_xml_string_value(rootNode, "//Instance_Id/Nick_Name")
        self.ReferenceSiteDefinitionId = xml_tools.get_xml_string_value(rootNode, "//Reference_SiteDefinition_Id")
        l_AcquisitionDateTime = xml_tools.get_xml_string_value(rootNode, "//Product_Information/Acquisition_Date_Time")
        self.ProductDate = date_utils.get_datetime_from_utc(l_AcquisitionDateTime)
        self.ProductDateStr = self.ProductDate.strftime('%Y%m%d')
        LOGGER.debug("Product Date: " + self.ProductDateStr)

        self.ProductId = xml_tools.get_xml_string_value(rootNode, "//Fixed_Header/File_Name")


        genDate = xml_tools.get_xml_string_value(rootNode, "//Processing_Information/Date_Time")
        genDate = genDate[4:]
        if genDate[-1] != 'Z':
            genDate = genDate + 'Z'
        self.GenerationDateStr = genDate
        self.AcquisitionStart = l_AcquisitionDateTime[4:]

        self.OrbitNumber = xml_tools.get_xml_string_value(rootNode, "//Product_Information/Acquisition_Orbit_Number")
        self.SpectralContent = "XS"

        self.FilenamesProvider.initialize(l_hdrfilename, validate=validate, schema_path=schema_path)
        self.HeaderFilename = self.FilenamesProvider.m_hdrfilename
        self.SOLImageFileName = self.FilenamesProvider.m_SOLImageFileName
        self.SOLHeaderFileName = self.FilenamesProvider.m_SOLHeaderFileName
        self.VIEImageFileName = self.FilenamesProvider.m_VIEImageFileName
        self.VIEHeaderFileName = self.FilenamesProvider.m_VIEHeaderFileName

        self.HeaderHandler = VenusL1HeaderImageEarthExplorerXMLFileHandler(l_hdrfilename)
        # Estimation of the coordinate of the central point
        self.CenterCorner.longitude = self.HeaderHandler.get_useful_image_geo_coverage_center_corner_long()
        self.CenterCorner.latitude = self.HeaderHandler.get_useful_image_geo_coverage_center_corner_lat()
        self.CenterCorner.column = self.HeaderHandler.get_useful_image_geo_coverage_center_corner_column()
        self.CenterCorner.line = self.HeaderHandler.get_useful_image_geo_coverage_center_corner_line()

        # Initialize the Validity Start/Stop
        self.UTCValidityStart = l_AcquisitionDateTime
        self.UTCValidityStop = l_AcquisitionDateTime
        # Initialize the Viewing angles for each detectors (Zenith and Azimuth)
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution = []
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution = []

        l_meanViewingZenith = 0.0
        l_meanViewingAzimuth = 0.0
        l_count = 0.0
        l_BandsDefinitions = self._plugin.BandsDefinitions
        for det in l_BandsDefinitions.DetectorMap:
            l_Zenith = self.HeaderHandler.get_useful_image_center_view_angle_zenith(det)
            l_Azimuth = self.HeaderHandler.get_useful_image_center_view_angle_azimuth(det)
            l_meanViewingZenith += l_Zenith
            l_meanViewingAzimuth += l_Azimuth
            l_count += 1.0
            self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(str(l_Zenith))
            self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(str(l_Azimuth))
            self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append(
              { "incidence_zenith_angle": str(l_Zenith),
                "incidence_azimuth_angle": str(l_Azimuth)
              })

        self.ViewingAngle = {
            "incidence_zenith_angle": str(l_meanViewingZenith / l_count),
            "incidence_azimuth_angle": str(l_meanViewingAzimuth / l_count)
            }

        # Fill the L2 resolution angles
        self.ListOfViewingAnglesPerBandAtL2Resolution = self.ListOfViewingAnglesPerBandAtL2CoarseResolution
        # Solar Angles
        self.SolarAngle = {
            "sun_zenith_angle": self.HeaderHandler.get_useful_image_image_center_solar_angle_zenith(),
            "sun_azimuth_angle": self.HeaderHandler.get_useful_image_image_center_solar_angle_azimuth()
        }

        # Detect pixel size and product size
        originX = xml_tools.get_xml_float_value(rootNode, "//Geo_Referencing_Information/Product_Coverage/Cartographic/Upper_Left_Corner/X")
        originY = xml_tools.get_xml_float_value(rootNode, "//Geo_Referencing_Information/Product_Coverage/Cartographic/Upper_Left_Corner/Y")
        pixSizeX = xml_tools.get_xml_float_value(rootNode, "//Product_Sampling/By_Column")
        pixSizeY = xml_tools.get_xml_float_value(rootNode, "//Product_Sampling/By_Line")
        nbCol = xml_tools.get_xml_int_value(rootNode, "//Image_Information/Size/Columns")
        nbRow = xml_tools.get_xml_int_value(rootNode, "//Image_Information/Size/Lines")
        gridColStep = (nbCol - 1.0) * pixSizeX
        gridRowStep = (nbRow - 1.0) * pixSizeY

        gridColStepStr = f"{gridColStep:.1f}"
        gridRowStepStr = f"{gridRowStep:.1f}"
        
        # Solar angle grid
        ula = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Upper_Left_Corner/Azimuth")
        ulz = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Upper_Left_Corner/Zenith")
        ura = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Upper_Right_Corner/Azimuth")
        urz = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Upper_Right_Corner/Zenith")
        lla = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Lower_Left_Corner/Azimuth")
        llz = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Lower_Left_Corner/Zenith")
        lra = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Lower_Right_Corner/Azimuth")
        lrz = xml_tools.get_xml_string_value(rootNode, "//Solar_Angles/Product/Lower_Right_Corner/Zenith")
        self.SolarAngleGrid["StepUnit"] = "m"
        self.SolarAngleGrid["ColStep"] = gridColStepStr
        self.SolarAngleGrid["RowStep"] = gridRowStepStr
        self.SolarAngleGrid["Azimuth"] = [ula+' '+ura, lla+' '+lra]
        self.SolarAngleGrid["Zenith"] = [ulz+' '+urz, llz+' '+lrz]
        
        # Viewing angle grids
        detectors = [1,2,3,4]
        self.ViewingAngleGrids = []
        l_pathView = "//List_of_Viewing_Angles/Viewing_Angles[@sn='{}']/Product/{}"
        for det in detectors:
            ula = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Upper_Left_Corner/Azimuth"))
            ulz = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Upper_Left_Corner/Zenith"))
            ura = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Upper_Right_Corner/Azimuth"))
            urz = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Upper_Right_Corner/Zenith"))
            lla = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Lower_Left_Corner/Azimuth"))
            llz = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Lower_Left_Corner/Zenith"))
            lra = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Lower_Right_Corner/Azimuth"))
            lrz = xml_tools.get_xml_string_value(rootNode, l_pathView.format(det,"Lower_Right_Corner/Zenith"))
            self.ViewingAngleGrids.append({
                "StepUnit":"m",
                "ColStep":gridColStepStr,
                "RowStep":gridRowStepStr,
                "Detector":str(det),
                "Azimuth":[ula+' '+ura, lla+' '+lra],
                "Zenith":[ulz+' '+urz, llz+' '+lrz]
                })

        # Set Area by resolution
        curArea = Area()
        curArea.origin = (
            f"{originX:.1f}",
            f"{originY:.1f}")
        curArea.spacing = (
            f"{pixSizeX:.1f}",
            f"{-pixSizeY:.1f}")
        curArea.size = (
            str(nbCol),
            str(nbRow))
        self.AreaByResolution = [curArea]

        # Gather spectral information
        l_resol = l_BandsDefinitions.ListOfL1Resolution[0]
        l_pathAk = "//List_of_Aks/Ak[@sk='{}']"
        l_pathPolarCoef = "//List_of_Polarization_Coefficients/Polarization_Coefficient[@sk='{}']"
        l_pathWavelenghCentral = "//List_of_Band_Central_Wavelength/Band_Central_Wavelength[@sk='{}']"
        self.SpectralInfo = []
        for b, bidx in l_BandsDefinitions.L1BandMap.items():
            bcode = l_BandsDefinitions.L1ListOfBandsMap[l_resol][bidx]
            self.SpectralInfo.append({
                "Band":b.replace("B0", "B"),
                "Ak":xml_tools.get_xml_string_value(rootNode,l_pathAk.format(bcode)) ,
                "PolarizationCoefficient":xml_tools.get_xml_string_value(rootNode,l_pathPolarCoef.format(bcode)),
                "WavelengthCentral": xml_tools.get_xml_string_value(rootNode,l_pathWavelenghCentral.format(bcode))
                })

        # 4.2: New
        # Set the L1 no data value
        self.L1NoData = self.HeaderHandler.get_no_data_value_as_int()
        # Set the reflectance quantification value
        self.ReflectanceQuantification = self.HeaderHandler.get_reflectance_quantification_value()
        # Computes the real value of the L1 NoData
        self.RealL1NoData = self.L1NoData * self.ReflectanceQuantification

        return True