Ejemplo n.º 1
0
                #                        fit_dark.p0_func(y, x, config=None),
                #                         slice=fit_dark.slice_func(y, x, config=None),
                #                         bounds=fit_dark.bounds_func(y, x, config=None),
                #                         fixed_param=None)

            if level > dark_threshold and level <= low_light_threshold:  ## Low

                if options.verbose: print('----> Pix', pix, 'low light')

                fit_result = mpes._axis_fit(
                    (
                        level,
                        pix,
                    ),
                    fit_low_light.fit_func,
                    fit_low_light.p0_func(y, x, config=prev_fit_result),
                    slice=fit_low_light.slice_func(y,
                                                   x,
                                                   config=prev_fit_result),
                    bounds=fit_low_light.bounds_func(y,
                                                     x,
                                                     config=prev_fit_result),
                    fixed_param=None)

            if level > low_light_threshold:  ## High
                if options.verbose: print('----> Pix', pix, 'high light')

                fit_result = mpes._axis_fit(
                    (
                        level,
                        pix,
Ejemplo n.º 2
0
def fit_consecutive_hist(hist, levels, pixels, config=None, fit_type=None):

    prev_fit_result = None

    for level in levels:

        print("################################# Level", level)

        for pix in pixels:

            if len(levels) <= 1:
                y = hist.data[pix]
            else:
                y = hist.data[level, pix]

            x = hist.bin_centers

            fit_result = None

            if level == levels[0]:

                # prev_fit_result = np.array([[0.5, np.nan], [0.08, np.nan], [5.6, np.nan], [2020, np.nan], [0.07, np.nan], [0.09,np.nan], [3500, np.nan], [0., np.nan]])
                prev_fit_result = config

            else:

                prev_fit_result = hist.fit_result[level - 1, pix]

            if np.any(np.isnan(hist.data[level, pix])):
                print('----> Pix', pix, 'abort')
                continue

            if fit_type == 'dark':  ## Dark

                print('----> Pix', pix, 'as dark')

                fit_result = hist._axis_fit(
                    (
                        level,
                        pix,
                    ),
                    fit_low_light.fit_func,
                    fit_low_light.p0_func(y, x, config=prev_fit_result),
                    slice=fit_low_light.slice_func(y,
                                                   x,
                                                   config=prev_fit_result),
                    bounds=fit_low_light.bounds_func(y,
                                                     x,
                                                     config=prev_fit_result),
                    fixed_param=None)

            elif fit_type == 'low_light':  ## Low

                print('----> Pix', pix, 'low light')

                fit_result = hist._axis_fit(
                    (
                        level,
                        pix,
                    ),
                    fit_low_light.fit_func,
                    fit_low_light.p0_func(y, x, config=prev_fit_result),
                    slice=fit_low_light.slice_func(y,
                                                   x,
                                                   config=prev_fit_result),
                    bounds=fit_low_light.bounds_func(y,
                                                     x,
                                                     config=prev_fit_result),
                    fixed_param=np.array([[7], [0.]]))
                print(fit_result)

            elif fit_type == 'high_light':  ## High
                print('----> Pix', pix, 'high light')

                fit_result = hist._axis_fit(
                    (
                        level,
                        pix,
                    ),
                    fit_low_light.fit_func,
                    fit_low_light.p0_func(y, x, config=prev_fit_result),
                    slice=fit_low_light.slice_func(y,
                                                   x,
                                                   config=prev_fit_result),
                    bounds=fit_low_light.bounds_func(y,
                                                     x,
                                                     config=prev_fit_result),
                    fixed_param=np.array(
                        [[1, 2, 3, 4, 5, 7],
                         [
                             prev_fit_result[1, 0], prev_fit_result[2, 0],
                             prev_fit_result[3, 0], prev_fit_result[4, 0],
                             prev_fit_result[5, 0], prev_fit_result[7, 0]
                         ]]))

            elif fit_type == 'hv_off':  ## HV off
                print('----> Pix', pix, 'hv off')

                fit_result = hist._axis_fit(
                    pix,
                    fit_hv_off.fit_func,
                    fit_hv_off.p0_func(y, x, config=prev_fit_result),
                    slice=fit_hv_off.slice_func(y, x, config=prev_fit_result),
                    bounds=fit_hv_off.bounds_func(y, x,
                                                  config=prev_fit_result),
                    fixed_param=np.array([[0, 1, 2, 5, 7],
                                          [
                                              prev_fit_result[0, 0],
                                              prev_fit_result[1, 0],
                                              prev_fit_result[2, 0],
                                              prev_fit_result[5, 0],
                                              prev_fit_result[7, 0]
                                          ]]))

            else:

                print(' Impossible to fit', ' pixel', pix, ' in level ', level,
                      ' !!!!!!!!!!!!!!!')

            if len(levels) <= 1:

                hist.fit_result[pix] = fit_result

            else:
                hist.fit_result[level, pix] = fit_result
Ejemplo n.º 3
0
             ## to be replaced by fit_dark
             mpes_peaks.fit_result[level, pix] = [[2., 1.e3],
                                                  [prev_fit[0, pix, 1]],
                                                  [prev_fit[0, pix, 2]],
                                                  [prev_fit[0, pix, 3]],
                                                  [prev_fit[0, pix, 4]],
                                                  [0.7, 10.],
                                                  [1000, 1.e8],
                                                  [prev_fit[0, pix, 7]]]
         else:
             if options.verbose: print('----> Pix', pix, 'low light')
             mpes_peaks.fit_result[level, pix] = \
                 mpes_peaks._axis_fit((level,pix,),
                                             fit_low_light.fit_func,
                                             fit_low_light.p0_func(mpes_peaks.data[level,pix],
                                                                   mpes_peaks.bin_centers,
                                                                   config=prev_fit[0,pix]),
                                             slice=fit_low_light.slice_func(mpes_peaks.data[level,pix],
                                                                            mpes_peaks.bin_centers,
                                                                            config=prev_fit[0,pix]),
                                             bounds=fit_low_light.bounds_func(mpes_peaks.data[level,pix],
                                                                              mpes_peaks.bin_centers,
                                                                              config=prev_fit[0,pix]),
                                             # mu_xt,baseline,sigma_e,offset
                                             fixed_param = np.array([[i for i in [1,3,4,7]],[prev_fit[0, pix, i , 0] for i in [1,3,4,7]]])
                                             )
 else:
     ## Take from previous
     for pix in range(mpes_peaks.data[level].shape[0]):
         if np.any(np.isnan(mpes_peaks.data[level, pix])):
             if options.verbose: print('----> Pix', pix, 'abort')