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