-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 parent
fecde0e
commit 01ac22a
Showing
1 changed file
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import numpy as np | ||
from scipy.optimize import curve_fit | ||
import matplotlib.pyplot as plt | ||
|
||
# Eample data | ||
xpos = np.array([ | ||
-0.89500, | ||
-0.78900, | ||
-0.68400, | ||
-0.57900, | ||
-0.47400, | ||
-0.36800, | ||
-0.26300, | ||
-0.15800, | ||
-0.05300, | ||
0.05300, | ||
0.15800, | ||
0.26300, | ||
0.36800, | ||
0.47400, | ||
0.57900, | ||
0.68400, | ||
0.78900, | ||
0.89500, | ||
1.00000, | ||
]) | ||
|
||
sig = np.array([ | ||
5225.44680, | ||
10406.54446, | ||
29364.11991, | ||
91847.11330, | ||
39397.99591, | ||
12719.50183, | ||
5950.02145, | ||
3483.21205, | ||
2210.18858, | ||
1552.42419, | ||
1088.73029, | ||
882.58759, | ||
680.85617, | ||
562.82269, | ||
466.21100, | ||
385.87965, | ||
315.28561, | ||
284.60984, | ||
246.65506, | ||
]) | ||
|
||
|
||
dy_dx = np.gradient(sig, xpos) | ||
|
||
# Plotting | ||
plt.figure(figsize=(10, 5)) | ||
|
||
# Plot the original curve | ||
plt.subplot(1, 2, 1) | ||
plt.plot(xpos, sig, label='Original curve') | ||
plt.legend() | ||
|
||
# Plot the derivative | ||
plt.subplot(1, 2, 2) | ||
plt.plot(xpos, dy_dx, label='Derivative', color='red') | ||
plt.legend() | ||
|
||
plt.tight_layout() | ||
plt.show() |