Skip to content

Commit

Permalink
Added new wetdep and drydep params in tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesc Alted committed Dec 19, 2014
1 parent e891231 commit 7a1bed4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 14 additions & 6 deletions reflexible/conv2netcdf4/tests/test_netcdf4_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ def __init__(self, fp_name):
self.fp_name = fp_name
self.fp_path = rf.datasets[fp_name]

def setup(self, tmpdir):
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=False, outfile=self.nc_path)
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 cleanup(self):
Expand Down Expand Up @@ -206,13 +208,20 @@ def test_species_pptv(self):
# for attr in attr_names:
# assert attr in var_attrs


class TestWetDryDeps:
@pytest.fixture(autouse=True, params=['Fwd1_V9.02', 'Fwd2_V9.02', 'Bwd1_V9.02', 'Bwd2_V9.2beta'])
def setup(self, request, tmpdir):
self.dataset = dataset = Dataset(request.param)
self.ncid, self.fp_path, self.nc_path, self.H = dataset.setup(tmpdir)
request.addfinalizer(dataset.cleanup)

def test_WDspecies(self):
attr_names = ('units', 'weta', 'wetb', 'weta_in', 'wetb_in',
'wetc_in', 'wetd_in', 'dquer', 'henry')
for i in range(0, self.H.nspec):
anspec = "%3.3d" % (i + 1)
# Assume wetdep is True
if True:
if self.dataset.wetdep:
var_name = "WD_spec" + anspec
var_attrs = self.ncid.variables[var_name].ncattrs()
assert var_name in self.ncid.variables
Expand All @@ -227,8 +236,7 @@ def test_DDspecies(self):
'dquer', 'density', 'dsigma')
for i in range(0, self.H.nspec):
anspec = "%3.3d" % (i + 1)
# Assume drydep is True
if True:
if self.dataset.drydep:
var_name = "DD_spec" + anspec
var_attrs = self.ncid.variables[var_name].ncattrs()
assert var_name in self.ncid.variables
Expand Down
4 changes: 2 additions & 2 deletions reflexible/scripts/create_ncfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ def write_variables(H, ncid, wetdep, drydep, iout):
dry[:, :, idt, :, :] = fd.dry[:, :, np.newaxis, :, :]


def create_ncfile(fddir, nested, wetdep, drydep, command_path=None,
dirout=None, outfile=None):
def create_ncfile(fddir, nested, wetdep=False, drydep=False,
command_path=None, dirout=None, outfile=None):
"""Main function that create a netCDF4 file from a FLEXPART output."""

if fddir.endswith('/'):
Expand Down

0 comments on commit 7a1bed4

Please sign in to comment.