# sas.qtgui.Utilities.MuMag package

## Subpackages

- sas.qtgui.Utilities.MuMag.SANSData package
  - Module contents
- sas.qtgui.Utilities.MuMag.UI package
  - Submodules
  - sas.qtgui.Utilities.MuMag.UI.MuMagUI module
    - `Ui_MuMagTool`
      - `Ui_MuMagTool.retranslateUi()`
      - `Ui_MuMagTool.setupUi()`
  - Module contents

## Submodules

## sas.qtgui.Utilities.MuMag.MuMag module

class sas.qtgui.Utilities.MuMag.MuMag.MuMag(parent=None)

  Bases: `QMainWindow`, `Ui_MuMagTool`

  Main widget for the MuMag tool

  get_fit_parameters() → FitParameters

    Get an object containing all the parameters needed for doing the fitting

  hide_everything()

    Hide all plots, disable tabs

  importData()

    Callback for the import data button

  onFit()
  onHelp()
  onSave()

    Save button pressed

  show_fit_results()

    Show the results of the fit in the widget

  show_input_data()

    Plot Experimental Data: Generate Figure

  staticMetaObject = PySide6.QtCore.QMetaObject("MuMag" inherits "QMainWindow": )

sas.qtgui.Utilities.MuMag.MuMag.main()

  Show a demo of the slider

## sas.qtgui.Utilities.MuMag.MuMagLib module

class sas.qtgui.Utilities.MuMag.MuMagLib.MuMagLib

  Bases: `object`

  Library for methods supporting MuMag

  static directory_popup()
  static import_data(directory)

    Import experimental data and get information from filenames

  static least_squares_parallel(data: list[ExperimentalData], A)

    Least squares fitting for a given exchange stiffness, A, parallel case

    We are fitting the equation:

    > I_sim = I_res + response_H * S_H

    >   = (I_res, S_H) . (1, response_H) = (I_res, S_H) . least_squares_x

    finding I_res and S_H for each q value

  static least_squares_perpendicular(data: list[ExperimentalData], A) → LeastSquaresOutputPerpendicular

    Least squares fitting for a given exchange stiffness, A, perpendicular case

    We are fitting the equation:

    > I_sim = I_res + response_H * S_H + response_M * S_M

    >   = (I_res, S_H, S_M) . (1, response_H, response_M) = (I_res, S_H, S_M) . least_squares_x

    finding I_res, S_H, and S_M for each q value

  logger = <Logger MuMag (WARNING)>
  mu_0 = 1.2566370614359173e-06
  static nice_log_plot_bounds(data: list[ndarray])

    Get nice bounds for the loglog plots

    Returns:

      (lower, upper) bounds appropriate to pass to plt.xlim/ylim

  static refine_exchange_A(data: list[ExperimentalData], exchange_A_initial: float, geometry: ExperimentGeometry, epsilon: float = 0.0001) → LeastSquaresOutputPerpendicular | LeastSquaresOutputParallel

    Refines the A parameter using Jarratt’s method of successive parabolic interpolation

  static save_data(data: FitResults, directory: str)

    Save the data

  static simple_fit(data: list[ExperimentalData], parameters: FitParameters)

    Main fitting (“simple fit”)

  static sweep_exchange_A(parameters: FitParameters, data: list[ExperimentalData]) → SweepOutput

    Sweep over Exchange Stiffness A for perpendicular SANS geometry to get an initial estimate which can then be refined

  static uncertainty(data: list[ExperimentalData], A_opt: float, geometry: ExperimentGeometry) → float

    Calculate the uncertainty for the optimal exchange stiffness A

## sas.qtgui.Utilities.MuMag.datastructures module

class sas.qtgui.Utilities.MuMag.datastructures.ExperimentGeometry(*values)

  Bases: `Enum`

  Type of experiment

  PARALLEL = 1
  PERPENDICULAR = 2

class sas.qtgui.Utilities.MuMag.datastructures.ExperimentalData(scattering_curve: Data1D, applied_field: float, saturation_magnetisation: float, demagnetising_field: float)

  Bases: `object`

  Datapoint used as input for the MuMag tool

  applied_field: float
  demagnetising_field: float
  restrict_by_index(max_index: int)

    Remove all points from data up to given index

  saturation_magnetisation: float
  scattering_curve: Data1D

exception sas.qtgui.Utilities.MuMag.datastructures.FitFailure

  Bases: `Exception`

  Fit failed

class sas.qtgui.Utilities.MuMag.datastructures.FitParameters(q_max: float, min_applied_field: float, exchange_A_min: float, exchange_A_max: float, exchange_A_n: int, experiment_geometry: ExperimentGeometry)

  Bases: `object`

  Input parameters for the fit

  exchange_A_max: float
  exchange_A_min: float
  exchange_A_n: int
  experiment_geometry: ExperimentGeometry
  min_applied_field: float
  q_max: float

class sas.qtgui.Utilities.MuMag.datastructures.FitResults(parameters: FitParameters, input_data: list[ExperimentalData], sweep_data: SweepOutput, refined_fit_data: LeastSquaresOutputParallel | LeastSquaresOutputPerpendicular, optimal_exchange_A_uncertainty: float)

  Bases: `object`

  Output the MuMag fit

  input_data: list[ExperimentalData]
  optimal_exchange_A_uncertainty: float
  parameters: FitParameters
  refined_fit_data: LeastSquaresOutputParallel | LeastSquaresOutputPerpendicular
  sweep_data: SweepOutput

class sas.qtgui.Utilities.MuMag.datastructures.LeastSquaresOutput(exchange_A: float, exchange_A_chi_sq: float, q: ndarray, I_simulated: ndarray, I_residual: ndarray, S_H: ndarray, I_residual_stdev: ndarray, S_H_stdev: ndarray)

  Bases: `object`

  Output from least squares method

  I_residual: ndarray
  I_residual_stdev: ndarray
  I_simulated: ndarray
  S_H: ndarray
  S_H_stdev: ndarray
  exchange_A: float
  exchange_A_chi_sq: float
  q: ndarray

class sas.qtgui.Utilities.MuMag.datastructures.LeastSquaresOutputParallel(exchange_A: float, exchange_A_chi_sq: float, q: ndarray, I_simulated: ndarray, I_residual: ndarray, S_H: ndarray, I_residual_stdev: ndarray, S_H_stdev: ndarray)

  Bases: `LeastSquaresOutput`

  Output from least squares method for parallel case

class sas.qtgui.Utilities.MuMag.datastructures.LeastSquaresOutputPerpendicular(exchange_A: float, exchange_A_chi_sq: float, q: ndarray, I_simulated: ndarray, I_residual: ndarray, S_H: ndarray, I_residual_stdev: ndarray, S_H_stdev: ndarray, S_M: ndarray, S_M_stdev: ndarray)

  Bases: `LeastSquaresOutput`

  Output from least squares method for perpendicular case

  S_M: ndarray
  S_M_stdev: ndarray

exception sas.qtgui.Utilities.MuMag.datastructures.LoadFailure

  Bases: `Exception`

  File loading failed

class sas.qtgui.Utilities.MuMag.datastructures.SweepOutput(exchange_A_checked: ndarray, exchange_A_chi_sq: ndarray, optimal: T)

  Bases: `Generic`[`T`]

  Results from brute force optimisiation of the chi squared for the exchange A parameter

  exchange_A_checked: ndarray
  exchange_A_chi_sq: ndarray
  optimal: T

## sas.qtgui.Utilities.MuMag.models module

sas.qtgui.Utilities.MuMag.models.LorentzianModelPAR(q, A, M_s, H_0, H_dem, a_H, l_c)

  Lorentzian Model for the generation of clean synthetic test data for parallel SANS geometry

sas.qtgui.Utilities.MuMag.models.LorentzianModelPERP(q, A, M_s, H_0, H_dem, a_H, a_M, l_c)

  Lorentzian Model for the generation of clean synthetic test data for perpendicular SANS geometry

sas.qtgui.Utilities.MuMag.models.LorentzianNoisyModelPERP(q, A, M_s, H_0, H_dem, a_H, a_M, l_c, beta)

  Lorentzian Model for the generation of noisy synthetic test data for perpendicular SANS geometry

sas.qtgui.Utilities.MuMag.models.SANS_Model_PAR(q, S_H, I_res, M_s, H_0, H_dem, A)

  1D-Cross-Section of the parallel model

sas.qtgui.Utilities.MuMag.models.SANS_Model_PERP(q, S_H, S_M, I_res, M_s, H_0, H_dem, A)

  1D-Cross-Section of the perendicular model

## Module contents