Repository navigation
Fix calibration bugs and clean up solvers, UDFs, UI and packaging - #69
Merged
Merged
Conversation
The test checked scan_rotation, which the fit doesn't change. - Fix docstring of make_overfocus_loss_function, which named scan_rotation - Raise ValueError for a starting model in focus instead of dividing by zero Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_focus The center ray of the inverted model was traced with the original model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Float models got SymPy numbers from adjust_*() and invert_focus(), and jax.grad() through adjust_*() failed. - Add util/backend.py, used by rotate(), generated code and runtime derivations - Regenerate _generated.py - Add docstring to invert_focus() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…x.jit() The derived compensation is the identity for an unchanged flip factor anyway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
normalize_types() maps float() over the pytree. - Fields of subclasses are kept instead of being reset to their defaults - derive() only accepts keyword arguments - Specifying both flip_y and flip_factor raises ValueError instead of AssertionError Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No change in results since the components scale offsets with Ray._one. The new test checks that trace() is homogeneous in _one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UI downcast the point tables. The solvers now convert their input points to float64. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s one The flip factor came back as e.g. 0.99, and a start with the wrong sign could converge to the wrong orientation. - Return the residual without the flip penalty term - Raise RuntimeError if the better fit didn't converge - Add docstring and a round-trip test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ra_length() It traced tilted rays with zero overfocus, so the fitted camera length included the overfocus. Behavior changes: - The parameter diffraction_angle is renamed to twotheta - The result is the specimen-to-detector distance for any overfocus Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… errors float() accepted strings like "1.5", and its errors didn't say which parameter couldn't be converted. NaN and infinity are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Failures with random models couldn't be reproduced. The seed depends on the test ID. The pixel tolerance was at the level of float64 rounding. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…solvers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… arbitrary values Behavior changes: - solve_tilt_descan_error_points() raises ValueError for fewer than 3 points - solve_coords_points() raises ValueError without points The UI test now adds three distinct descan points; it fitted from two before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- solve_hit_specimen() returns the residual in YX order and the slope as floats - Add a round-trip test for solve_hit_specimen() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it__ The matrices were recalculated in __init__ when the model changed, which relied on how LiberTEM re-creates UDFs. Behavior changes: - The UDFs no longer accept back_mat, corr_mat and ref_model - Models with JAX or NumPy scalars work instead of raising TypeError - A singular matrix, e.g. the back-projection in focus, logs a warning - Cached matrices are read-only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Raise ValueError for scans that aren't 2D - Sum the results of CorrectedPickUDF without stacking all chunks - Remove empty docstrings and the ineffective where="device" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ites Model functions stay SymPy-compatible. Numeric NumPy or JAX versions are created with lambdify() once where they are needed, see CLAUDE.md. - Remove util/backend.py and regenerate _generated.py - Test adjust_*() and invert_focus() through lambdified NumPy and JAX functions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pins were for Python 3.11 and lacked the extras of the package, e.g. JAX and optimistix. - Re-enable the CI job that tests the pinned requirements Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Remove setup.cfg with the unused flake8 configuration - Remove test_requirements.txt, which duplicated part of the test extra - Coverage no longer warns that include is ignored Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n versions optax is only used in a test. The project requires Python 3.14. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Files were opened repeatedly and never closed. Behavior changes: - The model functions take the tags of a DM4 file instead of an open file, see read_tags() - CalibratedJEOLDM4.dm4 is removed, use CalibratedJEOLDM4.tags - microscope_info() only includes tags of the 4D STEM data, not of the thumbnail Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The same dot product was written out seven times. - Remove the project_tilt_*() and project_det_*() helpers, use affine_column() - Run test_project_frame_forward() without JIT for coverage, too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 133 reflection of the reference is outside the default reciprocal radius. - Test that the angles scale with the electron wavelength at 300 kV Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shapes Square shapes and centers couldn't detect mix-ups of y and x. - test_correct_smallnumba is a parameter set of test_correct_fixed_manualref Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kernels used it as an angle, the transformation matrices and the beam radius as a slope. See the Model4DSTEM docstring. Behavior changes: - Back-projection and simulation limit the source slope to semiconv instead of tan(semiconv) - The UI still shows the convergence semi-angle and converts it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ets and events No change in behavior. - Add helpers for figures, cursors, diffraction rings and fix point tables - Remove redundant column checks in the table click handlers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No change in behavior. - Replace commented-out code with a note on why it doesn't work Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No change in behavior. - Correlation pattern, expected beam shifts and regression of the descan refinement - Formatting of the model and descan error tables Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stants No change in the displayed text, since Panel dedents Markdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he GUI ui.py imports it from there, so it is still available from microscope_calibration.ui. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ordingly Behavior changes: - The instructions name the plots by their titles and fix a typo - The corrected plots follow the uncorrected ones in the first section, the scale bar section follows the plot it refers to - Remove a double space from the title of the corrected frame Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #69 +/- ##
==========================================
+ Coverage 87.94% 93.80% +5.86%
==========================================
Files 13 14 +1
Lines 2015 2002 -13
Branches 171 173 +2
==========================================
+ Hits 1772 1878 +106
+ Misses 203 83 -120
- Partials 40 41 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
Example notebooks seem to work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
invert_focus()Model4DSTEM.derive()usesdataclasses.replace(),normalize_types()names the field in errorsCalibratedDatasetmoved todataset.py, still importable fromuijeol_dm4reads each DM4 file once and is tested with fake tagspyproject.toml,setup.cfgandtest_requirements.txtremovedlambdify()Behavior changes
semiconvis the slope at the source everywhere, back-projection and simulation used it as an angle (seeModel4DSTEMdocstring)solve_coords_points()returns a flip factor of exactly ±1, also when starting with the wrong signsolve_camera_length()returns the specimen-to-detector distance for any overfocus,diffraction_angleis renamed totwothetasolve_tilt_descan_error_points()requires at least three points,solve_coords_points()at least onemake_overfocus_loss_function()raisesValueErrorfor a starting model in focusModel4DSTEM.derive()only accepts keyword arguments and keeps fields of subclassesModel4DSTEM.normalize_types()rejects stringslambdify(args=...)worksback_mat,corr_matandref_model, and accept models with JAX or NumPy scalarsValueErrorfor scans that aren't 2Djeol_dm4functions take DM4 tags instead of an open file,CalibratedJEOLDM4.dm4is removedCalibratedJEOLDM4.microscope_info()ignores the thumbnailoptaxmoved from thecommonto thetestextraReview notes
cos/sinand c2e741c replaces it withlambdify()at the call sites, so the net change is in the testslambdify-modelbuilds on this branch🤖 Generated with Claude Code