def setup(self, tmpdir, nested=False, wetdep=True, drydep=True): self.tmpdir = tmpdir # bring the fixture to the Dataset instance self.nc_path = tmpdir.join("%s.nc" % self.fp_name).strpath rf.create_ncfile(self.fp_path, nested, wetdep, drydep, outfile=self.nc_path) self.oldH = OldHeader(self.fp_path, nested=False) self.oldH.fill_backward(nspec=(0,)) self.wetdep = wetdep self.drydep = drydep return self.nc_path, self.oldH
def setup(self, tmpdir, nested=False, wetdep=True, drydep=True): self.tmpdir = tmpdir # bring the fixture to the Dataset instance self.nc_path = tmpdir.join("%s.nc" % self.fp_name).strpath rf.create_ncfile(self.fp_path, nested, wetdep, drydep, outfile=self.nc_path) self.ncid = nc.Dataset(self.nc_path, 'r') self.H = Header(self.fp_path, nested=False) self.wetdep = wetdep self.drydep = drydep return self.ncid, self.fp_path, self.nc_path, self.H
def setup(self, tmpdir, nested=False, wetdep=True, drydep=True): self.tmpdir = tmpdir # bring the fixture to the Dataset instance self.nc_path = tmpdir.join("%s.nc" % self.fp_name).strpath nc_path, options_dir, output_dir = rf.create_ncfile( self.fp_pathnames, nested, wetdep, drydep, outfile=self.nc_path) self.oldH = conv.Header(output_dir, nested=False) self.oldH.fill_backward(nspec=(0, )) self.wetdep = wetdep self.drydep = drydep return self.nc_path, self.oldH
def setup(self, tmpdir, nested=False, wetdep=True, drydep=True): self.tmpdir = tmpdir # bring the fixture to the Dataset instance self.nc_path = tmpdir.join("%s.nc" % self.fp_name).strpath pathnames = os.path.join(self.fp_path, "pathnames") nc_path, options_dir, output_dir = rf.create_ncfile( pathnames, nested, wetdep, drydep, outfile=self.nc_path) self.ncid = nc.Dataset(self.nc_path, 'r') self.H = OldHeader(output_dir, nested=False) self.wetdep = wetdep self.drydep = drydep return self.ncid, self.fp_path, self.nc_path, self.H
def setup(self, tmpdir): self.tmpdir = tmpdir # bring the fixture to the Dataset instance options_dir, output_dir = rf.conv2netcdf4.get_fpdirs(self.fp_pathnames) ncfiles = glob.glob(output_dir + '/*.nc') if ncfiles: self.nc_path = [f for f in ncfiles if ("nest" in f) == self.fp_nested][0] else: self.tmpdir = tmpdir # bring the fixture to the Dataset instance self.nc_path = tmpdir.join("%s.nc" % self.fp_name).strpath ncfile, options_dir, output_dir = rf.create_ncfile( self.fp_pathnames, self.fp_nested, True, True, outfile=self.nc_path) # raise IOError("This test module is only valid for NetCDF4 files.") self.ncid = nc.Dataset(self.nc_path, 'r') return self.ncid, self.fp_path, self.nc_path, None
def test_nc_create(self): rf.create_ncfile(self.fp_pathnames, nested=False, outfile=self.nc_path) assert os.path.exists(self.nc_path)
"wget -O %s http://folk.uio.no/johnbur/sharing/%s" % (ptarball, tarball), shell=True) if retcode < 0: print >>sys.stderr, "wget was terminated by signal", -retcode retcode = subprocess.call("tar xvfz %s -C %s" % (ptarball, wdir), shell=True) if retcode < 0: print >>sys.stderr, "tar was terminated by signal", -retcode return datadir test_data = check_test_data("test_data") ncfile = os.path.join(wdir, "test_data.nc") if not os.path.isfile(ncfile): rf.create_ncfile(test_data, nested=False, wetdep=True, drydep=True, outfile=ncfile) with fprof.lmprof(), fprof.ctime("Read the original Header"): H = conv.Header(test_data) with fprof.lmprof(), fprof.ctime("Read the new Header"): Hnc = rf.Header(ncfile) with fprof.lmprof(), fprof.ctime("Read all the concentrations with old Header"): H.fill_backward(nspec=range(H.nspec)) for nspec, pointspec in zip(range(H.nspec), range(H.numpointspec)): print "C[(%d, %d)]:" % (nspec, pointspec), H.C[(nspec, pointspec)] with fprof.lmprof(), fprof.ctime("Read all the concentrations with new Header"): for nspec, pointspec in zip(range(Hnc.nspec), range(Hnc.numpointspec)): print "C[(%d, %d)]:" % (nspec, pointspec), Hnc.C[(nspec, pointspec)]