Skip to content

Commit

Permalink
Merge pull request #6 from AngelFP/improve_astra_saving
Browse files Browse the repository at this point in the history
Improve species checks in ASTRA saver
  • Loading branch information
AngelFP authored Mar 10, 2023
2 parents feae5c1 + bebdba0 commit e11fcdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion aptools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .data_analysis import beam_diagnostics

__version__ = "0.2.0"
__version__ = "0.2.1"
__all__ = ['beam_diagnostics', '__version__']
14 changes: 10 additions & 4 deletions aptools/particle_distributions/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ def save_to_astra(
w = distribution.w

# Determine particle index (type of species).
if m_species == ct.m_e:
index = 1 if q_species == -ct.e else 2
if m_species == ct.m_p:
index == 3
if m_species == ct.m_e and q_species == -ct.e:
index = 1
elif m_species == ct.m_e and q_species == ct.e:
index = 2
elif m_species == ct.m_p and q_species == ct.e:
index = 3
else:
raise ValueError(
'Only electrons, positrons and protons are supported when saving '
'to ASTRA.')

# Create arrays
x = np.zeros(q_orig.size + 1)
Expand Down

0 comments on commit e11fcdb

Please sign in to comment.