Skip to content

pz Numerical Problems #69

@electronsandstuff

Description

@electronsandstuff

When beams have very small px and py, the method bunch_data(...) can try to take the square root of negative numbers. You get some warnings and pz comes out as NaN.

/Users/chris/miniforge3/envs/my_env/lib/python3.11/site-packages/pytao/tao_ctypes/extra_commands.py:57: RuntimeWarning: invalid value encountered in sqrt
  dat['pz'] = np.sqrt((dat['pz'] + 1)**2 - dat['px']**2 - dat['py']**2) * p0c

Maybe clipping inside of the square root would fix this?

 dat['pz'] = np.sqrt(np.max(0.0, (dat['pz'] + 1)**2 - dat['px']**2 - dat['py']**2)) * p0c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions