Esempio n. 1
0
 def test_write(self):
     
     ncvariable = NcVariable("Prcp","mm",constant=5)
     bounds = Polygon(((0,0),(10,0),(10,15),(0,15)))
     res = 5
     ncspatial = NcSpatial(bounds,res)
     rng = [datetime.datetime(2007,10,1),datetime.datetime(2007,10,3)]
     interval = datetime.timedelta(days=1)
     nctime = NcTime(rng,interval)
     ncw = NcWrite(ncvariable,ncspatial,nctime)
     path = get_temp_path(suffix='.nc')
     rootgrp = ncw.get_rootgrp(path)
     self.assertEquals(
         rootgrp.variables["Prcp"][:].shape,
         (3, 4, 3)
     )
     ncw = NcWrite(ncvariable,ncspatial,nctime,nlevels=4)
     path = get_temp_path(suffix='.nc')
     rootgrp = ncw.get_rootgrp(path)
     self.assertEquals(
         rootgrp.variables["Prcp"][:].shape,
         (3, 4, 4, 3)
     )
     ## check spatial dimensions
     self.assertEqual(ncw.ncspatial.dim_col.shape[0],3)
     self.assertEqual(ncw.ncspatial.dim_row.shape[0],4)
     ## write to a file
     ncw.write()
Esempio n. 2
0
    def test_write(self):

        ncvariable = NcVariable("Prcp", "mm", constant=5)
        bounds = Polygon(((0, 0), (10, 0), (10, 15), (0, 15)))
        res = 5
        ncspatial = NcSpatial(bounds, res)
        rng = [datetime.datetime(2007, 10, 1), datetime.datetime(2007, 10, 3)]
        interval = datetime.timedelta(days=1)
        nctime = NcTime(rng, interval)
        ncw = NcWrite(ncvariable, ncspatial, nctime)
        path = get_temp_path(suffix='.nc')
        rootgrp = ncw.get_rootgrp(path)
        self.assertEquals(rootgrp.variables["Prcp"][:].shape, (3, 4, 3))
        ncw = NcWrite(ncvariable, ncspatial, nctime, nlevels=4)
        path = get_temp_path(suffix='.nc')
        rootgrp = ncw.get_rootgrp(path)
        self.assertEquals(rootgrp.variables["Prcp"][:].shape, (3, 4, 4, 3))
        ## check spatial dimensions
        self.assertEqual(ncw.ncspatial.dim_col.shape[0], 3)
        self.assertEqual(ncw.ncspatial.dim_row.shape[0], 4)
        ## write to a file
        ncw.write()
Esempio n. 3
0
 def get_uri(self,bounds=Polygon(((0,0),(10,0),(10,15),(0,15))),rng=[datetime.datetime(2007,10,1),datetime.datetime(2007,10,3)],res=5,constant=5,nlevels=1,path=None,bnds=True,seed=None):
     """
     constant=5 -- provides a constant value when generating data to fill
         a NC variable. set to None to generate random values.
     nlevels=1 -- a value greater than 1 will create a NC with a fourth level
         dimension. the input values determines the number of levels.
     """
     ncspatial = NcSpatial(bounds,res,add_bounds=bnds)
     
     interval = datetime.timedelta(days=1)
     nctime = NcTime(rng,interval)
     
     ncvariable = NcVariable("Prcp","mm",constant=constant,seed=seed)
     
     ncw = NcWrite(ncvariable,ncspatial,nctime,nlevels=nlevels)
     uri = ncw.write(path)
     return(uri)
Esempio n. 4
0
    def get_uri(self, constant=5, nlevels=1):
        """
        constant=5 -- provides a constant value when generating data to fill
            a NC variable. set to None to generate random values.
        nlevels=1 -- a value greater than 1 will create a NC with a fourth level
            dimension. the input values determines the number of levels.
        """
        bounds = Polygon(((0, 0), (10, 0), (10, 15), (0, 15)))
        res = 5
        ncspatial = NcSpatial(bounds, res)

        rng = [datetime.datetime(2007, 10, 1), datetime.datetime(2007, 10, 3)]
        interval = datetime.timedelta(days=1)
        nctime = NcTime(rng, interval)

        ncvariable = NcVariable("Prcp", "mm", constant=constant)

        ncw = NcWrite(ncvariable, ncspatial, nctime, nlevels=nlevels)
        uri = ncw.write()
        return (uri)