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

Utility to denoise laser profile and adding a test for the same #315

Open
wants to merge 45 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7ff5913
D1: Utility to denoise laser profile
Paaaaarth Oct 23, 2024
04d4e34
trial change
Paaaaarth Nov 7, 2024
f20666f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 7, 2024
59457f5
Merge branch 'LASY-org:development' into utility
Paaaaarth Nov 7, 2024
b4e5490
Merge branch 'LASY-org:development' into utility
Paaaaarth Nov 12, 2024
3f9d979
Changes to mode_decomposition code and documentation
Nov 7, 2024
f4dd7c8
D2: Utility to denoise laser profile
Nov 12, 2024
92b662a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
ecf3cb0
Fixing accidental commits
Nov 12, 2024
829e9e6
Merge branch 'development' into utility
Paaaaarth Nov 12, 2024
2670372
minor changes
Paaaaarth Nov 12, 2024
285973a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
0859fd6
minor changes
Paaaaarth Nov 12, 2024
9e0cf03
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
eff919b
minor changes
Paaaaarth Nov 12, 2024
51a7269
D1_test_denoise
Nov 19, 2024
1379fb4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
f01c74b
D2_test_denoise
Nov 19, 2024
e410bce
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
f996b4d
D3: Utility to denoise laser profile
Nov 19, 2024
e7fe531
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 19, 2024
be798e3
Minor change
Paaaaarth Nov 20, 2024
2bd3392
D3: Adding additional user-defined parameters.
Nov 21, 2024
aa01d24
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 21, 2024
a42264c
Merge branch 'LASY-org:development' into utility
Paaaaarth Nov 21, 2024
24dc4d5
D4: adding capability to add an img file as input.
Paaaaarth Nov 22, 2024
bbba42d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2024
5d24d74
D5: Minor changes
Paaaaarth Nov 22, 2024
4506458
D6: Changes to if else statement
Paaaaarth Nov 22, 2024
0f4bf4e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 22, 2024
bf128c6
Minor changes
Paaaaarth Nov 22, 2024
d7a0237
parameter order as per #326
Paaaaarth Dec 2, 2024
3377eef
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2024
f0827ce
D7:utility:denoise:remove skimage package
Paaaaarth Dec 3, 2024
f811464
Minor changes
Paaaaarth Dec 3, 2024
117f069
Merge branch 'LASY-org:development' into utility
Paaaaarth Dec 5, 2024
ba87f81
Requested changes implemented
Jan 2, 2025
9d371ac
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
111cf2a
Removing unnecessary outputs(new laser energy)
Paaaaarth Jan 2, 2025
c66c567
Minor changes
Paaaaarth Jan 2, 2025
1bd7d3a
Minor Changes
Paaaaarth Jan 2, 2025
e87b2dc
Minor changes
Paaaaarth Jan 2, 2025
41a1ceb
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
b796669
Minor change
Paaaaarth Jan 2, 2025
5357182
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions lasy/utils/denoise.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from lasy.profiles.combined_profile import CombinedLongitudinalTransverseProfile
from lasy.profiles.transverse.hermite_gaussian_profile import (
HermiteGaussianTransverseProfile,
)
from lasy.utils.mode_decomposition import hermite_gauss_decomposition


def denoise_laser(parameters, n_modes_x=2, n_modes_y=2):
transverse_profile = parameters["transverse_profile"]
longitudinal_profile = parameters["longitudinal_profile"]
polarization = parameters["polarization"]
laser_energy_new = 0

if parameters.get("wavelength") is None:
wavelength = longitudinal_profile.lambda0
else:
wavelength = parameters["wavelength"]

if parameters.get("laser_energy") is None:
laser_energy = 1 # In joules
else:
laser_energy = parameters["laser_energy"]

if parameters.get("resolution") is None:
resolution = 0.2e-6
else:
resolution = parameters["resolution"]

# Calculate the decomposition and waist of the laser pulse
modeCoeffs, waist = hermite_gauss_decomposition(
transverse_profile, n_modes_x, n_modes_y, resolution
)

# Denosing the laser profile
for i, mode_key in enumerate(list(modeCoeffs)):
tmp_transverse_profile = HermiteGaussianTransverseProfile(
waist, mode_key[0], mode_key[1]
)
print(f"Mode {i}: {mode_key} with coefficient {modeCoeffs[mode_key]}")
laser_energy_new += modeCoeffs[mode_key] ** 2 # Energy fraction of the mode
if i == 0: # First mode (0,0)
laser_profile_cleaned = modeCoeffs[
mode_key
] * CombinedLongitudinalTransverseProfile(
wavelength,
polarization,
laser_energy,
longitudinal_profile,
tmp_transverse_profile,
)
else: # All other modes
laser_profile_cleaned += modeCoeffs[
mode_key
] * CombinedLongitudinalTransverseProfile(
wavelength,
polarization,
laser_energy,
longitudinal_profile,
tmp_transverse_profile,
)
# Energy loss due to decomposition
energy_loss = 1 - laser_energy_new
print(f"Energy loss: {energy_loss * 100:.2f}%")
return laser_profile_cleaned, laser_energy_new
Loading