Ejemplo n.º 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)
Ejemplo n.º 2
0
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:
dta, stats = hgi.hhg_open_data(filename)
print stats

if dta == []:
	exit()

#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, (res_ngt*4)-20, nums)
Ejemplo n.º 3
0
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()
    exit(0)

#do night detection and prepare long-term plot, if enough data:
if len(dta) > 100000:
    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, (res_ngt * 4) - 20, nums)