Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add molecular data exposure to tardis atom data #2806

Merged
merged 13 commits into from
Aug 22, 2024
74 changes: 67 additions & 7 deletions tardis/io/atom_data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import pandas as pd
from astropy.units import Quantity
from dataclasses import dataclass

from tardis import constants as const
from tardis.io.atom_data.collision_data import (
Expand Down Expand Up @@ -103,6 +104,17 @@
columns: atomic_number, element, Rad energy, Rad intensity decay mode.
Curated from nndc

linelist_atoms : pandas.DataFrame
A DataFrame containing a linelist of input atoms

linelist_molecules : pandas.DataFrame
A DataFrame containing a linelist of input molecules

molecule_data : MolecularData
A class containing the *molecular data* with:
equilibrium_constants, partition_functions, dissociation_energies


Attributes
----------
prepared : bool
Expand All @@ -117,6 +129,9 @@
photoionization_data : pandas.DataFrame
two_photon_data : pandas.DataFrame
decay_radiation_data : pandas.DataFrame
linelist_atoms : pandas.DataFrame
linelist_molecules : pandas.DataFrame
molecule_data : MolecularData

Methods
-------
Expand Down Expand Up @@ -147,7 +162,8 @@
"photoionization_data",
"yg_data",
"two_photon_data",
"linelist",
"linelist_atoms",
"linelist_molecules",
"decay_radiation_data",
]

Expand Down Expand Up @@ -219,10 +235,21 @@
raise ValueError(
f"Current carsus version, {carsus_version}, is not supported."
)
if "linelist" in store:
dataframes["linelist"] = store["linelist"]
if "linelist_atoms" in store:
dataframes["linelist_atoms"] = store["linelist_atoms"]

Check warning on line 239 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L239

Added line #L239 was not covered by tests
if "linelist_molecules" in store:
dataframes["linelist_molecules"] = store["linelist_molecules"]

Check warning on line 241 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L241

Added line #L241 was not covered by tests

if "molecules" in store:
molecule_data = MoleculeData(

Check warning on line 244 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L244

Added line #L244 was not covered by tests
store["molecules/equilibrium_constants"],
store["molecules/partition_functions"],
store["molecules/dissociation_energies"],
)
else:
molecule_data = None

atom_data = cls(**dataframes)
atom_data = cls(**dataframes, molecule_data=molecule_data)

atom_data.uuid1 = cls.get_attributes_from_store(store, "uuid1")
atom_data.md5 = cls.get_attributes_from_store(store, "md5")
Expand Down Expand Up @@ -259,8 +286,10 @@
photoionization_data=None,
yg_data=None,
two_photon_data=None,
linelist=None,
linelist_atoms=None,
linelist_molecules=None,
decay_radiation_data=None,
molecule_data=None,
):
self.prepared = False

Expand Down Expand Up @@ -329,8 +358,13 @@

self.two_photon_data = two_photon_data

if linelist is not None:
self.linelist = linelist
if linelist_atoms is not None:
self.linelist_atoms = linelist_atoms

Check warning on line 362 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L362

Added line #L362 was not covered by tests
if linelist_molecules is not None:
self.linelist_molecules = linelist_molecules

Check warning on line 364 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L364

Added line #L364 was not covered by tests

if molecule_data is not None:
self.molecule_data = molecule_data

Check warning on line 367 in tardis/io/atom_data/base.py

View check run for this annotation

Codecov / codecov/patch

tardis/io/atom_data/base.py#L367

Added line #L367 was not covered by tests

if decay_radiation_data is not None:
self.decay_radiation_data = decay_radiation_data
Expand Down Expand Up @@ -672,3 +706,29 @@
attribute = None

return attribute


@dataclass
class MoleculeData:
"""
Class to hold molecular data. Held by the AtomData object.

equilibrium_constants : pandas.DataFrame
A DataFrame containing the *molecular equilibrium constants* with:
index: molecule
columns: temperatures

partition_functions : pandas.DataFrame
A DataFrame containing the *molecular partition functions* with:
index: molecule
columns: temperatures

dissociation_energies : pandas.DataFrame
A DataFrame containing the *molecular dissociation energies* with:
index: molecule

"""

equilibrium_constants: pd.DataFrame
partition_functions: pd.DataFrame
dissociation_energies: pd.DataFrame
Loading