Skip to content

Commit

Permalink
Merge pull request #34 from ColwynGulliford/master
Browse files Browse the repository at this point in the history
Remove np.complex (depreciated)
  • Loading branch information
ChristopherMayes authored Apr 12, 2023
2 parents c49f8b4 + 1592edf commit 20559fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 14 additions & 0 deletions pmd_beamphysics/interfaces/simion.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,17 @@ def simion_ion_file_particles_to_particle_data(filename, flip_x_to_z=True):

return data

def KE_AZ_EL_to_momentum(KE, AZ, EL):

p = np.sqrt( (KE + mec2)**2 - mec2**2) # total momentum in [eV/c]
phi = AZ*(np.pi/180)
theta = EL*(np.pi/180)

px = p*np.cos(theta)*np.cos(phi)
py = p*np.sin(theta)
pz = p*np.cos(theta)*np.sin(phi)

return (px, py, pz)



4 changes: 2 additions & 2 deletions pmd_beamphysics/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def write_pmd_field(h5, data, name=None):
u = pg_units(key)

# Ensure complex
val = val.astype(np.complex)
val = val.astype(complex)

# Write
g2 = write_component_data(g, key, val, unit=u)

Expand Down

0 comments on commit 20559fd

Please sign in to comment.