def test_good(self): list = xraylib.GetRadioNuclideDataList() self.assertEqual(len(list), 10) for i, v in enumerate(list): rnd = xraylib.GetRadioNuclideDataByIndex(i) self.assertEqual(rnd['name'], v) rnd = xraylib.GetRadioNuclideDataByName(v) self.assertEqual(rnd['name'], v) rnd = xraylib.GetRadioNuclideDataByIndex(3) self.assertEqual(rnd['A'], 125) self.assertAlmostEqual(rnd['GammaEnergies'], [35.4919]) self.assertAlmostEqual(rnd['GammaIntensities'], [0.0668]) self.assertEqual(rnd['N'], 72) XrayIntensities = [ 0.0023, 0.00112, 0.0063, 0.056, 0.035, 0.0042, 0.007, 0.00043, 0.0101, 0.0045, 0.00103, 0.0016, 3.24e-05, 0.406, 0.757, 0.0683, 0.132, 0.00121, 0.0381, 0.0058 ] self.assertAlmostEqual(rnd['XrayIntensities'], XrayIntensities) XrayLines = [ -86, -60, -89, -90, -63, -33, -34, -91, -95, -68, -38, -39, -1, -2, -3, -5, -6, -8, -11, -13 ] self.assertEqual(rnd['XrayLines'], XrayLines) self.assertEqual(rnd['Z'], 53) self.assertEqual(rnd['Z_xray'], 52) self.assertEqual(rnd['nGammas'], 1) self.assertEqual(rnd['nXrays'], 20) self.assertEqual(rnd['name'], '125I') rnd = xraylib.GetRadioNuclideDataByName('125I') self.assertEqual(rnd['A'], 125) self.assertAlmostEqual(rnd['GammaEnergies'], [35.4919]) self.assertAlmostEqual(rnd['GammaIntensities'], [0.0668]) self.assertEqual(rnd['N'], 72) XrayIntensities = [ 0.0023, 0.00112, 0.0063, 0.056, 0.035, 0.0042, 0.007, 0.00043, 0.0101, 0.0045, 0.00103, 0.0016, 3.24e-05, 0.406, 0.757, 0.0683, 0.132, 0.00121, 0.0381, 0.0058 ] self.assertAlmostEqual(rnd['XrayIntensities'], XrayIntensities) XrayLines = [ -86, -60, -89, -90, -63, -33, -34, -91, -95, -68, -38, -39, -1, -2, -3, -5, -6, -8, -11, -13 ] self.assertEqual(rnd['XrayLines'], XrayLines) self.assertEqual(rnd['Z'], 53) self.assertEqual(rnd['Z_xray'], 52) self.assertEqual(rnd['nGammas'], 1) self.assertEqual(rnd['nXrays'], 20) self.assertEqual(rnd['name'], '125I')
rnd['XrayIntensities'][i])) print(" Gamma rays:") for i in range(rnd['nGammas']): print(" {} keV -> {}".format(rnd['GammaEnergies'][i], rnd['GammaIntensities'][i])) rnd = xraylib.GetRadioNuclideDataByIndex(xraylib.RADIO_NUCLIDE_125I) print("RADIO_NUCLIDE_125I") print(" Name: {}".format(rnd['name'])) print(" Z: {}".format(rnd['Z'])) print(" A: {}".format(rnd['A'])) print(" N: {}".format(rnd['N'])) print(" Z_xray: {}".format(rnd['Z_xray'])) print(" X-rays:") for i in range(rnd['nXrays']): print(" {} keV -> {}".format( xraylib.LineEnergy(rnd['Z_xray'], rnd['XrayLines'][i]), rnd['XrayIntensities'][i])) print(" Gamma rays:") for i in range(rnd['nGammas']): print(" {} keV -> {}".format(rnd['GammaEnergies'][i], rnd['GammaIntensities'][i])) radioNuclides = xraylib.GetRadioNuclideDataList() print("List of available radionuclides:") for i in range(len(radioNuclides)): print(" Radionuclide {}: {}".format(i, radioNuclides[i])) print("") print("------------------------ END OF XRLEXAMPLE5 -------------------------") print("")
def index(): form = Xraylib_Request() version = xraylib.__version__ # Populates select fields form.function.choices = form.function.choices + cs_tup + dcs_tup form.transition.siegbahn.choices = trans_S_tup form.shell.choices = shell_tup form.nistcomp.choices = nist_tup form.rad_nuc.choices = rad_name_tup if request.method == 'POST': # Get user input select_input = request.form.get('function') examples = request.form.get('examples') notation = request.form.get('transition-notation') siegbahn = request.form.get('transition-siegbahn') iupac1 = request.form.get('transition-iupac1') iupac2 = request.form.get('transition-iupac2') ex_shell = request.form.get('augtrans-ex_shell') trans_shell = request.form.get('augtrans-trans_shell') aug_shell = request.form.get('augtrans-aug_shell') cktrans = request.form.get('cktrans') nistcomp = request.form.get('nistcomp') rad_nuc = request.form.get('rad_nuc') shell = request.form.get('shell') int_z = request.form['int_z'] float_q = request.form['float_q'] comp = request.form['comp'] int_z_or_comp = request.form['int_z_or_comp'] energy = request.form['energy'] theta = request.form['theta'] phi = request.form['phi'] density = request.form['density'] pz = request.form['pz'] # Turns user input => valid args for calc_output trans = iupac1 + iupac2 + '_LINE' augtrans = ex_shell + '_' + trans_shell + aug_shell + '_AUGER' if select_input == 'AtomicWeight' or select_input == 'ElementDensity': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z) output = calc_output(select_input, int_z) return render_template('index.html', form=form, version=version, output=output, units=getattr(Request_Units, select_input + '_u'), code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'FF_Rayl' or select_input == 'SF_Compt': if validate_int( int_z) or validate_str(int_z) and validate_float(float_q): examples = code_example(form.examples.choices, select_input, int_z, float_q) output = calc_output(select_input, int_z, float_q) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'AugerRate': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, augtrans) output = calc_output(select_input, int_z, augtrans) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'LineEnergy' or select_input == 'RadRate': if notation == 'IUPAC': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, trans) output = calc_output(select_input, int_z, trans) if select_input == 'LineEnergy': return render_template('index.html', form=form, version=version, output=output, units=Request_Units.Energy_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif notation == 'Siegbahn': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, siegbahn) output = calc_output(select_input, int_z, siegbahn) print(output) if select_input == 'LineEnergy': return render_template('index.html', form=form, version=version, output=output, units=Request_Units.Energy_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, output=output, code_examples=examples) return render_template('index.html', form=form, version=version, error=Request_Error.error) elif notation == 'All': if validate_int(int_z) or validate_str(int_z): output = all_trans(trans_I_tup, select_input, int_z) if select_input == 'LineEnergy': #needs units #output = dict(out, Line = 'Energies') return render_template('index.html', form=form, version=version, output=output, units=Request_Units.Energy_u) else: return render_template('index.html', form=form, version=version, output=output) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) else: return render_template('index.html', error=Request_Error.error) elif (select_input == 'EdgeEnergy' or select_input == 'JumpFactor' or select_input == 'FluorYield' or select_input == 'AugerYield' or select_input == 'AtomicLevelWidth' or select_input == 'ElectronConfig'): if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, shell) output = calc_output(select_input, int_z, shell) if select_input == 'EdgeEnergy' or select_input == 'AtomicLevelWidth': return render_template('index.html', form=form, version=version, output=output, units=Request_Units.Energy_u, code_examples=examples) elif select_input == 'ElectronConfig': return render_template( 'index.html', form=form, version=version, output=output, units=Request_Units.ElectronConfig_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'CS_Photo_Partial': if validate_int( int_z) or validate_str(int_z) and validate_float(energy): output = calc_output(select_input, int_z, shell, energy) examples = code_example(form.examples.choices, select_input, int_z, shell, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'CS_KN': if validate_float(energy) and energy != '0': output = calc_output(select_input, energy) examples = code_example(form.examples.choices, select_input, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input.startswith('CS_FluorLine'): if validate_float(energy): if notation == 'IUPAC': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, trans, energy) output = calc_output(select_input, int_z, trans, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif notation == 'Siegbahn': if validate_int(int_z) or validate_str(int_z): examples = code_example(form.examples.choices, select_input, int_z, siegbahn, energy) output = calc_output(select_input, int_z, siegbahn, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif notation == 'All': if validate_int(int_z) or validate_str(int_z): output = all_trans_xrf(form.transition.iupac.choices, select_input, int_z, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input.startswith('CS_'): if validate_float(energy) and validate_int( int_z_or_comp) or validate_str(int_z_or_comp): examples = code_example(form.examples.choices, select_input, int_z_or_comp, energy) output = calc_output(select_input, int_z_or_comp, energy) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.CS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'DCS_Thoms': if validate_float(theta): output = calc_output(select_input, theta) examples = code_example(form.examples.choices, select_input, theta) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'DCS_KN' or select_input == 'ComptonEnergy': if validate_float(energy, theta): output = calc_output(select_input, energy, theta) examples = code_example(form.examples.choices, select_input, energy, theta) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input.startswith('DCS_'): if validate_float(energy, theta) and validate_int( int_z_or_comp) or validate_str(int_z_or_comp): output = calc_output(select_input, int_z_or_comp, energy, theta) examples = code_example(form.examples.choices, select_input, int_z_or_comp, energy, theta) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'DCSP_KN': if validate_float(energy, theta, phi): output = calc_output(select_input, energy, theta, phi) examples = code_example(form.examples.choices, select_input, energy, theta, phi) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'DCSP_Thoms': if validate_float(theta, phi): output = calc_output(select_input, theta, phi) examples = code_example(form.examples.choices, select_input, theta, phi) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input.startswith('DCSP_'): if validate_float(energy, theta, phi) and validate_int( int_z_or_comp) or validate_str(int_z_or_comp): output = calc_output(select_input, int_z_or_comp, energy, theta, phi) examples = code_example(form.examples.choices, select_input, int_z_or_comp, energy, theta, phi) return render_template('index.html', form=form, version=version, output=output, units=Request_Units.DCS_u, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input.startswith('Fi'): if validate_int( int_z) or validate_str(int_z) and validate_float(energy): output = calc_output(select_input, int_z, energy) examples = code_example(form.examples.choices, select_input, int_z, energy) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'CosKronTransProb': if validate_int(int_z) or validate_str(int_z): output = calc_output(select_input, int_z, cktrans) examples = code_example(form.examples.choices, select_input, int_z, cktrans) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'ComptonProfile': if validate_float(pz) and validate_int(int_z) or validate_str( int_z): output = calc_output(select_input, int_z, pz) examples = code_example(form.examples.choices, select_input, int_z, pz) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'ComptonProfile_Partial': if validate_float(pz) and validate_int(int_z) or validate_str( int_z): output = calc_output(select_input, int_z, shell, pz) examples = code_example(form.examples.choices, select_input, int_z, shell, pz) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'MomentTransf': if validate_float(energy, theta) == True: output = calc_output(select_input, energy, theta) examples = code_example(form.examples.choices, select_input, energy, theta) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'Refractive_Index': # Special Case: Refractive_Index input needs to be const char compound if validate_float(energy, density) and validate_int( int_z_or_comp) or validate_str(int_z_or_comp): try: output = xraylib.Refractive_Index( xraylib.AtomicNumberToSymbol(int(int_z_or_comp), float(energy), float(density))) examples = code_example(form.examples.choices, select_input, int_z_or_comp, energy, density) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) except: output = xraylib.Refractive_Index(int_z_or_comp, float(energy), float(density)) examples = code_example(form.examples.choices, select_input, int_z_or_comp, energy, density) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'CompoundParser': # Special Case: CompoundParser input needs to be const char compound if validate_str(comp): try: out = xraylib.CompoundParser(str(comp)) # Format output w_fracts = out['massFractions'] w_pers = [str(round(i * 100, 2)) + ' %' for i in w_fracts] z = out['Elements'] sym = [ '<sub>' + str(i) + '</sub>' + str(xraylib.AtomicNumberToSymbol(i)) for i in z ] mmass = str(out['molarMass']) + ' g mol<sup>-1</sup>' output = { 'Elements': sym, 'Weight Fraction': w_pers, 'Number of Atoms': out['nAtoms'], ' Molar Mass': mmass } examples = code_example(form.examples.choices, select_input, comp) return render_template('index.html', form=form, version=version, output=output, code_examples=examples, units=Request_Units.per_u) except: return render_template('index.html', form=form, version=version, error=Request_Error.error) else: return render_template('index.html', form=form, version=version, error=Request_Error.error) elif select_input == 'GetRadioNuclideDataList': output = xraylib.GetRadioNuclideDataList() output.insert(0, '<b> Radionuclides: </b>') output = '<br/>'.join(output) examples = code_example(form.examples.choices, select_input) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) elif select_input == 'GetRadioNuclideDataByIndex': out = calc_output(select_input, rad_nuc) print(out) # Format output line_nos = out['XrayLines'] x_energy = [xraylib.LineEnergy(out['Z_xray'], i) for i in line_nos] output = { 'X-ray Energies': x_energy, 'Disintegrations s<sup>-1</sup>': out['XrayIntensities'], 'Gamma-ray Energy': out['GammaEnergies'], 'Disintegrations s<sup>-1</sup> ': out['GammaIntensities'] } examples = code_example(form.examples.choices, 'GetRadioNuclideDataByName', rad_nuc) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) elif select_input == 'GetCompoundDataNISTList': output = xraylib.GetCompoundDataNISTList() output.insert(0, '<b> NIST Compounds: </b>') output = '<br/>'.join(output) examples = code_example(form.examples.choices, select_input) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) elif select_input == 'GetCompoundDataNISTByIndex': out = calc_output(select_input, nistcomp) # Format output w_fracts = out['massFractions'] w_pers = [str(round(i * 100, 2)) + ' %' for i in w_fracts] z = out['Elements'] sym = [ '<sub>' + str(i) + '</sub>' + str(xraylib.AtomicNumberToSymbol(i)) for i in z ] density = str(out['density']) + ' g cm<sup>-3</sup>' output = { 'Elements': sym, 'Weight Fraction': w_pers, ' Density': density } examples = code_example(form.examples.choices, 'GetCompoundDataNISTByName', nistcomp) return render_template('index.html', form=form, version=version, output=output, code_examples=examples) return render_template('index.html', form=form, version=version)
def __init__(self, parent=None): super(ApplicationWindow, self).__init__(parent) QMainWindow.__init__(self) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle("xray yield simulation") self.resize(1200, 750) self.er_low=0.1# keV self.er_high=20.# keV self.er_step=0.001# keV self.enes_keV=np.arange(self.er_low,self.er_high+self.er_low+self.er_step,self.er_step) self.qeout=np.zeros_like(self.enes_keV)# for output self.flout=np.zeros_like(self.enes_keV)# for output # IUPAC macro self.LINES=['KL3','KL2','KM3','KM2', 'L3M5','L3M4','L2M4','L3N5', 'L1M3','L1M2','L2N4','L3M1'] # Siegbahn self.SGBLINES=['KA1','KA2','KB1','KB3', 'LA1','LA2','LB1','LB2', 'LB3','LB4','LG1','LL'] # radionuclide list self.RDNLIST=list(xrl.GetRadioNuclideDataList()) #['55Fe','57Co','109Cd','125I','137Cs', #'133Ba','153Gd','238Pu','241Am','244Cm'] # half life self.RDNHL=[1006.70,272.11,463.26,59.49,11018.3, 3854.7,239.472,32031.74,157857.678,6610.52]# days # universal parameters self.rad_duration=3600.# sec self.beam_duration=7200.# sec self.detector_resolution=8.0# eV self.detector_solidangle=1.0 self.csvd="./csv/" IUPACdf=pd.read_csv(self.csvd+"IUPAC_macro.csv") self.IUPACmac=IUPACdf['IUPAC_macro'].values self.allLINES=[xrl.__getattribute__(mac) for mac in self.IUPACmac] # ---- layout ---- # main widget main_widget = QWidget(self) self.setCentralWidget(main_widget) main_layout = QHBoxLayout() # target, detector, filter materials topleft=QWidget() topleftbox=QVBoxLayout() self.fopenButton = QPushButton("Load csv file") self.fopenButton.clicked.connect(self.openFileNameDialog) self.default_none = "None (reset all)" self.default_tes_jparc_mlf = "TES(Bi) J-PARC MLF" self.default_tes_spring8 = "TES(Bi) Spring-8" self.default_tes_sn = "TES(Sn)" self.default_cdte = "CdTe" self.default_ge = "Ge" self.default_si = "Si" self.chkbox0 = QCheckBox(self.default_none) self.chkbox1 = QCheckBox(self.default_tes_jparc_mlf) self.chkbox2 = QCheckBox(self.default_tes_spring8) self.chkbox3 = QCheckBox(self.default_tes_sn) self.chkbox4 = QCheckBox(self.default_cdte) self.chkbox5 = QCheckBox(self.default_ge) self.chkbox6 = QCheckBox(self.default_si) self.chkbg = QButtonGroup() self.chkbg.addButton(self.chkbox0,1) self.chkbg.addButton(self.chkbox1,2) self.chkbg.addButton(self.chkbox2,3) self.chkbg.addButton(self.chkbox3,4) self.chkbg.addButton(self.chkbox4,5) self.chkbg.addButton(self.chkbox5,6) self.chkbg.addButton(self.chkbox6,7) self.chkbg.buttonClicked[QAbstractButton].connect(self.btngroup) self.chkbox0.setChecked(True) ltboxw=QWidget() ltbox=QVBoxLayout(ltboxw) ltbox.setContentsMargins(0, 0, 0, 0) ltbox.addWidget(QLabel("Default setting")) ltbox.addWidget(self.fopenButton) ltbox.addWidget(self.chkbox0) ltbox.addWidget(self.chkbox1) ltbox.addWidget(self.chkbox2) ltboxw_02=QWidget() ltbox_02=QHBoxLayout(ltboxw_02) ltbox_02.setContentsMargins(0, 0, 0, 0) ltbox_02.addWidget(self.chkbox3) ltbox_02.addWidget(self.chkbox4) ltbox_02.addWidget(self.chkbox5) ltbox_02.addWidget(self.chkbox6) ltboxw2=QWidget() ltbox2=QVBoxLayout(ltboxw2) qtab=QTabWidget() self.bem={} self.tgt={} self.det={} self.bet={} self.rad={} self.dets=[] self.bets=[] self.rads=[] self.bemtab=material.MaterialTabWidget(parent=self,name='bem') self.tgttab=material.MaterialTabWidget(parent=self,name='tgt') self.dettab=material.MaterialTabWidget(parent=self,name='det') self.bettab=material.MaterialTabWidget(parent=self,name='bet') self.radtab=material.MaterialTabWidget(parent=self,name='rad') qtab.addTab(self.dettab,'Detector') qtab.addTab(self.tgttab,'Target') qtab.addTab(self.bettab,'Filter') qtab.addTab(self.radtab,'RadioNucl') qtab.addTab(self.bemtab,'Beam') ltbox2.addWidget(qtab) topleftbox.addWidget(ltboxw) topleftbox.addWidget(ltboxw_02) topleftbox.addWidget(ltboxw2) topleft.setLayout(topleftbox) plotButton = QPushButton("Plot") plotButton.clicked.connect(self._plot_trans_fluor) saveButton = QPushButton("Save") saveButton.clicked.connect(self._save_trans_fluor) #plotButton = QPushButton("Plot transmission") #plotButton.clicked.connect(self._update_trans_cv) #fluorButton = QPushButton("Plot flurorescence") #fluorButton.clicked.connect(self._update_fluor_cv) # energy range rangebox=QHBoxLayout() self.ene_range_low_le = QLineEdit() self.ene_range_low_le.setValidator(QDoubleValidator(0.,800.,999)) self.ene_range_low_le.returnPressed.connect(self.apply_enerangelow) self.ene_range_low_le.setText("0.1") self.ene_range_high_le = QLineEdit() self.ene_range_high_le.setValidator(QDoubleValidator(0.,800.,999)) self.ene_range_high_le.returnPressed.connect(self.apply_enerangehigh) self.ene_range_high_le.setText("20.") self.ene_range_step_le = QLineEdit() self.ene_range_step_le.setValidator(QDoubleValidator(0.,800.,999)) self.ene_range_step_le.returnPressed.connect(self.apply_enerangestep) self.ene_range_step_le.setText("0.001") rangebox.addWidget(QLabel("Low:")) rangebox.addWidget(self.ene_range_low_le) rangebox.addWidget(QLabel("High:")) rangebox.addWidget(self.ene_range_high_le) rangebox.addWidget(QLabel("Step:")) rangebox.addWidget(self.ene_range_step_le) # detector resolution self.detector_resolution_le = QLineEdit() self.detector_resolution_le.setValidator(QDoubleValidator(0.,1e5,999)) self.detector_resolution_le.returnPressed.connect(self.apply_detector_resolution) self.detector_resolution_le.setText(str(self.detector_resolution)) # detector solidangle self.detector_solidangle_le = QLineEdit() self.detector_solidangle_le.setValidator(QDoubleValidator(0.,1.,999)) self.detector_solidangle_le.returnPressed.connect(self.apply_detector_solidangle) self.detector_solidangle_le.setText(str(self.detector_solidangle)) # check current setup topmiddle=QWidget() tmbox=QVBoxLayout() self.cc_table = QTableWidget() self.init_cc_table() self.not_draw_lines=[] self.line_table = QTableWidget() self.init_line_table() tmbox.addWidget(QLabel("Plot")) tmbox.addWidget(QLabel("Energy range (keV)")) tmbox.addLayout(rangebox) tmbox.addWidget(plotButton) tmbox.addWidget(saveButton) self.chkbox_resol = QCheckBox("Detector resolution FWHM (eV)") self.chkbox_resol.stateChanged.connect(self.chkbox_resol_action) self.chkbox_resol.setChecked(True) #tmbox.addWidget(QLabel("Detector resolution FWHM (eV)")) tmbox.addWidget(self.chkbox_resol) tmbox.addWidget(self.detector_resolution_le) tmbox.addWidget(QLabel("Solidangle ratio (0.-1.)")) tmbox.addWidget(self.detector_solidangle_le) #tmbox.addWidget(fluorButton) tmbox.addWidget(QLabel("Current setting")) tmbox.addWidget(self.cc_table) tmbox.addWidget(QLabel("X-ray lines")) tmbox.addWidget(self.line_table) topmiddle.setLayout(tmbox) topright=QWidget() trbox=QVBoxLayout() mini_width=300 self.fig_tr = Figure(figsize=(8, 6), dpi=80) trans_cv = FigureCanvas(self.fig_tr) trans_tlbar = NavigationToolbar(trans_cv, self) trans_tlbar.setMinimumWidth(mini_width) trans_tlbar.setStyleSheet("QToolBar { border: 0px }") self.ax = trans_cv.figure.subplots() self.fig_fl = Figure(figsize=(8, 6), dpi=80) fluor_cv = FigureCanvas(self.fig_fl) fluor_tlbar = NavigationToolbar(fluor_cv, self) fluor_tlbar.setMinimumWidth(mini_width) fluor_tlbar.setStyleSheet("QToolBar { border: 0px }") self.ax_fl = fluor_cv.figure.subplots() trbox.addWidget(trans_tlbar) trbox.addWidget(trans_cv) trbox.addWidget(fluor_cv) trbox.addWidget(fluor_tlbar) topright.setLayout(trbox) topright.layout().setSpacing(0) ## cosole outputs ## used for debug #resultTE = QTextEdit() #resultTE.setReadOnly( True ) #resultTE.setUndoRedoEnabled( False ) #sys.stdout = line_wrap.Logger(resultTE, sys.stdout, QColor(0, 100, 100)) #sys.stderr = line_wrap.Logger(resultTE, sys.stderr, QColor(200, 0, 0)) splitter1 = QSplitter(Qt.Horizontal) splitter1.addWidget(topleft) splitter1.addWidget(topmiddle) splitter3 = QSplitter(Qt.Horizontal) splitter3.addWidget(splitter1) splitter3.addWidget(topright) #splitter2 = QSplitter(Qt.Vertical) #splitter2.addWidget(splitter3) #splitter2.addWidget(resultTE) #main_layout.addWidget(splitter2) main_layout.addWidget(splitter3) main_widget.setLayout(main_layout) main_widget.setFocus() self.show()