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()
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()