Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion utu/spectrum/_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def ions(
worth including.
kwargs
Additional arguments passed to :class:`fiasco.Ion`.
If ``hdf5_dbase_root`` is among them, the ions are listed from that
database too.

Notes
-----
Expand Down Expand Up @@ -116,7 +118,10 @@ def _catalog(
"""
result = {}

for name in fiasco.list_ions():
# the ions of the database they are read from, not of the default one
database = kwargs.get("hdf5_dbase_root")

for name in fiasco.list_ions(hdf5_dbase_root=database):
try:
ion = fiasco.Ion(name, 1 * u.MK, **kwargs)

Expand Down
18 changes: 18 additions & 0 deletions utu/spectrum/_tests/test_lines.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pathlib

import astropy.units as u
import fiasco
import named_arrays as na
Expand Down Expand Up @@ -83,6 +85,22 @@ def test_ions(ions_window: list[str], ions_all: list[str]):
assert len(ions_window) < len(ions_all)


def test_ions_database(monkeypatch: pytest.MonkeyPatch, tmp_path: pathlib.Path):
"""The ions are listed from the database they are read from."""
found = []

def list_ions(hdf5_dbase_root: object = None, sort: bool = True) -> list[str]:
"""Record the database the ions are listed from, which has none."""
found.append(hdf5_dbase_root)
return []

monkeypatch.setattr(fiasco, "list_ions", list_ions)
database = tmp_path / "chianti.h5"

assert utu.spectrum.ions(hdf5_dbase_root=database) == []
assert found == [database]


@needs_database
def test_contribution_function(proton_electron_ratio: u.Quantity):
ion = fiasco.Ion("O 5", temperature.ndarray)
Expand Down
Loading