Exemplo n.º 1
0
 def __init__(self,
              uri=None,
              variable=None,
              interface_overload={},
              request_dataset=None):
     self.request_dataset = request_dataset
     if self.request_dataset is None:
         self.uri = uri
         self.variable = variable
         self.alias = None
         self.did = None
         if self.variable is None:
             try:
                 self.ds = None
                 rootgrp = nc.Dataset(uri)
                 self.meta = NcMetadata(rootgrp)
             finally:
                 rootgrp.close()
         else:
             from ocgis.api.request import RequestDataset
             kwds = {'uri': uri, 'variable': variable}
             kwds.update(interface_overload)
             rd = RequestDataset(**kwds)
             self.ds = NcDataset(request_dataset=rd)
             self.meta = self.ds.metadata
     else:
         self.uri = self.request_dataset.uri
         self.variable = self.request_dataset.variable
         self.ds = self.request_dataset.ds
         self.meta = self.request_dataset.ds.metadata
         self.alias = self.request_dataset.alias
         self.did = self.request_dataset.did
Exemplo n.º 2
0
 def metadata(self):
     if self._metadata is None:
         self._metadata = NcMetadata(self._ds)
     return(self._metadata)
Exemplo n.º 3
0
 def test_ncmeta(self):
     ncm = NcMetadata(self.rootgrp)
     self.assertEqual(ncm.keys(), ['dataset', 'variables', 'dimensions'])