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'] )
def getVariable( ivar, **subset_args ): 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 ) t0 = time.time() rv = dset( id, **subset_args ) #, latitude=[self.cache_lat,self.cache_lat,'cob'] ) t1 = time.time() print "Loaded subset %s in %.2f " % ( subset_args, ( t1 - t0 ) ) return rv
return os.path.isfile( file ) if __name__ == "__main__": import pprint, cdms2, sys from datacache.data_collections import CollectionManager from modules.configuration import MERRA_TEST_VARIABLES wpsLog.addHandler( logging.StreamHandler(sys.stdout) ) wpsLog.setLevel(logging.DEBUG) pp = pprint.PrettyPrinter(indent=4) test_array = np.array( range(0,1000), np.int32) pid = 'test1' collection = MERRA_TEST_VARIABLES["collection"] id = MERRA_TEST_VARIABLES["vars"][0] cm = CollectionManager.getInstance('CreateV') url = cm.getURL( collection, id ) d = cdms2.open( url ) v = d[ id ] data = v( level=10000.0 ) pp.pprint( data ) engine = DataPersistenceEngine() engine.store( data.data, pid ) result = engine.load( pid ) pp.pprint(result)