def xtest02_domain_cache(self): from datacache.domains import Domain TestVariable = getVariable( 0, CacheLevel ) data_chunk = TestVariable.data domain = Domain( { 'level': CacheLevel }, TestVariable ) # , 'latitude': self.cache_lat domain.persist() result = domain.getData() self.assertEqual( data_chunk.shape, result.shape ) sample0 = data_chunk.flatten()[0:5].tolist() sample1 = result.flatten()[0:5].tolist() self.assertEqual( sample0, sample1 )
wpsLog.addHandler( logging.StreamHandler(sys.stdout) ) wpsLog.setLevel(logging.DEBUG) def getVariable( ivar, cache_level ): from modules.configuration import MERRA_TEST_VARIABLES from datacache.data_collections import CollectionManager collection = MERRA_TEST_VARIABLES["collection"] id = MERRA_TEST_VARIABLES["vars"][ivar] cm = CollectionManager.getInstance('CreateV') url = cm.getURL( collection, id ) dset = cdms2.open( url ) return dset( id, level=cache_level ) #, latitude=[self.cache_lat,self.cache_lat,'cob'] ) CacheLevel = 10000.0 TestVariable = getVariable( 0, CacheLevel ) data_chunk = TestVariable.data domain = Domain( { 'level': CacheLevel }, TestVariable ) # , 'latitude': self.cache_lat t0 = time.time() domain.persist() t1 = time.time() result = domain.getData() t2 = time.time() sample0 = data_chunk.flatten()[0:5].tolist() sample1 = result.flatten()[0:5].tolist() print " Persist time: %.3f" % ( t1 - t0 ) print " Restore time: %.3f" % ( t2 - t1 ) print " Data shape: %s " % str( result.shape ) print " Data pre-sample: %s " % str( sample0 ) print " Data post-sample: %s " % str( sample1 )