コード例 #1
0
ファイル: detect_gui.py プロジェクト: SINS-Lab/SAFARI
 def push_2():
     AllItems = [filebox.itemText(i) for i in range(filebox.count())]
     for file in AllItems:
         data = detect.load(file)
         try:
             spectrum = Spectrum()
             app.spectrums.append(spectrum)
             spectrum.name = file
             filename = os.path.basename(file)
             if file.endswith('.data'):
                 file = file.replace('.data', '.input')
             elif file.endswith('.txt'):
                 file = file.replace('.txt', '.input')
             elif file.endswith('.undata'):
                 file = file.replace('.undata', '.input')
             elif file.endswith('.npy'):
                 file = file.replace('.npy', '.input')
             else:
                 file = file + '.input'
             spectrum.safio = safari_input.SafariInput(file)
             spectrum.run(data)
             spectrum.popup.setWindowTitle(file)
         except Exception as e:
             print(e)
             pass
         #Wait a second for it to start running
         time.sleep(1)
コード例 #2
0
ファイル: detect_cli.py プロジェクト: SINS-Lab/SAFARI
def e_theta_loop(dir, theta1, theta2, theta_step):
    if dir != '.':
        dir = os.path.join('.',dir)

    for filename in os.listdir(dir):
        if filename.endswith('.data'):
            file = os.path.join(dir, filename)
            safio = safari_input.SafariInput(file.replace('.data', '.input'))
            print('loading data')
            data = detect.load(file)
            print('data loaded')
            fig, ax = plt.subplots()
            num = 0
            for theta in frange(theta1, theta2, theta_step):
                print('Theta: '+str(theta))
                spectrum = detect.Spectrum()
                spectrum.plots = False
                spectrum.name = filename.replace('.data','')
                spectrum.safio = safio
                spectrum.safio.DTECTPAR[0] = theta
                spectrum.detector = None
                spectrum.clean(data)
                energy, intensity = spectrum.detector.spectrum(res=spectrum.safio.ESIZE)
                intensity = intensity + num
                ax.plot(energy, intensity, label=str(theta))
                num = num + 1
                spectrum = None
            ax.legend()
            ax.set_title("Intensity vs Energy")
            ax.set_xlabel('Energy (eV)')
            ax.set_ylabel('Intensity')
            fig.show()
    input('Press Enter to exit')
コード例 #3
0
ファイル: detect_cli.py プロジェクト: SINS-Lab/SAFARI
def azimuthal_spectrum(dir, theta, size=3, emin=0, emin_rel=0):
    if dir != '.':
        dir = os.path.join('.',dir)

    output = open(os.path.join(dir, "azimuthal_spectrum_{}_{}_{}.txt".format(theta, size, emin)), 'w');

    for filename in os.listdir(dir):
        if filename.endswith('.data'):
            file = os.path.join(dir, filename)
            safio = safari_input.SafariInput(file.replace('.data', '.input'))
            print('loading: '+filename)
            data = detect.load(file)
            print('data loaded')

            # Setup the spectrum object for this file
            spectrum = detect.Spectrum()
            spectrum.plots = False
            spectrum.name = ""
            spectrum.pics = False
            spectrum.safio = safio
            spectrum.safio.DTECTPAR[0] = theta
            spectrum.detector = None
            spectrum.detector = detect.SpotDetector(theta, safio.PHI0, size)
            
            if emin_rel!=0:
                emin = emin_rel * safio.E0
            spectrum.clean(data, emin=emin)
            output.write("{}\t{}\n".format(safio.PHI0, len(spectrum.detector.detections)));
        
    output.close();
    input('Press Enter to exit')
コード例 #4
0
ファイル: detect_gui.py プロジェクト: SINS-Lab/SAFARI
 def push():
     data = detect.load(filebox.currentText())
     try:
         app.spectrums.append(spectrum)
         file = filebox.currentText()
         spectrum.name = file
         filename = os.path.basename(file)
         if file.endswith('.data'):
             file = file.replace('.data', '.input')
         elif file.endswith('.txt'):
             file = file.replace('.txt', '.input')
         elif file.endswith('.undata'):
             file = file.replace('.undata', '.input')
         elif file.endswith('.npy'):
             file = file.replace('.npy', '.input')
         else:
             file = file + '.input'
         spectrum.safio = safari_input.SafariInput(file)
         spectrum.run(data)
         spectrum.popup.setWindowTitle(file)
     except Exception as e:
         print(e)
         pass