Thanks to visit codestin.com
Credit goes to github.com

Skip to content

add units to summary hyst table - #915

Open
Swanson-Hysell wants to merge 1 commit into
masterfrom
spell_out_hyst_units
Open

Swanson-Hysell wants to merge 1 commit into
masterfrom
spell_out_hyst_units

Conversation

@Swanson-Hysell

Copy link
Copy Markdown
Member

Closes #889

The summary table displayed by rmag.process_hyst_loop / rmag.process_hyst_loops reported parameter values without units. Column headers now spell them out:

Ms (Am²/kg) Mr (Am²/kg) Bc (T) Brh (T) sigma Q Qf chi_HF (m³/kg) FNL60 FNL70 FNL80

Parameters that are ratios, logarithms of ratios, or F statistics (Q, Qf, sigma, the FNL family) are dimensionless and stay bare; the closure-test ratios shown at the open-loop decision-tree exit (SNR, HAR) are labeled dB. The TableColumn field names are unchanged, so nothing downstream of the display shifts.

Changes

  • New unit lookup tables and two helpers, _hyst_param_unit and _hyst_param_label, at the top of the hysteresis section of rockmag.py. _show_hyst_summary_table uses them for its headers, so all three decision-tree outcomes (full processing, linear loop, open loop) are labeled consistently.
  • The susceptibility unit is derived rather than hardcoded. chi_HF is returned as μ₀·dM/dB, so its unit is the magnetization unit times m/A: Am²/kg → m³/kg, A/m → SI (dimensionless), Am² → m³. An unrecognized magnetization unit leaves chi_HF unlabeled rather than guessing.
  • Added a magn_unit keyword (at the end of the signature) to process_hyst_loop, plot_hyst_loop, and process_hyst_loops. It only labels output — no values are converted. In process_hyst_loops it defaults to None and is inferred from the MagIC column name (magn_mass → Am²/kg, magn_volume → A/m, magn_moment → Am²), so the usual call needs no new argument while volume-normalized data is no longer mislabeled as mass-normalized.
  • The hysteresis plot y-axis label, previously hardcoded to Am²/kg in both the Bokeh and matplotlib paths, now follows the same unit.
  • Docstring Returns sections state the unit of each reported quantity. process_hyst_loops additionally notes that the returned DataFrame's column names deliberately carry no units, since renaming them would break add_hyst_stats_to_specimens_table and the specimens-table writers.
  • Incidental fix: the comment explaining _HYST_UNDEFINED_RESULTS had drifted above _show_hyst_summary_table; it is back on the constant it describes.

Tests

New TestSummaryTableUnits class in pmagpy/test/test_rockmag_hysteresis.py covers the unit of each reported parameter, the chi_HF/magnetization-unit relation including the unrecognized-unit fallback, the rendered DataTable headers (with the field names verified unchanged), and the magn_col → unit inference in batch processing.

All 62 tests in the hysteresis suite pass, as do the curie, unmixing, and FORC suites (303 tests).

🤖 Assisted by Claude Opus 5 in code development.

These units are inferred from a MagIC contribution or can be specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add units to summary hysteresis table

1 participant