def user_input(self, volt): z, name = get_options('Please enter Element Symbol:', 'els', count=True) # make sure the selected line is valid while True: line = get_options('Please enter Element X-Ray Line ' '(Ka, Lg2, etc.):', 'lines') xray = get_data(z, line) if xray > 0: break user_alert('Invalid line for this element; try again:') opt = self.get_opt() if volt is None: volt = get_nums('Accelerating voltage for this element?:', 50, 0) return name, line, z, volt, opt
def get_opt(self): """Options for analysis s -- Determined by stoichiometry. c -- analyzed with a compound std. d -- analyzed by difference (bulk only). E -- analyzed with pure element standard. """ return get_options('Options((S)toic, (C)omp, (D)iff, (E)lem):', ['S', 'C', 'D', 'E'], 'C')
def fixlayer(self): """Get fixed values for thickness and composition""" # Get Thickness (layers not sub - sub has "infinite" thickness) if not self.fix: self.thick = 0.0 return False self.units = get_options('+Enter fixed thicknesses in Angstroms (a)' 'or ug/cm**2 (u), (def=a):', ('A', 'U'), 'A') if self.units == 'A': label = 'Angstroms' if self.units == 'U': label = 'ug/cm**2' self.thick = get_nums('Fixed thickness [%s]:' % label, 10e5, 0, 0) self.thick = self.thick/1.0e6 # g/cm**2 if self.units == 'A': self.thick = self.thick*self.rho/100. # cm # Get Composition if len(self.els) == 1: # fraction in layer is one if only 1 element self.els[0] = 1.0 else: reply = get_options('Enter the fixed composition %s by ' 'weight fractions (w) or by atomic ' 'formula (def=a) :', ('W', 'A'), 'A') for i in range(0, len(self.els)): if reply == 'W': for j in range(0, self.els): self.els[j].wtfrac = get_nums( 'Weight fraction concentration' 'of element %s:' % self.els[j], 1.0, 0.0, default=1, zeroval=1.0e-9) elif reply == 'A': self.els[j].atform = get_nums( 'Atomic Formula of element %s ' '(i.e 1 for Si in SiO2):' % self.els[j], 100) if reply == 'A': wtfracs = wtfract([el.name for el in self.els], [el.atform for el in self.els]) for x, _ in enumerate(wtfracs): self.els[x].wtfrac = wtfracs[x]
def get_phimodel(): """gets desired phi(rz) model from user""" phimodel = get_options( 'Choices of phi(rz) models are(default=E):\n' '\t(B)\tBastin\'s Scanning (1986)\n' '\t(C)\tBastin\'s Scanning (1990)\n' '\t(E)\tPouchou, Pichoir (PAP) Scanning (1990)\n' '\t(P)\tPackwood\'s MAS (1986):\n', ('B', 'C', 'E', 'P'), 'E') return phimodel
def check_volts(self): for layer, el in self: while True: if el.edge <= min(self.volts)*0.9: break print ('Overvoltage ratio for %s (%5.1f keV Ec) with Eo=' '%5.1f keV is too low!\nTry Again:' % (el.name, el.edge, min(self.volts))) el.line = get_options('Lower Energy X-Ray Line for %s(%s)?' '(Ka, Lg2, etc.):' % (el.name, el.line), 'lines') el.setup_vars()
def new_std(self): how = get_options('Input %s standard composition in wt. %% (w) ' 'or atomic formula(a) (def=a):' % self.name, ('W', 'A'), 'A') while True: count = 0 while True: count += 1 print "Element %d in %s" % (count, self.name) name = get_options('Element Symbol:', 'els') line = get_options('Lowest Excited X-Ray Line:', 'lines') self.els.append(AtomicElement(name, line)) if how.upper() == 'W': self.els[-1].wtfract = get_nums('Weight Fraction:', 1) else: self.els[-1].atform = get_nums('Atomic Formula:', 100) print ("Entered so far: %s" % ' '.join([el.name for el in self.els])) if not yes_no("Add another element? (Y/N)"): break if how.upper() == 'A': wtfracs = wtfract(self.els, [el.atform for el in self.els]) for x, _ in enumerate(wtfracs): self.els[x].wtfrac = wtfracs[x] print ('%s compound standard: els, weight fractions:' % self.name) print "\t".join([self.els[x].name for x in range(0, len(self.els))]) print "\t".join([str(round(el.wtfrac, 5)) for el in self.els]) if yes_no("Is this correct?\n(restarts if no)(Y/N):", False): break data = "" for i in range(0, len(self.els)): data += "\t%s\t%s\t%s" % (self.els[i].name, self.els[i].line, self.els[i].wtfrac) towrite = "%s%s\n" % (self.name, data) with open('empastds.txt', 'a') as myfile: myfile.write(towrite)