andycasey / smhr

Spectroscopy Made Hard(er)
14 stars 7 forks source link

[WIP] Refactor scatterplot #325

Closed alexji closed 2 years ago

alexji commented 5 years ago

I have completely refactored the stellar parameters tab (#246 and #261 ) to use the gui/base.py GUI features. This finishes the major milestones of v0.2 and several in v0.3. Currently it is in branch refactor-scatterplot but will soon be moved to master.

One aim is to remove all dependency on utils.equilibrium_state and session.stellar_parameter_state. Instead, it uses a new utils.fit_line and session.measure_abundances for everything.

I have redone the stellar parameter state table as just labels instead of a table. (We have never used Ti I and Ti II for stellar parameters, so I figured just removing this is fine. In special cases I can reconfigure it easily.) This adds enough space for displaying the slope errors as well.

There are redundant computations being done now (e.g. line slopes are fit once for plotting and once for the table; a lot of redundant searches through existing measurements to avoid maintaining a separate consistent state). But the GUI is not any slower as far as I can tell, and the code is WAY cleaner and maintainable [1000 fewer lines in gui/stellar_parameters.py largely due to refactoring into gui/base.py]. It will also help greatly in a transition to python 3 due to the refactoring. I expect as long as the number of total measurements stays under a few thousand this will not ever be a problem (and above that number, probably aren't doing too much interactive fitting anyway).

The refactoring has solved the biggest problem with loading a new session (#53, also see #273): the catastrophic crashes that occurred when loading a new session and having the stellar parameter state be unsync'd with the actual measurements. This would cause SMHR to go into an infinite loop and require force killing, potentially losing work. The GUI now uses the general interface new_session_loaded that is applicable to the Stellar parameters, Line Measurements, and Review tab. The "refresh" button in those tabs also reloads that tab's GUI from the session, so state issues are avoided.

The refactoring also makes it easier to construct new tab/dialog layouts. In particular I was imagining making a separate synthesis widget that gives syntheses with a lot more options (linelist editing, adding/editing metadata, custom isotopes, etc); and a widget loading customizable scatterplots to check things like wavelength vs FWHM or whatever. That is for the far future, but this makes the GUI part much easier.

There is now a keyboard shortcut on the SPtab to unselect points with the "u" key. Makes clipping obvious outliers much easier. There are also visual improvements to the review tab plotting (showing unacceptable points as crosses, user flagged points outlined in red).

A side effect of merging this branch is the manual synthesis updates for #260.

I think everything is working great, but it needs to be tested before it can be merged into master, hence WIP.