Exemple #1
0
    def create_stats_dict_normal( self ):

	    stats_dict = {}
	    import numpy as np, db_methods as dbm, pickle	
            for view in ( 'TT_Features', 'TF_Features' ):
	        dbm.write_db_table( '.', self.db, view )
		a = dbm.table2mem( self.db, view )
		a1 = np.array( a )
		CSParray = a1[ : , -2: ]
		print 'CSParray dims :', np.shape( CSParray )
		with open( 'CSParray_' + view + '.pickle', 'w') as f:
			pickle.dump( CSParray, f )
		#print a1
		means, stdevs = dbm.array2stats( a1[:, :-2] )
		#print means
		#print stdevs
		
		alpha, loc, beta = dbm.CSParray2stats( CSParray, self.scaling )

		stats_dict[ view ] = { 'drlw' : { 'mean' : means[0], 'stdev' : stdevs[0] },
			'drh' : { 'mean' : means[1], 'stdev' : stdevs[1] }, 
			'dlwH' : { 'mean' : means[2], 'stdev' : stdevs[2] }, 
			'dlwN' : { 'mean' : means[3], 'stdev' : stdevs[3] },
			'dheight' : { 'mean' : means[4], 'stdev' : stdevs[4] },
			'dlwHadj' : { 'mean' : means[5], 'stdev' : stdevs[5] },
			'dlwNadj' : { 'mean' : means[6], 'stdev' : stdevs[6] },
			'drlwadj' : { 'mean' : means[7], 'stdev' : stdevs[7] }, 
			'CSPs' : { 'alpha' : alpha, 'loc' : loc, 'beta' : beta } }
	    #print stats_dict
	    self.stats_dict = stats_dict
Exemple #2
0
    def write_db_stats( self ):


	import sqlite3 as sq3, db_methods as dbm
        conn = sq3.connect( self.db )
        c = conn.cursor()
        views = [ str(b[0]) for b in c.execute( 'SELECT name from sqlite_master \
	where type = \'view\'' ).fetchall() ]
	for view in views:
	    if view in ( 'TT_Features', 'TF_Features' ):
                dbm.write_db_table( '.', self.db, view )