def plot_laser(ax,arena,ldf,tdf,hdf,geom): madplot.plot_laser_trajectory(ax, ldf, arena) ax.add_patch(arena.get_patch(color='k', alpha=0.1))
def plot_data(arena, path, data): target_name = data['target_name'] pool_df = data['pooldf'] ldf = data['ldf'] hdf = data['hdf'] target_ranges = data['target_ranges'] fig = plt.figure("Image Processing Time (%s)" % target_name) ax = fig.add_subplot(1, 1, 1) ax.hist(hdf['h_processing_time'].values, bins=100) ax.set_xlabel('processing time (s)') ax.set_title("Distribution of time taken for %s detection" % target_name) fig.savefig('imgproc_%s.png' % target_name) fig = plt.figure("TTM Tracking", figsize=(8, 8)) ax = fig.add_subplot(1, 1, 1) ax.add_patch(arena.get_patch(color='k', alpha=0.1)) madplot.plot_laser_trajectory(ax, ldf, arena) ax.set_title("The effect of TTM tracking on laser position.\n"\ "Values required to hit the fly %s" % target_name) ax.legend() fig.savefig('ttmeffect_%s.png' % target_name) all_v = [] all_e = [] #YAY finally plot for k in target_ranges: vmin, vmax = k fvels = "%s-%s px" % (vmin, vmax) figf = plt.figure("tFly %s/s" % fvels) axf = figf.add_subplot(1, 1, 1) axf_w = axf.twinx() figt = plt.figure("tTTM %s/s" % fvels) axt = figt.add_subplot(1, 1, 1) axt_w = axt.twinx() for trg in target_ranges[k]: #widefiled err = trg.wf_err axf_w.plot(err.dt_thisfly, wide_conv(err.err), 'r', alpha=0.3) axt_w.plot(err.dt_ttm, wide_conv(err.err), 'r', alpha=0.3) #ttm err = trg.ttm_err axf.plot(err.dt_thisfly, ttm_conv(err.err), 'k', alpha=0.2) axt.plot(err.dt_ttm, ttm_conv(err.err), 'k', alpha=0.2) all_v.append(trg.v) all_e.append(np.mean(ttm_conv(err.err))) for ax in (axf, axt): ax.set_xlim([0, 0.25]) ax.set_xlabel('time (s)') ax.set_ylabel('TTM error (%s)' % ttm_unit) ax.set_ylim([0, 1.5]) for ax in (axf_w, axt_w): ax.set_ylabel('deviation from WF COM (%s)' % wide_unit) ax.set_ylim([0, 4]) for axttm, axwf in [(axt, axt_w), (axf, axf_w)]: axttm.set_zorder(axwf.get_zorder() + 1) # put ax in front of ax2 axttm.patch.set_visible(False) axf.set_title("Spacial accuracy of %s targeting (fly speed %s/s)\n"\ "(time since targeting this fly)" % (target_name,fvels)) axt.set_title("Spacial accuracy of %s targeting (fly speed %s/s)\n"\ "(time since switching to TTM targeting)" % (target_name,fvels)) figf.savefig(('tFly%s%s.png' % (fvels, target_name)).replace(' ', '')) figt.savefig(('tTTM%s%s.png' % (fvels, target_name)).replace(' ', '')) fig = plt.figure("Speed %s" % target_name) ax = fig.add_subplot(1, 1, 1) ax.scatter(wide_conv(all_v), all_e) ax.set_ylim([0, 1.5]) ax.set_xlim([0, 2.5]) ax.set_title("Spacial accuracy of %s targeting" % target_name) ax.set_xlabel('fly speed (%s/s)' % wide_unit) ax.set_ylabel('error (%s)' % ttm_unit) fig.savefig('flyv_errpx_%s.png' % target_name)
def plot_laser(ax, arena, ldf, tdf, hdf, geom): madplot.plot_laser_trajectory(ax, ldf, arena) ax.add_patch(arena.get_patch(color='k', alpha=0.1))
def plot_data(arena, path, data): target_name = data['target_name'] pool_df = data['pooldf'] ldf = data['ldf'] hdf = data['hdf'] target_ranges = data['target_ranges'] fig = plt.figure("Image Processing Time (%s)" % target_name) ax = fig.add_subplot(1,1,1) ax.hist(hdf['h_processing_time'].values, bins=100) ax.set_xlabel('processing time (s)') ax.set_title("Distribution of time taken for %s detection" % target_name) fig.savefig('imgproc_%s.png' % target_name) fig = plt.figure("TTM Tracking", figsize=(8,8)) ax = fig.add_subplot(1,1,1) ax.add_patch(arena.get_patch(color='k', alpha=0.1)) madplot.plot_laser_trajectory(ax, ldf, arena) ax.set_title("The effect of TTM tracking on laser position.\n"\ "Values required to hit the fly %s" % target_name) ax.legend() fig.savefig('ttmeffect_%s.png' % target_name) all_v = [] all_e = [] #YAY finally plot for k in target_ranges: vmin,vmax = k fvels = "%s-%s px" % (vmin,vmax) figf = plt.figure("tFly %s/s" % fvels) axf = figf.add_subplot(1,1,1) axf_w = axf.twinx() figt = plt.figure("tTTM %s/s" % fvels) axt = figt.add_subplot(1,1,1) axt_w = axt.twinx() for trg in target_ranges[k]: #widefiled err = trg.wf_err axf_w.plot(err.dt_thisfly, wide_conv(err.err), 'r', alpha=0.3) axt_w.plot(err.dt_ttm, wide_conv(err.err), 'r', alpha=0.3) #ttm err = trg.ttm_err axf.plot(err.dt_thisfly, ttm_conv(err.err), 'k', alpha=0.2) axt.plot(err.dt_ttm, ttm_conv(err.err), 'k', alpha=0.2) all_v.append(trg.v) all_e.append(np.mean(ttm_conv(err.err))) for ax in (axf,axt): ax.set_xlim([0, 0.25]) ax.set_xlabel('time (s)') ax.set_ylabel('TTM error (%s)' % ttm_unit) ax.set_ylim([0, 1.5]) for ax in (axf_w,axt_w): ax.set_ylabel('deviation from WF COM (%s)' % wide_unit) ax.set_ylim([0, 4]) for axttm,axwf in [(axt,axt_w),(axf,axf_w)]: axttm.set_zorder(axwf.get_zorder()+1) # put ax in front of ax2 axttm.patch.set_visible(False) axf.set_title("Spacial accuracy of %s targeting (fly speed %s/s)\n"\ "(time since targeting this fly)" % (target_name,fvels)) axt.set_title("Spacial accuracy of %s targeting (fly speed %s/s)\n"\ "(time since switching to TTM targeting)" % (target_name,fvels)) figf.savefig(('tFly%s%s.png' % (fvels,target_name)).replace(' ','')) figt.savefig(('tTTM%s%s.png' % (fvels,target_name)).replace(' ','')) fig = plt.figure("Speed %s" % target_name) ax = fig.add_subplot(1,1,1) ax.scatter(wide_conv(all_v),all_e) ax.set_ylim([0, 1.5]) ax.set_xlim([0, 2.5]) ax.set_title("Spacial accuracy of %s targeting" % target_name) ax.set_xlabel('fly speed (%s/s)' % wide_unit) ax.set_ylabel('error (%s)' % ttm_unit) fig.savefig('flyv_errpx_%s.png' % target_name)