ferrodispcalc.sed package

Submodules

ferrodispcalc.sed.calc module

class ferrodispcalc.sed.calc.DipoleModeResult(mode_movie: ndarray, primitive_mode_movie: ndarray, phases: ndarray, evec_basis: ndarray, amplitude_basis: ndarray, qpoint: ndarray, requested_freq_THz: float, actual_freq_THz: float, primitive_shape: tuple[int, int, int], cell_shape: tuple[int, int, int], freq_method: str, gauge: str, normalize: bool, remove_mean: bool)[source]

Bases: object

Result of a basis-resolved local-mode extraction.

mode_movie

Real-space mode movie with shape (nphase, nx, ny, nz, 3).

Type:

np.ndarray

primitive_mode_movie

Representative primitive-block movie with shape (nphase, px, py, pz, 3).

Type:

np.ndarray

phases

Phase samples in radians with shape (nphase,).

Type:

np.ndarray

evec_basis

Complex basis-resolved eigenvector with shape (px, py, pz, 3).

Type:

np.ndarray

amplitude_basis

Complex, unnormalized Fourier amplitude after gauge fixing, with shape (px, py, pz, 3).

Type:

np.ndarray

qpoint

Reduced-coordinate q-point used for extraction.

Type:

np.ndarray

requested_freq_THz

Target frequency requested by the user.

Type:

float

actual_freq_THz

Frequency actually used. This can differ from the requested value for freq_method="nearest_fft".

Type:

float

primitive_shape

Primitive block size used to group the input grid.

Type:

tuple[int, int, int]

cell_shape

Number of primitive cells along each grid direction.

Type:

tuple[int, int, int]

freq_method

Frequency extraction method, either "nearest_fft" or "direct".

Type:

str

gauge

Gauge-fixing method, either "max_real" or "none".

Type:

str

normalize

Whether evec_basis was normalized by sqrt(sum(abs(A)**2)).

Type:

bool

remove_mean

Whether per-grid-point time means were removed before extraction.

Type:

bool

actual_freq_THz: float
amplitude_basis: ndarray
cell_shape: tuple[int, int, int]
evec_basis: ndarray
freq_method: str
gauge: str
mode_movie: ndarray
normalize: bool
phases: ndarray
primitive_mode_movie: ndarray
primitive_shape: tuple[int, int, int]
qpoint: ndarray
remove_mean: bool
requested_freq_THz: float
class ferrodispcalc.sed.calc.DipoleSedResult(freq_THz: ndarray, qpoints: ndarray, sed: ndarray, primitive_shape: tuple[int, int, int], cell_shape: tuple[int, int, int], basis_summation: str = 'incoherent')[source]

Bases: object

Result of a local-mode SED calculation.

freq_THz

Positive-frequency axis in THz.

Type:

np.ndarray

qpoints

Reduced q-points used in the spatial Fourier transform.

Type:

np.ndarray

sed

SED intensity with shape (nfreq, nq, 4). The last axis stores x, y, z, and total.

Type:

np.ndarray

primitive_shape

Primitive block size used to group the input grid.

Type:

tuple[int, int, int]

cell_shape

Number of primitive cells along each grid direction.

Type:

tuple[int, int, int]

basis_summation

Basis summation rule. "incoherent" sums intensities over basis degrees of freedom; "coherent" sums amplitudes before squaring.

Type:

str

basis_summation: str = 'incoherent'
cell_shape: tuple[int, int, int]
freq_THz: ndarray
primitive_shape: tuple[int, int, int]
qpoints: ndarray
sed: ndarray
ferrodispcalc.sed.calc.calculate_sed(field: ndarray, dt_ps: float, qpoints: ndarray, primitive_shape: tuple[int, int, int] = (1, 1, 1), num_splits: int = 1, remove_mean: bool = False, n_jobs: int = 1, parallel_backend: str = 'threading', *, basis_summation: str = 'incoherent') DipoleSedResult[source]

Calculate a local-mode fluctuation spectrum for a gridded trajectory.

The input field is assumed to be fixed on a regular grid of local modes, such as Ti-centered displacement, local dipole, local polarization, or the corresponding time derivative. Users must provide the reduced q-points explicitly; use generate_commensurate_qpath() when a path should be sampled by q-points commensurate with the simulation cell.

Parameters:
  • field (np.ndarray) – Input trajectory with shape (nframe, nx, ny, nz, 3). The last axis stores the Cartesian x, y, and z components. If dt_ps is in ps and the field is from LAMMPS metal units, displacement-like input is typically in Angstrom and velocity-like input is in Angstrom/ps.

  • dt_ps (float) – Time interval between stored frames in ps. The returned frequency axis is in THz because 1 / ps = 1 THz.

  • qpoints (np.ndarray) – Reduced q-points with shape (nq, 3). The spatial phase is exp(+i * 2*pi * dot(q, cell_index + basis_offset)), where basis_offset is the fractional position inside the primitive block. The opposite sign gives the same intensity after taking |A|^2.

  • primitive_shape (tuple[int, int, int], optional) – Primitive block size in grid units. For example, (1, 1, 5) groups five local modes into each primitive cell along z. Defaults to (1, 1, 1).

  • num_splits (int, optional) – Number of equal time blocks used for block averaging. nframe must be divisible by this value. Defaults to 1.

  • remove_mean (bool, optional) – If True, subtract the per-block time average at every grid point and component before the FFT. This is usually appropriate for a displacement-like field to remove the static/DC component. Velocity-like fields are usually used as-is. Defaults to False.

  • n_jobs (int, optional) – Number of q-points to evaluate in parallel with joblib. 1 means serial execution; negative values follow joblib’s convention. Defaults to 1.

  • parallel_backend (str, optional) – Joblib backend. The default "threading" avoids copying the large block array into worker processes.

  • basis_summation ({"incoherent", "coherent"}, optional) – Basis summation rule. "incoherent" computes sum_b |U_b(q, omega)|^2 and is the default local-fluctuation spectrum. "coherent" computes |sum_b U_b(q, omega)|^2 and preserves basis interference, closer to a structure-factor-like representation.

Returns:

Frequency axis, q-points, SED intensity, and grid metadata.

Return type:

DipoleSedResult

Notes

The normalization is 1 / (Nt * Ncell) before averaging over time blocks, where Nt is the number of frames per block and Ncell is the number of primitive cells. No mass weighting is applied, so this is not a strict mass-weighted phonon SED unless the input field and normalization are defined accordingly. The spatial Fourier transform uses the full local-mode position within the current folded-cell representation and, by default, sums basis intensities incoherently.

ferrodispcalc.sed.calc.extract_eigen_vector(field: ndarray, dt_ps: float, qpoint: ndarray, freq_THz: float, primitive_shape: tuple[int, int, int] = (1, 1, 1), nphase: int = 24, remove_mean: bool = True, freq_method: str = 'nearest_fft', gauge: str = 'max_real', normalize: bool = True) DipoleModeResult[source]

Extract a basis-resolved complex mode and rebuild a real-space movie.

The extraction uses the full local-mode position, cell_index + basis_offset, in the spatial Fourier transform. It keeps the complex amplitude before any basis summation or absolute-square operation, then reconstructs the selected (q, frequency) mode over one artificial vibration period.

Parameters:
  • field (np.ndarray) – Input trajectory with shape (nframe, nx, ny, nz, 3).

  • dt_ps (float) – Time interval between stored frames in ps.

  • qpoint (np.ndarray) – Single reduced-coordinate q-point with shape (3,).

  • freq_THz (float) – Target frequency in THz.

  • primitive_shape (tuple[int, int, int], optional) – Primitive block size in grid units. This should match the SED calculation used to identify the selected peak.

  • nphase (int, optional) – Number of phase frames in the returned one-period movie.

  • remove_mean (bool, optional) – If True, remove the per-grid-point time average before extracting the mode. Defaults to True.

  • freq_method ({"nearest_fft", "direct"}, optional) – "nearest_fft" uses the closest non-negative FFT frequency bin. "direct" projects the trajectory directly at freq_THz.

  • gauge ({"max_real", "none"}, optional) – "max_real" rotates the global complex phase so the largest eigenvector component is positive real. "none" leaves the phase as extracted.

  • normalize (bool, optional) – If True, normalize the eigenvector by sqrt(sum(abs(A)**2)). Defaults to True.

Returns:

Mode movies, basis eigenvector, raw basis amplitude, and metadata.

Return type:

DipoleModeResult

Notes

The returned mode_movie and primitive_mode_movie are normalized local-mode patterns when normalize=True. Their amplitudes are therefore not the physical MD vibration amplitude; use amplitude_basis or the SED intensity to judge mode strength.

ferrodispcalc.sed.calc.generate_commensurate_qpath(q_path: ndarray, cell_shape: tuple[int, int, int]) tuple[ndarray, ndarray][source]

Generate q-points along a path that is commensurate with a cell grid.

For cell shape (Nx, Ny, Nz), allowed reduced q-points satisfy q * (Nx, Ny, Nz) being integer-valued.

Returns:

Reduced q-points and cumulative reduced-coordinate distances.

Return type:

qpoints, q_distances

ferrodispcalc.sed.calc.load_eigen_vector(filename: str | Path) DipoleModeResult[source]

Load a DipoleModeResult saved by save_eigen_vector().

ferrodispcalc.sed.calc.load_sed(filename: str | Path) DipoleSedResult[source]

Load a DipoleSedResult saved by save_sed().

ferrodispcalc.sed.calc.save_eigen_vector(result: DipoleModeResult, filename: str | Path) None[source]

Save an extracted mode result to a compressed npz file.

ferrodispcalc.sed.calc.save_sed(result: DipoleSedResult, filename: str | Path) None[source]

Save SED arrays and grid metadata to a compressed npz file.

ferrodispcalc.sed.plot module

ferrodispcalc.sed.plot.plot_sed(result: DipoleSedResult | ndarray, freq_THz: ndarray | None = None, qpoints: ndarray | None = None, q_distances: ndarray | None = None, component: str = 'total', ax: Axes | None = None, q_labels: tuple[str, str] = ('$\\Gamma$', 'X'), freq_max: float | None = None, freq_interval: float = 5.0, cmap: str = 'RdBu_r', colorbar_min: float | None = None, colorbar_max: float | None = None, use_contourf: bool = False, savepath: str | Path | None = None, show: bool = False) tuple[Figure, Axes][source]

Plot one SED component.

Parameters:
  • result (DipoleSedResult | np.ndarray) – A DipoleSedResult, or a raw SED array with shape (nfreq, nq, 4) or (nfreq, nq). If an array is provided, freq_THz and qpoints must also be provided.

  • freq_THz (np.ndarray | None, optional) – Frequency axis in THz. Ignored when result is a DipoleSedResult.

  • qpoints (np.ndarray | None, optional) – Reduced q-points with shape (nq, 3). Ignored when result is a DipoleSedResult.

  • q_distances (np.ndarray | None, optional) – Cumulative q-path distances. If not provided, they are reconstructed from neighboring q-point differences.

  • component (str, optional) – One of "x", "y", "z", or "total". Defaults to "total".

  • ax (matplotlib.axes.Axes | None, optional) – Existing axes. A new figure and axes are created when None.

  • q_labels (tuple[str, str], optional) – Labels for the first and last q-points. Defaults to Gamma-X labels.

  • freq_max (float | None, optional) – Maximum plotted frequency in THz. Defaults to the maximum available frequency.

  • freq_interval (float, optional) – Frequency tick interval in THz. Defaults to 5.0.

  • cmap (str, optional) – Matplotlib colormap. Defaults to "RdBu_r".

  • colorbar_min (float | None, optional) – Colorbar limits on the log-intensity scale.

  • colorbar_max (float | None, optional) – Colorbar limits on the log-intensity scale.

  • use_contourf (bool, optional) – Use contourf instead of the default imshow rendering.

  • savepath (str | Path | None, optional) – Save the figure when provided.

  • show (bool, optional) – Show the figure interactively before returning.

Returns:

Matplotlib figure and axes.

Return type:

fig, ax

ferrodispcalc.sed.plot.plot_sed_1d(result: DipoleSedResult, qpoint: int | Sequence[float] | ndarray, component: str = 'total', ax: Axes | None = None, style: dict | None = None, file_name: str | Path | None = None, data_only: bool = False) Axes | tuple[ndarray, ndarray][source]

Plot the SED spectrum at one exact q-point.

Parameters:
  • result (DipoleSedResult) – A DipoleSedResult containing the SED intensity, frequency axis, and q-points.

  • qpoint (int | sequence of float | np.ndarray) – Q-point selector. An integer is interpreted as a zero-based q-point index. A length-3 array-like value is interpreted as a reduced q-point coordinate and must match exactly one row in qpoints; no nearest-neighbor or tolerance-based matching is applied.

  • component (str, optional) – Component plotted when data_only is False. One of "total", "x", "y", or "z". Defaults to "total".

  • ax (matplotlib.axes.Axes | None, optional) – Existing axes. A new figure and axes are created when None.

  • style (dict | None, optional) – Matplotlib style arguments passed directly to ax.plot.

  • file_name (str | pathlib.Path | None, optional) – Save the figure to this path when provided. The figure is saved with dpi=650 and bbox_inches="tight".

  • data_only (bool, optional) – If True, return the selected q-point data instead of plotting. The returned intensity array has shape (nfreq, 4) with columns total, x, y, and z. This requires full component SED data with shape (nfreq, nq, 4).

Returns:

  • ax (matplotlib.axes.Axes) – Returned when data_only is False.

  • freq_THz, intensity (tuple[np.ndarray, np.ndarray]) – Returned when data_only is True.

Module contents

class ferrodispcalc.sed.DipoleModeResult(mode_movie: ndarray, primitive_mode_movie: ndarray, phases: ndarray, evec_basis: ndarray, amplitude_basis: ndarray, qpoint: ndarray, requested_freq_THz: float, actual_freq_THz: float, primitive_shape: tuple[int, int, int], cell_shape: tuple[int, int, int], freq_method: str, gauge: str, normalize: bool, remove_mean: bool)[source]

Bases: object

Result of a basis-resolved local-mode extraction.

mode_movie

Real-space mode movie with shape (nphase, nx, ny, nz, 3).

Type:

np.ndarray

primitive_mode_movie

Representative primitive-block movie with shape (nphase, px, py, pz, 3).

Type:

np.ndarray

phases

Phase samples in radians with shape (nphase,).

Type:

np.ndarray

evec_basis

Complex basis-resolved eigenvector with shape (px, py, pz, 3).

Type:

np.ndarray

amplitude_basis

Complex, unnormalized Fourier amplitude after gauge fixing, with shape (px, py, pz, 3).

Type:

np.ndarray

qpoint

Reduced-coordinate q-point used for extraction.

Type:

np.ndarray

requested_freq_THz

Target frequency requested by the user.

Type:

float

actual_freq_THz

Frequency actually used. This can differ from the requested value for freq_method="nearest_fft".

Type:

float

primitive_shape

Primitive block size used to group the input grid.

Type:

tuple[int, int, int]

cell_shape

Number of primitive cells along each grid direction.

Type:

tuple[int, int, int]

freq_method

Frequency extraction method, either "nearest_fft" or "direct".

Type:

str

gauge

Gauge-fixing method, either "max_real" or "none".

Type:

str

normalize

Whether evec_basis was normalized by sqrt(sum(abs(A)**2)).

Type:

bool

remove_mean

Whether per-grid-point time means were removed before extraction.

Type:

bool

actual_freq_THz: float
amplitude_basis: ndarray
cell_shape: tuple[int, int, int]
evec_basis: ndarray
freq_method: str
gauge: str
mode_movie: ndarray
normalize: bool
phases: ndarray
primitive_mode_movie: ndarray
primitive_shape: tuple[int, int, int]
qpoint: ndarray
remove_mean: bool
requested_freq_THz: float
class ferrodispcalc.sed.DipoleSedResult(freq_THz: ndarray, qpoints: ndarray, sed: ndarray, primitive_shape: tuple[int, int, int], cell_shape: tuple[int, int, int], basis_summation: str = 'incoherent')[source]

Bases: object

Result of a local-mode SED calculation.

freq_THz

Positive-frequency axis in THz.

Type:

np.ndarray

qpoints

Reduced q-points used in the spatial Fourier transform.

Type:

np.ndarray

sed

SED intensity with shape (nfreq, nq, 4). The last axis stores x, y, z, and total.

Type:

np.ndarray

primitive_shape

Primitive block size used to group the input grid.

Type:

tuple[int, int, int]

cell_shape

Number of primitive cells along each grid direction.

Type:

tuple[int, int, int]

basis_summation

Basis summation rule. "incoherent" sums intensities over basis degrees of freedom; "coherent" sums amplitudes before squaring.

Type:

str

basis_summation: str = 'incoherent'
cell_shape: tuple[int, int, int]
freq_THz: ndarray
primitive_shape: tuple[int, int, int]
qpoints: ndarray
sed: ndarray
ferrodispcalc.sed.calculate_sed(field: ndarray, dt_ps: float, qpoints: ndarray, primitive_shape: tuple[int, int, int] = (1, 1, 1), num_splits: int = 1, remove_mean: bool = False, n_jobs: int = 1, parallel_backend: str = 'threading', *, basis_summation: str = 'incoherent') DipoleSedResult[source]

Calculate a local-mode fluctuation spectrum for a gridded trajectory.

The input field is assumed to be fixed on a regular grid of local modes, such as Ti-centered displacement, local dipole, local polarization, or the corresponding time derivative. Users must provide the reduced q-points explicitly; use generate_commensurate_qpath() when a path should be sampled by q-points commensurate with the simulation cell.

Parameters:
  • field (np.ndarray) – Input trajectory with shape (nframe, nx, ny, nz, 3). The last axis stores the Cartesian x, y, and z components. If dt_ps is in ps and the field is from LAMMPS metal units, displacement-like input is typically in Angstrom and velocity-like input is in Angstrom/ps.

  • dt_ps (float) – Time interval between stored frames in ps. The returned frequency axis is in THz because 1 / ps = 1 THz.

  • qpoints (np.ndarray) – Reduced q-points with shape (nq, 3). The spatial phase is exp(+i * 2*pi * dot(q, cell_index + basis_offset)), where basis_offset is the fractional position inside the primitive block. The opposite sign gives the same intensity after taking |A|^2.

  • primitive_shape (tuple[int, int, int], optional) – Primitive block size in grid units. For example, (1, 1, 5) groups five local modes into each primitive cell along z. Defaults to (1, 1, 1).

  • num_splits (int, optional) – Number of equal time blocks used for block averaging. nframe must be divisible by this value. Defaults to 1.

  • remove_mean (bool, optional) – If True, subtract the per-block time average at every grid point and component before the FFT. This is usually appropriate for a displacement-like field to remove the static/DC component. Velocity-like fields are usually used as-is. Defaults to False.

  • n_jobs (int, optional) – Number of q-points to evaluate in parallel with joblib. 1 means serial execution; negative values follow joblib’s convention. Defaults to 1.

  • parallel_backend (str, optional) – Joblib backend. The default "threading" avoids copying the large block array into worker processes.

  • basis_summation ({"incoherent", "coherent"}, optional) – Basis summation rule. "incoherent" computes sum_b |U_b(q, omega)|^2 and is the default local-fluctuation spectrum. "coherent" computes |sum_b U_b(q, omega)|^2 and preserves basis interference, closer to a structure-factor-like representation.

Returns:

Frequency axis, q-points, SED intensity, and grid metadata.

Return type:

DipoleSedResult

Notes

The normalization is 1 / (Nt * Ncell) before averaging over time blocks, where Nt is the number of frames per block and Ncell is the number of primitive cells. No mass weighting is applied, so this is not a strict mass-weighted phonon SED unless the input field and normalization are defined accordingly. The spatial Fourier transform uses the full local-mode position within the current folded-cell representation and, by default, sums basis intensities incoherently.

ferrodispcalc.sed.extract_eigen_vector(field: ndarray, dt_ps: float, qpoint: ndarray, freq_THz: float, primitive_shape: tuple[int, int, int] = (1, 1, 1), nphase: int = 24, remove_mean: bool = True, freq_method: str = 'nearest_fft', gauge: str = 'max_real', normalize: bool = True) DipoleModeResult[source]

Extract a basis-resolved complex mode and rebuild a real-space movie.

The extraction uses the full local-mode position, cell_index + basis_offset, in the spatial Fourier transform. It keeps the complex amplitude before any basis summation or absolute-square operation, then reconstructs the selected (q, frequency) mode over one artificial vibration period.

Parameters:
  • field (np.ndarray) – Input trajectory with shape (nframe, nx, ny, nz, 3).

  • dt_ps (float) – Time interval between stored frames in ps.

  • qpoint (np.ndarray) – Single reduced-coordinate q-point with shape (3,).

  • freq_THz (float) – Target frequency in THz.

  • primitive_shape (tuple[int, int, int], optional) – Primitive block size in grid units. This should match the SED calculation used to identify the selected peak.

  • nphase (int, optional) – Number of phase frames in the returned one-period movie.

  • remove_mean (bool, optional) – If True, remove the per-grid-point time average before extracting the mode. Defaults to True.

  • freq_method ({"nearest_fft", "direct"}, optional) – "nearest_fft" uses the closest non-negative FFT frequency bin. "direct" projects the trajectory directly at freq_THz.

  • gauge ({"max_real", "none"}, optional) – "max_real" rotates the global complex phase so the largest eigenvector component is positive real. "none" leaves the phase as extracted.

  • normalize (bool, optional) – If True, normalize the eigenvector by sqrt(sum(abs(A)**2)). Defaults to True.

Returns:

Mode movies, basis eigenvector, raw basis amplitude, and metadata.

Return type:

DipoleModeResult

Notes

The returned mode_movie and primitive_mode_movie are normalized local-mode patterns when normalize=True. Their amplitudes are therefore not the physical MD vibration amplitude; use amplitude_basis or the SED intensity to judge mode strength.

ferrodispcalc.sed.generate_commensurate_qpath(q_path: ndarray, cell_shape: tuple[int, int, int]) tuple[ndarray, ndarray][source]

Generate q-points along a path that is commensurate with a cell grid.

For cell shape (Nx, Ny, Nz), allowed reduced q-points satisfy q * (Nx, Ny, Nz) being integer-valued.

Returns:

Reduced q-points and cumulative reduced-coordinate distances.

Return type:

qpoints, q_distances

ferrodispcalc.sed.load_eigen_vector(filename: str | Path) DipoleModeResult[source]

Load a DipoleModeResult saved by save_eigen_vector().

ferrodispcalc.sed.load_sed(filename: str | Path) DipoleSedResult[source]

Load a DipoleSedResult saved by save_sed().

ferrodispcalc.sed.plot_sed(result: DipoleSedResult | ndarray, freq_THz: ndarray | None = None, qpoints: ndarray | None = None, q_distances: ndarray | None = None, component: str = 'total', ax: Axes | None = None, q_labels: tuple[str, str] = ('$\\Gamma$', 'X'), freq_max: float | None = None, freq_interval: float = 5.0, cmap: str = 'RdBu_r', colorbar_min: float | None = None, colorbar_max: float | None = None, use_contourf: bool = False, savepath: str | Path | None = None, show: bool = False) tuple[Figure, Axes][source]

Plot one SED component.

Parameters:
  • result (DipoleSedResult | np.ndarray) – A DipoleSedResult, or a raw SED array with shape (nfreq, nq, 4) or (nfreq, nq). If an array is provided, freq_THz and qpoints must also be provided.

  • freq_THz (np.ndarray | None, optional) – Frequency axis in THz. Ignored when result is a DipoleSedResult.

  • qpoints (np.ndarray | None, optional) – Reduced q-points with shape (nq, 3). Ignored when result is a DipoleSedResult.

  • q_distances (np.ndarray | None, optional) – Cumulative q-path distances. If not provided, they are reconstructed from neighboring q-point differences.

  • component (str, optional) – One of "x", "y", "z", or "total". Defaults to "total".

  • ax (matplotlib.axes.Axes | None, optional) – Existing axes. A new figure and axes are created when None.

  • q_labels (tuple[str, str], optional) – Labels for the first and last q-points. Defaults to Gamma-X labels.

  • freq_max (float | None, optional) – Maximum plotted frequency in THz. Defaults to the maximum available frequency.

  • freq_interval (float, optional) – Frequency tick interval in THz. Defaults to 5.0.

  • cmap (str, optional) – Matplotlib colormap. Defaults to "RdBu_r".

  • colorbar_min (float | None, optional) – Colorbar limits on the log-intensity scale.

  • colorbar_max (float | None, optional) – Colorbar limits on the log-intensity scale.

  • use_contourf (bool, optional) – Use contourf instead of the default imshow rendering.

  • savepath (str | Path | None, optional) – Save the figure when provided.

  • show (bool, optional) – Show the figure interactively before returning.

Returns:

Matplotlib figure and axes.

Return type:

fig, ax

ferrodispcalc.sed.plot_sed_1d(result: DipoleSedResult, qpoint: int | Sequence[float] | ndarray, component: str = 'total', ax: Axes | None = None, style: dict | None = None, file_name: str | Path | None = None, data_only: bool = False) Axes | tuple[ndarray, ndarray][source]

Plot the SED spectrum at one exact q-point.

Parameters:
  • result (DipoleSedResult) – A DipoleSedResult containing the SED intensity, frequency axis, and q-points.

  • qpoint (int | sequence of float | np.ndarray) – Q-point selector. An integer is interpreted as a zero-based q-point index. A length-3 array-like value is interpreted as a reduced q-point coordinate and must match exactly one row in qpoints; no nearest-neighbor or tolerance-based matching is applied.

  • component (str, optional) – Component plotted when data_only is False. One of "total", "x", "y", or "z". Defaults to "total".

  • ax (matplotlib.axes.Axes | None, optional) – Existing axes. A new figure and axes are created when None.

  • style (dict | None, optional) – Matplotlib style arguments passed directly to ax.plot.

  • file_name (str | pathlib.Path | None, optional) – Save the figure to this path when provided. The figure is saved with dpi=650 and bbox_inches="tight".

  • data_only (bool, optional) – If True, return the selected q-point data instead of plotting. The returned intensity array has shape (nfreq, 4) with columns total, x, y, and z. This requires full component SED data with shape (nfreq, nq, 4).

Returns:

  • ax (matplotlib.axes.Axes) – Returned when data_only is False.

  • freq_THz, intensity (tuple[np.ndarray, np.ndarray]) – Returned when data_only is True.

ferrodispcalc.sed.save_eigen_vector(result: DipoleModeResult, filename: str | Path) None[source]

Save an extracted mode result to a compressed npz file.

ferrodispcalc.sed.save_sed(result: DipoleSedResult, filename: str | Path) None[source]

Save SED arrays and grid metadata to a compressed npz file.