Update loading to use calibration file
This commit is contained in:
parent
7a0d016905
commit
e509199bf9
1 changed files with 12 additions and 42 deletions
|
@ -8,7 +8,9 @@ rect = [0.125,0.11,0.775,0.77]
|
|||
|
||||
calib_top = np.load( 'asset/calib_top.npy' )
|
||||
calib_down = np.load( 'asset/calib_down.npy' )
|
||||
reference = np.load( 'asset/reference.npy' )
|
||||
|
||||
peaks_reference_sorted = np.loadtxt( 'calibration/OHP_Hg.calib' )
|
||||
peaks_reference = np.sort( peaks_reference_sorted )
|
||||
|
||||
mean_calib_top = np.mean( calib_top , axis = 0 )
|
||||
mean_calib_down = np.mean( calib_down , axis = 0 )
|
||||
|
@ -16,13 +18,6 @@ mean_calib_down = np.mean( calib_down , axis = 0 )
|
|||
peaks_calib_top = np.array(
|
||||
utils.retrieve_peaks( mean_calib_top )
|
||||
).astype( int )
|
||||
peaks_reference = np.array(
|
||||
utils.retrieve_peaks(
|
||||
reference[1] ,
|
||||
window_size = 1 ,
|
||||
max_window_size = 1,
|
||||
)
|
||||
).astype( int )
|
||||
|
||||
"""
|
||||
Signal without peaks
|
||||
|
@ -121,35 +116,18 @@ peaks_calib_top = np.array(
|
|||
Calibration
|
||||
"""
|
||||
|
||||
polyval = np.polyfit(
|
||||
polyval_wavelength = np.polyfit(
|
||||
peaks_calib_top,
|
||||
peaks_reference,
|
||||
1 ,
|
||||
) # We suppose there is as much calib peak than ref peak for now
|
||||
|
||||
peaks_values = [ reference[ 1 , i ] for i in peaks_reference ]
|
||||
sorting = np.argsort( peaks_values )[ :: -1 ]
|
||||
wavelength = np.array( [
|
||||
reference[ 0 , i ] for i in np.array( [
|
||||
peaks_reference[ j ] for j in sorting
|
||||
] ).astype( int )
|
||||
] )
|
||||
|
||||
polyval_wavelength = np.polyfit(
|
||||
peaks_reference,
|
||||
np.sort( wavelength ),
|
||||
1,
|
||||
)
|
||||
|
||||
wavelength = np.polyval(
|
||||
polyval_wavelength,
|
||||
np.polyval(
|
||||
polyval,
|
||||
np.arange(
|
||||
0 ,
|
||||
len( mean_calib_top ),
|
||||
1 ,
|
||||
)
|
||||
np.arange(
|
||||
0 ,
|
||||
len( mean_calib_top ),
|
||||
1 ,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -190,18 +168,10 @@ manager = qt.FigureManager(
|
|||
),
|
||||
0,
|
||||
)
|
||||
|
||||
manager.canvas.figure.add_subplot( 2 , 1 , 1 , xlim = ( 3800 , 4000 ) , xmargin = 0 ).plot(
|
||||
wavelength ,
|
||||
mean_calib_top,
|
||||
manager.canvas.figure.gca().plot(
|
||||
peaks_reference,
|
||||
peaks_reference - np.polyval( polyval_wavelength , peaks_calib_top ),
|
||||
'o-' ,
|
||||
)
|
||||
manager.canvas.figure.axes[0].set_title( 'raw data' )
|
||||
|
||||
manager.canvas.figure.add_subplot( 2 , 1 , 2 , xlim = ( 3800 , 4000 ) , xmargin = 0 ).plot(
|
||||
reference[0],
|
||||
reference[1],
|
||||
)
|
||||
manager.canvas.figure.axes[1].set_title( 'reference' )
|
||||
|
||||
manager.show()
|
||||
manager.start_main_loop()
|
||||
|
|
Loading…
Reference in a new issue