From ccece1fe3a67f0eb04f1742a7679e93d7241b29f Mon Sep 17 00:00:00 2001 From: Ken Lauer <152229072+ken-lauer@users.noreply.github.com> Date: Thu, 13 Jun 2024 16:14:11 -0700 Subject: [PATCH] CLN: remove extra_commands --- docs/api/pytao.md | 2 - pytao/tao_ctypes/core.py | 3 -- pytao/tao_ctypes/extra_commands.py | 66 ------------------------------ 3 files changed, 71 deletions(-) delete mode 100644 pytao/tao_ctypes/extra_commands.py diff --git a/docs/api/pytao.md b/docs/api/pytao.md index eb990832..78243d86 100644 --- a/docs/api/pytao.md +++ b/docs/api/pytao.md @@ -1,3 +1 @@ ::: pytao.Tao -::: pytao.interface_commands -::: pytao.tao_ctypes.extra_commands diff --git a/pytao/tao_ctypes/core.py b/pytao/tao_ctypes/core.py index e5016acb..40960c4b 100644 --- a/pytao/tao_ctypes/core.py +++ b/pytao/tao_ctypes/core.py @@ -45,9 +45,6 @@ def __init__(self, init='', so_lib=''): # we try to autogenerate it will complain about the broken # interface_commands file. - from pytao import interface_commands - from pytao.tao_ctypes import extra_commands - # Library needs to be set. self.so_lib_file = None if so_lib == '': diff --git a/pytao/tao_ctypes/extra_commands.py b/pytao/tao_ctypes/extra_commands.py deleted file mode 100644 index 08485f28..00000000 --- a/pytao/tao_ctypes/extra_commands.py +++ /dev/null @@ -1,66 +0,0 @@ -import numpy as np - -# These methods will be added to the Tao class -# Skip these: -__deny_list = ['np'] - - - -def bunch_data(tao, ele_id, *, which='model', ix_bunch=1, verbose=False): - """ - Returns bunch data in openPMD-beamphysics format/notation. - - Notes - ----- - Note that Tao's 'write beam' will also write a proper h5 file in this format. - - Expected usage: - data = bunch_data(tao, 'end') - from pmd_beamphysics import ParticleGroup - P = ParicleGroup(data=data) - - - Returns - ------- - data : dict - dict of arrays, with keys 'x', 'px', 'y', 'py', 't', 'pz', 'status', 'weight', 'z', 'species' - - - Examples - -------- - Example: 1 - init: $ACC_ROOT_DIR/tao/examples/csr_beam_tracking/tao.init - args: - ele_id: end - which: model - ix_bunch: 1 - - """ - - # Get species - stats = tao.bunch_params(ele_id, which=which, verbose=verbose) - species = stats['species'] - - dat = {} - for coordinate in ['x', 'px', 'y', 'py', 't', 'pz', 'p0c', 'charge', 'state']: - dat[coordinate] = tao.bunch1(ele_id, coordinate=coordinate, which=which, ix_bunch=ix_bunch, verbose=verbose) - - # Remove normalizations - p0c = dat.pop('p0c') - - dat['status'] = dat.pop('state') - dat['weight'] = dat.pop('charge') - - # px from Bmad is px/p0c - # pz from Bmad is delta = p/p0c -1. - # pz = sqrt( (delta+1)**2 -px**2 -py**2)*p0c - dat['pz'] = np.sqrt((dat['pz'] + 1)**2 - dat['px']**2 - dat['py']**2) * p0c - dat['px'] = dat['px']*p0c - dat['py'] = dat['py']*p0c - - # z = 0 by definition - dat['z'] = np.full(len(dat['x']), 0) - - dat['species'] = species.lower() - - return dat \ No newline at end of file