Handwritten API reference
This handwritten reference covers the classes in src/fdmnes_util for direct use from Python. Each class lists its import, every public method’s parameters, defaults and return value, and a short example for each class. See the Sphinx-generated API for full signatures and docstrings and the script guide for command-line examples.
Parameters with = have defaults. Parameters after * are keyword-only. __init__ initializes the object. Calling the class returns an instance. ndarray is a NumPy array and Path is pathlib.Path. Replace example filenames with your calculation or measurement files.
Calculation inputs and batch jobs
FdmInp
from fdmnes_util.fdm_inp import FdmInp
Read, inspect, and generate FDMNES calculation inputs.
Input files have no revision line. Use FdmInp(filename, format_year=2026) for extended input. The default is 2016. get_absorbers() returns site indices, and get_calculations() returns (filename, weight, shift, cutoff) records. FdmInp.write(..., format_year=2026) accepts absorber=[1, 2], density_complex=True, and lmax_dosout=3. FdmInp.write_convolution(filename, calculations, *, output, format_year=2026, header=False, energy_step=None, per_atom=False) writes a combined convolution input. Each calculation is a (raw XAS path, weight, shift in eV) tuple.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
str: Last |
|
— |
int. One-based absorber index from the last |
|
— |
int: Two when |
|
— |
bool: True when |
|
— |
bool: True when |
|
— |
bool: True when the keyword is present. |
|
— |
bool: True when |
|
— |
str: Convolution-output value, or an empty string. |
|
— |
str: First filename in the last |
|
— |
list[float] | None: The six cell parameters, or None when absent. |
|
— |
ase.Atoms: Periodic atomic structure with fractional positions. |
|
— |
ase.Atoms: Atom positions in angstroms, with periodicity disabled. |
|
|
str: FDMNES input content including the structural section. |
|
|
Path: Destination of the written input file. |
Example
from fdmnes_util.fdm_inp import FdmInp
inp = FdmInp("read_pdb.inp")
prefix = inp.get_filout()
absorber = inp.get_absorber()
Fdmfile
from fdmnes_util.fdmfile import Fdmfile
Represent the ordered input filenames in an FDMNES batch list.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
str. First job’s input filename, or an empty string. |
|
|
Path. Selected calculation input path. |
|
|
Path: Path of the generated job-list file. |
Example
from fdmnes_util.fdmfile import Fdmfile
jobs = Fdmfile("fdmfile.txt")
first_input = jobs.get_filout()
XAS and experimental spectra
FdmTxt
from fdmnes_util.fdm_txt import FdmTxt
Read one XAS output, including edge and Fermi-energy metadata.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
ndarray. Energy axis in the reference frame stored in the file. |
|
|
numpy.ndarray: Absorption intensity values. |
|
— |
ndarray. Absorption matrix with one row per energy point. |
|
|
numpy.ndarray: The matching absorption intensities. |
|
— |
float or None. Edge energy in eV, if present. |
|
— |
float. Fermi energy in eV, defaulting to 0.0. |
|
|
None. Writes the two-column spectrum with its raw header. |
Example
from fdmnes_util.fdm_txt import FdmTxt
raw = FdmTxt("Fe.txt")
energy, intensity = raw.get_eng(), raw.get_xas()
edge = raw.get_eedge()
FdmConv
from fdmnes_util.fdm_conv import FdmConv
Retain the energy axis and all absorption columns of one output file.
Use FdmConv(filename, format_year=None) to detect the November 5, 2026 revision line output by Header. Ordinary output uses the 2016 layout. Set format_year=2016 or 2026 to choose explicitly. With the 2026 layout, preamble, parameters, and shifts expose the extra header data.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
ndarray. Energy axis in the reference frame stored in the file. |
|
|
numpy.ndarray: Absorption intensity values. |
|
|
None. Writes the two-column spectrum. |
Example
from fdmnes_util.fdm_conv import FdmConv
conv = FdmConv("Fe_conv.txt")
energy, intensity = conv.get_eng(), conv.get_xas()
AthenaNor
from fdmnes_util.athena_nor import AthenaNor
Read the energy axis and normalized absorption from an Athena file.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
numpy.ndarray: Photon-energy values. |
|
— |
numpy.ndarray: Normalized absorption values. |
Example
from fdmnes_util.athena_nor import AthenaNor
measured = AthenaNor("Fe_obs.txt.nor")
photon_energy, normalized = measured.get_eng(), measured.get_nor()
FdmPhotoenergy
from fdmnes_util.fdm_photoenergy import FdmPhotoenergy
Represent the *_conv_photoe.txt output file format.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
pathlib.Path: Path to the generated text file. |
Example
from fdmnes_util.fdm_photoenergy import FdmPhotoenergy
output = FdmPhotoenergy().write([7112.0, 7113.0], [0.2, 0.5], "Fe_conv_photoe.txt")
SD and BAV readers
FdmSd
from fdmnes_util.fdm_sd import FdmSd
Select the format-specific parser for a site-resolved DOS file. For files such as the 2019 Cu output, the BAV revision does not identify the SD layout. Pass format_year=None to inspect the SD column names.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
FdmSd2016, FdmSd2020, or FdmSd2026. |
|
|
int: Supported SD layout year. |
|
|
None. Writes the SD table. |
Example
from fdmnes_util.fdm_sd import FdmSd
sd = FdmSd("Fe_sd0.txt", format_year=None).select_reader()
energy, p_ldos = sd.get_eng(), sd.get_ldos("p")
FdmSd2016
from fdmnes_util.fdm_sd_2016 import FdmSd2016
Read DOS projections and spin channels from a 2016 SD file.
spin accepts 0 or, for two spins, 1. Aliases for 0 are up, non, and nonmag. Aliases for 1 are dn and down. Group names are s, p, d, and f.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
ndarray. Density and integral columns in file order, excluding energy. |
|
— |
ndarray. Energy axis in eV. |
|
— |
int. Maximum orbital angular momentum index. |
|
— |
int. Number of spin channels. |
|
|
numpy.ndarray: One value per energy point. |
|
|
numpy.ndarray: One value per energy point. |
|
|
numpy.ndarray: Orbital densities on the file’s energy grid. |
|
|
ndarray. Sum of the orbital-group DOS for the selected spin. |
|
|
ndarray. Sum of the leading integral column and orbital-group integrals for the selected spin. |
Example
from fdmnes_util.fdm_sd_2016 import FdmSd2016
sd = FdmSd2016("Fe_2016_sd0.txt", ispin=1)
energy, s_ldos = sd.get_eng(), sd.get_ldos("s")
FdmSd2020
from fdmnes_util.fdm_sd_2020 import FdmSd2020
Read orbital-resolved density of states from a 2020-format SD file.
This reader supports nonmagnetic columns and the 31-column magnetic layout verified on 2021 and 2026 Ni output. Pass 0 (up, non, or nonmag) or, for magnetic output, 1 (dn or down). The total and Int(total) columns describe both spins together.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
ndarray. Density and integral columns in file order, excluding energy. |
|
— |
ndarray. Energy axis in eV. |
|
— |
int. Maximum orbital angular momentum index. |
|
— |
int. Number of spin channels. |
|
|
numpy.ndarray: Density values for the requested orbital. |
|
|
numpy.ndarray: Integrated densities on the file’s energy grid. |
|
|
numpy.ndarray: Partial density values. |
|
|
ndarray. Stored total DOS across all spins. |
|
|
ndarray. Stored integrated total DOS across all spins. |
Example
from fdmnes_util.fdm_sd_2020 import FdmSd2020
sd = FdmSd2020("Fe_sd0.txt")
energy, pz_pdos = sd.get_eng(), sd.get_pdos(lm="p_z")
FdmSd2026
This reader supports complex and f-orbital projections. Use FdmSd(filename, format_year=None) to detect the layout from the columns, or choose format_year=2026. For example, get_pdos(l=3, m=0) reads a complex projection, get_pdos(lm="fxyz") reads a real f projection, and get_ldos(l=3) reads the f group. Ordinary s, p, and d columns from the 2026 binary use the existing reader.
FdmBav
from fdmnes_util.fdm_bav import FdmBav
Inspect a _bav.txt header and select its version-specific parser.
Each version reader parses its own BAV records. FdmBav selects the reader from the revision line and forwards the 13 common methods, such as get_edge(), to their counterparts. Direct calls reuse the reader selected on the first call.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
FdmBav2016 through 2016, FdmBav2020 for 2017–2021, and FdmBav2026 for November 5, 2026. Other revisions from 2022 onward raise ValueError. |
|
— |
list[tuple[int, float | None]]. Cycle numbers and total energies (eV) for the 2026 release. A missing energy is None. An unavailable history is an empty list. |
Example
from fdmnes_util.fdm_bav import FdmBav
bav = FdmBav("Fe_bav.txt")
print(bav.year, bav.get_edge())
FdmBav2016
from fdmnes_util.fdm_bav_2016 import FdmBav2016
Extract calculation information from a 2016-format _bav.txt file.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
str. Absorption-edge label, or an empty string. |
|
— |
int. One or two spin channels. |
|
— |
bool. Whether the log reports a self-consistent calculation. |
|
— |
int or None. Reported SCF iteration limit. |
|
— |
int. Last reported SCF cycle number, or zero. |
|
— |
list[float]. Unit-cell energy for each SCF record. |
|
— |
ndarray. Cartesian cluster coordinates. |
|
— |
list[str]. Chemical symbols in cluster order. |
|
— |
int. Number of atoms in the cluster. |
|
— |
float or None. Recorded absorption-edge energy. |
|
— |
int or None. Number of atom groups, if available. |
|
— |
ndarray or None. 3×3 crystal-basis transformation matrix. |
|
— |
int or None. Highest angular momentum index in the atom listing. |
Example
from fdmnes_util.fdm_bav_2016 import FdmBav2016
log = FdmBav2016("Fe_2016_bav.txt")
edge, last_cycle = log.get_edge(), log.get_n_scf_loop()
FdmBav2020
from fdmnes_util.fdm_bav_2020 import FdmBav2020
Extract calculation information from a 2020-format _bav.txt file.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
str. Absorption-edge label, or an empty string. |
|
— |
int. One or two spin channels. |
|
— |
bool. Whether the log reports a self-consistent calculation. |
|
— |
int or None. Reported SCF iteration limit. |
|
— |
int. Last reported SCF cycle number, or zero. |
|
— |
list[float]. Unit-cell energy for each SCF record. |
|
— |
ndarray. Cartesian cluster coordinates. |
|
— |
list[str]. Chemical symbols in cluster order. |
|
— |
int. Number of atoms in the cluster. |
|
— |
float or None. Recorded absorption-edge energy. |
|
— |
int or None. Number of atom groups, if available. |
|
— |
ndarray or None. 3×3 crystal-basis transformation matrix. |
|
— |
int or None. Highest angular momentum index in the atom listing. |
Example
from fdmnes_util.fdm_bav_2020 import FdmBav2020
log = FdmBav2020("Fe_bav.txt")
symbols, positions = log.get_atoms_index_j(), log.get_position()
FdmBav2026
from fdmnes_util.fdm_bav_2026 import FdmBav2026
Read BAV reports from the November 5, 2026 release. The public reader methods match FdmBav2016 and FdmBav2020. Use the common FdmBav entry point to read total energies by cycle.
from fdmnes_util.fdm_bav import FdmBav
log = FdmBav("Fe_SCF_bav.txt")
history = log.get_scf_history()
Structure I/O
Cif
from fdmnes_util.cif import Cif
Provide FDMNES structure conversion with CIF-backed atomic data.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
list[str]: Atomic symbols. |
|
— |
numpy.ndarray: A 3-by-3 array of lattice vectors. |
|
— |
numpy.ndarray: Atomic positions in fractional coordinates. |
|
— |
numpy.ndarray: Cartesian atomic positions. |
Example
from fdmnes_util.cif import Cif
cell = Cif("Fe.cif")
symbols, lattice = cell.get_symbols(), cell.get_lattice_vectors()
Pdb
from fdmnes_util.pdb import Pdb
Represent the atomic structure and cell information in a PDB file.
Without a CRYST1 record, molecule is true. Lattice vectors and fractional coordinates are for periodic structures.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
list[str]: Chemical symbols. |
|
— |
list[tuple[float, float, float]]: Cartesian coordinates. |
|
— |
numpy.ndarray: Three lattice vectors in angstroms. |
|
— |
numpy.ndarray: Fractional atomic coordinates. |
Example
from fdmnes_util.pdb import Pdb
pdb = Pdb("Fe.pdb")
symbols, coordinates = pdb.get_symbols(), pdb.get_cartesian_positions()
Xyz
from fdmnes_util.xyz import Xyz
Read and write atomic symbols and Cartesian coordinates in standard XYZ format.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
None. Refreshes symbols and positions in place. |
|
|
str. Complete XYZ text, including a trailing newline. |
|
|
Path. Saved XYZ path. |
Example
from fdmnes_util.xyz import Xyz
cluster = Xyz("cluster.xyz")
symbols, positions = cluster.symbols, cluster.positions
ElementTable
from fdmnes_util.fdm_structure import ElementTable
Look up atomic numbers and element symbols used in structure records.
Method |
Argument |
Return value |
|---|---|---|
|
Atomic number. |
Element symbol as str. |
|
Element symbol. |
Atomic number as int. |
FdmStructure
from fdmnes_util.fdm_structure import FdmStructure
Convert structure information into a FDMNES structural section.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
FDMNES input path. |
ase.Atoms for POSCAR writing. |
|
POSCAR path passed to vasp_util. |
Periodic ase.Atoms with the original lattice and atom order. |
|
Six cell lengths and angles, followed by atom records containing atomic numbers and fractional coordinates. |
ase.Atoms with periodic boundaries. |
|
Molecular scale and atomic-coordinate records. |
ase.Atoms for an isolated molecule with Cartesian coordinates in Å. |
|
|
str: Formatted FDMNES structure section. |
|
|
str. FDMNES Molecule section from XYZ coordinates. |
|
|
Path: Written file path. |
Example
from fdmnes_util.fdm_structure import FdmStructure
from vasp_util.vasp_poscar import VaspPoscar
structure = FdmStructure(VaspPoscar("POSCAR"))
output = structure.write("Fe.fdmnes")
Analysis
AnalyzeFdmAverage
from fdmnes_util.analyze_fdm_average import AnalyzeFdmAverage
Average data from independent calculations on a shared energy grid.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
tuple[float, float]: Energy-axis shift and absolute Fermi position in the photon-energy reference, both in eV. |
|
|
tuple[numpy.ndarray, numpy.ndarray]: Energy and mean values. |
Example
from fdmnes_util.analyze_fdm_average import AnalyzeFdmAverage
from fdmnes_util.fdm_conv import FdmConv
readers = [FdmConv("Fe_1_conv.txt"), FdmConv("Fe_2_conv.txt")]
energy, mean_xas = AnalyzeFdmAverage().average(readers, "get_xas")
AnalyzeFdmXas
from fdmnes_util.analyze_fdm_xas import AnalyzeFdmXas
Numerical analysis of FDMNES absorption spectra.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
tuple[numpy.ndarray, numpy.ndarray]: Common energy grid and mean XAS. |
|
|
tuple[numpy.ndarray, numpy.ndarray]: Converted energy and XAS. |
|
|
tuple[numpy.ndarray, numpy.ndarray]: Fermi-relative energy and absorption intensity, in the original row order. |
|
|
numpy.ndarray: Energy grid in the requested reference frame, in eV. |
|
|
list[tuple]: Tuples of energy, intensity, and site label. |
Example
from fdmnes_util.analyze_fdm_xas import AnalyzeFdmXas
from fdmnes_util.fdm_conv import FdmConv
from fdmnes_util.fdm_txt import FdmTxt
conv, raw = FdmConv("Fe_conv.txt"), FdmTxt("Fe.txt")
energy, intensity = AnalyzeFdmXas.photon_energy(conv, raw)
Plotting
Plotting requires Matplotlib. Match the number of energies to the number of values in each curve and convert compared curves to the same energy reference. Plotting methods return the saved Path. save_multiple_formats() returns a list of paths.
PlotFdmXas
from fdmnes_util.plot.plot_fdm_xas import PlotFdmXas
Matplotlib visualizations for FDMNES XAS.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
Path to the saved figure. |
|
|
pathlib.Path: Path to the saved figure. |
|
|
pathlib.Path: Destination of the saved figure. |
|
|
pathlib.Path: Saved figure filename. |
|
|
pathlib.Path: Main figure path. |
Example
from fdmnes_util.plot.plot_fdm_xas import PlotFdmXas
from fdmnes_util.fdm_conv import FdmConv
conv = FdmConv("Fe_conv.txt")
output = PlotFdmXas().plot([(conv.get_eng(), conv.get_xas(), "Fe")], "Fe_XAS.pdf")
PlotFdmDos
from fdmnes_util.plot.plot_fdm_dos import PlotFdmDos
Create density-of-states figures without parsing an SD file.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
Path to the saved figure. |
|
|
pathlib.Path: The generated image file. |
|
|
pathlib.Path: Destination of the saved figure. |
|
|
pathlib.Path: Path to the figure written to disk. |
|
|
list[pathlib.Path]: Paths to the generated image files. |
|
|
pathlib.Path: Path of the saved figure. |
|
|
pathlib.Path: Path to the saved figure. |
|
|
pathlib.Path: Main saved figure. |
Example
from fdmnes_util.plot.plot_fdm_dos import PlotFdmDos
from fdmnes_util.fdm_sd_2020 import FdmSd2020
sd = FdmSd2020("Fe_sd0.txt")
output = PlotFdmDos().plot_single_orbital(sd, "Fe_LDOS.pdf", orbital="p")
PlotFdmXasLdos
from fdmnes_util.plot.plot_fdm_xas_ldos import PlotFdmXasLdos
Draw XAS and orbital-resolved LDOS using prepared numerical arrays.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
pathlib.Path: Path to the generated figure. |
|
|
pathlib.Path: Saved figure path. |
Example
from fdmnes_util.plot.plot_fdm_xas_ldos import PlotFdmXasLdos
from fdmnes_util.fdm_conv import FdmConv
from fdmnes_util.fdm_sd_2020 import FdmSd2020
conv, sd = FdmConv("Fe_conv.txt"), FdmSd2020("Fe_sd0.txt")
xas = (conv.get_eng(), conv.get_xas())
ldos = [("p", sd.get_eng(), sd.get_ldos("p"))]
output = PlotFdmXasLdos().plot(xas, ldos, "Fe_XAS_LDOS.pdf")
PlotFdmAverage
from fdmnes_util.plot.plot_fdm_average import PlotFdmAverage
Draw averaged FDMNES orbital projections and absorption spectra.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
pathlib.Path: Path to the generated figure. |
Example
from fdmnes_util.plot.plot_fdm_average import PlotFdmAverage
from fdmnes_util.analyze_fdm_average import AnalyzeFdmAverage
from fdmnes_util.fdm_sd_2020 import FdmSd2020
readers = [FdmSd2020("Fe_1_sd0.txt"), FdmSd2020("Fe_2_sd0.txt")]
energy, density = AnalyzeFdmAverage().average(readers, "get_pdos", lm="p_z")
output = PlotFdmAverage().plot([("p_z", energy, density)], "Fe_PDOS_mean.pdf")
Result file operations and convolution job preparation
SiteConvolutionJobPreparer
from fdmnes_util.util.site_convolution_job_preparer import SiteConvolutionJobPreparer
Prepare site-by-site convolution jobs by selecting numbered raw XAS spectra in filename order and writing one input per spectrum plus a shared job list. FDmakeCconvAllsite.py uses this utility.
With input files Fe_1.txt and Fe_2.txt, the example writes conv_1.inp, conv_2.inp, and fdmfile.txt in convolution_jobs/.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
list[str]: Input filenames in lexicographic order of source spectra. |
Example
from fdmnes_util.util.site_convolution_job_preparer import SiteConvolutionJobPreparer
jobs = SiteConvolutionJobPreparer().write("Fe", output_dir="convolution_jobs")
print(jobs)
ResultFileOperations
from fdmnes_util.util.result_file_operations import ResultFileOperations
Find, clean, rename, or archive files associated with a Filout prefix.
Method and parameter defaults |
Parameter meanings |
Return value |
|---|---|---|
|
|
None. |
|
— |
list[Path]. Existing result and auxiliary files. |
|
— |
list[Path]. Existing XAS, BAV, convolution, and SD files eligible for relocation. |
|
— |
list[Path]. Paths that were deleted. |
|
|
list[Path]. Paths in the archive directory. |
|
|
list[Path]. Destination paths in result order. A collision raises FileExistsError. |
Example
from fdmnes_util.util.result_file_operations import ResultFileOperations
results = ResultFileOperations("Fe")
print(results.outputs())
Python examples
Extract orbital density from SD
from fdmnes_util.fdm_sd import FdmSd
sd = FdmSd("Fe_sd0.txt", format_year=None).select_reader()
energy = sd.get_eng()
p_ldos = sd.get_ldos("p")
pz_pdos = sd.get_pdos(lm="p_z")
Export a calculation cluster from BAV to XYZ
from fdmnes_util.fdm_bav import FdmBav
from fdmnes_util.xyz import Xyz
bav = FdmBav("Fe_bav.txt").select_reader()
symbols = bav.get_atoms_index_j()
positions = bav.get_position()
Xyz.write(symbols, positions, "Fe_cluster.xyz")
Plot the mean XAS across sites
from fdmnes_util.analyze_fdm_average import AnalyzeFdmAverage
from fdmnes_util.fdm_conv import FdmConv
from fdmnes_util.plot.plot_fdm_xas import PlotFdmXas
spectra = [FdmConv("Fe_1_conv.txt"), FdmConv("Fe_2_conv.txt")]
energy, intensity = AnalyzeFdmAverage().average(spectra, "get_xas")
PlotFdmXas().plot([(energy, intensity, "Fe mean")], "Fe_mean.pdf")