Example #1
0
    def test_variable(self):
        with netCDF4.Dataset(self.file, 'a') as ds:
            root = parse_nc_dataset_as_etree(ds)
            vs = root.xpath('/x:netcdf/x:variable', namespaces=namespaces)
            assert len(vs) > 0
            for v in vs:
                assert v.attrib['name']

            v = root.xpath("x:variable[@name='var4']", namespaces=namespaces)[0]
            assert v.attrib['name'] == 'var4'

            v = root.xpath("x:variable[@name='var4']/x:attribute[@name='foo']", namespaces=namespaces)[0]
            assert v.attrib['name'] == 'foo'
            assert v.attrib['value'] == 'bar'
Example #2
0
    def test_variable(self):
        with netCDF4.Dataset(self.file, "a") as ds:
            root = parse_nc_dataset_as_etree(ds)
            vs = root.xpath("/x:netcdf/x:variable", namespaces=namespaces)
            assert len(vs) > 0
            for v in vs:
                assert v.attrib["name"]

            v = root.xpath("x:variable[@name='var4']", namespaces=namespaces)[0]
            assert v.attrib["name"] == "var4"

            v = root.xpath("x:variable[@name='var4']/x:attribute[@name='foo']", namespaces=namespaces)[0]
            assert v.attrib["name"] == "foo"
            assert v.attrib["value"] == "bar"
Example #3
0
 def test_global(self):
     with netCDF4.Dataset(self.file, 'a') as ds:
         root = parse_nc_dataset_as_etree(ds)
         g = root.xpath("/x:netcdf/x:attribute[@name='foo']", namespaces=namespaces)[0]
         assert g.attrib['name'] == 'foo'
Example #4
0
 def test_dimension(self):
     with netCDF4.Dataset(self.file, 'a') as ds:
         root = parse_nc_dataset_as_etree(ds)
         dim = root[0]
         assert dim.attrib['name'] == 'bad_name'
Example #5
0
 def test_global(self):
     with netCDF4.Dataset(self.file, "a") as ds:
         root = parse_nc_dataset_as_etree(ds)
         g = root.xpath("/x:netcdf/x:attribute[@name='foo']", namespaces=namespaces)[0]
         assert g.attrib["name"] == "foo"
Example #6
0
 def test_dimension(self):
     with netCDF4.Dataset(self.file, "a") as ds:
         root = parse_nc_dataset_as_etree(ds)
         dim = root[0]
         assert dim.attrib["name"] == "bad_name"