New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JP-3584: Use rolling window median for TSO outlier detection #8473
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8473 +/- ##
==========================================
+ Coverage 57.93% 58.05% +0.11%
==========================================
Files 387 388 +1
Lines 38839 38912 +73
==========================================
+ Hits 22502 22589 +87
+ Misses 16337 16323 -14 ☔ View full report in Codecov by Sentry. |
Regression tests started here. Marking this ready for review even though I still need to figure out why the readthedocs build is failing. |
the only regtest failure was also present here, so I don't think this PR causes that issue. However, I seem to have introduced a new unit test failure with the last small bugfix. Will track that down |
New regtest run started here for code changes that address comment from @braingram. The imaging mode is still refactored, but the new version should preserve the way memory is used. Let me know whether the refactor is desired - some of the refactoring is definitely extraneous to the TSO changes and could be reverted if not desired. |
Thanks for putting this together. One general question I have is: what does the refactoring of the non-tso modes provide? If it's not required for the tso changes I think it makes sense to be a separate PR where the addressed issues and improvements are described. |
Agree with you RE some aspects of the additional refactor, specifically the modelwise_operation decorator. I started working on it when I misunderstood exactly what was needed for the TSO modes, and then just didn't revert it when I realized the TSO modes needed something different. I do think the decorators could be a useful way to ensure that memory is taken care of responsibly when running certain operations, and I'd be curious to hear your thoughts on that. However it's a solution to a problem that doesn't exist yet, and may never exist. It does feel a bit strange to revert the use of I think splitting the imaging mode into its own class and inheriting from a base class makes sense to include in this PR because imaging, spec, and now TSO all use similar but distinct data processing workflows. I don't know much about the coronagraphic modes but it's possible that coronagraphy might need its own, very similar, workflow as well - this is something I have been meaning to ask @hbushouse. |
Thanks for the detailed response!
Thanks for the clarification. I'd be happy to discuss this.
Perhaps we could discuss this also as I'm still struggling to see how the Is the input tso data a 3D cube? If so, the entirety of the input will be read on the first call to
Splitting up the modes into sub-classes sounds great to me. I'm much less familiar with the non-image paths in this step and have been mostly focused on trying to improve the performance. I certainly do not mean to derail this PR but hopefully some of my comments have been helpful. |
After a long discussion with @braingram about existing memory issues with calwebb_tso3 and calwebb_image3, it's clear that this PR is attempting to do too much. It's trying to use, and make more generic, some memory optimizations that are not necessarily working correctly anyway, e.g. this issue. The proposed path forward for this JIRA ticket is to make a very straightforward change to support the rolling median calculation, without worrying about memory at all. This requires undoing a lot of the changes in this PR. Then for the future, in order to implement the above-mentioned issue in a way that will also support TSO data, I'll look into what kinds of large datasets might need to be processed through this step. |
Yet another regtest run started here. In this version the only refactors should be splitting some chunks of the imaging pipeline flow into their own functions to be re-used by outlier_detection_tso. I think I fixed all the other issues @braingram brought up too and I'm going to resolve those comments now. |
Thanks! Please do consider all of my previous comments addressed. The code changes look good to me and feel free to ping me when the regtests finish if a review would be helpful. |
All the regression test failures seem to be unrelated. This is ready for your review @hbushouse. You may wonder why there aren't any expected regtest failures for such a change, which should affect all data processed through calwebb_tso3. The reason is that there are no regtest datasets with >25 integrations (the default rolling window), which means that as written the code will revert to using a simple median. Another note: I did check that the unit test I wrote fails for simple median but succeeds for rolling-median. I think the fake test data are therefore similar to the real test cases where this behavior was seen. |
I think that all references to the term "drizzle" in |
So in looking at things, it seems that this aspect should be able to be handled by your PR entirely. Namely, that you change |
@perrygreenfield if I understand what you're suggesting, it's to remove all the logic in
That seems like a reasonable idea, especially given the long fixme comment. Then, you are suggesting that the Is everyone comfortable with the differences named here, i.e., that outlier detection still generates a weight even though drizzling is not actually done, and the bitwise_or is removed in favor of handling setting dq flags entirely within the step? |
Just to note - there is a related ticket (JP-3441, #8009) that requests the ability to directly run the outlier detection step on a calints file, outside the pipeline. If cube handling is moved inside the step, that should incidentally solve the other issue as well. |
@emolter, yes, I think so. If it can be made to work, it would be much more straightforward, and work better with Brett's new |
I'm to blame for the long comment. I still don't fully understand what's going on but looking at it now I'm confused by the weights :-/ For the default |
I can confirm that the weights seem to just be the DQ mask, and the var_noise is not passed into the step at all, neither during |
I want to make sure I understand the situation. In past behavior it was just the DQ mask? And with this change, what changes with regard to this, instead it has |
I don't know what was desired by the instrument teams initially @perrygreenfield, all I can say is it's a bit silly to call |
Resolves JP-3584
Closes #8378
This PR updates the outlier detection step to use a rolling median instead of a flat median for all TSO modes, such that real time variability in the data is less likely to be flagged as outliers. The number of integrations that comprise the window for the rolling median can be specified by an input parameter to the step.
Checklist for PR authors (skip items if you don't have permissions or they are not applicable)
CHANGES.rst
within the relevant release sectionHow to run regression tests on a PR