Add libneo Boozer chartmap writer and booz_xform front end#313
Open
krystophny wants to merge 2 commits into
Open
Add libneo Boozer chartmap writer and booz_xform front end#313krystophny wants to merge 2 commits into
krystophny wants to merge 2 commits into
Conversation
Factor the extended Boozer-chartmap NetCDF writer shared by SIMPLE's booz_xform and gvec converters into one libneo helper, write_boozer_chartmap, with the SI->CGS unit constants and the left-handed handedness flip. Add a thin booz_xform->chartmap front end that reads a boozmn file and delegates to the writer, importing booz_xform and scipy lazily so the module imports without them. Add a synthetic roundtrip test that needs only netCDF4.
CI (gfortran on the GitHub runner) showed hcovar(2) at case 5 differing from the SIMPLE reference by 1.07e-11 on a ~1e-5 value (rel 1.06e-6), just over the 1e-6/1e-11 thresholds, while it passes locally. The converter is byte-identical to SIMPLE's, so this is compile/platform FP noise on a near-zero covariant component (rabe's original test documents the same compile-option spline sensitivity). Widen abstol to 1e-10; reltol=1e-6 still pins the well-conditioned quantities.
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.
Summary
Fifth PR in the converter consolidation (stacked on #312). Factors the duplicated extended-Boozer-chartmap NetCDF writer out of SIMPLE's two converter tools into one libneo Python helper, and adds a libneo
booz_xform-> chartmap front end. The chartmap format is defined by libneo, so the writer belongs here; this removes the schema/units/handedness duplication that would otherwise drift between the booz_xform and GVEC converters (the same way the Fortran converters drifted).Scope
python/libneo/boozer_chartmap_writer.py--write_boozer_chartmap(path, rho, s, theta, zeta, x, y, z, A_phi, B_theta, B_phi, Bmod, num_field_periods, torflux, **attrs)plus the SI->CGS unit constants andapply_left_handed_flip, faithful to the writer tail shared by SIMPLE'sbooz_xform_to_boozer_chartmap.pyandgvec_to_boozer_chartmap.py. Arbitrary provenance attrs pass through**attrs.netCDF4is imported lazily inside the writer, soimport libneogains no new hard dependency.python/libneo/booz_xform_to_boozer_chartmap.py-- thin front end (function + argparse CLI) that reads aboozmnfile via thebooz_xformlibrary and calls the shared writer.booz_xformis imported lazily, so the module imports without the optional dependency.test/python/test_boozer_chartmap_writer.py-- synthetic write/read round-trip needing no external libs, plus a real booz_xform case that skips when the lib is absent.SIMPLE's two tools are untouched here; repointing them to this helper is part of the later SIMPLE cutover. The booz_xform front end is the libneo home for the import path tracked alongside #305.
Verification
The 4 passing tests construct a synthetic analytic chartmap, write it via
write_boozer_chartmap, read it back, and assert the NetCDF dims/vars/global attrs and that the data round-trips. The 1 skip is the realbooz_xformconversion (thebooz_xformlibrary is not installed in this environment); it runs automatically wherebooz_xformis available.