-
Notifications
You must be signed in to change notification settings - Fork 168
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
With new calibration knowledge, hical needs an update to (or alternative to) its dark current correction (ZeroDark) module. #4324
Comments
In case there is any question, the work on the otherorb fork/branch mentioned above is being carried out under the auspices of the HiRISE Calibration Team, such that the to-be-PRed code represents not only the best practice (which honestly is the only thing that should matter here), but also happens to be the desire of the instrument team. Sincerely,
|
I realize the "How to reproduce" section in the original issue is somewhat lacking in useful information. I've attached a gif that might help better illustrate the issue. This is a comparison between: the raw image (no calibration---to illustrate one of the main calibration challenges); the existing calibration result (hical run to the point of removing the dark current); and the proposed update to the dark current correction. This is observation ESP_068088_0950, CCD6, Channel 1. |
Is this available anywhere? I'm not sure how to help out with any of this without the new correction and a description of how it's going to be implemented. |
Thanks for being willing to help, and we may need it, but we're not asking for external help ... yet. @otherorb and I are starting to work the problem in the designated fork/branch, I think I properly assigned us to this Issue. Our intent is to work this from our side. If we encounter no difficulties, we'll just PR it (yay). However, if we run into issues, then we'll post them here and solicit help. |
Alright.
Separately from the API and programming: |
Can you provide a link to the place in code you are talking about? There's over a dozen files to look through in hical.
I would check at either config file read-in in HiCalConf or when you go to apply the ZeroDarkRate step in the main.
If these files can be added without any conflicts, go ahead and send them to us or point us to the files that need to be added. We can get those added to the data area. |
Hi Jesse. The specific part I'm struggling with starts on line 98. My hacky way to indicate the problem is to put a DEBUG line in the code so it won't compile and someone who knows what they're doing can help fix the next part. If what I'm trying to accomplish here is unclear, please let me know.
|
I will send a tarball for upload to the USGS internal drives; none of those data files conflict with any existing data files. |
Okay I took a look at LoadCSV and it should be able to ready your CSV into a matrix. The three lines at the start of the CSV are comments, not headers. So, if you set IgnoreComments in the config, LoadCSV should automatically skip them. From there, it will load all of the data into a HiMatrix which you can get from LoadCSV::getMatrix. This is just a TNT::Array2D so you can access values via matrix[row][column]. Hope that helps! Let me know if there's something I missed. |
Here's a brief code snippet assuming that samples is the row of the CSV you want:
|
Thanks Jesse, I'll update my code with those snippets. The next part that I'm not terribly comfortable with is how, within mro/apps/hical/main.cpp, to check for both ZeroDark and ZeroDarkRate being "activated" (!SkipModule()) and to exit with a user error if they're both active. If one or the other is skipped in the configuration file, the SkipModule flag basically just fills HiVectors with 0s, and we can just subtract both vectors during the calibration stage in main.ccp. |
I'm not super familiar with the dbprofile API, I don't see a way to check if a profile exists. We could add it, but @KrisBecker may have some input on a better way. |
Hi @otherorb... There are several options that come to mind. The easiest perhaps is to set a flag above the first occurring module, ZeroDark or ZeroDarkRate, set the flag to indicate if it was executed (i.e., SkipModel(prof) == false), then test the flag in the next occurring module code block if it is also not skipped. This should trigger an error and you can then throw your exception. The other option is to directly test skip status for both models and test for conflict:
|
Thanks Kris, I'm a little confused by this boolean logic in your example. Does SkipModule(hiconf.getMatrixProfile()) return True if the module is skipped or True if the module is not skipped? I think it's okay if both modules are skipped (perhaps someone is trying to test the earlier modules, for example). It's just problematic if neither module is skipped. |
Hey @otherorb, SkipModule() returns true if the module is to be skipped. You will see in the code that the test used for each module is:
So in my previous post, the (zdark == zrate) tests if both are true or both are false. And, based upon this definition, the other test in the code is wrong. The other test should be (false == zdark) which indicates both are not skipped, which is not what you want, and should result in an error. I think all other conditions are allowed, one or both can be skipped. Sorry for the confusion. |
@otherorb Can you reply here about the status of this work. Here's my main questions:
|
|
Okay, I've gotten the code compiling and what appears to be applying the new dark current correction, see my fork https://github.com/jessemapel/ISIS3/tree/ZeroDarkRate. Tomorrow I'm going to start testing this out and writing some simple automated tests. I have a few questions:
|
Didn't we fix this in #4290? |
Oh cool! Our hical test image still has -9999, so I'll just use a more up to date image for testing. |
I did not see a significant improvement in results when I filtered, but I wouldn't mind if we had the ability to have a filter that is (currently) turned off by default. A simple smoothing was what I tested; something like what Zero Dark uses. |
Another question. Should ZeroDarkRate be used over ZeroDark by default? I've updated the code so that it uses ZeroDark with old config files, but I'm not sure if I should update the default config file to use ZeroDarkRate. |
I would leave ZeroDark as default until Ken and the HiROC people have a chance to determine whether it should be switched to the new behavior by default. |
ISIS version(s) affected: All
Description
The ISIS3 hical program was written early in the MRO mission, before it became necessary to increase the operating temperature of the HiRISE instrument to improve image quality and reduce problematic hardware behaviors as the instrument has degraded over time. Dark current (thermal noise) in the HiRISE CCDs increases exponentially with temperature, and is not being properly corrected in HiRISE images taken at higher temperatures. Therefore, the dark current correction code in hical must be modified to improve HiRISE calibration accuracy. This modification is urgently needed, as poorly-calibrated data have been and continue to be released to the public and science community. A new dark current correction has been derived and is ready for implementation and testing within hical.
How to reproduce
This isn’t a software problem, so there’s no simple way to “reproduce” this. This is more of a correction to previously-acceptable behavior issue. Ultimately, if you run hical on any high-temperature HiRISE image after ingestion (hi2isis) the DN (or I/F) values that result from the calibration in the output image will look okay, but do not reflect the best possible calibration that could be achieved.
Possible Solution
Proposed patches are being worked at this time and will be uploaded after testing external to USGS ISIS3 development. A fork/branch where we are working on this issue can be found here: https://github.com/otherorb/ISIS3/tree/ZeroDarkRate and when it is more mature, we will submit a PR to the USGS repo. Contributions and participation (via PRs to the fork/branch) are welcome, but to keep discussions centralized, let's keep the discussion here in this issue, please.
We believe that, at a minimum, the following files may require some changes:
.../mro/objs/HiCal/ZeroDarkRate.h (new file, implements the new calibration algorithm)
.../mro/objs/HiCal/HiCalConf.h (patch)
.../mro/objs/HiCal/Module.h (patch)
.../mro/aps/hical/main.cpp (patch)
There will also need to be new files added to the DATA directory and a patch made and version increment to the hical.conf file.
The text was updated successfully, but these errors were encountered: