<jupyter_start><jupyter_text>Astra Generator - particle generation<jupyter_code># Useful for debugging
%load_ext autoreload
%autoreload 2
from astra import AstraGenerator
import os
# Point to executable, template input file
MY_GENERATOR_BIN = os.path.expandvars('$HOME/Code/astra/bin/generator')
GENERATOR_IN = 'templates/dcgun/generator.in'
list(map(os.path.exists, [MY_GENERATOR_BIN, GENERATOR_IN ]))
# Make generator object
G = AstraGenerator(input_file=GENERATOR_IN, generator_bin=MY_GENERATOR_BIN)
# Look at its input
G.input
# Change some input
G.input['ipart']= 999
# Run
G.verbose=True
G.run()
# Output is parsed as a ParticleGroup
P = G.output['particles']
P.plot('x', 'y', figsize=(6,6))
P.plot('t', 'pz', figsize=(6,6))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13026315789473683, 'fraction_numerical': 0.010526315789473684, 'mean_word_length': 7.095744680851064, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '142635', 'license': 'Apache-2.0', 'n_tokens_mistral': 282, 'n_tokens_neox': 273, 'n_words': 63, 'path': 'examples/simple_generator_example.ipynb', 'repo_name': 'hhslepicka/lume-astra', 'size': '760'}