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

typo at_element -> at_turn in get_normalized_coordinates and reshape … #545

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pbelange
Copy link
Contributor

typo in twiss_init.get_normalized_coordinates. Also when XX_norm.ndim == 3, the return table was not working because all the arrays were 2D. flatten fixes it. (I think this ONLY happens if the passedparticles is in fact a monitor object, with turn-by-turn data)

@pbelange
Copy link
Contributor Author

Also side note: I personally like to pass a monitor and get the normalized coordinates seamlessly... to do so the table which is returned is not ideal because it has a different shape than the monitor which is passed to the function. My personal solution is to do something like this (suggestion):

# Within a custom class which has the twiss_init and the emittances stored:
#...
    def phys2norm(self,monitor):

        table = self.twiss_init.get_normalized_coordinates(monitor,nemitt_x=self.nemitt_x, nemitt_y=self.nemitt_y,nemitt_zeta=self.nemitt_zeta)

        monitor_norm = monitor.copy()
        norm_vars = tuple((tt,nn+'_norm') for tt,nn in xt.Particles.per_particle_vars+((xo.Float64, 'pzeta'),) if nn in ['x','y','zeta','px','py','pzeta'])
        for tt, nn in norm_vars:
            setattr(monitor_norm, nn, xt.monitors.particles_monitor._FieldOfMonitor(name=nn))

        monitor_norm.x_norm = table.x_norm.reshape(monitor.x.shape)
        monitor_norm.y_norm = table.y_norm.reshape(monitor.y.shape)
        monitor_norm.zeta_norm = table.zeta_norm.reshape(monitor.zeta.shape)
        monitor_norm.px_norm = table.px_norm.reshape(monitor.px.shape)
        monitor_norm.py_norm = table.py_norm.reshape(monitor.py.shape)
        monitor_norm.pzeta_norm = table.pzeta_norm.reshape(monitor.pzeta.shape)
        
        return monitor_norm

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

Successfully merging this pull request may close these issues.

1 participant