Skip to content

Commit 6eaf8ce

Browse files
author
Angelus Vincent
committed
restructured example dir and seperated peak analysis into three distinct files
1 parent b61ae29 commit 6eaf8ce

File tree

15 files changed

+151
-235
lines changed

15 files changed

+151
-235
lines changed

examples/data_cleaning/README.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/data_cleaning/data_smoothing.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/data_cleaning/remove_background.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/data_cleaning/remove_pixels.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

examples/data_cleaning/remove_spikes.py

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Data Processing
1+
Data Processing
22
===============
33

4-
Gallery of examples for data processing in lumispy/hyperspy.
4+
Below is a gallery of examples on how to proccess data.

examples/data_processing/data_smoothing.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,46 @@
55
This example shows how to smooth a dataset.
66
"""
77

8+
# %%
9+
# Load the data
810
import lumispy as lum
911

10-
# Load the data
1112
cl1 = lum.data.asymmetric_peak_map()
1213
cl1 = cl1.remove_background(signal_range=(550.0, 620.0), background_type="Offset")
1314
cl1 = cl1.isig[:-3]
1415
cl1.spikes_removal_tool(interactive=False)
1516

16-
cl3 = cl1.deepcopy()
17+
cl3 = lum.data.asymmetric_peak_map()
1718
cl3 = cl3.remove_background(signal_range=(550.0, 620.0), background_type="Offset")
1819
cl3 = cl3.isig[:-3]
1920
cl3.spikes_removal_tool(interactive=False)
2021

21-
22+
# %%
2223
# Display the original data
2324

2425
cl1.inav[0, 0].plot()
2526

27+
# %%
2628
# The current dataset is quite noisy. As the peak is broad in comparison with the spectral resolution.
2729
# One way to improve that is by rebinning the data along the signal axis:
2830

2931
cl2 = cl1.rebin(scale=[1, 1, 2])
3032

33+
# %%
3134
# Display the smoothed data
3235

3336
cl2.inav[0, 0].plot()
3437

38+
# %%
3539
# Another way to smooth
3640

3741
cl3.smooth_lowess(smoothing_parameter=0.1, number_of_iterations=2)
3842

43+
# %%
3944
# Display the data
4045

4146
cl3.inav[0, 0].plot()
4247

43-
# %%
48+
# sphinx_gallery_start_ignore
4449
# sphinx_gallery_thumbnail_number = 3
50+
# sphinx_gallery_end_ignore

examples/data_processing/remove_background.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@
55
This example removes the background from a dataset.
66
"""
77

8+
# %%
9+
# Load the data
810
import lumispy as lum
911
import matplotlib.pyplot as plt
1012

11-
# Load the data
1213
cl1 = lum.data.asymmetric_peak_map()
1314

15+
# %%
1416
# Display the original data
1517

1618
cl1.plot()
1719
plt.close(1)
1820

19-
# Now we remove the background
21+
# %%
22+
# Now we remove the background and display the data
2023

2124
cl2 = cl1.remove_background(signal_range=(550.0, 620.0), background_type="Offset")
2225

23-
# Display the background removed data
24-
2526
cl2.plot()
26-
plt.close(3)
27+
plt.close(1)
2728

28-
# %%
29+
# sphinx_gallery_start_ignore
2930
# sphinx_gallery_thumbnail_number = 2
31+
# sphinx_gallery_end_ignore

examples/data_processing/remove_pixels.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,31 @@
55
This example removes pixels from a dataset.
66
"""
77

8+
# %%
9+
# Load the data
810
import lumispy as lum
911
import matplotlib.pyplot as plt
1012

11-
# Load the data
1213
cl1 = lum.data.asymmetric_peak_map()
1314
cl1 = cl1.remove_background(signal_range=(550.0, 620.0), background_type="Offset")
1415

16+
# %%
1517
# Display the original data
1618

1719
cl1.plot()
1820
plt.close(1)
1921

22+
# %%
2023
# The signal beyond 800 nm goes to negative values, so lets remove the last three pixels from every spectrum:
2124

2225
cl2 = cl1.isig[:-3]
2326

27+
# %%
2428
# Display cleaned data
2529

2630
cl2.plot()
27-
plt.close(3)
28-
# %%
31+
plt.close(1)
32+
33+
# sphinx_gallery_start_ignore
2934
# sphinx_gallery_thumbnail_number = 2
35+
# sphinx_gallery_end_ignore

examples/data_processing/remove_spikes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@
55
This example shows how to remove spikes from a dataset.
66
"""
77

8+
# %%
9+
# Load the data
810
import lumispy as lum
911

10-
# Load the data
1112
cl1 = lum.data.asymmetric_peak_map()
1213
cl1 = cl1.remove_background(signal_range=(550.0, 620.0), background_type="Offset")
1314
cl1 = cl1.isig[:-3]
1415

16+
# %%
1517
# Display the original data
1618

1719
cl1.inav[29, 0].plot()
1820

21+
# %%
1922
# As seen there is a heavy spike, so lets remove it:
2023

2124
cl1.spikes_removal_tool(interactive=False)
2225

26+
# %%
2327
# Display cleaned data
2428

2529
cl1.inav[29, 0].plot()
26-
# %%
30+
31+
# sphinx_gallery_start_ignore
2732
# sphinx_gallery_thumbnail_number = 2
33+
# sphinx_gallery_end_ignore

0 commit comments

Comments
 (0)