def scientific_processing(self): LOGGER.info("Starting ScientifiqProcessing") # Scientific processing mode. Set to INIT, NOMINAL or BACKWARD value l_NumberOfL1Product = len(self._listofl1product) LOGGER.debug(self._listofl1product) # Check if more than one valid input is in the list if l_NumberOfL1Product == 1: raise MajaDataException( "L2BackwardProcessing need more than one input L1 image product." ) # Process the last product in the list with INIT MODE # Initialize the mode l_InitMode = True l_BackwardMode = True l_IndexOfL1Product = l_NumberOfL1Product l_finalize_backward = False l_EnableL2ResolutionProcessing = self._apphandler.get_user_conf( ).get_Computing().get_EnableL2ResolutionProcessing() if not l_EnableL2ResolutionProcessing: LOGGER.info( "*************************************************************************************************" ) LOGGER.info( "ATTENTION: L2BACKWARD PROCESSING: The option to Write product to L2 resolution has been DISABLE !!!" ) LOGGER.info( "**************************************************************************************************" ) # ---------------------------------------------------------------- # Initialize the flag to validate the clouds probably # ---------------------------------------------------------------- self._checking_conditional_clouds = False l_conditional_loop = False l_write_earthexplorer_headers = False l_write_temporary_l2_product = True l_write_l2_product_to_l2resolution = False l_InputL2ImageFilename = "" while not l_conditional_loop: l_InputL1ProductInfo = self._listofl1product[l_IndexOfL1Product - 1] l_Sat = l_InputL1ProductInfo.Satellite # If last L1 product, write headers and write in the output directory # ---------------------------------------------------------------- if l_IndexOfL1Product == 1: l_write_earthexplorer_headers = True l_write_l2_product_to_l2resolution = l_EnableL2ResolutionProcessing l_write_temporary_l2_product = False l_finalize_backward = True LOGGER.warn( "L2Backward processing: the input L1 product valid for the Init mode is the last product. The Standard mode is disable !" ) # ************************************************************************************************************* # Init the current PluginBase pointer for the satellite in the MAIN global DataApplicationHandler Instance # ************************************************************************************************************* self.plugin = MAJAPluginProvider.create( l_InputL1ProductInfo.PluginName, self._apphandler) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Get and registers the L2COMM GIPP file L2COMM parameters have been read in the L1ImaegFileReader !! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2COMM_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2COMM", l_Sat) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") l_GIP_L2COMM_Filename = file_utils.copy_file_to_directory( l_GIP_L2COMM_Filename, self._apphandler.get_working_directory(), notestmode=True) translate_xsl(l_GIP_L2COMM_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2COMM file detected for the satellite '" + l_Sat + "' is <" + l_GIP_L2COMM_Filename + ">.") l_GIPPL2COMMHandler = GippL2COMMEarthExplorerXMLFileHandler( l_GIP_L2COMM_Filename) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Register the GIPP file "GIP_L2SITE" */ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2SITE_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2SITE", l_InputL1ProductInfo.UniqueSatellite) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2SITE parameters...") l_GIP_L2SITE_Filename = file_utils.copy_file_to_directory( l_GIP_L2SITE_Filename, self._apphandler.get_working_directory(), notestmode=True) translate_xsl(l_GIP_L2SITE_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2SITE file detected for the satellite '" + l_InputL1ProductInfo.UniqueSatellite + "' is <" + l_GIP_L2SITE_Filename + ">.") # ************************************************************************************************************* # Initialize the L1 Image file reader # ************************************************************************************************************* l_UniqueSatelliteD = l_InputL1ProductInfo.UniqueSatellite l1_image_reader = L1ImageReaderProvider.create( l_InputL1ProductInfo.PluginName, l_InputL1ProductInfo, self._apphandler, l_GIPPL2COMMHandler, self.DataDEMMap.get(l_UniqueSatelliteD), constants.ReadL1Mode.READ_L1_MODE_FOR_ALGORITHMS) # ************************************************************************************************************* # Initialize the L2 Image file writer # ************************************************************************************************************* if self._apphandler.get_output_plugin() is not None: l2_image_file_writer = L2ImageWriterProvider.create( self._apphandler.get_output_plugin()) else: l2_image_file_writer = L2ImageWriterProvider.create( MAJAPluginProvider.auto_tm( l_InputL1ProductInfo.PluginName)) if not l2_image_file_writer.can_write( l_InputL1ProductInfo.PluginName): raise MajaDriverException( "Plugin '" + self._apphandler.get_output_plugin() + "' can not write product from '" + l_InputL1ProductInfo.PluginName + "' products ") # Log system infos LOGGER.info(self._apphandler.get_system_infos()) # Compute the Single product # ---------------------------------------------------------------- self.single_product_processing( l_InitMode, l_BackwardMode, l_finalize_backward, l_InputL1ProductInfo, l1_image_reader, l_write_earthexplorer_headers, l_write_temporary_l2_product, l_write_l2_product_to_l2resolution, None, l2_image_file_writer, l_GIPPL2COMMHandler) LOGGER.debug(" -> self._productIsValid = " + str(self._productIsValid)) LOGGER.debug(" -> p_checking_conditional_clouds = " + str(self._checking_conditional_clouds)) if (self._checking_conditional_clouds is True) and (self._productIsValid is True): l_conditional_loop = True elif l_IndexOfL1Product == 1: l_conditional_loop = True else: l_conditional_loop = False # Store the output file name for the following loop # ---------------------------------------------------------------- l_InputL2ImageFilename = l2_image_file_writer.get_global_product_filename( ) # Decrement the input L1 index product l_IndexOfL1Product = l_IndexOfL1Product - 1 # Log system infos LOGGER.info(self._apphandler.get_system_infos()) # Check the Init mode # ---------------------------------------------------------------- # LAIG-DM-MAC-143599-CS # LAIG-FA-MAC-1658-CNES if (self._checking_conditional_clouds == False) or (self._productIsValid == False): LOGGER.warn( "The INIT mode in Backward processing fail: all L1 products are not valid (too cloudy or too cirrus)" " or the output L2 product generated contains too NoData values! " "See previous [W] messages for more details.") # ************************************************************************************************************* # ************************************************************************************************************* # Process the Nominal mode # ************************************************************************************************************* # ************************************************************************************************************* if l_IndexOfL1Product > 0: l_InitMode = False l_write_earthexplorer_headers = False l_write_l2_product_to_l2resolution = False l_write_temporary_l2_product = True while l_IndexOfL1Product > 1: l_InputL1ProductInfo = self._listofl1product[l_IndexOfL1Product - 1] l_Sat = l_InputL1ProductInfo.Satellite # ************************************************************************************************************* # Init the current PluginBase pointer for the satellite in the MAIN global DataApplicationHandler Instance # ************************************************************************************************************* plugin = MAJAPluginProvider.create( l_InputL1ProductInfo.PluginName, self._apphandler) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Get and registers the L2COMM GIPP file L2COMM parameters have been read in the L1ImaegFileReader !! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2COMM_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2COMM", l_Sat) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") translate_xsl(l_GIP_L2COMM_Filename, self._apphandler._stylesheet) LOGGER.info( "The GIP_L2COMM file detected for the satellite '" + l_Sat + "' is <" + l_GIP_L2COMM_Filename + ">.") l_GIPPL2COMMHandler = GippL2COMMEarthExplorerXMLFileHandler( l_GIP_L2COMM_Filename) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Register the GIPP file "GIP_L2SITE" */ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2SITE_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2SITE", l_InputL1ProductInfo.UniqueSatellite) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") translate_xsl(l_GIP_L2SITE_Filename, self._apphandler._stylesheet) LOGGER.info( "The GIP_L2SITE file detected for the satellite '" + l_InputL1ProductInfo.UniqueSatellite + "' is <" + l_GIP_L2SITE_Filename + ">.") # ************************************************************************************************************* # Initialize the L1 Image file reader # ************************************************************************************************************* l_UniqueSatelliteD = l_InputL1ProductInfo.UniqueSatellite l1_image_reader = L1ImageReaderProvider.create( l_InputL1ProductInfo.PluginName, l_InputL1ProductInfo, self._apphandler, l_GIPPL2COMMHandler, self.DataDEMMap.get(l_UniqueSatelliteD), constants.ReadL1Mode.READ_L1_MODE_FOR_ALGORITHMS) # ************************************************************************************************************* # Initialize the L2 Image file reader # ************************************************************************************************************* LOGGER.debug( "Starting L2NominalProcessor::ScientificProcessing(): get the L2 product filename in the input directory..." ) l2_image_reader = L2ImageReaderProvider.create( l_InputL2ImageFilename, self._apphandler, False, self.DataDEMMap.get(l_UniqueSatelliteD)) LOGGER.info("The L2 product found is <" + l2_image_reader.ProductFilename + ">.") # ************************************************************************************************************* # Initialize the L2 Image file writer # ************************************************************************************************************* if self._apphandler.get_output_plugin() is not None: l2_image_file_writer = L2ImageWriterProvider.create( self._apphandler.get_output_plugin()) else: l2_image_file_writer = L2ImageWriterProvider.create( MAJAPluginProvider.auto_tm( l_InputL1ProductInfo.PluginName)) if not l2_image_file_writer.can_write( l_InputL1ProductInfo.PluginName): raise MajaDriverException( "Plugin '" + self._apphandler.get_output_plugin() + "' can not write product from '" + l_InputL1ProductInfo.PluginName + "' products ") # Log system infos LOGGER.info(self._apphandler.get_system_infos()) # Compute the L2 temporary product # ---------------------------------------------------------------- self.single_product_processing( l_InitMode, l_BackwardMode, l_finalize_backward, l_InputL1ProductInfo, l1_image_reader, l_write_earthexplorer_headers, l_write_temporary_l2_product, l_write_l2_product_to_l2resolution, l2_image_reader, l2_image_file_writer, l_GIPPL2COMMHandler) # Store the output file name for the following loop # ---------------------------------------------------------------- l_InputL2ImageFilename = l2_image_file_writer.get_global_product_filename( ) # Decrement Index of L1 image input # ---------------------------------------------------------------- l_IndexOfL1Product = l_IndexOfL1Product - 1 # Log system infos LOGGER.info(self._apphandler.get_system_infos()) # Finalize the product # Compute the last L2 product # ---------------------------------------------------------------- l_write_earthexplorer_headers = True l_write_l2_product_to_l2resolution = self._apphandler.get_user_conf( ).get_Computing().get_EnableL2ResolutionProcessing() l_write_temporary_l2_product = False l_finalize_backward = True l_InputL1ProductInfo = self._listofl1product[l_IndexOfL1Product - 1] l_Sat = l_InputL1ProductInfo.Satellite # ************************************************************************************************************* # Init the current PluginBase pointer for the satellite in the MAIN global DataApplicationHandler Instance # ************************************************************************************************************* plugin = MAJAPluginProvider.create(l_InputL1ProductInfo.PluginName, self._apphandler) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Get and registers the L2COMM GIPP file L2COMM parameters have been read in the L1ImaegFileReader !! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2COMM_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2COMM", l_Sat) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") translate_xsl(l_GIP_L2COMM_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2COMM file detected for the satellite '" + l_Sat + "' is <" + l_GIP_L2COMM_Filename + ">.") l_GIPPL2COMMHandler = GippL2COMMEarthExplorerXMLFileHandler( l_GIP_L2COMM_Filename) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Register the GIPP file "GIP_L2SITE" */ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2SITE_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2SITE", l_InputL1ProductInfo.UniqueSatellite) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") translate_xsl(l_GIP_L2SITE_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2SITE file detected for the satellite '" + l_InputL1ProductInfo.UniqueSatellite + "' is <" + l_GIP_L2SITE_Filename + ">.") # ************************************************************************************************************* # Initialize the L1 Image file reader # ************************************************************************************************************* l_UniqueSatelliteD = l_InputL1ProductInfo.UniqueSatellite l1_image_reader = L1ImageReaderProvider.create( l_InputL1ProductInfo.PluginName, l_InputL1ProductInfo, self._apphandler, l_GIPPL2COMMHandler, self.DataDEMMap.get(l_UniqueSatelliteD), constants.ReadL1Mode.READ_L1_MODE_FOR_ALGORITHMS) # ************************************************************************************************************* # Initialize the L2 Image file reader # ************************************************************************************************************* LOGGER.debug( "Starting L2NominalProcessor::ScientificProcessing(): get the L2 product filename in the input directory..." ) l2_image_reader = L2ImageReaderProvider.create( l_InputL2ImageFilename, self._apphandler, False, self.DataDEMMap.get(l_UniqueSatelliteD)) LOGGER.info("The L2 product found is <" + l2_image_reader.ProductFilename + ">.") # ************************************************************************************************************* # Initialize the L2 Image file writer # ************************************************************************************************************* if self._apphandler.get_output_plugin() is not None: l2_image_file_writer = L2ImageWriterProvider.create( self._apphandler.get_output_plugin()) else: l2_image_file_writer = L2ImageWriterProvider.create( MAJAPluginProvider.auto_tm( l_InputL1ProductInfo.PluginName)) if not l2_image_file_writer.can_write( l_InputL1ProductInfo.PluginName): raise MajaDriverException( "Plugin '" + self._apphandler.get_output_plugin() + "' can not write product from '" + l_InputL1ProductInfo.PluginName + "' products ") # Log system infos LOGGER.info(self._apphandler.get_system_infos()) self.single_product_processing( l_InitMode, l_BackwardMode, l_finalize_backward, l_InputL1ProductInfo, l1_image_reader, l_write_earthexplorer_headers, l_write_temporary_l2_product, l_write_l2_product_to_l2resolution, l2_image_reader, l2_image_file_writer, l_GIPPL2COMMHandler) # end if it is not the last product else: LOGGER.debug( "L1ImageInformationProvider initialized during backward but no associated valid L2 product. No more products." ) LOGGER.info("L2BackwardProcessor::ScientificProcessing() done.") # Log system infos LOGGER.info(self._apphandler.get_system_infos())
def scientific_processing(self): LOGGER.info("Starting ScientifiqProcessing") l_InitMode = False l_BackwardMode = False l_Sat = self._l1product.Satellite """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Get and registers the L2COMM GIPP file L2COMM parameters have been read in the L1ImaegFileReader !! ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2COMM_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2COMM", l_Sat) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2COMM parameters...") l_GIP_L2COMM_Filename = file_utils.copy_file_to_directory( l_GIP_L2COMM_Filename, self._apphandler.get_working_directory(), notestmode=True) translate_xsl(l_GIP_L2COMM_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2COMM file detected for the satellite '" + l_Sat + "' is <" + l_GIP_L2COMM_Filename + ">.") l_GIPPL2COMMHandler = GippL2COMMEarthExplorerXMLFileHandler( l_GIP_L2COMM_Filename) """ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** Register the GIPP file "GIP_L2SITE" */ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *""" l_GIP_L2SITE_Filename = gipp_utils.get_gipp_filename_with_mission( self._apphandler.get_input_directory(), "GIP_L2SITE", self._l1product.UniqueSatellite) if self._apphandler._stylesheet is not None: LOGGER.debug("Overloading L2SITE parameters...") l_GIP_L2SITE_Filename = file_utils.copy_file_to_directory( l_GIP_L2SITE_Filename, self._apphandler.get_working_directory(), notestmode=True) translate_xsl(l_GIP_L2SITE_Filename, self._apphandler._stylesheet) LOGGER.info("The GIP_L2SITE file detected for the satellite '" + self._l1product.UniqueSatellite + "' is <" + l_GIP_L2SITE_Filename + ">.") # Get the athmospheric/CAMS # --------------------------------------------------------------------------------------------- if l_GIPPL2COMMHandler.get_value_b("UseCamsData"): l_modelList = l_GIPPL2COMMHandler.get_value("ListOfModels").split() l_avgTime = date_utils.get_julianday_as_double( self._l1product.ProductDate) LOGGER.info("Cams data requested") # Verify if cams file are available before anything if self._CAMS_Files_HandlersMAP[l_Sat].has_cams_data(l_avgTime): self._CAMS_Files_HandlersMAP[l_Sat].extract_cams_datas( self._l1product.CenterCorner.latitude, self._l1product.CenterCorner.longitude, l_avgTime) if self._CAMS_Files_HandlersMAP[l_Sat].valid: self._AthmosphericLutHandlerMap[l_Sat].set_proportions( self._CAMS_Files_HandlersMAP[l_Sat].proportions) LOGGER.info("CAMS found, sampling : " + str( self._CAMS_Files_HandlersMAP[l_Sat].out_rh_sampling)) for m in l_modelList: l_use_rh = self._CAMS_Files_HandlersMAP[ l_Sat].get_extinction_map()[m]["rh_dep"] self._AthmosphericLutHandlerMap[ l_Sat].add_lut_for_model( self._apphandler.get_input_directory(), self._apphandler.get_working_directory(), l_Sat, m, self._validate_schemas, os.path.join( self._apphandler. get_schemas_root_install_dir(), self.plugin.MAJA_INSTALL_SCHEMAS_DIR), p_userh=l_use_rh, p_rh=self._CAMS_Files_HandlersMAP[l_Sat]. out_rh_sampling) tmp_atmolut = self._apphandler.get_directory_manager( ).get_temporary_directory("AtmoLut_", do_always_remove=True) self._AthmosphericLutHandlerMap[ l_Sat].gen_synthetised_luts(tmp_atmolut) self._cams_status = CAMSStatus.ACTIVATED_OK else: LOGGER.warn( "No valid cam data found for product, using constant model" ) self._cams_status = CAMSStatus.ACTIVATED_NOAVAILABLEDATA else: LOGGER.warn("No valid cam data found for product at time " + date_utils.get_date_yyyymmdd_from_tm( self._l1product.ProductDate) + ", using constant model") self._cams_status = CAMSStatus.ACTIVATED_NOAVAILABLEDATA # --------------------------------------------------------------------------------------------- # Initialize L1 image reader l_UniqueSatelliteD = self._l1product.UniqueSatellite l1_image_reader = L1ImageReaderProvider.create( self._l1product.PluginName, self._l1product, self._apphandler, l_GIPPL2COMMHandler, self.DataDEMMap.get(l_UniqueSatelliteD), constants.ReadL1Mode.READ_L1_MODE_FOR_ALGORITHMS) # ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** # Initialize the L2 Image file reader # Only in Nominal and Backward mode # ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** LOGGER.debug( "Starting L2NominalProcessor::ScientificProcessing(): get the L2 product filename in the input directory..." ) l2_image_reader = product_utils.get_input_l2_image_product( self._apphandler.get_input_directory(), self._apphandler, False, self.DataDEMMap.get(l_UniqueSatelliteD)) LOGGER.info("The L2 product found is <" + l2_image_reader.ProductFilename + ">.") # ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** # Initialize the Output L2 Image product filename if self._apphandler.get_output_plugin() is not None: l2_image_file_writer = L2ImageWriterProvider.create( self._apphandler.get_output_plugin()) else: l2_image_file_writer = L2ImageWriterProvider.create( MAJAPluginProvider.auto_tm(self._l1product.PluginName)) if not l2_image_file_writer.can_write(self._l1product.PluginName): raise MajaChainException("Plugin '" + self._apphandler.get_output_plugin() + "' can not write product from '" + self._l1product.PluginName + "' products ") # --------------------------------------------------------------------------------------------- # Get the ozone value l_UseDefaultConstantOzoneAmount = self.plugin.ConfigUserCamera.get_Algorithms(). \ get_Atmospheric_Absorption_Correction().get_Use_Default_Constant_Ozone_Amount() # l_UseDefaultConstantOzoneAmount = True l_OzoneAmountValue = 0.0 if not l_UseDefaultConstantOzoneAmount: l_OzoneAmountValue = get_ozone_amount( gipp_utils.get_gipp_filename( self._apphandler.get_input_directory(), "EXO_METDTA"), self._l1product.CenterCorner) else: l_OzoneAmountValue = float( l_GIPPL2COMMHandler.l2_comm_values["OzoneAmountDefaultValue"]) LOGGER.info("The 'OzoneAmount' used is " + str(l_OzoneAmountValue)) # Log system infos LOGGER.info(self._apphandler.get_system_infos()) # check conditional clouds ? self._checking_conditional_clouds = True LOGGER.info( "Starting from L2InitProcessor, the main ScientificSingleProductProcessing() method..." ) l_enableL2resolution = self._apphandler.get_user_conf().get_Computing( ).get_EnableL2ResolutionProcessing() super(L2NominalProcessor, self).process_one_product(l_InitMode, l_BackwardMode, l_enableL2resolution, False, True, True, self._l1product, l1_image_reader, l_OzoneAmountValue, self._cams_status, l2_image_reader, l2_image_file_writer) LOGGER.info("Ending ScientifiqProcessing") # Log system infos LOGGER.info(self._apphandler.get_system_infos())
def test(argv): l1_input_dir = argv[1] l2_input_dir = argv[2] outdir = argv[3] l_cloudrate_value = int(argv[5]) l_snowrate_value = int(argv[6]) register_all() app_handler = AppHandler() app_handler._workingDirectory = outdir app_handler._inputDirectory = l1_input_dir app_handler._nbThreads = int(argv[4]) global_output_dict = {} test_maja_l2_writer_setup.set_input_l2_writer(l2_input_dir, global_output_dict) # Set L1 product and extrat plugin name l1product = product_utils.get_input_l1_image_product(l1_input_dir) creators = FactoryBase.get_registered("L1ImageReaderBase") for crea in creators: LOGGER.info("Trying : " + crea.__name__) if crea().can_read(l1product.PluginName): l1reader = crea() l_CurrentPluginBase = l1reader.get_plugin() # Load L2COMM gipp_l2comm_filename = gipp_utils.get_gipp_filename_with_mission(l1_input_dir, "GIP_L2COMM", l1product.Satellite) LOGGER.debug("l_GIPPL2COMMHandler filename : " + gipp_l2comm_filename) l_GIPPL2COMMHandler = GippL2COMMEarthExplorerXMLFileHandler(gipp_l2comm_filename) # Load DTM dem_filename = gipp_utils.get_gipp_filename_with_mission(l1_input_dir, "AUX_REFDE2", l1product.UniqueSatellite) dem = DEMBase() dem.initialize(dem_filename, app_handler._workingDirectory, False) # Extract product informations l_L2NoData = float(l_GIPPL2COMMHandler.get_value("NoData")) l_ReflectanceQuantificationValue = float(l1product.ReflectanceQuantification) l_RealL2NoData = l_L2NoData * l_ReflectanceQuantificationValue l_CurrentPluginBase.initialize(app_handler) l_BandDefinitons = l_CurrentPluginBase.BandsDefinitions l_AOTMethodString = l_GIPPL2COMMHandler.get_value("AOTMethod") l_AOTMethod = AOTEstimation.get_aot_method(l_AOTMethodString) l_CurrentConfigAdminCamera = l_CurrentPluginBase.ConfigAdminCamera param_dic = {} prepare_bands(l_BandDefinitons, l_BandDefinitons, l_GIPPL2COMMHandler, l_AOTMethod, l_CurrentConfigAdminCamera, True, False, param_dic) l_EnvCorOption = l_GIPPL2COMMHandler.get_value("EnvCorrOption") # Set L2 image Writer l2_image_writer = L2ImageWriterProvider.create(l1product.PluginName) l2_image_writer.set_dtm(dem) l2_image_writer.set_current_plugin_base(l_CurrentPluginBase) l2_image_writer.set_copy_private_from_l2_input_to_l2_output(False) l2_image_writer.set_write_l2_products(True) l2_image_writer.set_output_directory(app_handler._workingDirectory) l2_image_writer.set_l2_image_file_reader(None) l2_image_writer.set_l1_image_informations_provider(l1product) l2_image_writer.set_real_l2_nodata(l_RealL2NoData) l2_image_writer.set_reflectance_quantification_value(l1product.ReflectanceQuantification) l2_image_writer.set_aot_quantification_value(l_GIPPL2COMMHandler.get_value_f("AOTQuantificationValue")) l2_image_writer.set_vap_quantification_value(l_GIPPL2COMMHandler.get_value_f("VAPQuantificationValue")) l2_image_writer.set_vap_nodata_value(l_GIPPL2COMMHandler.get_value_f("VAPNodataValue")) l2_image_writer.set_aot_nodata_value(l_GIPPL2COMMHandler.get_value_f("AOTNodataValue")) l2_image_writer.set_quicklook_min_refl_redband(l_GIPPL2COMMHandler.get_value("QuicklookMinReflRedBand")) l2_image_writer.set_quicklook_min_refl_greenband( l_GIPPL2COMMHandler.get_value("QuicklookMinReflGreenBand")) l2_image_writer.set_quicklook_min_refl_blueband(l_GIPPL2COMMHandler.get_value("QuicklookMinReflBlueBand")) l2_image_writer.set_quicklook_max_refl_redband(l_GIPPL2COMMHandler.get_value("QuicklookMaxReflRedBand")) l2_image_writer.set_quicklook_max_refl_greenband( l_GIPPL2COMMHandler.get_value("QuicklookMaxReflGreenBand")) l2_image_writer.set_quicklook_max_refl_blueband(l_GIPPL2COMMHandler.get_value("QuicklookMaxReflBlueBand")) l2_image_writer.set_quicklook_red_band_code(l_GIPPL2COMMHandler.get_value("QuicklookRedBandCode")) l2_image_writer.set_quicklook_green_band_code(l_GIPPL2COMMHandler.get_value("QuicklookGreenBandCode")) l2_image_writer.set_quicklook_blue_band_code(l_GIPPL2COMMHandler.get_value("QuicklookBlueBandCode")) l2_image_writer.set_projection_ref(l1product.ProjectionRef) l2_image_writer.set_write_public_product(True) l2_image_writer.set_env_cor_option(l_EnvCorOption) l2_image_writer.set_sre_image_list(global_output_dict["SRE_List"]) l2_image_writer.set_fre_image_list(global_output_dict["FRE_List"]) l2_image_writer.set_aot_image_list(global_output_dict["L2AOT_List"]) l2_image_writer.set_tao_image_list(global_output_dict["L2TAO_List"]) l2_image_writer.set_vap_image_list(global_output_dict["L2VAP_List"]) l2_image_writer.set_iwc_image_list(global_output_dict["L2IWC_List"]) l2_image_writer.set_hid_image(global_output_dict["dtm_hid"]) l2_image_writer.set_shd_image(global_output_dict["dtm_shd"]) l2_image_writer.set_sat_image_list(global_output_dict["L2SAT_List"]) l2_image_writer.set_pix_image_list(global_output_dict["L2PIX_List"]) l2_image_writer.set_edg_image_list(global_output_dict["L2EDG_List"]) l2_image_writer.set_stl_image_list(global_output_dict["L2STL_List"]) l2_image_writer.set_tgs_image_list(global_output_dict["L2TGS_List"]) if global_output_dict["L2DFP_List"]: l2_image_writer.set_dfp_image_list(global_output_dict["L2DFP_List"]) if global_output_dict["snow"]: l2_image_writer.set_snw_image(global_output_dict["snow"]) if global_output_dict["cla"]: l2_image_writer.set_cla_image(global_output_dict["cla"]) l2_image_writer.set_rta_image(global_output_dict["rta_composite"]) l2_image_writer.set_rtc_image(global_output_dict["rtc_composite"]) l2_image_writer.set_rcr_image(global_output_dict["rcr_composite"]) l2_image_writer.set_sto_image(global_output_dict["sto_composite"]) l2_image_writer.set_pxd_image(global_output_dict["pxd_composite"]) l2_image_writer.set_ndt_image(global_output_dict["ndt_composite"]) l2_image_writer.set_cld_image(global_output_dict["CLD_List"]) l2_image_writer.set_l2_cld_image_list(global_output_dict["L2CLD_List"]) l2_image_writer.set_was_image(global_output_dict["was"]) l2_image_writer.set_pwa_image(global_output_dict["pwa"]) l2_image_writer.set_twa_image(global_output_dict["twa"]) if global_output_dict["ltc"]: l_write_ltc = True l2_image_writer.set_write_ltc(l_write_ltc) LOGGER.debug(global_output_dict["ltc"]) l2_image_writer.set_ltc_image(global_output_dict["ltc"]) else: l_write_ltc = False l2_image_writer.set_write_ltc(l_write_ltc) l2_image_writer.initialize_product() l2_image_writer.write(app_handler._workingDirectory) # Set L2 Header l_L2HeaderFileWriter = L2HeaderWriterProvider.create(l1product.PluginName, app_handler) l_L2HeaderFileWriter.l1imageinformationsproviderbase = l1product l_L2HeaderFileWriter.outputfileclass = l1product.FileClass l_L2HeaderFileWriter.outputdirectory = app_handler._workingDirectory l_L2HeaderFileWriter.outputl2productfilename = l2_image_writer.get_global_product_filename() l_L2HeaderFileWriter.outputl2privateimagefilenamesprovider = l2_image_writer.get_private_filenames_provider() l_L2HeaderFileWriter.reflectancequantificationvalue = l1product.ReflectanceQuantification l_L2HeaderFileWriter.dem = dem l_L2HeaderFileWriter.listofgippsfilenames = get_listoffilenames_filetype_sorted( app_handler.get_input_directory(), "GIP_") l_L2HeaderFileWriter.creator = 'MAJA_L2_INIT_CHAIN' l_L2HeaderFileWriter.system = 'MAJA' l_L2HeaderFileWriter.checkxmlfileswithschema = True l_L2HeaderFileWriter.notes = 'L2 note' l_L2HeaderFileWriter.listofbandtheoreticalwavelengthforreflectancescomposite = param_dic[ "ListOfBandTheoreticalWavelengthForReflectancesComposite"] l_L2HeaderFileWriter.listofbandtheoreticalwavelengthforltccomposite = param_dic[ "ListOfBandTheoreticalWavelengthForLTCComposite"] l_L2HeaderFileWriter.correlbandtheoreticalwavelengthforstocomposite = param_dic[ "CorrelTheoreticalWavelength_DateD"] l_L2HeaderFileWriter.nodatavalue = l_GIPPL2COMMHandler.get_value("NoData") l_L2HeaderFileWriter.vapnodatavalue = l_GIPPL2COMMHandler.get_value("VAPNodataValue") l_L2HeaderFileWriter.vapquantificationvalue = l_GIPPL2COMMHandler.get_value("VAPQuantificationValue") l_L2HeaderFileWriter.aotnodatavalue = l_GIPPL2COMMHandler.get_value("AOTNodataValue") l_L2HeaderFileWriter.aotquantificationvalue = l_GIPPL2COMMHandler.get_value("AOTQuantificationValue") l_L2HeaderFileWriter.quicklookredbandcode = l_GIPPL2COMMHandler.get_value("QuicklookRedBandCode") l_L2HeaderFileWriter.quicklookgreenbandcode = l_GIPPL2COMMHandler.get_value("QuicklookGreenBandCode") l_L2HeaderFileWriter.quicklookbluebandcode = l_GIPPL2COMMHandler.get_value("QuicklookBlueBandCode") # Set the L2 images flags l_L2HeaderFileWriter.cirrusflag = False l_L2HeaderFileWriter.cloudrate = l_cloudrate_value l_L2HeaderFileWriter.snowrate = l_snowrate_value l_L2HeaderFileWriter.hotspotflag = False l_L2HeaderFileWriter.sunglintflag = False l_L2HeaderFileWriter.adjacencyeffectsandslopecorrection = l_EnvCorOption l_L2HeaderFileWriter.cirruscorrection = False l_L2HeaderFileWriter.initmode = True l_L2HeaderFileWriter.backwardmode = False l_STOListOfStringDates = [] l_STOListOfStringDates.insert(0, l1product.ProductDateStr) l_L2HeaderFileWriter.productisvalid = True l_L2HeaderFileWriter.writel2products = True l_L2HeaderFileWriter.writepublicproduct = True l_L2HeaderFileWriter.numberofstackimages = len(l_STOListOfStringDates) l_L2HeaderFileWriter.stolistofstringdates = l_STOListOfStringDates l_L2HeaderFileWriter.enablewriteearthexplorerheaders = True l_L2HeaderFileWriter.writeltc = l_write_ltc l_L2HeaderFileWriter.ignorecurrentltc = False l_L2HeaderFileWriter.camsstatus = CAMSStatus.ACTIVATED_NOAVAILABLEDATA LOGGER.info("Writing L2 EarthExplorer headers files into the output L2 product") l_L2HeaderFileWriter.write() # Set the L2 header filename and the PMC report filename m_HDRFileNameOfProductImage = l2_image_writer.get_global_product_filename() m_ProductionReportFilename = l2_image_writer.get_production_report_filename() LOGGER.debug( "HDRFileNameOfProductImage: <" + m_HDRFileNameOfProductImage + ">") LOGGER.debug( "ProductionReportFilename: <" + m_ProductionReportFilename + ">") LOGGER.debug("THREADS = ") LOGGER.debug(app_handler._nbThreads)