Exemplo n.º 1
0
    def process(self, l1a_file: str, monitor: Monitor = Monitor.NULL) -> int:
        """
        runs the L1B Processing Chain
        """
        self.l1a_file = L1ADataset(l1a_file,
                                   chd=self.chd,
                                   cst=self.cst,
                                   cnf=self.cnf)

        print('processing %s using "%s"' %
              (self.l1a_file.file_path, self.name))

        t0 = time.time()

        with monitor.starting('processing',
                              total_work=self.l1a_file.max_index +
                              self.min_surfs):
            status = self._process(l1a_file, monitor)

        dt = time.time() - t0

        print('produced %s' % self.l1b_file.file_path)
        if self.l1bs_file is not None:
            print('produced %s' % self.l1bs_file.file_path)

        print('processing took %s' % str(datetime.timedelta(seconds=dt)))

        return status
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')
Exemplo n.º 3
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.º 4
0
    def process(self, l1a_file: str, monitor: Monitor = Monitor.NULL) -> int:
        """
        runs the L1B Processing Chain
        """
        self.l1a_file = L1ADataset(l1a_file, chd=self.chd, cst=self.cst, cnf=self.cnf)

        print('processing %s using "%s"' % (self.l1a_file.file_path, self.name))

        t0 = time.time()

        with monitor.starting('processing', total_work=self.l1a_file.max_index + self.min_surfs):
            status = self._process(l1a_file, monitor)

        dt = time.time() - t0

        print('produced %s' % self.l1b_file.file_path)
        if self.l1bs_file is not None:
            print('produced %s' % self.l1bs_file.file_path)

        print('processing took %s' % str(datetime.timedelta(seconds=dt)))

        return status