#             ("dif index","middle","ring","pinky"))             
#plo.plotter2d((dif_A[:,:3], dif_A[:,3:6], dif_A[:,6:9], dif_A[:,9:]),
#             ("dif_A index","middle","ring","pinky"))                     




f.write("Start of estimation routine!\n")
for i in range(0,2):
    methString = "METHOD:" + str(i)
    print methString
    f.write(methString + '\n')
    
    ''' dip without ad-ab '''
    startT = time.time()    
    estAng_dip = modD.estimateSeries(b_cyl_A, fingList, sensList, jointList, bnds=True, met=i)
    endT = time.time()-startT
    
    resString = "model: dipole, without adduction-abduction\n"
    resString += "total time[sec] needed: " + str(endT) + "\n"
    resString += "avg time per step[sec]: " + str(endT/len(simValues_A)) + "\n\n"
    # resString += "max fun value: " + str(max(fun_dip)) + "\n\n"
    print resString
    f.write(resString)
    datAc.saveStates(folderStr+"estAng_dip"+str(i), estAng_dip)
    plo.plotter2d((estAng_dip[:,:3], estAng_dip[:,3:6]),
                  ("model: dip without Adduction index","middle"+methString))
#    plo.plotter2d((estAng_dip[:,:3], estAng_dip[:,3:6], estAng_dip[:,6:9], estAng_dip[:,9:]),
#             ("model: dip without Adduction index","middle"+methString,"ring","pinky"))
    plt.savefig(folderStr+str(i)+"dip_nA.png")
            (0.0,np.pi/2.))
#
#startDip = time.time()
#cnt = 0
#for i in b_dip[1:]:
#    print "dipole estimation step: ", cnt
##    tmp = modD.estimate_BtoAng(estAng_dip[cnt],fingList_dip,jointList_dip,sensList_dip,i)
#    tmp = modD.estimate_BtoAng(estAng_dip[cnt],fingList,sensList,jointList,i,bnds=bnds_dip[:len(fingList)*2],method=2)
##    print "function value: ", tmp.fun
#    estAng_dip[cnt+1] = tmp.x
#    fun_dip[cnt+1] = tmp.fun
#    
#    cnt += 1
#
#timeDip = time.time()-startDip

ang_d = modD.estimateSeries(b_dip,fingList,sensList,jointList,bnds=True,met=1)
ang_c = modC.estimateSeries(b_cyl,fingList,sensList,jointList,bnds=True,met=1)
plo.plotter2d((ang_d[:,:3],ang_c[:,:3]),("dipole","cyl"))
#plo.plotter2d((angles_cyl,estAng_dip,ang_d,estAng_cyl,ang_c),("perfect","dip","dipPacked","cyl","cylPacked"))


#plo.plotter2d((estAng_cyl, estAng_dip),("est cyl", "est dip"), mtitle='estimated angles')
#print "time for cyl: ", timeCyl
#print "max cyl: ", max(fun_cyl)
#print "mean cyl: ", np.mean(fun_cyl)
#
#print "time for dip: ", timeDip
#print "max cyl: ", max(fun_dip)
#print "mean cyl: ", np.mean(fun_dip)