bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
7 stars 13 forks source link

Tao: Correct Output Datatype for `ix_ele` in Python `bunch1` JSON Description #994

Closed electronsandstuff closed 1 month ago

electronsandstuff commented 1 month ago

This PR updates the description to the function bunch1 to give the correct datatype for ix_ele output. This allows pytao's automatic code generation script to to write a correct function to read it.

Currently, pytao assumes that ix_ele is a real-valued array and the data is not loaded correctly. This function is automatically generated based on the data in bmad's file tao/doc/python-interface-commands.json and requires an update to documentation here to fix.

I updated the description to explicitly list the coordinates' datatypes and added the new output.

! Returns
! -------
! real_array
!   if coordinate in ['x', 'px', 'y', 'py', 'z', 'pz', 's', 't', 'charge', 'p0c']
! integer_array
!   if coordinate in ['state', 'ix_ele']

I then ran the script tao/doc/generate_tex_for_python_commands.py to regenerate the JSON file.

Testing was done by running generate_interface_commands.py from my local copy of pytao and generating code based on the new JSON file. I then successfully used the library in one of my scripts which needs access to ix_ele from bunch1.