[INSTRM-1588] Inconsistency of coordinate transformation across different version of pfs_utils on different actors Created: 25/Apr/22 Updated: 17/May/22 Resolved: 17/May/22 |
|
| Status: | Done |
| Project: | Instrument control development |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | chyan | Assignee: | rhl |
| Resolution: | Done | Votes: | 0 |
| Labels: | EngRun | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Sprint: | PreEngRun05 F, PreEngRun05 G | ||||||||
| Reviewers: | rhl | ||||||||
| Description |
|
In the past few days, I found the pfs_utils returns different result across different version, especially, 6.2.0 and 6.1.3. Currently, MCS actor uses pfs_utils 6.1.3 without any problem. However, pfs_utils 6.2.0 causes error in transformation when I pull data from database (see attached figure). Since the pfs_utils is now widely used in all different actors, consistency is important. Therefore, we should take care this issue before the engineering run |
| Comments |
| Comment by cloomis [ 26/Apr/22 ] |
|
6.1.3 was from the middle of the 2021-11 run, 6.2.0 includes transform changes which were were running (and thus had tested) at the end of the run, plus a couple of tickets from after the run. If I am not being dim there is a bug in the new MeasureDistortion.clip() but have no idea whether it could show your problem. If I put a fix for that on a branch can you test? |
| Comment by cloomis [ 28/Apr/22 ] |
|
That bug fix did not fix Chi-Hung's problem. Leaving branch open, and leaving the .clip() change on the branch. |
| Comment by chyan [ 28/Apr/22 ] |
|
So, I did two tests last night. Two phi-arm motor map runs. The result looks like the following figure with version 6.1.3. Those spots are exactly at expected positions. However, if I use version 6.2.0, they looks lie this. |
| Comment by hassan [ 29/Apr/22 ] |
|
Chi-Hung will provide Hassan and Yuki input data to test the transform routines in pfs_utils and help to identify the problem. |
| Comment by hassan [ 29/Apr/22 ] |
|
Chi-Hung to confirm that 6.1.4 and 6.1.5 work correctly. |
| Comment by chyan [ 06/May/22 ] |
|
Uploading notebooks file for transformation INSTRM-1588.ipynb |
| Comment by chyan [ 10/May/22 ] |
|
OK, now I have better picture. Please see the plot. This evening, I use MCS with different versions of pfs_utils to transform cobra locations from pixel to mm unit. Since I did not command cobra to move, so they are pretty close to the cobra center (red spot). As you can see, 6.1.2 and 6.1.3 return reliable transformations. |
| Comment by hassan [ 10/May/22 ] |
|
The plots above shows that tag 6.1.4 is not reliable, but this tag is not applied to any code on any branch in GitHub, so possibly a fork: https://github.com/Subaru-PFS/pfs_utils/commit/9d076ba123d0933baafd009bd0682944f740eaff . If you have the opportunity, then a test with tag 6.1.5 would be great. (My apologies. I wrote an earlier comment following a ICS/PFI telecon discussion suggesting to check 6.1.4, but I did not check at that time that this tag is in fact invalid). |
| Comment by cloomis [ 11/May/22 ] |
|
6.1.4 is the code which was being used at the end of the Nov run. It was at the tip of the 6.1.4 was left at the end of that branch for posterity. We could add a more descriptive label name, or even a branch name if the GitHub web interface is confused. So checking against both 6.1.4 and 6.1.5 would be interesting. If 6.1.4 does not work I am worried, since it contained the last few RHL transform changes, some of which mattered quite a bit. |
| Comment by hassan [ 11/May/22 ] |
|
According to Chi-Hung's latest plots, 6.1.4 is problematic, as well as 6.2.0 which seems to give different results to 6.1.4. |
| Comment by hassan [ 11/May/22 ] |
|
Yuki and I independently find a bug in the sigma-clipping algorithm which was introduced after 6.1.3 . Preparing a fix. However I see Craig's comment above where this appears to be discounted. cloomis: can you elaborate why your fix did not work? |
| Comment by hassan [ 11/May/22 ] |
|
Fix pushed. chyan could you test please? |
| Comment by cloomis [ 11/May/22 ] |
|
chyan ran with the change, but still saw the problem. So the fix is still on the branch, but it does not solve this problem. |
| Comment by cloomis [ 11/May/22 ] |
|
There was also a swap in two of the distort() args (scale and theta), which seemed far more plausible, but I never tracked down how that could have leaked out into mcs/fps/cobracharmer. |
| Comment by cloomis [ 11/May/22 ] |
|
The recent proposed fixes are on a git branch named "PIPE2D-1588". Given the time I will go ahead and rename that to " |
| Comment by cloomis [ 11/May/22 ] |
|
Boring FYI: my fix on |
| Comment by chyan [ 11/May/22 ] |
|
hassan Please check the result of your fix. The transformation is still not good. |
| Comment by hassan [ 11/May/22 ] |
|
chyan Can you provide me with the frameId related to the MCS pixel coordinates you used to perform the transformation in the above plot please? |
| Comment by yuki.moritani [ 12/May/22 ] |
|
chyan I think you should call pfa_utils by setting insr0t=0 anytime for 71M camera. By changing pt = transformUtils.fromCameraName('rmod',altitude=90, insrot=teleInfo['insrot'].values[0]) to
pt = transformUtils.fromCameraName('rmod',altitude=90, insrot=0.)
(and using the same parameters as before) I got the same result. (without this change, I see a few micron difference, which I thought acceptable yesterday...) |
| Comment by hassan [ 12/May/22 ] |
|
Pushed the latest fix (previously in u/hassans/20220511a) to the ticket branch, such that it is ready to be merged to master. This fix re-introduces the basic algorithm in the MeasureDistortion._call_ method that was used in the pfs_utils 6.1.3, ie., without sigma-clipping. I believe that the sigma-clipping algorithm is however still valid, but a little more work is required to check its robustness across a number of scenarios. Given that there is little time before the May Eng Run, this should be addressed in a separate ticket after that run. |
| Comment by rhl [ 14/May/22 ] |
|
The change isn't in the sigma clipping, it's in the definition of the cost function (np.mean(d**n); n = 2 works; n = 1 doesn't). With n=1 the initial solution looks like this. The solution is to add a prior on the rotation for the original ring fit; this seems to work well. |
| Comment by rhl [ 14/May/22 ] |
|
The code sets alphaRot=0 for the final solution, so there's no bias due this prior (it'd be small anyway for any reasonable alphaRot as the number of points fitted is much larger). |
| Comment by rhl [ 14/May/22 ] |
|
I have just pushed these changes to the ticket branch. We need to make sure that chyan sees them and makes suitable changes in the calling code to take advantage of this work.
|
| Comment by hassan [ 14/May/22 ] |
|
One comment: if the algorithm (n=1) selected different fiducials in the first and second match, due to rotational symmetry. Is it good practice in any case of a prior, for Chi-Hung to select the original fiducials such that it is rotationally asymmetric? Eg pick 5 fiducials on the left of the PFI and 3 on the right? |
| Comment by chyan [ 17/May/22 ] |
|
I have tested Robert's fix. Attached plot show that the current transformation. The new fix consistent with the center positions of cobra. I would suggest this ticket to be closed and merge to mater. |
| Comment by hassan [ 17/May/22 ] |
|
Merged RHL's fix to master. |