radiasoft / rslaser_old

Integrated modeling of CPA crystal-based laser amplifiers
Apache License 2.0
1 stars 1 forks source link

calc_int_from_elec reshape arguments reversed #175

Closed mkeilman closed 1 year ago

mkeilman commented 1 year ago

This is the code now:

# reshape to 2d mesh
elec_fields_re = np.array(re0).reshape((_wfr.mesh.nx, _wfr.mesh.ny), order='C').astype(np.float64)
...

The reshape args should be:

reshape((_wfr.mesh.ny, _wfr.mesh.nx))
...

(or reshape((_wfr.mesh.ny, -1)))

To reproduce, start with a LaserPulse with different nx_slice and ny_slice values:

LP = pulse.LaserPulse(
    PKDict(
        nslice=1,
        photon_e_ev=1.55,
        nx_slice=20,
        ny_slice=40,
    ), 
)
intens0_2d = srwl_uti_data.calc_int_from_elec(LP.slice_wfr(0))
with plt.style.context(('seaborn-poster')):
    fig = plt.figure(figsize=(4.6 * 2,3.6 * 2))
    ax = fig.gca()
    plt.pcolormesh(photonss0.x*1e3, photonss0.y*1e3, intens0_2d, cmap=plt.cm.jet, shading='auto')
...

The result will be:

TypeError: Dimensions of C (20, 40) are incompatible with X (20) and/or Y (40); see help(pcolormesh)

I also note that wfrGetPol also has a number of reshapes that have nx/ny in the wrong order. The function should be tested with nx != ny, but it's probably broken in a similar way.

bruhwiler commented 1 year ago

@mkeilman -- what is your time estimate for closing this issue?

mkeilman commented 1 year ago

@mkeilman -- what is your time estimate for closing this issue?

It was fixed and merged some time ago (#176) - the issue should have closed automatically, but I'll do so here