[PIPE2D-109] Include sigma clipping in wavelength calibration Created: 21/Oct/16  Updated: 03/Mar/17  Resolved: 09/Feb/17

Status: Done
Project: DRP 2-D Pipeline
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Story Priority: Major
Reporter: aritter Assignee: aritter
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
blocks PIPE2D-80 Task-ify code for creating normalized... Done
Relates
relates to PIPE2D-114 Apply clean-ups in PIPE2D-109 Done
relates to PIPE2D-110 Please ignore emission lines with too... Won't Fix
relates to PIPE2D-157 Split testPolyFit() in Utils.cc into ... Won't Fix
relates to PIPE2D-158 Replace C++ test code in testPolyFit(... Won't Fix
relates to PIPE2D-163 split up tests for PolyFit into sever... Won't Fix
Story Points: 2
Sprint: 2014-16
Reviewers: swinbank

 Description   

We should reject outlier emission lines which are affected by cosmics, misidentification, or blends. Please include sigma clipping of lines used for the wavelength calibration during the fitting procedure.



 Comments   
Comment by aritter [ 28/Oct/16 ]

Code is in drp_stella tickets/PIPE2D-109.
Tests are in drp_stella/tests/Math.py, part of the tests in Utils.cc as I couldn't figure out how to pass PolyFit keywords and keyword values from Python to C++. To test use master obs_pfs and master drp_stella_data and run

python tests/Math.py

Comment by swinbank [ 29/Oct/16 ]
  • Please clean up history. If possible, remove commits which are unrelated to this ticket (all the cleanups) and put them on another ticket.
  • Please set mask bits to indicate where clipping has taken place.
Comment by aritter [ 04/Nov/16 ]

Moved all clean-up commits to PIPE2D-114 and set mask bits where clipping has taken place.

Comment by swinbank [ 08/Nov/16 ]

I added a bunch of comments on this PR. However, I screwed up, and some of the comments seem to have appeared in odd places. I hope that everything is clear enough, but do ask if anything isn't or if something seems to be missing.

One thing that I found rather odd is the structure of the PolyFit tests. I see you referred to these above, but I didn't notice that until after I'd looked at the code. I think it would be worth spending a bit more effort to figure out how things are supposed to work.

I hope that after you've acted on my comments the code will be rather easier to read, and, at that point, I'd like to take another look through before we merge.

Comment by aritter [ 18/Dec/16 ]

I believe I addressed all comments from the previous review.

Comment by swinbank [ 24/Jan/17 ]

This is a significant improvement over the previous version of the code: thank you! Particularly welcome are the improved commit messages — it's much easier to understand what you've actually done.

Some more comments on the PR. Most of these are quite minor, though; while I encourage you to read them, I think you can ignore most of them. Here are things I'd specifically like you to act on:

  • If I understand correctly, you always perform sigma clipping, even if the user specifies nIterReject=0. That seems like pretty pathological behaviour. At a minimum, I think you need to make this clear in the documentation for the nIterReject option and print out a big warning when the users asks for no iterations but you give them one anyway.
  • Take out the if True in testPolyFit.
  • Squash 4962901 into 43f0228.
  • Expand the commit message of 43f0228 to explain why this change was necessary.
  • 40b75e0b should clearly be squashed into something: it's not a well-formed commit on its own.
  • Based on the commit messages, f9aa3554 seems to be addressing the same issue as 077f70ad7. Please clarify what's going on here — if these commits really are degenerate, remove one (or squash them); if not, change the messages so they can't be confused.
  • 12ed6b53 seems to be entirely superseded by 1778b3b2. Remove it.
  • I don't understand the motivation for 2c01217. If the measurement errors aren't used, why are you initializing them or allocating space for them at all? I don't see why one set of useless numbers is "cleaner" than another set of useless numbers.
  • c0726b254 is entirely degenerate with 03b9440ae. Remove it.
  • There are several separate commits which initialize various arrays or variables to 0. I don't understand why these have suddenly become necessary: are they fixing bugs (if so, where are the tests?) or are you just being neat? Can we at least squash all these various commits into one?
  • 1778b3b2 definitely requires a unit test. I'm worried that the tests added in 9cf52a3 didn't catch this problem — why not?
  • The changes in 09058d0 are very very extensive. I suggest:
    • Rather than making this change last in the history of the ticket, you add the relevant headers so you can use logging as the first commit. Then never add any #ifdef __DEBUG... statements at all during this work: all of the output you are adding on this ticket can be a call to the logger, and you will not need this final commit to convert them all.
    • File another ticket to convert any output which was not added on this ticket to use the logger.
Comment by swinbank [ 24/Jan/17 ]

I'd like to take another look at this before we regard it as finally done, so I'm setting it back to "in progress" for now.

Comment by aritter [ 24/Jan/17 ]
  • I changed the PolyFit function with sigma rejection to not perform the sigma rejection at all if nIterReject=0.
  • I don't see an if True in testPolyFit...?
  • Regarding 2c01217 I now only create a ndarray of length 1, added comments to the code, and changed the commit message
  • Regarding the initializing commits, the change in 03b9440 regarding sigma and covar is purely cosmetical, while the change in ee5215c (removed 2 initializations as they were unnecessary) was a bug fix (test added)
  • Regarding 1778b3b2 there are tests in the source code. The issue itself is very difficult to test from outside the function.
  • I applied all other suggested changes, except for the last one as it was too late for that, but will keep it in mind next time...
Comment by swinbank [ 24/Jan/17 ]
  • I think 188710084 is new since I looked at this previously. If these are purely cleanups, it seems like they'd be better suited on PIPE2D-114.
  • Similar story for f050bcd9c: you should not add new trailing spaces in any commit — where that's happened on this ticket, you need to edit the commit to take them out again. You should not insert them on one commit and then add another to take them out again. A commit to go through old work and remove spaces that were incorrectly added on other tickets is pure cleanup, and belongs on PIPE2D-114.
  • Here is the if True I object to: https://github.com/Subaru-PFS/drp_stella/blob/f3ed39943d32bcbfaf0f128d290fb979281fa7b9/tests/Spectra.py#L517
  • Please file a ticket to request that testPolyFit() in Utils.cc (ie, the C++ code, not the Python) should be split into multiple separate functions.
  • Please file another ticket to request that the C++ test code be replaced with (or augmented by) Python tests when either we figure out how to wrap the necessary functionality with Swig or we replace it with pybind11.

Otherwise, go ahead and merge.

Comment by aritter [ 08/Feb/17 ]

Fixed commits by removing freshly introduced trailing spaces.
Moved clean-up commits to PIPE2D-114.
Added tickets PIPE2D-157 and PIPE2D-158.

Comment by aritter [ 09/Feb/17 ]

Merged into master

Generated at Sat Feb 10 15:48:32 JST 2024 using Jira 8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b.