Exemplo n.º 1
0
    def process(self, l1a_file: str, monitor: Monitor = Monitor.NULL):
        """
        Simulate processing a single L1A to L1B and L1BS.

        :param l1a_file: Path to L1A file.
        :param monitor: Progress monitor.
        :raises ProcessorException: if the string 'ERR' occurs in the *l1a_file* filename
        """
        if 'ERR' in os.path.basename(l1a_file).upper():
            raise ProcessorException('failed to open L1A file %s' % l1a_file)

        num_recs = 100
        total_work = num_recs
        if not self.skip_l1bs:
            total_work += 1
        total_work += 1

        with monitor.starting('processing "%s"' % self.name,
                              total_work=total_work):
            for rec in range(num_recs):
                if monitor.is_cancelled():
                    return
                # simulate some processing
                time.sleep(1.0 / num_recs)
                monitor.progress(work=1)

            os.makedirs(self.output_dir, exist_ok=True)

            l1a_base, _ = os.path.splitext(os.path.basename(l1a_file))
            if l1a_base.startswith('L1A'):
                l1a_base = l1a_base[len('L1A'):]

            if not self.skip_l1bs:
                l1bs_name = 'L1BS_%s_%s.nc' % (l1a_base, self.name)
                with open(os.path.join(self.output_dir, l1bs_name), 'wb'):
                    monitor.progress(work=1, msg='writing L1BS')

            l1b_name = 'L1B_%s_%s.nc' % (l1a_base, self.name)
            with open(os.path.join(self.output_dir, l1b_name), 'wb'):
                monitor.progress(work=1, msg='writing L1B')
Exemplo n.º 2
0
    def process(self, l1a_file: str, monitor: Monitor = Monitor.NULL):
        """
        Simulate processing a single L1A to L1B and L1BS.

        :param l1a_file: Path to L1A file.
        :param monitor: Progress monitor.
        :raises ProcessorException: if the string 'ERR' occurs in the *l1a_file* filename
        """
        if 'ERR' in os.path.basename(l1a_file).upper():
            raise ProcessorException('failed to open L1A file %s' % l1a_file)

        num_recs = 100
        total_work = num_recs
        if not self.skip_l1bs:
            total_work += 1
        total_work += 1

        with monitor.starting('processing "%s"' % self.name, total_work=total_work):
            for rec in range(num_recs):
                if monitor.is_cancelled():
                    return
                # simulate some processing
                time.sleep(1.0 / num_recs)
                monitor.progress(work=1)

            os.makedirs(self.output_dir, exist_ok=True)

            l1a_base, _ = os.path.splitext(os.path.basename(l1a_file))
            if l1a_base.startswith('L1A'):
                l1a_base = l1a_base[len('L1A'):]

            if not self.skip_l1bs:
                l1bs_name = 'L1BS_%s_%s.nc' % (l1a_base, self.name)
                with open(os.path.join(self.output_dir, l1bs_name), 'wb'):
                    monitor.progress(work=1, msg='writing L1BS')

            l1b_name = 'L1B_%s_%s.nc' % (l1a_base, self.name)
            with open(os.path.join(self.output_dir, l1b_name), 'wb'):
                monitor.progress(work=1, msg='writing L1B')