HEXRD / hexrdgui

Qt6 PySide6 based GUI for the HEXRD library.
Other
29 stars 14 forks source link

"NaN values" error during calibration of new detector #1753

Closed ksg52 closed 2 days ago

ksg52 commented 3 weeks ago

I am trying to run a fast powder calibration on a prototype detector, and getting the error:

"The model function generated NaN values and the fit aborted! Please check your model function and/or set boundaries on parameters where applicable. In cases like this, using "nan_policy='omit'" will probably not work."

The text of the full error message is attached.

The detector data was read in as a .tiff, and I have a mask applied on pixels that have NaN values in the raw data (there are a lot of these - they are gaps between physical detector modules) as well as pixels with value < 0. In the GUI, if I click "show invalid" it highlights these pixels, so I assume the GUI is handling the mask correctly. It's not clear to me what's causing this error - I've tried changing the mask to include or exclude the pixels < 0, as well as changing the tth and eta sector widths and min peak amplitude in the auto-picker. hexrd_calibration_error.txt

If it's useful for debugging, the detector configuration file and the raw data can be found on the CHESS server at: /nfs/chess/aux/cycles/2024-3/id3a/wolford-3923-b/keck-masked.hexrd /nfs/chess/aux/cycles/2024-3/id3a/wolford-3923-b/ceo2-keck-1/from_ImageJ_tiffs/FG_CeO2_111_200_5ms_200ns_17_000000010000.tif

I can also provide these via email or another method if needed.

saransh13 commented 2 weeks ago

I've encountered this error before and it usually happens when no peaks were identified. Do you mind sharing a state file to which can reproduce the error?

psavery commented 2 weeks ago

@ksg52 I was able to reproduce the issue with those files. We'll look into it.

psavery commented 2 weeks ago

So, it appears that it is being caused by nan values within the tiff file that don't get masked out by the panel buffer. I checked the panel buffer in your .hexrd file, and it looks like it doesn't mask out all of the nan regions within the data. Maybe we should automatically mask out nan regions within the data? I'm not sure, but I fixed the .hexrd file. I'll send it to you over Slack (in case it shouldn't be publicly shared on GitHub).

Note that I also had to change the x of the detector to be 145 instead of -145, and to get more picks to appear, I had to decrease the eta width.

psavery commented 2 days ago

We got this working. However, we should have better handling of nans. I'll put up a separate issue for that.