Exemple #1
0
    def run_processing(self):
        """
        Process SAS_L2_HR_LakeTile
        """
        logger = logging.getLogger(self.__class__.__name__)
        logger.sigmsg("")
        logger.sigmsg("**********************")
        logger.sigmsg("***** PROCESSING *****")
        logger.sigmsg("**********************")
        logger.sigmsg("")
        timer_proc = my_timer.Timer()
        timer_proc.start()

        try:
            # Processing only if PixC pixels are selected
            if self.obj_pixc.nb_selected != 0:

                # 2 - F2-F3-F3b = Identify all separate entities in the water mask
                logger.info(
                    "1 - Identifying all separate entities in the water mask..."
                )
                self.obj_pixc.compute_separate_entities()
                logger.info("" + timer_proc.info(0))
                logger.info("")

                # 3 - F4 = Retrieve pixels corresponding to lakes and unknown entirely inside the tile
                logger.info(
                    "2 - Getting pixels corresponding to lakes and unknown entirely inside the tile..."
                )
                self.obj_pixc.compute_obj_inside_tile()
                logger.info("" + timer_proc.info(0))
                logger.info("")

                # 4 - F5 = Retrieve pixels indices and associated label of objects at the top/bottom edge of the tile
                logger.info(
                    "3 - Getting pixels corresponding to objects at the top/bottom edge of the tile..."
                )
                self.obj_pixc.compute_edge_indices_and_label()
                logger.info("" + timer_proc.info(0))
                logger.info("")

                # 5 - F6 = Fill lake product
                logger.info("4 - Filling LakeTile product...")
                self.obj_lake.compute_lake_products(
                    self.obj_pixc.labels_inside)
                logger.info("" + timer_proc.info(0))
                logger.info("")

            else:
                logger.info(
                    "NO selected PixC => empty lake tile product generated")
                logger.info("")

        except:
            message = "Something wrong happened in run_processing"
            raise service_error.SASLakeTileError(message, logger)
    def compute_lake_tile_filename_pixcvec(self):
        """
        Compute LakeTile_pixcvec full path
        """
        logger = logging.getLogger(self.__class__.__name__)
        filename = self.lake_tile_pattern % (self.cycle_num, self.pass_num, self.tile_ref, self.start_date, self.stop_date, self.lake_tile_crid, \
                                             self.product_counter, self.lake_tile_pixcvec_suffix)
        self.lake_tile_pixcvec_file = os.path.join(self.out_dir, filename)

        # Filename must not exist
        if os.path.exists(self.lake_tile_pixcvec_file):
            message = "ERROR = %s already exists" % self.lake_tile_pixcvec_file
            raise service_error.SASLakeTileError(message, logger)
Exemple #3
0
    def computeLakeTileFilename_pixcvec(self):
        """
        Compute LakeTile_pixcvec full path
        """
        logger = logging.getLogger(self.__class__.__name__)
        filename = my_var.LAKE_TILE_PATTERN % (
            self.cycle_num, self.pass_num, self.tile_ref, self.start_date,
            self.stop_date, my_var.LAKE_TILE_CRID, self.product_counter,
            my_var.LAKE_TILE_PIXCVEC_SUFFIX)
        self.lake_tile_pixcvec_file = os.path.join(self.out_dir, filename)

        # Filename must not exist
        if os.path.exists(self.lake_tile_pixcvec_file):
            message = "ERROR = %s already exists" % self.lake_tile_pixcvec_file
            raise service_error.SASLakeTileError(message, logger)
Exemple #4
0
    def run_preprocessing(self):
        """
        preprocessing lake_tile
        """
        logger = logging.getLogger(self.__class__.__name__)
        logger.sigmsg("")
        logger.sigmsg("**************************")
        logger.sigmsg("***** PRE-PROCESSING *****")
        logger.sigmsg("**************************")
        logger.sigmsg("")

        try:
            # 1 - Reshape PIXCVec arrays
            logger.info("> 1 - Reshape PIXCVecRiver arrays...")
            self.obj_pixc_vec.reshape(self.obj_pixc)
        except:
            message = "[lakeTileProcessing]   Something wrong happened in run_preprocessing"
            raise service_error.SASLakeTileError(message, logger)
def get_info_from_filename(in_filename, in_type):
    """
    Retrieve orbit info from in_filename

    :param in_filename: input full path
    :type in_filename: string
    :param in_type: type of product =PIXC =PIXCVecRiver =LakeTile
    :type in_type: string

    :return: dictionnary containing values found in in_filename
    :rtype: dict
    """
    logger = logging.getLogger("locness_filename")
    # 0 - Init variables
    # 0.1 - Output dictionary
    out_dict = {}
    # 0.2 - Get pattern variables depending on in_type
    if in_type == "PIXC":
        if not os.path.basename(in_filename).startswith(PIXC_PREFIX):
            logger.info("Filename %s doesn't match with PIXC pattern %s",
                        os.path.basename(in_filename), PIXC_PATTERN_PRINT)
            out_dict = {}
        pattern = PIXC_PATTERN_IND
    elif in_type == "PIXCVecRiver":
        if not os.path.basename(in_filename).startswith(PIXCVEC_RIVER_PREFIX):
            logger.info(
                "Filename %s doesn't match with PIXCVecRiver pattern %s",
                os.path.basename(in_filename), PIXCVEC_RIVER_PATTERN_PRINT)
            out_dict = {}
        pattern = PIXCVEC_RIVER_PATTERN_IND
    elif in_type == "LakeTile":
        if not os.path.basename(in_filename).startswith(LAKE_TILE_PREFIX):
            message = "Filename %s doesn't match with LakeTile pattern %s" % (
                os.path.basename(in_filename), LAKE_TILE_PATTERN_PRINT)
            raise service_error.SASLakeTileError(message, logger)
        pattern = LAKE_TILE_PATTERN_IND
    else:
        message = "Type %s unknown ; should be PIXC, PIXCVecRiver or LakeTile" % in_type
        raise service_error.SASLakeTileError(message, logger)

    # 1 - Split basename
    basename_split = os.path.splitext(
        os.path.basename(in_filename))[0].split("_")

    # 2 - Get values in filename
    # Add error check
    try:
        for key, val in pattern.items():  # Loop on keys
            tmp_val = None  # Init output value
            if val is not None:
                tmp_val = basename_split[
                    val]  # Read value in filename if not None
            out_dict[key] = tmp_val  # Store value in output dictionary
    except:
        message = "Filename %s doesn't match with LakeTile pattern %s" % (
            os.path.basename(in_filename), LAKE_TILE_PATTERN_PRINT)
        raise service_error.ProcessingError(message, logger)

    # 3 - Check if cycle and pass fields could be convert into int
    try:
        tmp_val = int(out_dict["cycle"])
        tmp_val = int(out_dict["pass"])
    except:
        message = "Filename %s doesn't match with LakeTile pattern %s" % (
            os.path.basename(in_filename), LAKE_TILE_PATTERN_PRINT)
        raise service_error.ProcessingError(message, logger)

    return out_dict