diff --git a/CHANGELOG.md b/CHANGELOG.md index 7404912b..b730916e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - Update versions in pre-commit config (see #148) (@jank324) - Split `accelerator` and `beam` into separate submodules (see #158) (@jank324) - Update reference from arXiv preprint to PRAB publication (see #166) (@jank324) +- Rename converter modules to the respective name of the accelerator code (see #167) (@jank324) ## [v0.6.3](https://github.com/desy-ml/cheetah/releases/tag/v0.6.3) (2024-03-28) diff --git a/cheetah/accelerator/segment.py b/cheetah/accelerator/segment.py index a72f2741..68d6acf1 100644 --- a/cheetah/accelerator/segment.py +++ b/cheetah/accelerator/segment.py @@ -9,7 +9,7 @@ from scipy.constants import physical_constants from torch import Size, nn -from cheetah.converters.dontbmad import convert_bmad_lattice +from cheetah.converters.bmad import convert_bmad_lattice from cheetah.converters.nxtables import read_nx_tables from cheetah.latticejson import load_cheetah_model, save_cheetah_model from cheetah.particles import Beam, ParticleBeam @@ -273,7 +273,7 @@ def from_ocelot( Cheetah or converted with potentially unexpected behavior. :return: Cheetah segment closely resembling the Ocelot cell. """ - from cheetah.converters.nocelot import ocelot2cheetah + from cheetah.converters.ocelot import ocelot2cheetah converted = [ ocelot2cheetah(element, warnings=warnings, device=device, dtype=dtype) diff --git a/cheetah/converters/__init__.py b/cheetah/converters/__init__.py index d19fa663..cda1cdc2 100644 --- a/cheetah/converters/__init__.py +++ b/cheetah/converters/__init__.py @@ -1,2 +1,2 @@ # flake8: noqa -from cheetah.converters import astralavista, dontbmad, nocelot, nxtables +from cheetah.converters import astra, bmad, nxtables, ocelot diff --git a/cheetah/converters/astralavista.py b/cheetah/converters/astra.py similarity index 100% rename from cheetah/converters/astralavista.py rename to cheetah/converters/astra.py diff --git a/cheetah/converters/dontbmad.py b/cheetah/converters/bmad.py similarity index 100% rename from cheetah/converters/dontbmad.py rename to cheetah/converters/bmad.py diff --git a/cheetah/converters/nocelot.py b/cheetah/converters/ocelot.py similarity index 100% rename from cheetah/converters/nocelot.py rename to cheetah/converters/ocelot.py diff --git a/cheetah/particles/parameter_beam.py b/cheetah/particles/parameter_beam.py index ae3f8c17..79378ce6 100644 --- a/cheetah/particles/parameter_beam.py +++ b/cheetah/particles/parameter_beam.py @@ -256,7 +256,7 @@ def from_ocelot(cls, parray, device=None, dtype=torch.float32) -> "ParameterBeam @classmethod def from_astra(cls, path: str, device=None, dtype=torch.float32) -> "ParameterBeam": """Load an Astra particle distribution as a Cheetah Beam.""" - from cheetah.converters.astralavista import from_astrabeam + from cheetah.converters.astra import from_astrabeam particles, energy, particle_charges = from_astrabeam(path) mu = torch.ones(7) diff --git a/cheetah/particles/particle_beam.py b/cheetah/particles/particle_beam.py index e1625d0b..b6e014fa 100644 --- a/cheetah/particles/particle_beam.py +++ b/cheetah/particles/particle_beam.py @@ -571,7 +571,7 @@ def from_ocelot(cls, parray, device=None, dtype=torch.float32) -> "ParticleBeam" @classmethod def from_astra(cls, path: str, device=None, dtype=torch.float32) -> "ParticleBeam": """Load an Astra particle distribution as a Cheetah Beam.""" - from cheetah.converters.astralavista import from_astrabeam + from cheetah.converters.astra import from_astrabeam particles, energy, particle_charges = from_astrabeam(path) particles_7d = torch.ones((particles.shape[0], 7)) diff --git a/docs/astralavista.rst b/docs/astralavista.rst deleted file mode 100644 index 5cbac7a1..00000000 --- a/docs/astralavista.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. Documents converters/astralavista.py - -Astralavista -============ - -.. automodule:: converters.astralavista - :members: - :undoc-members: diff --git a/docs/converters.rst b/docs/converters.rst new file mode 100644 index 00000000..8b446919 --- /dev/null +++ b/docs/converters.rst @@ -0,0 +1,20 @@ +.. Documents converters + +Converters +========== + +.. automodule:: converters.astra + :members: + :undoc-members: + +.. automodule:: converters.bmad + :members: + :undoc-members: + +.. automodule:: converters.nxtables + :members: + :undoc-members: + +.. automodule:: converters.ocelot + :members: + :undoc-members: diff --git a/docs/dontbmad.rst b/docs/dontbmad.rst deleted file mode 100644 index fe9a5519..00000000 --- a/docs/dontbmad.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. Documents converters/dontbemad.py - -DontBmad -======== - -.. automodule:: converters.dontbmad - :members: - :undoc-members: diff --git a/docs/index.rst b/docs/index.rst index ace7d6a3..5b06f138 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -48,11 +48,9 @@ For more advanced usage, please refer to the in-depth documentation. :caption: Documentation accelerator - astralavista - dontbmad + converters error latticejson - nocelot particles track_methods utils diff --git a/docs/nocelot.rst b/docs/nocelot.rst deleted file mode 100644 index e79f6c57..00000000 --- a/docs/nocelot.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. Documents nocelot.py - -NOcelot -======= - -.. automodule:: converters.nocelot - :members: - :undoc-members: diff --git a/tests/test_compare_ocelot.py b/tests/test_compare_ocelot.py index 3061ff3a..05ca9af0 100644 --- a/tests/test_compare_ocelot.py +++ b/tests/test_compare_ocelot.py @@ -256,7 +256,7 @@ def test_ares_ea(): Test that the tracking results through a Experimental Area (EA) lattice of the ARES accelerator at DESY match those using Ocelot. """ - cell = cheetah.converters.nocelot.subcell_of_ocelot( + cell = cheetah.converters.ocelot.subcell_of_ocelot( ares.cell, "AREASOLA1", "AREABSCR1" ) ares.areamqzm1.k1 = 5.0 diff --git a/tests/test_speed.py b/tests/test_speed.py index a5f32ee3..c78a9dee 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -10,7 +10,7 @@ # TODO: Test that Cheeath tracks faster than Ocelot def test_tracking_speed(): """Really only tests that Cheetah isn't super slow.""" - cell = cheetah.converters.nocelot.subcell_of_ocelot( + cell = cheetah.converters.ocelot.subcell_of_ocelot( ares.cell, "AREASOLA1", "AREABSCR1" ) segment = cheetah.Segment.from_ocelot(cell)