def plot2(): fig5 = plt.figure() x = map(lambda x: x + gauss(0,0.02)*(1-x*x), arange(-1,1,0.001)) y = map(lambda x: x + gauss(0,0.02)*(1-x*x), arange(-1,1,0.001)) z = map(lambda x: x + gauss(0,0.02)*(1-x*x), arange(-1,1,0.001)) line = array(zip(x,y,z)) lpc = LPCImpl(h = 0.05, mult = 2, it = 200, cross = False, scaled = False, convergence_at = 0.001) lpc_curve = lpc.lpc(X=line) ax = Axes3D(fig5) ax.set_title('testNoisyLine2') curve = lpc_curve[0]['save_xd'] ax.scatter(x,y,z, c = 'red') ax.plot(curve[:,0],curve[:,1],curve[:,2]) saveToPdf(fig5, '/tmp/testNoisyLine2.pdf') residuals_calc = LPCResiduals(line, tube_radius = 0.05, k = 10) residual_diags = residuals_calc.getPathResidualDiags(lpc_curve[0]) fig6 = plt.figure() #plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_num_NN'], drawstyle = 'step', linestyle = '--') plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_mean_NN']) plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_std_NN']) saveToPdf(fig6, '/tmp/testNoisyLine2PathResiduals.pdf') coverage_graph = residuals_calc.getCoverageGraph(lpc_curve[0], arange(0.001, .102, 0.005)) fig7 = plt.figure() plt.plot(coverage_graph[0],coverage_graph[1]) saveToPdf(fig7, '/tmp/testNoisyLine2Coverage.pdf') residual_graph = residuals_calc.getGlobalResiduals(lpc_curve[0]) fig8 = plt.figure() plt.plot(residual_graph[0], residual_graph[1]) saveToPdf(fig8, '/tmp/testNoisyLine2Residuals.pdf') fig9 = plt.figure() plt.plot(range(len(lpc_curve[0]['lamb'])), lpc_curve[0]['lamb']) saveToPdf(fig9, '/tmp/testNoisyLine2PathLength.pdf')
def helixHeteroscedasticDiags(): #Parameterise a helix (no noise) fig5 = plt.figure() t = arange(-1,1,0.0005) x = map(lambda x: x + gauss(0,0.001 + 0.001*sin(2*pi*x)**2), (1 - t*t)*sin(4*pi*t)) y = map(lambda x: x + gauss(0,0.001 + 0.001*sin(2*pi*x)**2), (1 - t*t)*cos(4*pi*t)) z = map(lambda x: x + gauss(0,0.001 + 0.001*sin(2*pi*x)**2), t) line = array(zip(x,y,z)) lpc = LPCImpl(h = 0.1, t0 = 0.1, mult = 1, it = 500, scaled = False, cross = False) lpc_curve = lpc.lpc(X=line) ax = Axes3D(fig5) ax.set_title('helixHeteroscedastic') curve = lpc_curve[0]['save_xd'] ax.scatter(x,y,z, c = 'red') ax.plot(curve[:,0],curve[:,1],curve[:,2]) saveToPdf(fig5, '/tmp/helixHeteroscedastic.pdf') residuals_calc = LPCResiduals(line, tube_radius = 0.2, k = 20) residual_diags = residuals_calc.getPathResidualDiags(lpc_curve[0]) fig6 = plt.figure() #plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_num_NN'], drawstyle = 'step', linestyle = '--') plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_mean_NN']) plt.plot(lpc_curve[0]['lamb'][1:], residual_diags['line_seg_std_NN']) saveToPdf(fig6, '/tmp/helixHeteroscedasticPathResiduals.pdf') coverage_graph = residuals_calc.getCoverageGraph(lpc_curve[0], arange(0.01, .052, 0.01)) fig7 = plt.figure() plt.plot(coverage_graph[0],coverage_graph[1]) saveToPdf(fig7, '/tmp/helixHeteroscedasticCoverage.pdf') residual_graph = residuals_calc.getGlobalResiduals(lpc_curve[0]) fig8 = plt.figure() plt.plot(residual_graph[0], residual_graph[1]) saveToPdf(fig8, '/tmp/helixHeteroscedasticResiduals.pdf') fig9 = plt.figure() plt.plot(range(len(lpc_curve[0]['lamb'])), lpc_curve[0]['lamb']) saveToPdf(fig9, '/tmp/helixHeteroscedasticPathLength.pdf')