Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytao crashes when bmad lattice throws an error #84

Open
vhranjbar opened this issue Jul 6, 2024 · 1 comment
Open

Pytao crashes when bmad lattice throws an error #84

vhranjbar opened this issue Jul 6, 2024 · 1 comment

Comments

@vhranjbar
Copy link

When I set a quad strength to a bad setting Pytao crashes:
python test2.py
Traceback (most recent call last):
File "/Users/vahidranjbar/Develop/RCS/RCS_2/RCS_DougH/May2024Lat/test2.py", line 17, in
error = tao.cmd("set element QF0 K1=.6")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vahidranjbar/miniconda3/lib/python3.11/site-packages/pytao/tao_ctypes/core.py", line 146, in cmd
raise RuntimeError(f"Command: {cmd} causes error: {err}")
RuntimeError: Command: set element QF0 K1=.6 causes error: ERROR detected: [ERROR | 2024-JUL-05 21:19:25] closed_orbit_calc:
PARTICLE LOST IN TRACKING!!
ABORTING CLOSED ORBIT SEARCH.
TRACKING BRANCH: 0:RING

This is the python script:

from pytao import Tao
import numpy
import sys
import time
import math
import subprocess
import os

from subprocess import Popen, PIPE

load_lattice ='-lat rcsl4s1-wig_henry.bmad -noplot'
tao=Tao(load_lattice)
#names = tao.ele_gen_attribs('k1')
#print(names[0:105])

#gammaT =float(names[42].split()[1]))
error = tao.cmd("set element QF0 K1=.6")
names = tao.cmd("show universe")
print(error)
print(names)

@ken-lauer
Copy link
Collaborator

You can still get the error output of the command by using:

 error = tao.cmd("set element QF0 K1=.6", raises=False)

There's not currently a good way of filtering out specific error messages or ignoring them entirely. Errors and warnings unfortunately come directly from Tao in the same data stream as the output information from each command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants