Skip to content

Commit

Permalink
Merge branch 'development' into spectral_phase
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Jul 24, 2024
2 parents 643ce6c + 19cd6ee commit 86adf66
Show file tree
Hide file tree
Showing 24 changed files with 359 additions and 216 deletions.
53 changes: 21 additions & 32 deletions examples/example_gerchberg_saxton_algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@

# NOW ADD THE PHASE TO EACH SLICE OF THE FOCUS
phase3D = np.repeat(phase[:, :, np.newaxis], npoints[2], axis=2)
laser.grid.field = np.abs(laser.grid.field) * np.exp(1j * phase3D)
laser.grid.set_temporal_field(
np.abs(laser.grid.get_temporal_field()) * np.exp(1j * phase3D)
)

# PROPAGATE THE FIELD FIELD FOWARDS AND BACKWARDS BY 1 MM
propDist = 2e-3
Expand Down Expand Up @@ -72,17 +74,16 @@ def addColorbar(im, ax, label=None):
cax.set_ylabel(label)


im0 = ax[0, 0].imshow(
np.abs(laser.grid.field[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd"
)
field = laser.grid.get_temporal_field()
im0 = ax[0, 0].imshow(np.abs(field[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd")
addColorbar(im0, ax[0, 0], "Intensity (norm.)")
ax[0, 0].set_title("Inten. z = 0.0 mm")
ax[0, 0].set_xlabel("x ($\mu m$)")
ax[0, 0].set_ylabel("y ($\mu m$)")


im1 = ax[0, 1].imshow(
np.angle(laser.grid.field[:, :, tIndx]) * phaseMask, extent=extent, cmap="coolwarm"
np.angle(field[:, :, tIndx]) * phaseMask, extent=extent, cmap="coolwarm"
)
addColorbar(im1, ax[0, 1], "Phase (rad.)")
ax[0, 1].set_title("Phase z = 0.0 mm")
Expand All @@ -91,13 +92,14 @@ def addColorbar(im, ax, label=None):


laser_calc = copy.deepcopy(laserBackward)
laser_calc.grid.field = np.abs(laser_calc.grid.field) * np.exp(1j * phaseBackward)
laser_calc.grid.set_temporal_field(
np.abs(laser_calc.grid.get_temporal_field()) * np.exp(1j * phaseBackward)
)
laser_calc.propagate(propDist)

field_calc = laser_calc.grid.get_temporal_field()
im2 = ax[1, 0].imshow(
np.abs(
np.abs(laser.grid.field[:, :, tIndx]) ** 2
- np.abs(laser_calc.grid.field[:, :, tIndx]) ** 2
),
np.abs(np.abs(field[:, :, tIndx]) ** 2 - np.abs(field_calc[:, :, tIndx]) ** 2),
extent=extent,
cmap="PuRd",
)
Expand All @@ -106,9 +108,7 @@ def addColorbar(im, ax, label=None):
ax[1, 0].set_ylabel("y ($\mu m$)")
addColorbar(im2, ax[1, 0], "Intensity (norm.)")

phaseResidual = np.angle(laser_calc.grid.field[:, :, tIndx]) - np.angle(
laser.grid.field[:, :, tIndx]
)
phaseResidual = np.angle(field_calc[:, :, tIndx]) - np.angle(field[:, :, tIndx])
phaseResidual -= phaseResidual[int(npoints[1] / 2), int(npoints[0] / 2)]
maxPhaseRes = np.max(np.abs(phaseResidual) * phaseMask)
im3 = ax[1, 1].imshow(
Expand All @@ -123,26 +123,20 @@ def addColorbar(im, ax, label=None):
ax[1, 1].set_ylabel("y ($\mu m$)")
addColorbar(im3, ax[1, 1], "Phase (rad.)")


im4 = ax[0, 2].imshow(
np.abs(laserBackward.grid.field[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd"
)
field_bw = laserBackward.grid.get_temporal_field()
im4 = ax[0, 2].imshow(np.abs(field_bw[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd")
addColorbar(im4, ax[0, 2], "Intensity (norm.)")
ax[0, 2].set_title("Inten. z = %.1f mm" % (-propDist * 1e3))
ax[0, 2].set_xlabel("x ($\mu m$)")
ax[0, 2].set_ylabel("y ($\mu m$)")

im5 = ax[0, 3].imshow(
np.angle(laserBackward.grid.field[:, :, tIndx]), extent=extent, cmap="coolwarm"
)
im5 = ax[0, 3].imshow(np.angle(field_bw[:, :, tIndx]), extent=extent, cmap="coolwarm")
addColorbar(im5, ax[0, 3], "Phase (rad.)")
ax[0, 3].set_title("Phase z = %.1f mm" % (-propDist * 1e3))
ax[0, 3].set_xlabel("x ($\mu m$)")
ax[0, 3].set_ylabel("y ($\mu m$)")

phaseResidual = (
np.angle(laserBackward.grid.field[:, :, tIndx]) - phaseBackward[:, :, tIndx]
)
phaseResidual = np.angle(field_bw[:, :, tIndx]) - phaseBackward[:, :, tIndx]
phaseResidual -= phaseResidual[int(npoints[1] / 2), int(npoints[0] / 2)]
maxPhaseRes = np.max(np.abs(phaseResidual) * phaseMask)
im6 = ax[0, 4].imshow(
Expand All @@ -157,24 +151,19 @@ def addColorbar(im, ax, label=None):
ax[0, 4].set_xlabel("x ($\mu m$)")
ax[0, 4].set_ylabel("y ($\mu m$)")

im7 = ax[1, 2].imshow(
np.abs(laserForward.grid.field[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd"
)
field_fw = laserForward.grid.get_temporal_field()
im7 = ax[1, 2].imshow(np.abs(field_fw[:, :, tIndx]) ** 2, extent=extent, cmap="PuRd")
addColorbar(im7, ax[1, 2], "Intensity (norm.)")
ax[1, 2].set_title("Inten. z = %.1f mm" % (propDist * 1e3))
ax[1, 2].set_xlabel("x ($\mu m$)")
ax[1, 2].set_ylabel("y ($\mu m$)")
im8 = ax[1, 3].imshow(
np.angle(laserForward.grid.field[:, :, tIndx]), extent=extent, cmap="coolwarm"
)
im8 = ax[1, 3].imshow(np.angle(field_fw[:, :, tIndx]), extent=extent, cmap="coolwarm")
addColorbar(im8, ax[1, 3], "Phase (rad.)")
ax[1, 3].set_title("Phase z = %.1f mm" % (propDist * 1e3))
ax[1, 3].set_xlabel("x ($\mu m$)")
ax[1, 3].set_ylabel("y ($\mu m$)")

phaseResidual = (
np.angle(laserForward.grid.field[:, :, tIndx]) - phaseForward[:, :, tIndx]
)
phaseResidual = np.angle(field_fw[:, :, tIndx]) - phaseForward[:, :, tIndx]
phaseResidual -= phaseResidual[int(npoints[1] / 2), int(npoints[0] / 2)]
maxPhaseRes = np.max(np.abs(phaseResidual) * phaseMask)
im9 = ax[1, 4].imshow(
Expand Down
Loading

0 comments on commit 86adf66

Please sign in to comment.