Add bias substraction after wavelength calibration

This commit is contained in:
linarphy 2023-06-23 10:09:51 +02:00
parent 32403fdce4
commit 78c02df9af
No known key found for this signature in database
GPG key ID: 3D4AAAC3AD16E79C

View file

@ -531,40 +531,42 @@ if calibration != None:
wavelengths = np.polyval( wavelength_polyval , abciss )
"""
mean_up = np.mean( data[
calibrations[ 'top' ][ 'y' ][ 'min' ] : calibrations[ 'top' ][ 'y' ][ 'max' ],
calibrations[ 'top' ][ 'x' ][ 'min' ] : claibrations[ 'top' ][ 'x' ][ 'max' ]
] , axis = 0 )
mean_up = np.mean( data[
calibrations[ 'down' ][ 'y' ][ 'min' ] : calibrations[ 'down' ][ 'y' ][ 'max' ],
calibrations[ 'down' ][ 'x' ][ 'min' ] : claibrations[ 'down' ][ 'x' ][ 'max' ]
] , axis = 0 )
peaks_up = np.array(
utils.retrieve_peaks(
mean_up ,
window_size = 1 ,
max_window_size = 1,
) ,
dtype = int,
)
peaks_down = np.array(
utils.retrieve_peaks(
mean_down ,
window_size = 1 ,
max_window_size = 1,
) ,
dtype = int,
)
"""
if verbose:
print( 'wavelength calibration finished' )
if verbose:
print( 'starting bias substraction' )
bias = {
'top': np.mean(
data[
calibrations[ 'top' ][ 'y' ][ 'min' ] - 100 :
calibrations[ 'top' ][ 'y' ][ 'min' ] ,
calibrations[ 'top' ][ 'x' ][ 'min' ] :
calibrations[ 'top' ][ 'x' ][ 'max' ]
] ,
axis = 0,
),
'down': np.mean(
data[
calibrations[ 'down' ][ 'y' ][ 'max' ] :
calibrations[ 'down' ][ 'y' ][ 'max' ] + 100,
calibrations[ 'down' ][ 'x' ][ 'min' ] :
calibrations[ 'down' ][ 'x' ][ 'max' ]
] ,
axis = 0,
),
}
mean_bias = np.mean( [ bias[ 'top' ] , bias[ 'down' ] ] , axis = 0 )
if verbose:
print( 'bias substraction finished' )
mean_data = np.mean( data[
spectrum[ 'y' ][ 'min' ] : spectrum[ 'y' ][ 'max' ],
spectrum[ 'x' ][ 'min' ] : spectrum[ 'x' ][ 'max' ]
] , axis = 0 )
] , axis = 0 ) - mean_bias
if intensity != None:
if verbose: