コード例 #1
0
def all_spectra( db_names ) :
    
    constrain_det_params = { 'a' : 1 }

    time_estimator = jutils.time_estimator( len(db_names) * 4 * 32 * 32, 20 )

    for name in db_names :

        # dets_used = bpt.dets_used( bpt_data_path, name )

        db = spec.spectrum_db( name, '../../../storage/', (32,32),
                               peak_types, constrain_det_params )

        spec.auto_fit_many_spectra( db, (4,4),
                                    fit_bounds_guesser,
                                    peak_params_guesser, det_params_guesses,
                                    fit_acceptor = fit_acceptor,
                                    params_shuffler = params_shuffler,
                                    rel_plot_bounds = rel_plot_bounds,
                                    logscale = 1,
                                    time_estimator = time_estimator,
                                    print_output = 0,
                                    debug_peaks = 0,
                                    overwrite = 0,
                                    mask = none )
        
        # mu_path = '../../storage/mu_values/%s_%d_mu_values.bin' % ( name, detnum ) 

            
        db.disconnect()
コード例 #2
0
def one_spectrum(db_name, detnum, x, y):

    db = spec.spectrum_db(db_name, '../../../storage/')

    global debug
    debug = 1

    chans, counts, dcounts = db.get_histo(detnum, x, y)

    dcounts = np.sqrt(counts)
    dcounts[(dcounts == 0)] = 1

    plt.figure(figsize=(10, 12))
    ax = plt.axes()

    primary_peaks = db.load_dill('primary_peaks')
    primary_peaks = primary_peaks[:, detnum, x, y]

    db.disconnect()

    # peak_params_guesses = [ peak_params_guesser( i, detnum, x, y )
    #                         for i in range(2) ]

    spec.auto_fit_spectrum(chans,
                           counts,
                           dcounts,
                           fit_bounds_guesser,
                           peak_params_guesser,
                           det_params_guesses,
                           fit_acceptor=fit_acceptor,
                           params_shuffler=params_shuffler,
                           primary_peaks=primary_peaks,
                           rel_plot_bounds=rel_plot_bounds,
                           ax=ax,
                           print_output=1)

    # spec.auto_fit_spectrum( x, y, dy,
    #                         group_ranges, peak_locations,
    #                         num_peaks_to_detect, primary_peak_detector,
    #                         peak_sizes_guesses, peak_width_guesses,
    #                         det_params_guesses, peak_mu_offset,
    #                         fit_acceptor = fit_acceptor,
    #                         params_shuffler = params_shuffler,
    #                         ax = ax,
    #                         rel_plot_bounds = rel_plot_bounds,
    #                         print_output = 1)

    plt.show()
コード例 #3
0
def all_spectra(db_names):

    constrain_det_params = {'a': 1}

    time_estimator = jutils.time_estimator(len(db_names) * 4 * 32 * 32, 20)

    for name in db_names:

        # dets_used = bpt.dets_used( bpt_data_path, name )

        db = spec.spectrum_db(name, '../../../storage/', (32, 32), peak_types,
                              constrain_det_params)

        mask = np.zeros((3, 32, 32))
        mask[0, 0:15, :] = 1
        mask[0, 23:, :] = 1

        spec.auto_fit_many_spectra(
            db,
            (4, 4),
            # group_ranges, peak_locations,
            # num_peaks_to_detect, primary_peak_detector,
            # peak_sizes_guesses, peak_width_guesses,
            # det_params_guesses,
            fit_bounds_guesser,
            peak_params_guesser,
            det_params_guesses,
            fit_acceptor=fit_acceptor,
            params_shuffler=params_shuffler,
            rel_plot_bounds=rel_plot_bounds,
            logscale=1,
            time_estimator=time_estimator,
            print_output=0,
            debug_peaks=0,
            overwrite=0,
            mask=mask)

        # mu_path = '../../storage/mu_values/%s_%d_mu_values.bin' % ( name, detnum )

        db.disconnect()
コード例 #4
0

num_peaks_to_detect = 6




exp1_secant_matrices = exp1_geometry.get_secant_matrices()
peak_group_ranges = [ [ -np.inf, 2700 ], [ 2700, 2900 ], [ 2900, np.inf ] ]

thresholds = [ 20, 20, 20 ] 

# for name in [ 'centered', 'moved', 'flat', 'angled' ] : # , 'det3_moved', 'det3_cent' ] : 
for name in [ 'moved' ] :

    db = spec.spectrum_db( name, '../../../storage/' ) 

    
    secant_matrices = exp1_secant_matrices[ name ] 

    # primary_peaks = spec.write_peakdetect( db, primary_peak_detector, data_retriever,
    #                                        num_peaks_to_detect )

    primary_peaks = db.compute_primary_peaks( group_ranges,
                                              primary_peak_detector,
                                              num_peaks_to_detect = num_peaks_to_detect,
                                              primary_peak_detector = primary_peak_detector,
                                              plot = 0, load = 1 )

    # primary_peaks = db.compute_primary_peaks( peak_group_ranges, thresholds,
    #                                           load = 0, plot = 1  )
コード例 #5
0
    vary_det_deadlayer=0,
    interp_det_stopping_power=1,
    interp_source_stopping_powers=0,
    fstrips_requested=np.arange(2, 30),
    # fstrips_requested = np.arange(32),
    bstrips=np.arange(2, 30),
    fix_source_deadlayers=None,
    one_source_constant=0,
    det_thickness=0,
    vary_source_thickness=1)

num_dbs = len(db_names)

db_path = '../../../storage/databases/'

dbs = [spec.spectrum_db(db_path + db_names[i]) for i in range(len(db_names))]

channels = [
    dbs[i].read_values('../../../storage/peak_values/' + db_names[i] +
                       '_peak_values.bin')[0] for i in range(len(db_names))
]

# print( channels )

# channels = [ dbs[i].read_mu_values( '../../storage/peak_values/'
#                                     + db_names[i]
#                                     + '_mu_values.bin' )
#              for i in range( len( db_names ) ) ]

num_sources = len(channels[0])
コード例 #6
0
    print(x, y)
    ax.text(x, y, text, fontsize=16, ha='center')


labels = [r'$^8$Li$\to\alpha\alpha\beta^-$', r'$^{148}$Gd', r'$^{244}$Cm']
guesses = [763, 1600, 2903]
num_labels = len(labels)

y_bottom = 1e-6
hist_bin_size = 10

kde_bandwidth = 1

savepath = '../../../../plots_important/'

db = spec.spectrum_db('full_bkgd_tot', '../../../../storage')

# coords = (0, 27, 16 )
coords = (0, 16, 16)

data = db.get_data(*coords)
x = np.arange(0, 3000, hist_bin_size)
y, bin_edges = np.histogram(data, x)
x = x[0:-1]

# ax = plt.axes()

f = plt.figure(figsize=(6, 7))
f.suptitle('Uncalibrated $^8$Li Decay Spectrum\nwith Calibration Sources',
           fontsize=20)
コード例 #7
0
import jspectroscopy as spec

db_name = 'full_bkgd_tot'

db = spec.spectrum_db('../../storage/databases/' + db_name)

success_rate = db.compute_fit_success_rate()
print(success_rate)

db.plot_success_pixels()

db.disconnect()
コード例 #8
0
import jspectroscopy as spec
import time 

test_db = spec.spectrum_db( 'test_db', None, ( 32, 32 ), [ 'a', 'a' ] )

start_time = time.time() 

for i in range( 100 ) :

    test_db.insert_fit_data( -1, 31, 31, 0, None ) 

stop_time = time.time()

print( start_time - stop_time )