-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Parth Ramakant Patil
committed
Jan 2, 2025
1 parent
117f069
commit ba87f81
Showing
2 changed files
with
27 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
"""Test the implementation of the denoise. | ||
"""Test the implementation of the HG recostruction. | ||
Test checks the implementation of the denoise | ||
by initializing a super-Gaussian pulse and denoise it. It then | ||
Test checks the implementation of the HG reconstruction. It does so | ||
by initializing a super-Gaussian pulse and denoising it. It then | ||
checks that the error remains positive and less than the predefined | ||
value. | ||
""" | ||
|
||
import numpy as np | ||
|
||
from lasy.profiles.transverse.super_gaussian_profile import ( | ||
SuperGaussianTransverseProfile, | ||
GaussianTransverseProfile, | ||
) | ||
from lasy.utils.denoise import denoise_transverse_hg | ||
from lasy.utils.denoise import hg_reconstruction | ||
|
||
|
||
def test_denoise_transverse_hg(): | ||
def test_denoise_hg_reconstruction(): | ||
# Parameters | ||
waist = 20e-6 | ||
shape_parameter = 3 | ||
wavelength = 8e-7 | ||
|
||
# Define the transverse profile | ||
transverse_profile = SuperGaussianTransverseProfile( | ||
transverse_profile = GaussianTransverseProfile( | ||
waist, shape_parameter | ||
) # Super-Gaussian profile | ||
transverse_profile_cleaned, waist, laser_energy_new = denoise_transverse_hg( | ||
transverse_profile_cleaned, waist, laser_energy_new = hg_reconstruction( | ||
transverse_profile, wavelength | ||
) # Denoised profile | ||
Check failure Code scanning / CodeQL Wrong number of arguments in a call Error test
Call to
function hg_reconstruction Error loading related location Loading |
||
|
||
# Calculate the error | ||
x = np.linspace(-5 * waist, 5 * waist, 500) | ||
x = np.linspace(-5 * waist[0], 5 * waist[0], 500) | ||
X, Y = np.meshgrid(x, x) | ||
prof1 = np.abs(transverse_profile.evaluate(X, Y)) ** 2 | ||
prof2 = np.abs(transverse_profile_cleaned.evaluate(X, Y)) ** 2 | ||
error = (prof1 - prof2) / np.max(prof1) | ||
assert 0 < np.max(error) < 0.2 | ||
assert 0 < np.max(error) < 0.2 |