Fix & Clean up
This commit is contained in:
parent
c70be8a74f
commit
4c25cf6ac5
1 changed files with 52 additions and 36 deletions
80
ETA.py
80
ETA.py
|
@ -211,12 +211,12 @@ else:
|
||||||
|
|
||||||
border = {
|
border = {
|
||||||
'x': {
|
'x': {
|
||||||
'min': points[0][1] + extremum[0][1] + 1,
|
'min': points[0][1] + extremum[0][1] + 25,
|
||||||
'max': points[0][1] + extremum[1][0] ,
|
'max': points[0][1] + extremum[1][0] - 25,
|
||||||
},
|
},
|
||||||
'y': {
|
'y': {
|
||||||
'min': points[2][0] + extremum[2][3] + 1,
|
'min': points[2][0] + extremum[2][3] + 25,
|
||||||
'max': points[2][0] + extremum[3][2] ,
|
'max': points[2][0] + extremum[3][2] - 25,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,11 +264,11 @@ else:
|
||||||
if label_x[ 'max' ] < data.shape[1] // 2:
|
if label_x[ 'max' ] < data.shape[1] // 2:
|
||||||
border[ 'x' ][ 'min' ] = label_x[ 'max' ]
|
border[ 'x' ][ 'min' ] = label_x[ 'max' ]
|
||||||
else:
|
else:
|
||||||
raise Exception( 'the label seems to be in the middle of the picture' )
|
raise Exception( 'ETA.py: the label seems to be in the middle of the picture' )
|
||||||
elif label_x[ 'max' ] > data.shape[1] // 2:
|
elif label_x[ 'max' ] > data.shape[1] // 2:
|
||||||
border[ 'x' ][ 'max' ] = label_x[ 'min' ]
|
border[ 'x' ][ 'max' ] = label_x[ 'min' ]
|
||||||
else:
|
else:
|
||||||
raise Exception( 'for an unkown reason, label_x[ \'min\' ] > label_x[ \'max\' ]' )
|
raise Exception( 'ETA.py: for an unkown reason, label_x[ \'min\' ] > label_x[ \'max\' ]' )
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print( 'label section deleted' )
|
print( 'label section deleted' )
|
||||||
|
@ -490,20 +490,44 @@ if calibration != None:
|
||||||
calibrations[ 'down' ][ 'x' ][ 'min' ]:
|
calibrations[ 'down' ][ 'x' ][ 'min' ]:
|
||||||
calibrations[ 'down' ][ 'x' ][ 'max' ]
|
calibrations[ 'down' ][ 'x' ][ 'max' ]
|
||||||
] , axis = 0 )
|
] , axis = 0 )
|
||||||
peaks_up = np.array(
|
|
||||||
utils.retrieve_peaks(
|
percent = 0.4
|
||||||
mean_up ,
|
|
||||||
window_size = 1 ,
|
peaks_up = np.array( [
|
||||||
max_window_size = 1,
|
np.mean( consecutive )
|
||||||
|
for consecutive in
|
||||||
|
utils.consecutive(
|
||||||
|
np.where(
|
||||||
|
mean_up > np.min(
|
||||||
|
mean_up
|
||||||
|
) + (
|
||||||
|
np.max(
|
||||||
|
mean_up
|
||||||
|
) - np.min(
|
||||||
|
mean_up
|
||||||
)
|
)
|
||||||
).astype( int )
|
) * percent
|
||||||
peaks_down = np.array(
|
)[0]
|
||||||
utils.retrieve_peaks(
|
|
||||||
mean_down ,
|
|
||||||
window_size = 1 ,
|
|
||||||
max_window_size = 1,
|
|
||||||
)
|
)
|
||||||
).astype( int )
|
] , dtype = int )
|
||||||
|
|
||||||
|
peaks_down = np.array( [
|
||||||
|
np.mean( consecutive )
|
||||||
|
for consecutive in
|
||||||
|
utils.consecutive(
|
||||||
|
np.where(
|
||||||
|
mean_down > np.min(
|
||||||
|
mean_down
|
||||||
|
) + (
|
||||||
|
np.max(
|
||||||
|
mean_down
|
||||||
|
) - np.min(
|
||||||
|
mean_down
|
||||||
|
)
|
||||||
|
) * percent
|
||||||
|
)[0]
|
||||||
|
)
|
||||||
|
] , dtype = int )
|
||||||
|
|
||||||
peakless_up = wave_calib.remove_peaks( mean_up , peaks_up )
|
peakless_up = wave_calib.remove_peaks( mean_up , peaks_up )
|
||||||
peakless_down = wave_calib.remove_peaks( mean_down , peaks_down )
|
peakless_down = wave_calib.remove_peaks( mean_down , peaks_down )
|
||||||
|
@ -521,6 +545,7 @@ if calibration != None:
|
||||||
'first': first,
|
'first': first,
|
||||||
'last' : last ,
|
'last' : last ,
|
||||||
}
|
}
|
||||||
|
|
||||||
peaks_up = peaks_up[ up[ 'first' ] : up[ 'last' ] + 1 ]
|
peaks_up = peaks_up[ up[ 'first' ] : up[ 'last' ] + 1 ]
|
||||||
peaks_down = peaks_down[ down[ 'first' ] : down[ 'last' ] + 1 ]
|
peaks_down = peaks_down[ down[ 'first' ] : down[ 'last' ] + 1 ]
|
||||||
peaks_calib = peaks_calib[ calib[ 'first' ] : calib[ 'last' ] + 1 ]
|
peaks_calib = peaks_calib[ calib[ 'first' ] : calib[ 'last' ] + 1 ]
|
||||||
|
@ -691,18 +716,10 @@ for line in range_:
|
||||||
abciss[ wrong_points ],
|
abciss[ wrong_points ],
|
||||||
)
|
)
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
data[
|
||||||
plt.plot(
|
line ,
|
||||||
abciss,
|
border[ 'x' ][ 'min' ] : border[ 'x' ][ 'max' ]
|
||||||
list_ ,
|
] = list_
|
||||||
)
|
|
||||||
plt.plot(
|
|
||||||
abciss,
|
|
||||||
interpolation(
|
|
||||||
abciss,
|
|
||||||
) ,
|
|
||||||
)
|
|
||||||
plt.show()
|
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print( 'artefact removed from intensity curve' )
|
print( 'artefact removed from intensity curve' )
|
||||||
|
@ -741,7 +758,7 @@ mean_bias = sp_convolve(
|
||||||
50,
|
50,
|
||||||
) ,
|
) ,
|
||||||
'same',
|
'same',
|
||||||
) / 50
|
) / 50 * 0
|
||||||
|
|
||||||
data[
|
data[
|
||||||
: ,
|
: ,
|
||||||
|
@ -804,7 +821,6 @@ if verbose:
|
||||||
if output == None:
|
if output == None:
|
||||||
print( stairs , wavelength )
|
print( stairs , wavelength )
|
||||||
else:
|
else:
|
||||||
|
|
||||||
output_file = pathlib.Path( output )
|
output_file = pathlib.Path( output )
|
||||||
with shelve.open( str( output_file ) ) as output:
|
with shelve.open( str( output_file ) ) as output:
|
||||||
output[ 'data' ] = stairs
|
output[ 'data' ] = stairs
|
||||||
|
|
Loading…
Reference in a new issue