예제 #1
0
	def __init__(self, pth, fname, num):
		filename = os.path.join(pth, fname)

		#open/parse the data:
		dta, stats = hgi.hhg_open_data(filename)
		print stats
		if dta == []:
			print 'exit'
			exit()
		
		window = gtk.Window()
		scr = window.get_screen()
		
		#do night detection and prepare long-term plot, if enough data:
		if len(dta)>5000:
			tme_ngt,acc_ngt,lgt_ngt,min_ngt,res_ngt, stats = hhg_nght_stats(dta)
			print stats
		
			#data should be loaded and analyzed, let's plot it:
			if (dta != False):
				fig = hplt.Hhg_nights_plot(scr.get_width()/80,8,80)
				if fig != False:
					nf = array((acc_ngt, lgt_ngt+100, min_ngt+200)).T
					nums = 0
					if dta.dtype == hgi.desc_raw:
						xyz = array((dta.x, dta.y, dta.z)).T
						nums = str(sum(dta.d))
					elif dta.dtype == hgi.desc_mv:
						xyz = array((dta.xm,dta.ym,dta.zm,dta.xv,dta.yv,dta.zv)).T
					fig.plot(dta.t,xyz,dta.l, tme_ngt,nf, nums, pth, (res_ngt*4)-20, num,)
									
		#otherwise prepare a raw plot:
		else:
			fig = hplt.Hhg_raw_plot(scr.get_width()/80,8,80)
			fig.plot(1, 3, dta.t, array((dta.x,dta.y,dta.z)).T, pth, num,'3D acceleration')
			fig.plot(2, 3, dta.t, array((dta.l)).T>>8, pth, num, 'ambient light')
			fig.plot(3, 3, dta.t, (array((dta.l)).T&0xFF)/2-30, pth, num, 'temperature')
			fig.draw_top_text( (('user: anonymous'),(stats )) )
			
		# if selected, write data to binary file (so it can be used later):
		if fig.save_dta_file:
			print 'saving data to ' + fig.save_dta_file
			save(fig.save_dta_file, dta)
예제 #2
0
# MA 02110-1301, USA.
#


import numpy  # for saving the equidistant data to ascii
import hhg_io.hhg_import as hgi
import hhg_features.hhg_bconv as hft
import hhg_plot.hhg_plot as hhg_plt
import hhg_dialogs.hhg_fopen as hhg_fopen


# check where to load from ():
filename, scr = hhg_fopen.load("/media/HEDGEHOG/log000.HHG")

# load data:
dta, stats = hgi.hhg_open_data(filename)
print stats

# convert to
dta_e, stats = hft.hhg_equidist(dta)
print stats

# create plot:
fig = hhg_plt.Hhg_raw_plot(scr.get_width() / 80, 10, 80)
fig.plot(1, 4, dta.t, numpy.array((dta.x, dta.y, dta.z)).T)
fig.plot(2, 4, dta.t, numpy.array((dta.l)).T >> 8, "ambient light")
fig.plot(3, 4, dta.t, ((numpy.array((dta.l)).T & 0xFF) / 2) - 30, "temperature")
fig.equidist_plot(4, 4, range(0, len(dta_e)), dta_e[:, :3])
fig.draw_top_text((("user: anonymous"), (stats)))
fig.show()
예제 #3
0
files = (	(file1, hft.HHGFEAT_TS_BSTATS, (10,0)),
				(file1, hft.HHGFEAT_TS_BSTATS, (100,0)),
				(file2, hft.HHGFEAT_TS_BSTATS, (10,0)),
				(file2, hft.HHGFEAT_TS_BSTATS, (100,0))
			)
########################################################################

#create plotting object:
fig = hhg_plt.Hhg_comp_plot(14,10,80)
	
#for each file above:
it = 0
for f in files:

	#load data:
	dta, stats = hgi.hhg_open_data(f[0])
	print stats

	#calculate basic stats anew (put to False to avoid re=calculating):
	if True:
		if f[1]==hft.HHGFEAT_BSTATS:
			ts, dta_mv, env, stats = hft.hhg_bstats_raw(dta, f[2][0])
		elif f[1]==hft.HHGFEAT_RWTS_BSTATS:
			ts, dta_mv, env, stats = hft.hhg_bstats_ts_raw(dta, f[2][0])
		elif f[1]==hft.HHGFEAT_MVTS_BSTATS:
			ts, dta_mv, env, stats = hft.hhg_bstats_ts_mv(dta, f[2][0])
		elif f[1]==hft.HHGFEAT_TS_BSTATS:
			ts, dta_mv, env, stats = hft.hhg_bstats_ts(dta, f[2][0])
		else: print 'Error: unknown feature id'
		print stats
		numpy.save(f[0][:-4]+'_ts'+'.npy', ts)
예제 #4
0
import hhg_plot.hhg_plot as hplt
import hhg_dialogs.hhg_fopen as hhg_fopen
import hhg_io.hhg_import as hgi
from hhg_features.hhg_nght_stats import *

import pdb

#check where to load from (default is the 1st HedgeHog's data):
filename, scr = hhg_fopen.load('/media/HEDGEHOG/log000.HHG')

#open/parse the data:
stats = []
dta = []

if len(sys.argv) == 1:
    dta, stats = hgi.hhg_open_data(filename)
if len(sys.argv) == 2:
    dta, stats = hgi.hhg_open_data(sys.argv[1])

print stats

if dta == []:
    exit()

#shortcut to read the new npy files (have 7 cols):
if len(dta[0]) == 7:
    fig = hplt.Hhg_raw_plot(scr.get_width() / 80, 8, 80)
    fig.plot(1, 3, dta.t, np.array((dta.x, dta.y, dta.z)).T, '3D acceleration')
    fig.plot(2, 3, dta.t, np.array((dta.e1)).T >> 8, 'ambient light')
    fig.plot(3, 3, dta.t, (np.array((dta.e1)).T & 0xFF) / 2 - 30,
             'temperature')
예제 #5
0
import hhg_plot.hhg_plot as hplt
import hhg_dialogs.hhg_fopen as hhg_fopen
import hhg_io.hhg_import as hgi
from hhg_features.hhg_nght_stats import *

import pdb

#check where to load from (default is the 1st HedgeHog's data):
filename, scr = hhg_fopen.load('/media/HEDGEHOG/log000.HHG')

#open/parse the data:
stats = []
dta = []

if len(sys.argv) == 1:
	dta, stats = hgi.hhg_open_data(filename)
if len(sys.argv) == 2: 
	dta, stats = hgi.hhg_open_data(sys.argv[1])
    
print stats

if dta == []:
	exit()

#shortcut to read the new npy files (have 7 cols):
if len(dta[0])==7:
	fig = hplt.Hhg_raw_plot(scr.get_width()/80,8,80)
	fig.plot(1, 3, dta.t, np.array((dta.x,dta.y,dta.z)).T,'3D acceleration')
	fig.plot(2, 3, dta.t, np.array((dta.e1)).T>>8, 'ambient light')
	fig.plot(3, 3, dta.t, (np.array((dta.e1)).T&0xFF)/2-30, 'temperature')
	fig.show()