sot / xija

Thermal modeling framework for Chandra X-ray Observatory
https://sot.github.io/xija
BSD 3-Clause "New" or "Revised" License
9 stars 5 forks source link

RuntimeError trying to run xija_gui_fit on Mac #126

Closed taldcroft closed 2 years ago

taldcroft commented 2 years ago

This is probably what Dan was seeing, but now I am also unable to run xija_gui_fit at all.

EDIT: works for python -m xija.gui_fit.app models/dpa/dpa_spec.json, so this might be particular to this model somehow.

image

From commit fbce00b:

Cleaning my repo

(ska3) ➜  xija git:(model_in_model) git cleans -fxd --exclude '*.json' --exclude 'profile*'
Removing .pytest_cache/
Removing build/
Removing xija/__pycache__/
Removing xija/component/__pycache__/
Removing xija/core_1.cpython-38-darwin.so
Removing xija/core_2.cpython-38-darwin.so
Removing xija/gui_fit/__pycache__/
Removing xija/tests/__pycache__/

Building in place

(ska3) ➜  xija git:(model_in_model) python setup.py build_ext --inplace
running build_ext
building 'xija.core_1' extension
creating build
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/xija
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/aldcroft/miniconda3/envs/ska3/include -arch x86_64 -I/Users/aldcroft/miniconda3/envs/ska3/include -arch x86_64 -I/Users/aldcroft/miniconda3/envs/ska3/include/python3.8 -c xija/core_1.c -o build/temp.macosx-10.9-x86_64-3.8/xija/core_1.o
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/xija
gcc -bundle -undefined dynamic_lookup -L/Users/aldcroft/miniconda3/envs/ska3/lib -arch x86_64 -L/Users/aldcroft/miniconda3/envs/ska3/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.9-x86_64-3.8/xija/core_1.o -o build/lib.macosx-10.9-x86_64-3.8/xija/core_1.cpython-38-darwin.so
building 'xija.core_2' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/aldcroft/miniconda3/envs/ska3/include -arch x86_64 -I/Users/aldcroft/miniconda3/envs/ska3/include -arch x86_64 -I/Users/aldcroft/miniconda3/envs/ska3/include/python3.8 -c xija/core_2.c -o build/temp.macosx-10.9-x86_64-3.8/xija/core_2.o
gcc -bundle -undefined dynamic_lookup -L/Users/aldcroft/miniconda3/envs/ska3/lib -arch x86_64 -L/Users/aldcroft/miniconda3/envs/ska3/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.9-x86_64-3.8/xija/core_2.o -o build/lib.macosx-10.9-x86_64-3.8/xija/core_2.cpython-38-darwin.so
copying build/lib.macosx-10.9-x86_64-3.8/xija/core_1.cpython-38-darwin.so -> xija
copying build/lib.macosx-10.9-x86_64-3.8/xija/core_2.cpython-38-darwin.so -> xija

Running with the new CEA model

(ska3) ➜  xija git:(model_in_model) python -m xija.gui_fit.app  2ceahvpt_spec.json         
WARNING: imaging routines will not be available, 
failed to import sherpa.image.ds9_backend due to 
'RuntimeErr: DS9Win unusable: Could not find ds9 on your PATH'
Fetching msid: 1dpamzt over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
INFO:numexpr.utils:Note: NumExpr detected 16 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
INFO:numexpr.utils:NumExpr defaulting to 8 threads.
Fetching msid: sim_z over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
Fetching msid: pitch over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
Fetching msid: roll over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
Fetching msid: aoeclips over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
Getting kadi commanded states over 2022:225:00:09:26.816 to 2022:240:16:15:50.816
Fetching msid: dp_dpa_power over 2022:224:23:42:06.816 to 2022:240:16:43:10.816
Fetching msid: 2ceahvpt over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: sim_z over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: pitch over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: roll over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: aoeclips over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 2ps5aon over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 2imonst over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 2sponst over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 2s2onst over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 224pcast over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Fetching msid: 215pcast over 2022:224:23:36:38.816 to 2022:240:16:54:06.816
Adding plot  2ceahvpt data__time
Adding plot  1dpamzt data__time
Traceback (most recent call last):
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3031, in _wait_cursor_for_draw_cm
    yield
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 439, in draw
    super().draw()
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backends/backend_qt.py", line 424, in draw
    self.update()
RuntimeError: wrapped C/C++ object of type FigureCanvasQTAgg has been deleted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backends/backend_qt.py", line 455, in _draw_idle
    self.draw()
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 439, in draw
    super().draw()
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 3033, in _wait_cursor_for_draw_cm
    self.canvas.set_cursor(self._lastCursor)
  File "/Users/aldcroft/miniconda3/envs/ska3/lib/python3.8/site-packages/matplotlib/backends/backend_qt.py", line 259, in set_cursor
    self.setCursor(_api.check_getitem(cursord, cursor=cursor))
RuntimeError: wrapped C/C++ object of type FigureCanvasQTAgg has been deleted
jzuhone commented 2 years ago

@taldcroft https://github.com/sot/xija/pull/127

jzuhone commented 2 years ago

@taldcroft I think what's happening is that for the HRC model we are only fitting over ~100 days or even less, which means it executes very fast. When it tries to repeatedly update a plot while it's doing a fit, there's some kind of (waves hands wildly) race condition encountered.

taldcroft commented 2 years ago

But this happened on startup. I never saw a GUI window.

jzuhone commented 2 years ago

Ah, sorry I missed that. It looks like this happens if you try to run with a very small amount of data (by default it's loading like ~16 days). When I ran it as you did, I got the crash, but when I specified 100 days I did not. I'm going to try something else.