Skip to content

Commit

Permalink
Issue 285: Add ionization energy data from NIST (#2657)
Browse files Browse the repository at this point in the history
* Added ionization energy data from NIST

* Remove extra newline to align with styling

* Add citation entry

* Add conversion to Joules

* Add changelog entry

* Add missing end of codeblock

* Fix markdown formatting

* Update 2657.feature.rst

* Added ionization_energy to Particles documentation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add tests for ionization energy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix failing ruff checks

* Fix failing ruff checks

* Fix failing ruff checks

* Add documentation

* Add full module path to raised exception

* Update tests/particles/test_particle_class.py

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update src/plasmapy/particles/particle_class.py

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Add ionization energy of ions

* Update changelog/2657.feature.rst

Co-authored-by: Nick Murphy <namurphy@cfa.harvard.edu>

* Handle case where element was initialized with a zero charge

* Provide information about where ionization energy data comes from

* Fix issue where isotopes don't load ionization energy correctly

* Change how pkgutil gets ionization energy data

* Add additional ionization energy tests

* Add utility script for dumping ionization energy data from NIST

* Revert pkgutil format to match others, and fix copy paste error in comment

* Try adding a type definition to obj hook

* Update missing documentation and revert function type definiton

* Add _ionization_energy to mypy.ini to align with _elements and _isotopes

* Add __init__.py to tools

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Resolve ruff errors

* Resolve ruff errors

* Resolve ruff errors

* Resolve mypy errors

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added ionization energy data from NIST

* Remove extra newline to align with styling

* Add conversion to Joules

* Add changelog entry

* Add missing end of codeblock

* Fix markdown formatting

* Update 2657.feature.rst

* Added ionization_energy to Particles documentation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add tests for ionization energy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix failing ruff checks

* Fix failing ruff checks

* Fix failing ruff checks

* Add documentation

* Add full module path to raised exception

* Update tests/particles/test_particle_class.py

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update src/plasmapy/particles/particle_class.py

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Update changelog/2657.feature.rst

Co-authored-by: Peter Heuer <pvheuer@gmail.com>

* Add ionization energy of ions

* Update changelog/2657.feature.rst

Co-authored-by: Nick Murphy <namurphy@cfa.harvard.edu>

* Handle case where element was initialized with a zero charge

* Provide information about where ionization energy data comes from

* Fix issue where isotopes don't load ionization energy correctly

* Change how pkgutil gets ionization energy data

* Add additional ionization energy tests

* Add utility script for dumping ionization energy data from NIST

* Revert pkgutil format to match others, and fix copy paste error in comment

* Try adding a type definition to obj hook

* Update missing documentation and revert function type definiton

* Add _ionization_energy to mypy.ini to align with _elements and _isotopes

* Add __init__.py to tools

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Resolve ruff errors

* Resolve ruff errors

* Resolve ruff errors

* Resolve mypy errors

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* Exclude tools from mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add check for isotope ionization energy

* Attempt to reduce complexity

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add docstring

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Peter Heuer <pvheuer@gmail.com>
Co-authored-by: Nick Murphy <namurphy@cfa.harvard.edu>
  • Loading branch information
4 people committed May 14, 2024
1 parent 21651ec commit 9b498fe
Show file tree
Hide file tree
Showing 12 changed files with 17,977 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -622,3 +622,7 @@ authors:
- given-names: Carol
family-names: Zhang
alias: carolyz

- given-names: Chase
family-names: Davies
alias: chasepd
3 changes: 3 additions & 0 deletions changelog/2657.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Added ionization energy data from NIST to the |Particle| class.
This can now be accessed using the `~plasmapy.particles.particle_class.Particle.ionization_energy` attribute
from the |Particle| class.
2 changes: 2 additions & 0 deletions docs/particles/particle_class.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ These properties are often returned as a |Quantity| in SI units.
<Quantity 3.888e+08 s>
>>> iron56.binding_energy.to('GeV')
<Quantity 0.49225958 GeV>
>>> hydrogen.ionization_energy
<Quantity 2.17870942e-18 J>

Strings representing particles may be accessed using the
`~plasmapy.particles.particle_class.Particle.symbol`,
Expand Down
6 changes: 5 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ exclude = (?x)(
^conftest.py|
build|
_version.py|
noxfile.py
noxfile.py|
^tools/
)

enable_error_code = ignore-without-code
Expand Down Expand Up @@ -204,6 +205,9 @@ disable_error_code = arg-type,index,no-untyped-def
[mypy-plasmapy.particles._isotopes]
disable_error_code = arg-type,no-untyped-def

[mypy-plasmapy.particles._ionization_energy]
disable_error_code = arg-type,no-untyped-def

[mypy-plasmapy.particles._parsing]
disable_error_code = arg-type,assignment,no-any-return,no-untyped-def,return-value,syntax,type-arg,union-attr,var-annotated

Expand Down
28 changes: 28 additions & 0 deletions src/plasmapy/particles/_ionization_energy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Module for loading ionization energy data from
:file:`src/plasmapy/particles/data/ionization_energy.json`.
"""

__all__ = [
"ionization_energy_obj_hook",
"data_about_ionization_energy",
]

import json
import pkgutil

import astropy.units as u


def ionization_energy_obj_hook(obj):
"""Provide an ``object_hook`` designed for `json.load` and `json.loads`."""
return (
(obj["ionization energy"] * u.eV).to(u.J) if "ionization energy" in obj else obj
)


#: Dictionary of ionization energy data.
data_about_ionization_energy = json.loads(
pkgutil.get_data("plasmapy", "particles/data/ionization_energy.json"),
object_hook=ionization_energy_obj_hook,
)
8 changes: 5 additions & 3 deletions src/plasmapy/particles/data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""
Data used in constructing `plasmapy.particles`.
There are currently two datasets, :file:`elements.json` and
:file:`isotopes.json`. :file:`elements.json` contains element/atomic
There are currently three datasets, :file:`elements.json`,
:file:`isotopes.json`, and :file:`ionization_energy.json`. :file:`elements.json` contains element/atomic
data that is loaded by the functionality contained in
``plasmapy.particles._elements``. :file:`isotopes.json` contains isotope
data that is loaded by the functionality contained in
``plasmapy.particles._isotopes``.
``plasmapy.particles._isotopes``. :file:`ionization_energy.json` contains ionization energy
data that is loaded by the functionality contained in
``plasmapy.particles._ionization_energy``.
"""

0 comments on commit 9b498fe

Please sign in to comment.