GitHub PullRequestReviewCommentEvent at 2014-06-21 07:38:07
Repository: pyao
Actor: forcaeluz
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/faitdivers/pyao/pulls/comments/14048785","id":14048785,"diff_hunk":"@@ -1,5 +1,134 @@\n from numpy import *\n+import numpy\n+import matplotlib.pyplot as pl\n+from mpl_toolkits.mplot3d import Axes3D\n+from matplotlib import cm\n \n-def dm(actCom, paramsSens):\n-\treturn zeros((paramsSens['numPupilx'],paramsSens['numPupily']))\n+def calculateH(nwfRec, numAct, posWfr, posAct, sig1, sig2, w1, w2):    \n+    H = zeros([nwfRec,numAct]);\n+    for i in range (0, nwfRec):\n+        for j in range ( 0, numAct):\n+            H[i][j] = w1/(2*pi*sig1**2)*exp(-((posWfr[i][0]-posAct[j][0])**2+(posWfr[i][1]- posAct[j][1])**2)/(2*sig1**2))+ w2/(2*pi*sig2**2)*exp(-((posWfr[i][0]-posAct[j][0])**2+(posWfr[i][1]-posAct[j][1])**2)/(2*sig2**2))\n+    return H\n+\n+    \n+def plotWFR(wfr, noApertx, noAperty):\n+    # plot a wavefront\n+    W = wfr.reshape(noAperty+1, noApertx+1)\n+    xgridw = linspace(0,1,noApertx+1)\n+    ygridw = linspace(0,1,noAperty+1)        \n+    Xw, Yw = numpy.meshgrid(xgridw, ygridw)\n+    figu = pl.figure()\n+    axi = figu.gca(projection='3d')        \n+    surfa = axi.plot_surface(Xw, Yw, W, rstride=1, cstride=1, cmap=cm.coolwarm,linewidth=0, antialiased=True)        \n+    figu.colorbar(surfa, shrink=0.5, aspect=5)\n+    axi.set_xlim3d(0, xgridw.max())\n+    axi.set_ylim3d(0, ygridw.max())\n+    axi.set_zlim3d(W.min(), 1.03*W.max())\n+    pl.show()\n+    \n+def calculatePosWFr(numActx, numActy, noApertx, noAperty, lensCentx, lensCenty, dl):\n+    # calculate the position of the wavefronts according to hudgin geometry\n+    nWrx = noApertx+1\n+    print(\"number of wavefront x:\",nWrx)\n+    nWry = noAperty+1    \n+    posWfr = numpy.zeros([nWrx*nWry,2])\n+    \n+    dwf = dl # wavefront spacing is equal to the lenslet diameter\n+    \n+    lensCentPos = 0;\n+    upperflag = 0;\n+    for i in range(0, nWry):\n+        for j in range (0, nWrx):        \n+            if (i*nWrx+j<(i+1)*nWrx-1):\n+                posWfr[i*nWrx+j][0] = lensCentx[lensCentPos] - dwf/2\n+                posWfr[i*nWrx+j][1] = lensCenty[lensCentPos] - dwf/2                                \n+            else:\n+                posWfr[i*nWrx+j][0] = lensCentx[lensCentPos] + dwf/2\n+                posWfr[i*nWrx+j][1] = lensCenty[lensCentPos] - dwf/2                                                \n+                    \n+            if (j<noApertx-1)&(i<nWry-1)&((i*nWrx+j)<(nWrx*(nWry-1)-1)):             \n+                lensCentPos = lensCentPos + 1\n+            if upperflag == 1:                \n+                posWfr[i*nWrx+j][0] = posWfr[(i-1)*nWrx+j][0]\n+                posWfr[i*nWrx+j][1] = posWfr[(i-1)*nWrx+j][1] + dwf\n+#        print (\"limit:\",(i+1)*nWrx-1)\n+        if ((i*nWrx+j)==((i+1)*nWrx-1))&((i*nWrx+j)<(nWrx*(nWry-1)-1)):\n+            lensCentPos = lensCentPos + 1 \n+        if ((i*nWrx+j)>=(nWrx*(nWry-1)-1)):\n+            upperflag = 1;            \n+\n+    return posWfr\n+    \n+            \n+def dm(actCommand, paramsSens, paramsAct):\n+\n+    noApertx= paramsSens['noApertx']\n+    noAperty= paramsSens['noAperty']\n+    lensCentx = paramsSens['lensCentx']\n+    lensCenty = paramsSens['lensCenty']    \n+    numActx=paramsAct['numActx']\n+    numActy=paramsAct['numActy']\n+    dl = lensCentx[1] - lensCentx[0] # distance of two lenslet\n+    \n+    noApert = noApertx*noAperty # number of subapertures\n+     \n+    numAct = numActx*numActy # number of actuators  \n+    \n+    # length of wavefront reconstruction vector\n+    nwfRec = (noApertx+1)*(noAperty+1)\n+        \n+    wfRec = 0.5+0.001*random.randn(nwfRec,1) # generate wavefront reconstruction vector\n+        \n+    # parameters to characterize influence function\n+    w1= 2\n+    w2= -1\n+    sig1= 0.54*dl\n+    sig2= 0.85*dl\n+    \n+        \n+    posWfr = calculatePosWFr(numActx, numActy, noApertx, noAperty, lensCentx, lensCenty, dl)\n+    \n+    #calculate the position of the actuators\n+    posAct = numpy.zeros([numActx*numActy,2])\n+    posAct = array([lensCentx, lensCenty])\n+    posAct = posAct.T    \n+    \n+    \n+    u = ones([numAct, 1])\n+    \n+    # calculate influence matrix H\n+    H = calculateH(nwfRec, numAct, posWfr, posAct, sig1, sig2, w1, w2)            \n+    \n+    # least square solution\n+    print(\"Influence matrix:\",H)\n+    u = dot(dot(numpy.linalg.inv(dot(H.T,H)),H.T),wfRec)\n+    # u = pinv(H)*wfRec; # alternatives for pseudo inverse\n+    \n+    # residual error\n+    wfDM = dot(H,u)\n+    print(\"wfDM:\",wfDM)\n+    print(\"wfRec:\",wfRec)\n+    wfRes = wfRec - wfDM\n+    powerRes = sqrt((wfRes*wfRes).mean())\n+    \n+    print(\"RMS power of wavefront error is %f  \", powerRes)\n+    \n+    \n+    xgrid = linspace(0,posAct[:,0].max()+dl/2,20)\n+    ygrid = linspace(0,posAct[:,1].max()+dl/2,20) \n+    print(\"Actuator input:\", u)\n+\n+    # for plotting purpose, comment out if unnecessary","path":"src/DM/mainDM.py","position":124,"original_position":124,"commit_id":"34414fd1fac5d619189019e08e9b0b5ceb2a31a0","original_commit_id":"34414fd1fac5d619189019e08e9b0b5ceb2a31a0","user":{"login":"forcaeluz","id":3944335,"avatar_url":"https://avatars.githubusercontent.com/u/3944335?","gravatar_id":"401c94e9363e34ffe8b63a394c27685b","url":"https://api.github.com/users/forcaeluz","html_url":"https://github.com/forcaeluz","followers_url":"https://api.github.com/users/forcaeluz/followers","following_url":"https://api.github.com/users/forcaeluz/following{/other_user}","gists_url":"https://api.github.com/users/forcaeluz/gists{/gist_id}","starred_url":"https://api.github.com/users/forcaeluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/forcaeluz/subscriptions","organizations_url":"https://api.github.com/users/forcaeluz/orgs","repos_url":"https://api.github.com/users/forcaeluz/repos","events_url":"https://api.github.com/users/forcaeluz/events{/privacy}","received_events_url":"https://api.github.com/users/forcaeluz/received_events","type":"User","site_admin":false},"body":"Can you please remove this from the dm function? We don't want to plot in here, as this runs in the main loop.","created_at":"2014-06-21T07:38:07Z","updated_at":"2014-06-21T07:38:07Z","html_url":"https://github.com/faitdivers/pyao/pull/81#discussion_r14048785","pull_request_url":"https://api.github.com/repos/faitdivers/pyao/pulls/81","_links":{"self":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/comments/14048785"},"html":{"href":"https://github.com/faitdivers/pyao/pull/81#discussion_r14048785"},"pull_request":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/81"}}},"pull_request":{"url":"https://api.github.com/repos/faitdivers/pyao/pulls/81","id":17220015,"html_url":"https://github.com/faitdivers/pyao/pull/81","diff_url":"https://github.com/faitdivers/pyao/pull/81.diff","patch_url":"https://github.com/faitdivers/pyao/pull/81.patch","issue_url":"https://api.github.com/repos/faitdivers/pyao/issues/81","number":81,"state":"open","title":"creating new branch for dm","user":{"login":"yudhapane","id":6567677,"avatar_url":"https://avatars.githubusercontent.com/u/6567677?","gravatar_id":"f4ac219fa5b2643ed45a9a4c4f7ada33","url":"https://api.github.com/users/yudhapane","html_url":"https://github.com/yudhapane","followers_url":"https://api.github.com/users/yudhapane/followers","following_url":"https://api.github.com/users/yudhapane/following{/other_user}","gists_url":"https://api.github.com/users/yudhapane/gists{/gist_id}","starred_url":"https://api.github.com/users/yudhapane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yudhapane/subscriptions","organizations_url":"https://api.github.com/users/yudhapane/orgs","repos_url":"https://api.github.com/users/yudhapane/repos","events_url":"https://api.github.com/users/yudhapane/events{/privacy}","received_events_url":"https://api.github.com/users/yudhapane/received_events","type":"User","site_admin":false},"body":"The branch includes test file (test.py). It works fine if we use the test file (with given lenslet position). However, calling it from main.py still needs parameters from others. Furthermore, the dm function now requires additional parameter (paramsActuator) in order to work.","created_at":"2014-06-17T07:31:25Z","updated_at":"2014-06-21T07:38:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2bf72c8781a51e109ed5c94a4b27aef6b6e9fca9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/faitdivers/pyao/pulls/81/commits","review_comments_url":"https://api.github.com/repos/faitdivers/pyao/pulls/81/comments","review_comment_url":"https://api.github.com/repos/faitdivers/pyao/pulls/comments/{number}","comments_url":"https://api.github.com/repos/faitdivers/pyao/issues/81/comments","statuses_url":"https://api.github.com/repos/faitdivers/pyao/statuses/34414fd1fac5d619189019e08e9b0b5ceb2a31a0","head":{"label":"faitdivers:dm2","ref":"dm2","sha":"34414fd1fac5d619189019e08e9b0b5ceb2a31a0","user":{"login":"faitdivers","id":1611375,"avatar_url":"https://avatars.githubusercontent.com/u/1611375?","gravatar_id":"1da230deb180f9418d12a70a75944600","url":"https://api.github.com/users/faitdivers","html_url":"https://github.com/faitdivers","followers_url":"https://api.github.com/users/faitdivers/followers","following_url":"https://api.github.com/users/faitdivers/following{/other_user}","gists_url":"https://api.github.com/users/faitdivers/gists{/gist_id}","starred_url":"https://api.github.com/users/faitdivers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faitdivers/subscriptions","organizations_url":"https://api.github.com/users/faitdivers/orgs","repos_url":"https://api.github.com/users/faitdivers/repos","events_url":"https://api.github.com/users/faitdivers/events{/privacy}","received_events_url":"https://api.github.com/users/faitdivers/received_events","type":"User","site_admin":false},"repo":{"id":19397453,"name":"pyao","full_name":"faitdivers/pyao","owner":{"login":"faitdivers","id":1611375,"avatar_url":"https://avatars.githubusercontent.com/u/1611375?","gravatar_id":"1da230deb180f9418d12a70a75944600","url":"https://api.github.com/users/faitdivers","html_url":"https://github.com/faitdivers","followers_url":"https://api.github.com/users/faitdivers/followers","following_url":"https://api.github.com/users/faitdivers/following{/other_user}","gists_url":"https://api.github.com/users/faitdivers/gists{/gist_id}","starred_url":"https://api.github.com/users/faitdivers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faitdivers/subscriptions","organizations_url":"https://api.github.com/users/faitdivers/orgs","repos_url":"https://api.github.com/users/faitdivers/repos","events_url":"https://api.github.com/users/faitdivers/events{/privacy}","received_events_url":"https://api.github.com/users/faitdivers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/faitdivers/pyao","description":"PyAO - Adaptive Optics simulation package","fork":false,"url":"https://api.github.com/repos/faitdivers/pyao","forks_url":"https://api.github.com/repos/faitdivers/pyao/forks","keys_url":"https://api.github.com/repos/faitdivers/pyao/keys{/key_id}","collaborators_url":"https://api.github.com/repos/faitdivers/pyao/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/faitdivers/pyao/teams","hooks_url":"https://api.github.com/repos/faitdivers/pyao/hooks","issue_events_url":"https://api.github.com/repos/faitdivers/pyao/issues/events{/number}","events_url":"https://api.github.com/repos/faitdivers/pyao/events","assignees_url":"https://api.github.com/repos/faitdivers/pyao/assignees{/user}","branches_url":"https://api.github.com/repos/faitdivers/pyao/branches{/branch}","tags_url":"https://api.github.com/repos/faitdivers/pyao/tags","blobs_url":"https://api.github.com/repos/faitdivers/pyao/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/faitdivers/pyao/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/faitdivers/pyao/git/refs{/sha}","trees_url":"https://api.github.com/repos/faitdivers/pyao/git/trees{/sha}","statuses_url":"https://api.github.com/repos/faitdivers/pyao/statuses/{sha}","languages_url":"https://api.github.com/repos/faitdivers/pyao/languages","stargazers_url":"https://api.github.com/repos/faitdivers/pyao/stargazers","contributors_url":"https://api.github.com/repos/faitdivers/pyao/contributors","subscribers_url":"https://api.github.com/repos/faitdivers/pyao/subscribers","subscription_url":"https://api.github.com/repos/faitdivers/pyao/subscription","commits_url":"https://api.github.com/repos/faitdivers/pyao/commits{/sha}","git_commits_url":"https://api.github.com/repos/faitdivers/pyao/git/commits{/sha}","comments_url":"https://api.github.com/repos/faitdivers/pyao/comments{/number}","issue_comment_url":"https://api.github.com/repos/faitdivers/pyao/issues/comments/{number}","contents_url":"https://api.github.com/repos/faitdivers/pyao/contents/{+path}","compare_url":"https://api.github.com/repos/faitdivers/pyao/compare/{base}...{head}","merges_url":"https://api.github.com/repos/faitdivers/pyao/merges","archive_url":"https://api.github.com/repos/faitdivers/pyao/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/faitdivers/pyao/downloads","issues_url":"https://api.github.com/repos/faitdivers/pyao/issues{/number}","pulls_url":"https://api.github.com/repos/faitdivers/pyao/pulls{/number}","milestones_url":"https://api.github.com/repos/faitdivers/pyao/milestones{/number}","notifications_url":"https://api.github.com/repos/faitdivers/pyao/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/faitdivers/pyao/labels{/name}","releases_url":"https://api.github.com/repos/faitdivers/pyao/releases{/id}","created_at":"2014-05-03T06:50:50Z","updated_at":"2014-06-21T07:29:04Z","pushed_at":"2014-06-21T07:29:03Z","git_url":"git://github.com/faitdivers/pyao.git","ssh_url":"git@github.com:faitdivers/pyao.git","clone_url":"https://github.com/faitdivers/pyao.git","svn_url":"https://github.com/faitdivers/pyao","homepage":"","size":5715,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":27,"forks":0,"open_issues":27,"watchers":5,"default_branch":"master"}},"base":{"label":"faitdivers:master","ref":"master","sha":"d2e4da77f97c7c9d0035a4bfdfbd17d19f40cfa5","user":{"login":"faitdivers","id":1611375,"avatar_url":"https://avatars.githubusercontent.com/u/1611375?","gravatar_id":"1da230deb180f9418d12a70a75944600","url":"https://api.github.com/users/faitdivers","html_url":"https://github.com/faitdivers","followers_url":"https://api.github.com/users/faitdivers/followers","following_url":"https://api.github.com/users/faitdivers/following{/other_user}","gists_url":"https://api.github.com/users/faitdivers/gists{/gist_id}","starred_url":"https://api.github.com/users/faitdivers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faitdivers/subscriptions","organizations_url":"https://api.github.com/users/faitdivers/orgs","repos_url":"https://api.github.com/users/faitdivers/repos","events_url":"https://api.github.com/users/faitdivers/events{/privacy}","received_events_url":"https://api.github.com/users/faitdivers/received_events","type":"User","site_admin":false},"repo":{"id":19397453,"name":"pyao","full_name":"faitdivers/pyao","owner":{"login":"faitdivers","id":1611375,"avatar_url":"https://avatars.githubusercontent.com/u/1611375?","gravatar_id":"1da230deb180f9418d12a70a75944600","url":"https://api.github.com/users/faitdivers","html_url":"https://github.com/faitdivers","followers_url":"https://api.github.com/users/faitdivers/followers","following_url":"https://api.github.com/users/faitdivers/following{/other_user}","gists_url":"https://api.github.com/users/faitdivers/gists{/gist_id}","starred_url":"https://api.github.com/users/faitdivers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faitdivers/subscriptions","organizations_url":"https://api.github.com/users/faitdivers/orgs","repos_url":"https://api.github.com/users/faitdivers/repos","events_url":"https://api.github.com/users/faitdivers/events{/privacy}","received_events_url":"https://api.github.com/users/faitdivers/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/faitdivers/pyao","description":"PyAO - Adaptive Optics simulation package","fork":false,"url":"https://api.github.com/repos/faitdivers/pyao","forks_url":"https://api.github.com/repos/faitdivers/pyao/forks","keys_url":"https://api.github.com/repos/faitdivers/pyao/keys{/key_id}","collaborators_url":"https://api.github.com/repos/faitdivers/pyao/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/faitdivers/pyao/teams","hooks_url":"https://api.github.com/repos/faitdivers/pyao/hooks","issue_events_url":"https://api.github.com/repos/faitdivers/pyao/issues/events{/number}","events_url":"https://api.github.com/repos/faitdivers/pyao/events","assignees_url":"https://api.github.com/repos/faitdivers/pyao/assignees{/user}","branches_url":"https://api.github.com/repos/faitdivers/pyao/branches{/branch}","tags_url":"https://api.github.com/repos/faitdivers/pyao/tags","blobs_url":"https://api.github.com/repos/faitdivers/pyao/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/faitdivers/pyao/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/faitdivers/pyao/git/refs{/sha}","trees_url":"https://api.github.com/repos/faitdivers/pyao/git/trees{/sha}","statuses_url":"https://api.github.com/repos/faitdivers/pyao/statuses/{sha}","languages_url":"https://api.github.com/repos/faitdivers/pyao/languages","stargazers_url":"https://api.github.com/repos/faitdivers/pyao/stargazers","contributors_url":"https://api.github.com/repos/faitdivers/pyao/contributors","subscribers_url":"https://api.github.com/repos/faitdivers/pyao/subscribers","subscription_url":"https://api.github.com/repos/faitdivers/pyao/subscription","commits_url":"https://api.github.com/repos/faitdivers/pyao/commits{/sha}","git_commits_url":"https://api.github.com/repos/faitdivers/pyao/git/commits{/sha}","comments_url":"https://api.github.com/repos/faitdivers/pyao/comments{/number}","issue_comment_url":"https://api.github.com/repos/faitdivers/pyao/issues/comments/{number}","contents_url":"https://api.github.com/repos/faitdivers/pyao/contents/{+path}","compare_url":"https://api.github.com/repos/faitdivers/pyao/compare/{base}...{head}","merges_url":"https://api.github.com/repos/faitdivers/pyao/merges","archive_url":"https://api.github.com/repos/faitdivers/pyao/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/faitdivers/pyao/downloads","issues_url":"https://api.github.com/repos/faitdivers/pyao/issues{/number}","pulls_url":"https://api.github.com/repos/faitdivers/pyao/pulls{/number}","milestones_url":"https://api.github.com/repos/faitdivers/pyao/milestones{/number}","notifications_url":"https://api.github.com/repos/faitdivers/pyao/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/faitdivers/pyao/labels{/name}","releases_url":"https://api.github.com/repos/faitdivers/pyao/releases{/id}","created_at":"2014-05-03T06:50:50Z","updated_at":"2014-06-21T07:29:04Z","pushed_at":"2014-06-21T07:29:03Z","git_url":"git://github.com/faitdivers/pyao.git","ssh_url":"git@github.com:faitdivers/pyao.git","clone_url":"https://github.com/faitdivers/pyao.git","svn_url":"https://github.com/faitdivers/pyao","homepage":"","size":5715,"stargazers_count":5,"watchers_count":5,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":27,"forks":0,"open_issues":27,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/81"},"html":{"href":"https://github.com/faitdivers/pyao/pull/81"},"issue":{"href":"https://api.github.com/repos/faitdivers/pyao/issues/81"},"comments":{"href":"https://api.github.com/repos/faitdivers/pyao/issues/81/comments"},"review_comments":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/81/comments"},"review_comment":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/faitdivers/pyao/pulls/81/commits"},"statuses":{"href":"https://api.github.com/repos/faitdivers/pyao/statuses/34414fd1fac5d619189019e08e9b0b5ceb2a31a0"}}}}