Ejemplo n.º 1
0
 def _run_convert(self,
                  infiles,
                  prefix,
                  suffix,
                  metadata,
                  ncfmt,
                  clevel,
                  serial,
                  verbosity,
                  wmode,
                  once,
                  print_diags=False):
     if not (serial and self.rank > 0):
         spec = Specifier(infiles=infiles,
                          ncfmt=ncfmt,
                          compression=clevel,
                          prefix=prefix,
                          suffix=suffix,
                          metadata=metadata)
         rshpr = create_reshaper(spec,
                                 serial=serial,
                                 verbosity=verbosity,
                                 wmode=wmode,
                                 once=once)
         rshpr.convert()
         if print_diags:
             rshpr.print_diagnostics()
     MPI_COMM_WORLD.Barrier()
Ejemplo n.º 2
0
    def setUp(self):
        self.infiles = ['input1.nc', 'input2.nc', 'input3.nc']
        self.ncfmt = 'netcdf'
        self.prefix = 'output.'
        self.suffix = '.nc'
        self.metadata = ['meta1', 'meta2']

        self.spec = Specifier(infiles=self.infiles,
                              ncfmt=self.ncfmt,
                              prefix=self.prefix,
                              suffix=self.suffix,
                              metadata=self.metadata)
Ejemplo n.º 3
0
 def convert(self):
     if self.run_args['serial']:
         if self.rank == 0:
             spec = Specifier(**self.spec_args)
             spec.write(self.run_args['specfile'])
             s2srun.main(self.runargs())
             remove(self.run_args['specfile'])
     else:
         if self.rank == 0:
             spec = Specifier(**self.spec_args)
             spec.write(self.run_args['specfile'])
         MPI_COMM_WORLD.Barrier()
         s2srun.main(self.runargs())
         if self.rank == 0:
             remove(self.run_args['specfile'])
     MPI_COMM_WORLD.Barrier()
Ejemplo n.º 4
0
 def _run_main(self, infiles, prefix, suffix, metadata,
               ncfmt, clevel, serial, verbosity, wmode, once, meta1d=False, tseries=None):
     if not (serial and self.rank > 0):
         spec = Specifier(infiles=infiles, ncfmt=ncfmt, compression=clevel,
                          prefix=prefix, suffix=suffix, timeseries=tseries,
                          metadata=metadata, meta1d=meta1d)
         specfile = 'input.s2s'
         pickle.dump(spec, open(specfile, 'wb'))
         argv = ['-v', str(verbosity), '-m', wmode]
         if once:
             argv.append('-1')
         argv.append(specfile)
         s2srun.main(argv)
         remove(specfile)
     MPI_COMM_WORLD.Barrier()
Ejemplo n.º 5
0
    def setUp(self):
        self.infiles = ['input1.nc', 'input2.nc', 'input3.nc']
        self.ncfmt = 'netcdf'
        self.prefix = 'output.'
        self.suffix = '.nc'
        self.metadata = ['meta1', 'meta2']

        self.spec = Specifier(infiles=self.infiles,
                              ncfmt=self.ncfmt,
                              prefix=self.prefix,
                              suffix=self.suffix,
                              metadata=self.metadata)

        self.size = MPI_COMM_WORLD.Get_size()
        self.rank = MPI_COMM_WORLD.Get_rank()
Ejemplo n.º 6
0
 def _test_create_reshaper(self, serial, verbosity, wmode):
     self._test_header(("create_reshaper(serial={0}, verbosity={1}, "
                        "wmode={2!r})").format(serial, verbosity, wmode))
     if not (serial and self.rank > 0):
         spec = Specifier(infiles=mkTestData.slices,
                          ncfmt='netcdf',
                          compression=0,
                          prefix='output.',
                          suffix='.nc',
                          metadata=[])
         rshpr = create_reshaper(spec,
                                 serial=serial,
                                 verbosity=verbosity,
                                 wmode=wmode)
         self._assertion("type(reshaper)", type(rshpr), Reshaper)
Ejemplo n.º 7
0
    def convert(self, print_diags=False):
        if self.create_args.get('verbosity', 1) == 0:
            oldout = sys.stdout
            newout = StringIO()
            sys.stdout = newout

        spec = Specifier(**self.spec_args)
        rshpr = create_reshaper(spec, **self.create_args)
        assert type(rshpr) == Reshaper, 'type(reshaper) failure'
        rshpr.convert(**self.convert_args)

        if self.create_args.get('verbosity', 1) == 0:
            actual = newout.getvalue()
            assert actual == '', 'stdout should be empty'
            sys.stdout = oldout

        if print_diags:
            rshpr.print_diagnostics()
Ejemplo n.º 8
0
    def convert(self, print_diags=False):
        if not (self.create_args.get('serial', False) and self.rank > 0):
            if self.create_args.get('verbosity', 1) == 0:
                oldout = sys.stdout
                newout = StringIO()
                sys.stdout = newout

            spec = Specifier(**self.spec_args)
            rshpr = create_reshaper(spec, **self.create_args)
            self.assertEqual(type(rshpr), Reshaper, 'type(reshaper) failure')
            rshpr.convert(**self.convert_args)

            if self.create_args.get('verbosity', 1) == 0:
                actual = newout.getvalue()
                self.assertEqual(actual, '', 'stdout should be empty')
                sys.stdout = oldout

            if print_diags:
                rshpr.print_diagnostics()
        MPI_COMM_WORLD.Barrier()
Ejemplo n.º 9
0
 def convert(self):
     Specifier(**self.spec_args).write('input.s2s')
     s2srun.main(self.runargs())
     remove('input.s2s')