<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Use of normalisation function
In this example we normalise a spectrum to different values
Step1:  Signal creation
Below we create a fake Gaussian signal for the example.
Step2:  We can consider that the area of the Gaussian peak should be equal to 1, as it is the value of the intergral of a Gaussian distribution.
To normalise the spectra, we can do
Step3:  We could also just want the signal to be comprised between 0 and 1, so we normalise to the maximum
Step4:  Now, if our signal intensity was shifted from 0 by a constant, the "intensity" method will not work well. For instance, I can add 0.1 to y and plot it.
Step5:  In this case, the "intensity" method will not work well
Step6:  The signal remains shifted from 0. For safety, we can do a min-max normalisation, which will put the minimum to 0 and maximum to 1
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import sys
sys.path.append("../")
import numpy as np
import scipy
from matplotlib import pyplot as plt
import rampy as rp
from sklearn import preprocessing
Explanation: Use of normalisation function
In this example we normalise a spectrum to different values: area, maximum, or min-max.
End of explanation
nb_points  =100
x = np.sort(np.random.uniform(0,100,nb_points)) # increasing point
y = 120.0*scipy.stats.norm.pdf(x,loc=50,scale=5)
plt.plot(x,y)
plt.ylabel("Y")
plt.xlabel("X")
plt.show()
Explanation: Signal creation
Below we create a fake Gaussian signal for the example.
End of explanation
y_norm_area = rp.normalise(y,x=x,method="area")
plt.plot(x,y_norm_area)
plt.ylabel("Y")
plt.xlabel("X")
plt.show()
Explanation: We can consider that the area of the Gaussian peak should be equal to 1, as it is the value of the intergral of a Gaussian distribution.
To normalise the spectra, we can do:
End of explanation
y_norm_area = rp.normalise(y,method="intensity")
plt.plot(x,y_norm_area)
plt.ylabel("Y")
plt.xlabel("X")
plt.show()
Explanation: We could also just want the signal to be comprised between 0 and 1, so we normalise to the maximum:
End of explanation
y2 = y + 1
plt.plot(x,y2)
plt.ylabel("Y")
plt.xlabel("X")
plt.ylim(0,12)
plt.show()
Explanation: Now, if our signal intensity was shifted from 0 by a constant, the "intensity" method will not work well. For instance, I can add 0.1 to y and plot it.
End of explanation
y_norm_area = rp.normalise(y2,method="intensity")
plt.plot(x,y_norm_area)
plt.ylabel("Y")
plt.xlabel("X")
plt.ylim(0,1)
plt.show()
Explanation: In this case, the "intensity" method will not work well:
End of explanation
y_norm_area = rp.normalise(y2,method="minmax")
plt.plot(x,y_norm_area)
plt.ylabel("Y")
plt.xlabel("X")
plt.show()
Explanation: The signal remains shifted from 0. For safety, we can do a min-max normalisation, which will put the minimum to 0 and maximum to 1:
End of explanation
<END_TASK>