Skip to content

Commit

Permalink
Make progress bar optional
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Oct 26, 2023
1 parent cf0d2dc commit 9e65b67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lasy/laser.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def normalize(self, value, kind="energy"):
else:
raise ValueError(f'kind "{kind}" not recognized')

def propagate(self, distance, nr_boundary=None, backend="NP"):
def propagate(self, distance, nr_boundary=None, backend="NP", show_progress=True):
"""
Propagate the laser pulse by the distance specified.
Expand All @@ -154,6 +154,8 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
Only used for ``'rt'``.
backend : string (optional)
Backend used by axiprop (see axiprop documentation).
show_progress : bool (optional)
Whether to show a progress bar when performing the computation
"""
time_axis_indx = -1

Expand Down Expand Up @@ -211,7 +213,7 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
for i_m in range(self.grid.azimuthal_modes.size):
transform_data = np.transpose(field_fft[i_m]).copy()
self.prop[i_m].step(
transform_data, distance, overwrite=True, show_progress=True
transform_data, distance, overwrite=True, show_progress=show_progress
)
field_fft[i_m, :, :] = np.transpose(transform_data).copy()
else:
Expand All @@ -229,7 +231,7 @@ def propagate(self, distance, nr_boundary=None, backend="NP"):
)
# Propagate the spectral image
transform_data = np.transpose(field_fft).copy()
self.prop.step(transform_data, distance, overwrite=True, show_progress=True)
self.prop.step(transform_data, distance, overwrite=True, show_progress=show_progress)
field_fft[:, :, :] = np.transpose(transform_data).copy()

# Choose the time translation assuming propagation at v=c
Expand Down
4 changes: 2 additions & 2 deletions lasy/utils/phase_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ def gerchberg_saxton_algo(
i = 0
while breakout(cond):
laser1.grid.field = amp1 * np.exp(1j * phase1)
laser1.propagate(dz)
laser1.propagate(dz, show_progress=False)

phase2 = np.angle(laser1.grid.field)
laser2.grid.field = amp2 * np.exp(1j * phase2)
laser2.propagate(-dz)
laser2.propagate(-dz, show_progress=False)

phase1 = np.angle(laser2.grid.field)
amp1_calc = np.abs(laser2.grid.field)
Expand Down

0 comments on commit 9e65b67

Please sign in to comment.