示例#1
0
 def test_get_date_pdv_formated_UTC(self):
     # Date formated:
     # Case1: <PRODUCTION_DATE>2014-12-17T09:36:57.0</PRODUCTION_DATE>
     # or
     # Case2: <PRODUCTION_DATE>2014-12-17T09:36:57</PRODUCTION_DATE>
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_date_pdv_formated_utc())
示例#2
0
 def test_get_string_value_of_L1C_product(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     list_of_key_missing_in_L1C = [
         'SunTooLowMaskFilename', 'DEMInformationMaximum',
         'ProcessingFlagsAndModesCAMSProcessing', 'DEMInformationAverage',
         'DEMInformationMinimum', 'AOT_Nodata_Value',
         'PrivateDirectoryFilename',
         'AerosolOpticalThicknessQuantificationValue', 'VAP_Nodata_Value',
         'JobProcessingInformationsFileFilename',
         'AerosolOpticalThicknessQuantificationValueAsString',
         'ProcessingFlagsAndModesFileType',
         'WaterVaporContentQuantificationValueAsString',
         'DEMInformationStandardDeviation', 'TopographyShadowMaskFilename',
         'WaterMaskFilename', 'AOTInterpolationMaskFilename',
         'SnowMaskFilename', 'Instrument', 'EdgeMaskFilename',
         'ProcessingFlagsAndModesProcessingAdjacencyEffectsAndSlopeCorrection',
         'ProcessingFlagsAndModesProcessingMode',
         'HiddenSurfaceMaskFilename',
         'WaterVaporContentQuantificationValue',
         'ProcessingFlagsAndModesQualityCheck', 'TangentSunMaskFilename',
         'ProcessingFlagsAndModesValidityFlag',
         'ProcessingFlagsAndModesCirrusCorrection'
     ]
     for k in list(MUSCATE_HANDLER_XPATH.keys()):
         if k not in list_of_key_missing_in_L1C:
             LOGGER.debug(self.maja_object.get_string_value_of(k))
 def is_a_muscate_by_checking_the_satellite(p_filename, plugin_base):
     LOGGER.debug("File detected with the filenaming <" + p_filename +
                  ">. Check with the field 'Platform' in the xml file...")
     lXMLHandler = MuscateXMLFileHandler(p_filename)
     LOGGER.debug("Is the filename " + p_filename +
                  " a 'muscate' L1 product compatible with the plugin '" +
                  plugin_base.PluginName + "' ??")
     if plugin_base.is_valid_with_satellite(
             lXMLHandler.get_string_value_of("Platform")):
         LOGGER.debug(
             "The filename " + p_filename +
             " is a 'muscate' L1 product compatible with the plugin '" +
             plugin_base.PluginName + "'!")
         return True
     return False
示例#4
0
    def test_save_view_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        view_angle_col_step = int(
            self.maja_object.get_string_value_of("SunAngleColStep"))
        view_angle_row_step = -1 * int(
            self.maja_object.get_string_value_of("SunAngleRowStep"))
        # ATTENTION : * -1 for compatibility negative spacing

        l_ListOfTOABandCode = self.maja_object.get_list_of_band_code(
        )  # ListOfStrings
        for l_band in l_ListOfTOABandCode:
            # Get the list of detectors (index)
            l_ListOfZone = self.maja_object.get_list_of_zones(l_band)
            LOGGER.debug("List of zone : ")
            LOGGER.debug(l_ListOfZone)
            # Get the list of viewing angles in the header file of the tile
            l_zenithVieAngles = self.maja_object.get_viewing_zenithal_angles(
                l_band)
            l_azimuthVieAngles = self.maja_object.get_viewing_azimuthal_angles(
                l_band)

            if len(l_zenithVieAngles) != len(l_azimuthVieAngles):
                raise Exception(
                    "The number of detector for viewing zenithal angles and viewing azimuthal angles is different or null !"
                )

            for detId in range(len(l_ListOfZone)):
                det = l_ListOfZone[detId]
                LOGGER.debug(("ZenithViewingAngles for band " + l_band +
                              " and det " + det + " ,  nb values: " +
                              str(len(l_zenithVieAngles[detId]))))
                LOGGER.debug(l_zenithVieAngles[detId])
                LOGGER.debug(
                    ("AzimuthViewingAngles " + l_band + " and det " + det +
                     " nb values: " + str(len(l_azimuthVieAngles[detId]))))
                LOGGER.debug(l_azimuthVieAngles[detId])
                output_filename = "/tmp/internal_angles_test_{}_{}.xml".format(
                    l_band, det)
                LOGGER.debug(("Angles output_filename : %s", output_filename))
                writer = MajaInternalXmlInputAngles(l_zenithVieAngles[detId],
                                                    l_azimuthVieAngles[detId],
                                                    view_angle_col_step,
                                                    view_angle_row_step,
                                                    output_filename)
                writer.write()
                self.assertTrue(os.path.exists(output_filename),
                                "File does not exist " + output_filename)
示例#5
0
    def test_save_sun_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        sun_angle_col_step = int(
            self.maja_object.get_string_value_of("SunAngleColStep"))
        sun_angle_row_step = -1 * int(
            self.maja_object.get_string_value_of("SunAngleRowStep"))
        # ATTENTION : * -1 for compatibility negative spacing

        l_zenithSolarAngles = self.maja_object.get_sun_zenithal_angles()
        l_azimuthSolarAngles = self.maja_object.get_sun_azimuthal_angles()
        LOGGER.debug(
            ("ZenithSolarAngles nb values: " + str(len(l_zenithSolarAngles))))
        LOGGER.debug(("AzimuthSolarAngles nb values: " +
                      str(len(l_azimuthSolarAngles))))
        LOGGER.debug(("Angles output_filename : %s", self.output_filename))
        writer = MajaInternalXmlInputAngles(l_zenithSolarAngles,
                                            l_azimuthSolarAngles,
                                            sun_angle_col_step,
                                            sun_angle_row_step,
                                            self.output_filename)
        writer.write()
        self.assertTrue(os.path.exists(self.output_filename),
                        "File does not exist")
    def read_with_plugin_base(self, p_filename, p_EnableReadingPublicData,
                              app_handler, p_PluginBase):
        """

        :param p_filename:
        :param p_EnableReadingPublicData: bool
        :param p_PluginBase: PluginBase::Pointer
        :return:
        """
        working_dir = app_handler.get_directory_manager(
        ).get_temporary_directory("L2Read_", do_always_remove=True)
        l_PublicDirectory = os.path.dirname(p_filename)
        # Init xml handler
        l_L2XMLHandler = MuscateXMLFileHandler(p_filename)
        # Do caching ?
        caching = app_handler.get_user_conf().get_Computing().get_Caching(
        ).get_EnableCachingConvertReflectanceData()
        # ex: l_L2XMLHandler->GetQuantificationValue() : 1000
        l_ReflectanceQuantificationValue = 1. / float(
            l_L2XMLHandler.get_string_value_of("QuantificationValue"))
        l_JpiFilename = os.path.join(
            l_PublicDirectory,
            l_L2XMLHandler.get_string_value_of(
                "JobProcessingInformationsFileFilename"))
        l_JPIL2XMLHandler = MuscateXMLFileHandler(l_JpiFilename)
        self._m_WriteFRE = bool(
            l_JPIL2XMLHandler.get_string_value_of(
                "ProcessingFlagsAndModesProcessingAdjacencyEffectsAndSlopeCorrection"
            ))
        LOGGER.debug("m_WriteFRE= " + str(self._m_WriteFRE))
        # ****  PUBLIC  DATA      *************************************************************************************
        if p_EnableReadingPublicData:
            self.muscate_read_public_images(l_L2XMLHandler, p_PluginBase,
                                            working_dir)
        # ****  PRIVATE  DATA     *************************************************************************************

        self.read_private_images(self.L2PrivateImageFilenamesProvider,
                                 l_ReflectanceQuantificationValue,
                                 p_PluginBase, working_dir)
示例#7
0
 def test_get_map_list_of_detector_footprint_image_filenames(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.
                  get_map_list_of_detector_footprint_image_filenames())
示例#8
0
 def test_get_list_of_defective_pixel_image_filenames(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(
         self.maja_object.get_list_of_defective_pixel_image_filenames())
示例#9
0
 def test_get_L1_DTF_image_index(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_l1_dtf_image_index(1, "10"))
示例#10
0
 def test_get_list_of_zones(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_list_of_zones("B1"))
示例#11
0
 def test_get_L1_NDT_image_index(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_l1_ndt_image_index(1))
示例#12
0
 def test_get_lower_left_corner(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_lower_left_corner())
示例#13
0
 def test_save_to_file(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
    def muscate_initialize(self,
                           product_filename,
                           plugin_base,
                           validate=False,
                           schema_path=None):
        # Initialize the Image filename provider
        if not MajaMuscateL1ImageInformations.is_a_muscate_by_checking_the_filename(
                product_filename):
            LOGGER.debug("The filename <" + product_filename +
                         "> is not an 'muscate' L1 header file.")
            return False
        if not MajaMuscateL1ImageInformations.is_a_muscate_by_checking_the_satellite(
                product_filename, plugin_base):
            LOGGER.debug(
                "The filename <" + product_filename +
                "> is not an 'muscate' L1 header file (by reading platform in the xml file)."
            )
            return False
        # Init XML handler
        lHandler = MuscateXMLFileHandler(product_filename,
                                         validate=validate,
                                         schema_path=schema_path)
        # Store the satellite
        self.Satellite = lHandler.get_string_value_of("Platform")
        self.SatelliteID = self.Satellite.upper().replace("-", "")
        # Store the plugin name
        self.PluginName = plugin_base.PluginName
        self.ProductFileName = product_filename

        self.FileCategory = plugin_base.ShortFileType  # LSC
        self.LevelType = "L1VALD"
        self.Prefix = self.Satellite
        self.FileClass = "TEST"  # LANDSAT5-TM-XSTH...
        self.Site = lHandler.get_string_value_of("ZoneGeo")
        self.ProductDateStr = lHandler.get_acquisition_date_formated_yyyymmdd(
        )  # YYYYMMDD
        # LANDSAT5-TM-XSTH_20100118-103000-000_L1C_EU93066200A00B_C_V1-0
        self.ProductId = lHandler.get_string_value_of("ProductId")
        self.ProductVersion = lHandler.get_string_value_of("ProductVersion")
        l_DatePDV = lHandler.get_date_pdv_formated_utc(
        )  # UTC=2010-01-18T12:00:00

        self.ProductDate = date_utils.get_datetime_from_utc(l_DatePDV)

        self.GenerationDateStr = lHandler.get_string_value_of("ProductionDate")

        self.AcquisitionStart = lHandler.get_string_value_of("AcquisitionDate")

        self.OrbitNumber = lHandler.get_string_value_of("OrbitNumber")

        self.ReferenceSiteDefinitionId = "UNKNOWN"

        self.HeaderFilename = product_filename
        self.HeaderHandler = lHandler

        if xml_tools.get_only_value(lHandler.root,
                                    "//Product_Characteristics/INSTRUMENT",
                                    check=True) is not None:
            self.Instrument = lHandler.get_string_value_of("Instrument")

        if xml_tools.get_only_value(
                lHandler.root,
                "//Product_Characteristics/SPECTRAL_CONTENT",
                check=True) is not None:
            self.SpectralContent = lHandler.get_string_value_of(
                "SpectralContent").replace("+", "")

        # VENUS specification
        # Store the VIE and SOL filenames (DATA and Headers) to copy in the L2 product
        self.SOLHeaderFileName = ""
        self.SOLImageFileName = ""
        self.VIEHeaderFileName = ""
        self.VIEImageFileName = ""
        #         Initialize the parameters necessary for the core of the algorithms of MACCS
        # Get longitude and latitude coordinates of the product
        ulc = lHandler.get_upper_left_corner()
        lrc = lHandler.get_lower_right_corner()
        # Estimation of the coordinate of the central point
        center = lHandler.get_center()

        #l_Corner.Longitude = ulc[0] + (lrc[0] - ulc[0]) / 2.
        #l_Corner.Latitude = ulc[1] + (lrc[1] - ulc[1]) / 2.
        self.CenterCorner.longitude = center[0]
        self.CenterCorner.latitude = center[1]
        self.CenterCorner.column = 0
        self.CenterCorner.line = 0
        # Initialize the Validity Start/Stop
        l_UTCValidity = date_utils.get_utc_from_datetime(self.ProductDate)
        if l_UTCValidity.endswith('.000Z'):
            l_UTCValidity = l_UTCValidity[:-5]
        self.UTCValidityStart = l_UTCValidity
        self.UTCValidityStop = l_UTCValidity

        # Get the list of bands in a L2 product
        l_BandsDefinitions = plugin_base.BandsDefinitions

        l_ListOfBandsL2Coarse = l_BandsDefinitions.get_list_of_band_id_in_l2_coarse(
        )
        l_NbBandsL2Coarse = len(l_ListOfBandsL2Coarse)

        LOGGER.debug(
            "l_BandsDefinitions->GetListOfBandCodeInL2Coarse -> l_NbBandsL2Coarse: "
            + str(l_NbBandsL2Coarse))
        LOGGER.debug(
            "MuscateXmllHandler->GetListOfBands      -> l_NbBands                : "
            + str(len(lHandler.get_list_of_bands())))

        self.ListOfViewingAnglesPerBandAtL2Resolution = []
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution = []
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution = []
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution = []

        # Initialize the Viewing angles for each detectors (Zenith and Azimuth)
        # Read the constants values from the Header Envi file name
        # The angles must be in degree
        if plugin_base.WideFieldSensor:
            # Initialize the Viewing angles for each detectors (Zenith and Azimuth)
            l_MeanViewingZenithalAngles = lHandler.get_mean_viewing_zenithal_angles(
            )
            l_MeanViewingAzimuthalAngles = lHandler.get_mean_viewing_azimuthal_angles(
            )
            self.ViewingAngle = {
                "incidence_zenith_angle":
                str(statistics.mean(l_MeanViewingZenithalAngles)),
                "incidence_azimuth_angle":
                str(statistics.mean(l_MeanViewingAzimuthalAngles))
            }

            # For each bands for EnviProduct
            for bd in range(0, len(l_ListOfBandsL2Coarse)):
                angles = {
                    "incidence_zenith_angle":
                    str(l_MeanViewingZenithalAngles[bd]),
                    "incidence_azimuth_angle":
                    str(l_MeanViewingAzimuthalAngles[bd])
                }
                self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append(
                    angles)
                self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
                    str(angles["incidence_zenith_angle"]))
                self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
                    str(angles["incidence_azimuth_angle"]))
        else:
            lViewingAngles = lHandler.get_mean_viewing_angles()
            l_ViewAngleZenith = lViewingAngles[0]
            l_ViewAngleAzimuth = lViewingAngles[1]
            self.ViewingAngle = {
                "incidence_zenith_angle": str(l_ViewAngleZenith),
                "incidence_azimuth_angle": str(l_ViewAngleAzimuth)
            }

            # For each bands for EnviProduct
            for bd in l_ListOfBandsL2Coarse:
                angles = {
                    "incidence_zenith_angle": str(l_ViewAngleZenith),
                    "incidence_azimuth_angle": str(l_ViewAngleAzimuth)
                }
                self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append(
                    angles)
                self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
                    str(angles["incidence_zenith_angle"]))
                self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
                    str(angles["incidence_azimuth_angle"]))

        # Fill the L2 resolution angles
        l_nbRes = len(l_BandsDefinitions.ListOfL2Resolution)
        for r in range(0, l_nbRes):
            l_res = l_BandsDefinitions.ListOfL2Resolution[r]
            l_l2bandcodes = l_BandsDefinitions.get_list_of_l2_band_code(l_res)
            l_l2bandidx = [
                l_BandsDefinitions.get_band_id_in_l2_coarse(b)
                for b in l_l2bandcodes
            ]
            for b in l_l2bandidx:
                self.ListOfViewingAnglesPerBandAtL2Resolution.append(
                    self.ListOfViewingAnglesPerBandAtL2CoarseResolution[b])

        # Solar Angles
        lSolarAngles = lHandler.get_mean_solar_angles()
        self.SolarAngle = {
            "sun_zenith_angle": lSolarAngles[0],
            "sun_azimuth_angle": lSolarAngles[1]
        }

        if xml_tools.get_only_value(lHandler.root,
                                    "//Angles_Grids_List/Sun_Angles_Grids",
                                    check=True) is not None:
            self.SolarAngleGrid["StepUnit"] = xml_tools.get_attribute(
                lHandler.root, "//Angles_Grids_List/Sun_Angles_Grids/Zenith",
                "step_unit")
            self.SolarAngleGrid["ColStep"] = lHandler.get_string_value_of(
                "SunAngleColStep")
            self.SolarAngleGrid["RowStep"] = lHandler.get_string_value_of(
                "SunAngleRowStep")
            self.SolarAngleGrid["Azimuth"] = lHandler.get_sun_azimuthal_angles(
            )
            self.SolarAngleGrid["Zenith"] = lHandler.get_sun_zenithal_angles()

        # Viewing angle grids
        self.ViewingAngleGrids = []
        if len(
                xml_tools.get_all_values(
                    lHandler.root,
                    "//Angles_Grids_List/Viewing_Incidence_Angles_Grids_List/Band_Viewing_Incidence_Angles_Grids_List"
                )):
            if lHandler.has_per_band_angles():
                for bn, bandid in l_BandsDefinitions.L2CoarseBandMap.items():
                    zonelist = lHandler.get_list_of_zones(bn)
                    zenith_values = lHandler.get_viewing_zenithal_angles(bn)
                    azimuth_values = lHandler.get_viewing_azimuthal_angles(bn)
                    LOGGER.debug("Viewing Angle grid for band " + str(bn))
                    for d, det in enumerate(zonelist):
                        self.ViewingAngleGrids.append({
                            "StepUnit":
                            lHandler.get_viewing_grid_step_unit(bn, det),
                            "ColStep":
                            lHandler.get_viewing_grid_col_step(bn, det),
                            "RowStep":
                            lHandler.get_viewing_grid_row_step(bn, det),
                            "Band":
                            str(bandid),
                            "Detector":
                            det.lstrip('0'),
                            "Azimuth":
                            azimuth_values[d],
                            "Zenith":
                            zenith_values[d]
                        })
            else:
                zonelist = lHandler.get_list_of_zones("dummy")
                for det in zonelist:
                    LOGGER.debug("Viewing Angle grid for det " + det)
                    self.ViewingAngleGrids.append({
                        "StepUnit":
                        lHandler.get_viewing_grid_step_unit(bandid=None,
                                                            det=det),
                        "ColStep":
                        lHandler.get_viewing_grid_col_step(bandid=None,
                                                           det=det),
                        "RowStep":
                        lHandler.get_viewing_grid_row_step(bandid=None,
                                                           det=det),
                        "Detector":
                        det.lstrip('0'),
                        "Azimuth":
                        lHandler.get_viewing_azimuthal_angles(det)[0],
                        "Zenith":
                        lHandler.get_viewing_zenithal_angles(det)[0]
                    })

        # Area by resolution
        self.AreaByResolution = []
        l_grpSuffixes = l_BandsDefinitions.ListOfL2Resolution
        if len(l_grpSuffixes) == 1:
            l_grpSuffixes = ["XS"]
        for res in l_grpSuffixes:
            l_path_group_geo = "//Group_Geopositioning_List/Group_Geopositioning[@group_id='{}']/{}"
            curArea = Area()
            curArea.origin = (xml_tools.get_xml_string_value(
                lHandler.root, l_path_group_geo.format(res, "ULX")),
                              xml_tools.get_xml_string_value(
                                  lHandler.root,
                                  l_path_group_geo.format(res, "ULY")))
            curArea.spacing = (xml_tools.get_xml_string_value(
                lHandler.root, l_path_group_geo.format(res, "XDIM")),
                               xml_tools.get_xml_string_value(
                                   lHandler.root,
                                   l_path_group_geo.format(res, "YDIM")))
            curArea.size = (xml_tools.get_xml_string_value(
                lHandler.root, l_path_group_geo.format(res, "NCOLS")),
                            xml_tools.get_xml_string_value(
                                lHandler.root,
                                l_path_group_geo.format(res, "NROWS")))
            self.AreaByResolution.append(curArea)
        # Spectral information
        self.SpectralInfo = []
        l_pathBase = "//Spectral_Band_Informations_List/Spectral_Band_Informations[@band_id='{}']"
        l_pathNativeCoeff = "/Calibration_Coefficients_Lists/Native_Coefficients_List/COEFFICIENT[@name='{}']"
        l_pathRadiance = "/SOLAR_IRRADIANCE"
        l_pathWavelength = "/Wavelength/{}"
        l_pathResponse = "/Spectral_Response/{}"
        l_pathsSpecInfo = {
            'PhysicalGain': l_pathNativeCoeff.format("PhysicalGain"),
            'LuminanceMax': l_pathNativeCoeff.format("LuminanceMax"),
            'LuminanceMin': l_pathNativeCoeff.format("LuminanceMin"),
            'QuantizeCalMax': l_pathNativeCoeff.format("QuantizeCalMax"),
            'QuantizeCalMin': l_pathNativeCoeff.format("QuantizeCalMin"),
            'RadianceAdd': l_pathNativeCoeff.format("RadianceAdd"),
            'RadianceMult': l_pathNativeCoeff.format("RadianceMult"),
            'ReflectanceAdd': l_pathNativeCoeff.format("ReflectanceAdd"),
            'ReflectanceMult': l_pathNativeCoeff.format("ReflectanceMult"),
            'SolarIrradiance': l_pathRadiance,
            'WavelengthMin': l_pathWavelength.format("MIN"),
            'WavelengthMax': l_pathWavelength.format("MAX"),
            'WavelengthCentral': l_pathWavelength.format("CENTRAL"),
            'ResponseStep': l_pathResponse.format("STEP"),
            'ResponseValues': l_pathResponse.format("VALUES")
        }
        for b, bidx in l_BandsDefinitions.L1BandMap.items():
            specInfo = {"Band": b}
            realBase = l_pathBase.format(b)
            for measure, pathMeasure in l_pathsSpecInfo.items():
                res = xml_tools.get_xml_string_value(lHandler.root,
                                                     realBase + pathMeasure,
                                                     check=True)
                if len(res):
                    specInfo[measure] = res
                    if measure == 'PhysicalGain':
                        specInfo[measure] = float(res)
            self.SpectralInfo.append(specInfo)

        # -------------------------------------------------------------------------
        # 4.2: New
        # Set the L1 no data value
        self.L1NoData = int(lHandler.get_string_value_of("L1NoData"))
        # Set the reflectance quantification value
        self.ReflectanceQuantification = 1. / float(
            lHandler.get_string_value_of("QuantificationValue"))
        # Computes the real value of the L1 NoData
        self.RealL1NoData = float(
            self.L1NoData) * self.ReflectanceQuantification

        # Save metadata related to Muscate format
        self.MuscateData["Node_MetadataFormat"] = xml_tools.extract_nodes(
            lHandler.root, "//Metadata_Identification/METADATA_FORMAT")
        l_NodeOriginalDataDiffuser = xml_tools.extract_nodes(
            lHandler.root, "//ORIGINAL_DATA_DIFFUSER")
        if l_NodeOriginalDataDiffuser is not None:
            self.MuscateData[
                "Node_OriginalDataDiffuser"] = l_NodeOriginalDataDiffuser
        self.MuscateData[
            "Node_Geoposition_Informations"] = xml_tools.extract_nodes(
                lHandler.root, "//Geoposition_Informations")
        self.MuscateData[
            "Node_Geometric_Informations"] = xml_tools.extract_nodes(
                lHandler.root, "//Geometric_Informations")
        #~ self.MuscateData["Identifier"] = lIdent
        self.MuscateData["Authority"] = lHandler.get_string_value_of(
            "Authority")
        self.MuscateData["Producer"] = lHandler.get_string_value_of("Producer")
        self.MuscateData["Project"] = lHandler.get_string_value_of("Project")
        self.MuscateData["ZoneGeo"] = lHandler.get_string_value_of("ZoneGeo")
        #~ self.MuscateData["Platform"] = self.Satellite

        self.MuscateData["AcquisitionDate"] = lHandler.get_string_value_of(
            "AcquisitionDate")
        self.MuscateData[
            "UTCAcquisitionRangeMean"] = lHandler.get_string_value_of(
                "UTCAcquisitionRangeMean")
        self.MuscateData[
            "UTCAcquisitionRangeDatePrecision"] = lHandler.get_string_value_of(
                "UTCAcquisitionRangeDatePrecision")

        l_NodeSolarAnglesGrid = xml_tools.extract_nodes(
            lHandler.root,
            "//Data_List/Data[Data_Properties/NATURE='Solar_Angles_Grid']")
        if l_NodeSolarAnglesGrid is not None:
            self.MuscateData["Node_Solar_Angles_Grid"] = l_NodeSolarAnglesGrid

        l_NodeViewingAnglesGrid = xml_tools.extract_nodes(
            lHandler.root,
            "//Data_List/Data[Data_Properties/NATURE='Viewing_Angles_Grid']")
        if l_NodeViewingAnglesGrid is not None:
            self.MuscateData[
                "Node_Viewing_Angles_Grid"] = l_NodeViewingAnglesGrid

        l_NodeUsefulImageInfoFile = xml_tools.extract_nodes(
            lHandler.root,
            "//Data_List/Data[Data_Properties/NATURE='Useful_Image_Informations_File']"
        )
        if l_NodeUsefulImageInfoFile is not None:
            self.MuscateData[
                "Node_Useful_Image_Informations_File"] = l_NodeUsefulImageInfoFile

        l_NodeUsefulImage = xml_tools.extract_nodes(
            lHandler.root,
            "//Mask_List/Mask[Mask_Properties/NATURE='Useful_Image']")
        if l_NodeUsefulImage is not None:
            self.MuscateData["Node_Useful_Image"] = l_NodeUsefulImage

        l_NodeDetFoo = xml_tools.get_only_value(
            lHandler.root,
            "//Mask_List/Mask/Mask_Properties/NATURE[.='Detector_Footprint']",
            check=True)
        if l_NodeDetFoo is not None:
            self.MuscateData[
                "ZoneMaskFileNames"] = lHandler.get_map_list_of_detector_footprint_image_filenames(
                )

        pix_node = xml_tools.get_only_value(
            lHandler.root,
            "//Mask_List/Mask/Mask_Properties/NATURE[.='Aberrant_Pixels']",
            check=True)
        if pix_node is not None:
            self.MuscateData[
                "PIXImages"] = lHandler.get_list_of_pix_mask_filenames()
            self.MuscateData[
                "PIXIndices"] = lHandler.get_list_of_pix_mask_indices()

        spectral_node = xml_tools.extract_nodes(
            lHandler.root,
            "//Radiometric_Informations/Spectral_Band_Informations_List")
        if spectral_node is not None:
            self.MuscateData[
                "Node_Spectral_Band_Informations_List"] = spectral_node

        qualityGeo_node = xml_tools.extract_nodes(
            lHandler.root,
            "//Current_Product/Product_Quality_List[@level='Geo']")
        if qualityGeo_node is not None:
            self.MuscateData["Node_Product_Quality_List_Geo"] = qualityGeo_node

        qualityNatif_node = xml_tools.extract_nodes(
            lHandler.root,
            "//Current_Product/Product_Quality_List[@level='Natif']")
        if qualityNatif_node is not None:
            self.MuscateData[
                "Node_Product_Quality_List_Natif"] = qualityNatif_node

        processingJob_node = xml_tools.extract_nodes(
            lHandler.root, "//Production_Informations/Processing_Jobs_List")
        if processingJob_node is not None:
            self.MuscateData["Node_Processing_Jobs_List"] = processingJob_node

        return True
    def read_info_with_plugin_base(self, p_filename, p_EnableReadingPublicData,
                                   p_PluginBase):
        # *************************************************************************************************************
        # ****  PRELIMINARY  DATA      ********************************************************************************
        l_L2XMLHandler = MuscateXMLFileHandler(p_filename)
        # Set Attributes
        self.ProductFilename = p_filename
        self.GlobalProductFilename = p_filename
        self.Satellite = l_L2XMLHandler.get_string_value_of("Platform")
        self.Acquisition_Date = l_L2XMLHandler.get_acquisition_date_formated_yyyymmdd(
        )
        self.Validity_Start = l_L2XMLHandler.get_date_pdv_formated_utc()
        self.Validity_Stop = l_L2XMLHandler.get_date_pdv_formated_utc()
        self.Nick_Name = l_L2XMLHandler.get_string_value_of("ZoneGeo")
        self.Reference_SiteDefinition_Id = "UNKNOWN"
        self.Reflectance_Quantification_Value = l_L2XMLHandler.get_string_value_of(
            "QuantificationValue")
        self.Nodata_Value = float(
            l_L2XMLHandler.get_string_value_of("Nodata_Value"))
        self.RealL2Nodata_Value = float(
            l_L2XMLHandler.get_string_value_of("Nodata_Value")) * float(
                l_L2XMLHandler.get_string_value_of("QuantificationValue"))
        self.VAP_Quantification_Value = float(
            l_L2XMLHandler.get_string_value_of(
                "WaterVaporContentQuantificationValue"))
        self.VAP_Nodata_Value = float(
            l_L2XMLHandler.get_string_value_of("VAP_Nodata_Value"))
        self.AOT_Quantification_Value = float(
            l_L2XMLHandler.get_string_value_of(
                "AerosolOpticalThicknessQuantificationValue"))
        self.AOT_Nodata_Value = float(
            l_L2XMLHandler.get_string_value_of("AOT_Nodata_Value"))
        self.RealVAP_Nodata_Value = self.VAP_Nodata_Value * 1. / self.VAP_Quantification_Value
        self.RealAOT_Nodata_Value = self.AOT_Nodata_Value * 1. / self.AOT_Quantification_Value
        # Init private part to get image filename for projRef
        l_PublicDirectory = os.path.dirname(p_filename)
        l_PrivateDirectory = os.path.join(
            l_PublicDirectory,
            l_L2XMLHandler.get_string_value_of("PrivateDirectoryFilename"))
        # Read the Private images
        self.L2PrivateImageFilenamesProvider = L2PrivateImageFilenamesProvider(
        )
        self.L2PrivateImageFilenamesProvider.initialize_for_reading(
            l_PrivateDirectory)
        # If public reading enable
        if p_EnableReadingPublicData:
            l_JpiFilename = os.path.join(
                l_PublicDirectory,
                l_L2XMLHandler.get_string_value_of(
                    "JobProcessingInformationsFileFilename"))
            l_JPIL2XMLHandler = MuscateXMLFileHandler(l_JpiFilename)
            self.Adjacency_Effects_And_Slope_Correction = l_JPIL2XMLHandler.get_string_value_of(
                "ProcessingFlagsAndModesProcessingAdjacencyEffectsAndSlopeCorrection"
            )

        # UTC=2010-01-18T12:00:00
        self.Date = date_utils.get_datetime_from_yyyymmdd(
            l_L2XMLHandler.get_acquisition_date_formated_yyyymmdd())
        self.PluginName = p_PluginBase.PluginName
        self.FileClass = "TEST"
        self.LevelType = "L2VALD"
        # -------------------------------------------------------------------------
        # Get the projection ref
        # this->m_ProjectionRef =
        # vnsGetProjectionRefMacro(this->m_L2PrivateImageFilenamesProvider.GetRTAImageFileName());
        self.Prefix = p_PluginBase.QCK_PREFIX_MAP[
            l_L2XMLHandler.get_string_value_of("Platform")]
示例#16
0
 def test_get_sun_zenithal_angles(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_sun_zenithal_angles())
示例#17
0
 def test_get_acquisition_date_formated_YYYYMMDD(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_acquisition_date_formated_yyyymmdd())
示例#18
0
 def test_get_mean_solar_angles(self):
     # solAngles[0] = zenith solAngles[1] = azimuth
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_mean_solar_angles())
示例#19
0
 def test_get_center(self):
     # lowerRightCorner[0] = Long lowerRightCorner[1] = Lat
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_center())
示例#20
0
class TestMajaMuscateXmlFileHandler(MajaTestCase):
    """Test class for ClassUndertestName"""
    def setUp(self):
        self.xml_filename = A_PRODUCT_S2_MUSCATE_L1.get("main_xml_fullpath")
        self.assertTrue(os.path.isfile(self.xml_filename))
        self.output_filename = "/tmp/internal_angles_test.xml"

    def test_object(self):
        """
        Assert the initialization of the object do not fail
        """
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        self.assertIsNotNone(self.maja_object)

    def test_save_to_file(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        # self.maja_object.save_to_file(output_filename)

    def test_save_sun_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        sun_angle_col_step = int(
            self.maja_object.get_string_value_of("SunAngleColStep"))
        sun_angle_row_step = -1 * int(
            self.maja_object.get_string_value_of("SunAngleRowStep"))
        # ATTENTION : * -1 for compatibility negative spacing

        l_zenithSolarAngles = self.maja_object.get_sun_zenithal_angles()
        l_azimuthSolarAngles = self.maja_object.get_sun_azimuthal_angles()
        LOGGER.debug(
            ("ZenithSolarAngles nb values: " + str(len(l_zenithSolarAngles))))
        LOGGER.debug(("AzimuthSolarAngles nb values: " +
                      str(len(l_azimuthSolarAngles))))
        LOGGER.debug(("Angles output_filename : %s", self.output_filename))
        writer = MajaInternalXmlInputAngles(l_zenithSolarAngles,
                                            l_azimuthSolarAngles,
                                            sun_angle_col_step,
                                            sun_angle_row_step,
                                            self.output_filename)
        writer.write()
        self.assertTrue(os.path.exists(self.output_filename),
                        "File does not exist")

    def test_save_view_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        view_angle_col_step = int(
            self.maja_object.get_string_value_of("SunAngleColStep"))
        view_angle_row_step = -1 * int(
            self.maja_object.get_string_value_of("SunAngleRowStep"))
        # ATTENTION : * -1 for compatibility negative spacing

        l_ListOfTOABandCode = self.maja_object.get_list_of_band_code(
        )  # ListOfStrings
        for l_band in l_ListOfTOABandCode:
            # Get the list of detectors (index)
            l_ListOfZone = self.maja_object.get_list_of_zones(l_band)
            LOGGER.debug("List of zone : ")
            LOGGER.debug(l_ListOfZone)
            # Get the list of viewing angles in the header file of the tile
            l_zenithVieAngles = self.maja_object.get_viewing_zenithal_angles(
                l_band)
            l_azimuthVieAngles = self.maja_object.get_viewing_azimuthal_angles(
                l_band)

            if len(l_zenithVieAngles) != len(l_azimuthVieAngles):
                raise Exception(
                    "The number of detector for viewing zenithal angles and viewing azimuthal angles is different or null !"
                )

            for detId in range(len(l_ListOfZone)):
                det = l_ListOfZone[detId]
                LOGGER.debug(("ZenithViewingAngles for band " + l_band +
                              " and det " + det + " ,  nb values: " +
                              str(len(l_zenithVieAngles[detId]))))
                LOGGER.debug(l_zenithVieAngles[detId])
                LOGGER.debug(
                    ("AzimuthViewingAngles " + l_band + " and det " + det +
                     " nb values: " + str(len(l_azimuthVieAngles[detId]))))
                LOGGER.debug(l_azimuthVieAngles[detId])
                output_filename = "/tmp/internal_angles_test_{}_{}.xml".format(
                    l_band, det)
                LOGGER.debug(("Angles output_filename : %s", output_filename))
                writer = MajaInternalXmlInputAngles(l_zenithVieAngles[detId],
                                                    l_azimuthVieAngles[detId],
                                                    view_angle_col_step,
                                                    view_angle_row_step,
                                                    output_filename)
                writer.write()
                self.assertTrue(os.path.exists(output_filename),
                                "File does not exist " + output_filename)

            # writer = MajaInternalXmlInputAngles(l_zenithVieAngles,
            #                                    l_azimuthVieAngles,
            #                                    view_angle_col_step, view_angle_row_step, output_filename)
            # writer.write()
            #self.assertTrue(os.path.exists(output_filename), "File does not exist")

    def test_get_string_value_of_L1C_product(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        list_of_key_missing_in_L1C = [
            'SunTooLowMaskFilename', 'DEMInformationMaximum',
            'ProcessingFlagsAndModesCAMSProcessing', 'DEMInformationAverage',
            'DEMInformationMinimum', 'AOT_Nodata_Value',
            'PrivateDirectoryFilename',
            'AerosolOpticalThicknessQuantificationValue', 'VAP_Nodata_Value',
            'JobProcessingInformationsFileFilename',
            'AerosolOpticalThicknessQuantificationValueAsString',
            'ProcessingFlagsAndModesFileType',
            'WaterVaporContentQuantificationValueAsString',
            'DEMInformationStandardDeviation', 'TopographyShadowMaskFilename',
            'WaterMaskFilename', 'AOTInterpolationMaskFilename',
            'SnowMaskFilename', 'Instrument', 'EdgeMaskFilename',
            'ProcessingFlagsAndModesProcessingAdjacencyEffectsAndSlopeCorrection',
            'ProcessingFlagsAndModesProcessingMode',
            'HiddenSurfaceMaskFilename',
            'WaterVaporContentQuantificationValue',
            'ProcessingFlagsAndModesQualityCheck', 'TangentSunMaskFilename',
            'ProcessingFlagsAndModesValidityFlag',
            'ProcessingFlagsAndModesCirrusCorrection'
        ]
        for k in list(MUSCATE_HANDLER_XPATH.keys()):
            if k not in list_of_key_missing_in_L1C:
                LOGGER.debug(self.maja_object.get_string_value_of(k))

    # Get the upper left corner in latitude / longitude coordinate system

    def test_get_upper_left_corner(self):
        # upperLeftCorner[0] = Long upperLeftCorner[1] = Lat
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_upper_left_corner())

    # Get the upper right corner in latitude / longitude coordinate system
    def test_get_upper_right_corner(self):
        # upperRightCorner[0] = Long upperRightCorner[1] = Lat
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_upper_right_corner())

    # Get the lower left corner in latitude / longitude coordinate system
    def test_get_lower_left_corner(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_lower_left_corner())

    # Get the lower right corner in latitude / longitude coordinate system
    def test_get_lower_right_corner(self):
        # lowerRightCorner[0] = Long lowerRightCorner[1] = Lat
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_lower_right_corner())

    # Get the center in latitude / longitude coordinate system
    def test_get_center(self):
        # lowerRightCorner[0] = Long lowerRightCorner[1] = Lat
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_center())

    # Get the mean solar angles
    def test_get_mean_solar_angles(self):
        # solAngles[0] = zenith solAngles[1] = azimuth
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_mean_solar_angles())

    # Get the acquisition date with the YYYYMMDD format
    def test_get_acquisition_date_formated_YYYYMMDD(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_acquisition_date_formated_yyyymmdd())

    # Get the acquisition date in UTC format

    def test_get_date_pdv_formated_UTC(self):
        # Date formated:
        # Case1: <PRODUCTION_DATE>2014-12-17T09:36:57.0</PRODUCTION_DATE>
        # or
        # Case2: <PRODUCTION_DATE>2014-12-17T09:36:57</PRODUCTION_DATE>
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_date_pdv_formated_utc())

    def test_get_mean_viewing_zenithal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_mean_viewing_zenithal_angles())

    def test_get_mean_viewing_azimuthal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_mean_viewing_azimuthal_angles())

    # Get the mean viewing angles
    # def test_get_mean_viewing_angles(self):
    #     # vieAngles[0] = zenith vieAngles[1] = azimuth
    #     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
    #     print self.maja_object.get_mean_viewing_angles()

    # get the sun zenithal angles
    def test_get_sun_zenithal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_sun_zenithal_angles())

    # get the sun azimuthal angles
    def test_get_sun_azimuthal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_sun_azimuthal_angles())

    # get the viewing zenithal angles
    def test_get_viewing_zenithal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_viewing_zenithal_angles("B1"))

    # get the viewing azimuthal angles
    def test_get_viewing_azimuthal_angles(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_viewing_azimuthal_angles("B1"))

    # Get the list of bands
    def test_get_list_of_bands(self):
        # Get the number of bands
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_list_of_bands())

    # Get the saturated mask filename
    def test_get_list_of_L1_SAT_image_filenames(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_list_of_l1_sat_image_filenames())

    # Get the saturated mask index within its file
    def test_get_L1_SAT_image_index(self):
        # Get the list of bands
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_l1_sat_image_index(1))

    # Get the saturated mask filename
    def test_get_list_of_L1_NDT_image_filenames(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_list_of_l1_ndt_image_filenames())

    # Get the saturated mask index within its file
    def test_get_L1_NDT_image_index(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_l1_ndt_image_index(1))

    # Get the zone mask filename for the band
    def test_get_list_of_zones(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_list_of_zones("B1"))

    # Get the zone image index
    def test_get_L1_DTF_image_index(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_l1_dtf_image_index(1, "10"))

    # Get the list of name of the L1 TOA image
    def test_get_list_of_TOA_image_filenames(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.get_list_of_toa_image_filenames())

    # Get the list of name of the L1 TOA image
    def test_get_list_of_defective_pixel_image_filenames(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(
            self.maja_object.get_list_of_defective_pixel_image_filenames())

    # Get the list of name of the L1 TOA image
    def test_get_map_list_of_detector_footprint_image_filenames(self):
        self.maja_object = MuscateXMLFileHandler(self.xml_filename)
        LOGGER.debug(self.maja_object.
                     get_map_list_of_detector_footprint_image_filenames())
示例#21
0
 def test_get_list_of_L1_SAT_image_filenames(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_list_of_l1_sat_image_filenames())
示例#22
0
 def test_object(self):
     """
     Assert the initialization of the object do not fail
     """
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     self.assertIsNotNone(self.maja_object)
示例#23
0
 def test_get_L1_SAT_image_index(self):
     # Get the list of bands
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_l1_sat_image_index(1))
示例#24
0
 def test_get_viewing_azimuthal_angles(self):
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_viewing_azimuthal_angles("B1"))
示例#25
0
 def test_get_upper_right_corner(self):
     # upperRightCorner[0] = Long upperRightCorner[1] = Lat
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_upper_right_corner())
    def initialize(self, product_filename, validate=False, schema_path=None):
        LOGGER.info("Start VenusMuscate L1 Initialize on product " +
                    product_filename)
        # Initialize the Image filename provider
        if not MajaMuscateL1ImageInformations.is_a_muscate_by_checking_the_filename(
                product_filename):
            LOGGER.debug("The filename <" + product_filename +
                         "> is not an 'muscate' L1 header file.")
            return False
        if not MajaMuscateL1ImageInformations.is_a_muscate_by_checking_the_satellite(
                product_filename, self._plugin):
            LOGGER.debug(
                "The filename <" + product_filename +
                "> is not an 'muscate' L1 header file (by reading platform in the xml file)."
            )
            return False
        # Generic metadata handling by MuscateL1ImageInfo
        if not self.muscate_initialize(product_filename, self._plugin):
            LOGGER.debug("Failed to load generic muscate information")
            return False

        # Customization for VENUS
        # Init XML handler
        lHandler = MuscateXMLFileHandler(product_filename,
                                         validate=validate,
                                         schema_path=schema_path)

        # Read the usefull image information xml
        l_useful_filename = lHandler.get_useful_image_infos_filename()
        l_uii_handler = MuscateUIIXMLFileHandler(l_useful_filename)

        # Get longitude and latitude coordinates of the product
        # -------------------------------------------------------------------------
        # Estimation of the coordinate of the central point
        l_center = l_uii_handler.get_geopositioning_center()
        self.CenterCorner.longitude = l_center[0]
        self.CenterCorner.latitude = l_center[1]
        self.CenterCorner.line = 0
        self.CenterCorner.column = 0

        self.ListOfViewingAnglesPerBandAtL2Resolution = []
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution = []
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution = []
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution = []

        # Initialize the Viewing angles for each detectors (Zenith and Azimuth)
        # Read the constants values from the Header Envi file name
        # The angles must be in degree
        l_ViewAngle1 = l_uii_handler.get_image_center_viewing_angles("01")
        l_ViewAngle2 = l_uii_handler.get_image_center_viewing_angles("02")
        l_ViewAngle3 = l_uii_handler.get_image_center_viewing_angles("03")
        l_ViewAngle4 = l_uii_handler.get_image_center_viewing_angles("04")

        LOGGER.debug("Viewing Zenith - tri-detector 1 : " +
                     str(l_ViewAngle1[0]))
        LOGGER.debug("Viewing Zenith - tri-detector 2 : " +
                     str(l_ViewAngle2[0]))
        LOGGER.debug("Viewing Zenith - tri-detector 3 : " +
                     str(l_ViewAngle3[0]))
        LOGGER.debug("Viewing Zenith - tri-detector 4 : " +
                     str(l_ViewAngle4[0]))

        # B01 -> D01
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle1[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle1[1])
        })
        # B02 -> D01
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle1[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle1[1])
        })
        # B03 -> D04
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle4[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle4[1])
        })
        # B04 -> D04
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle4[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle4[1])
        })
        # B05 -> D01
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle1[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle1[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle1[1])
        })
        # B06 -> D04
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle4[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle4[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle4[1])
        })
        # B07 -> D03
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle3[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle3[1])
        })
        # B08 -> D03
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle3[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle3[1])
        })
        # B09 -> D03
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle3[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle3[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle3[1])
        })
        # B10 -> D02
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle2[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle2[1])
        })
        # B11 -> D02
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle2[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle2[1])
        })
        # B12 -> D02
        self.ListOfViewingZenithAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[0]))
        self.ListOfViewingAzimuthAnglesPerBandAtL2CoarseResolution.append(
            str(l_ViewAngle2[1]))
        self.ListOfViewingAnglesPerBandAtL2CoarseResolution.append({
            "incidence_zenith_angle":
            str(l_ViewAngle2[0]),
            "incidence_azimuth_angle":
            str(l_ViewAngle2[1])
        })
        # Fill the L2 resolution angles
        self.ListOfViewingAnglesPerBandAtL2Resolution = self.ListOfViewingAnglesPerBandAtL2CoarseResolution

        # Viewing Angles
        self.ViewingAngle = {
            "incidence_zenith_angle":
            str((l_ViewAngle1[0] + l_ViewAngle2[0] + l_ViewAngle3[0] +
                 l_ViewAngle4[0]) / 4.0),
            "incidence_azimuth_angle":
            str((l_ViewAngle1[1] + l_ViewAngle2[1] + l_ViewAngle3[1] +
                 l_ViewAngle4[1]) / 4.0)
        }

        # Solar Angles
        lSolarAngles = l_uii_handler.get_image_center_solar_angles()
        self.SolarAngle = {
            "sun_zenith_angle": lSolarAngles[0],
            "sun_azimuth_angle": lSolarAngles[1]
        }

        return True
示例#27
0
 def test_get_list_of_bands(self):
     # Get the number of bands
     self.maja_object = MuscateXMLFileHandler(self.xml_filename)
     LOGGER.debug(self.maja_object.get_list_of_bands())