Skip to content
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

EDR_Stats KeyError on 'Average' for CAL_BUFFER #3

Closed
AndrewAnnex opened this issue Jul 6, 2021 · 2 comments · Fixed by #4
Closed

EDR_Stats KeyError on 'Average' for CAL_BUFFER #3

AndrewAnnex opened this issue Jul 6, 2021 · 2 comments · Fixed by #4

Comments

@AndrewAnnex
Copy link
Contributor

  • pyrise version: latest main branch
  • Python version: 3.9
  • Operating System: ubuntu

Description

I found that for one image that hiproc would fail somewhere in the pipeline for an image ESP_065856_1890 on a KeyError for 'Average' but it wasn't clear with verbose logging which function/area the pipeline was breaking. After some trial and error running things I found that EDR_Stats was failing on a single ccd channel (in this case ESP_065856_1890_RED2_1) because of a missing json file.

Diving deeper in I found the error was specifically with the "CAL_BUFFER" return for this ccd, where there is no average value/other statistical data.

Below is the output for the bad ccd:

PVLGroup([
  ('TotalPixels', 372)
  ('ValidPixels', 0)
  ('NullPixels', 0)
  ('LisPixels', 372)
  ('LrsPixels', 0)
  ('HisPixels', 0)
  ('HrsPixels', 0)
])

and the next is the "CAL_BUFFER" for ESP_065856_1890_RED2_0:

PVLGroup([
  ('Average', 1075.9247311828)
  ('StandardDeviation', 22.093155656939)
  ('Variance', 488.10752688172)
  ('Minimum', 1035.0)
  ('Maximum', 1104.0)
  ('TotalPixels', 372)
  ('ValidPixels', 372)
  ('NullPixels', 0)
  ('LisPixels', 0)
  ('LrsPixels', 0)
  ('HisPixels', 0)
  ('HrsPixels', 0)
])

There was nothing in the stderr for the histat kalasiris function, so I am not sure what went wrong, maybe something internal to ISIS?

As a longer term suggestion, it would be helpful if verbose logging was more verbose in terms of saying which step of the pipeline it is in, which image is being operated on etc.

What I Did

note: requires my moody tool to download the edr files, simply pip install moody

moody hirise_edr ESP_065856_1890
EDR_Stats ./*.IMG -v -k
@rbeyer
Copy link
Owner

rbeyer commented Jul 6, 2021

Fun.

So, -v is for casual chattiness. For debugging, use -vv. That will log which module you're in as you go, and will also show the stack traces. There are some hiproc operations which are run using Python's multiprocessing, and when N jobs are all being logged at the same time, things can, indeed, get messy. If that gets to be problematic, you can always set --max_workers 1 which should make it single-threaded and make the logs more "linear."

The source of the error is because I'm not handling the return from histat properly. In certain recent conditions (typically in the period after August 2020 when we changed some ADC settings on the instrument), the CAL_BUFFER pixels can legitimately all be the special value LIS. In this case, histat doesn't apparently return a key/value pair for "Average" (which is what stats used to do, but now does something different). So I need to handle the condition when there isn't an "Average" key in the PVL-text that comes back from histat.

Should be easy to fix.

@AndrewAnnex
Copy link
Contributor Author

I think using .get(key, default) for each line of parse_histat would work if None's can be used for missing values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants