Hi Walter,
Below is an example of a script that batch simulates films on substrates and saves the spectra. For K-ratios think it uses complex peak deconvolution and peak shape fitting so it would be hard to replicate.
The save command is
resF[fil].save("%s/%s.msa" % ( pathloc, resF[fil] ))
where pathloc is given a few lines up
Ben
import dtsa2 as dtsa2
import dtsa2.mcSimulate3 as mc3
test = {}
volt = 15 # accelerating voltage
det = findDetector("Si(Li)") # Replace with your detector's name
nE = 1000 # Number of electrons simulated
e0 = volt # kV using volt loop - 1st 15kV, then 10 kV
rhoAg = 10.49
# create materials
sAg = epq.Material(epq.Composition(map(dtsa2.element,["Ag"],),[1],"Silver"),epq.ToSI.gPerCC(10.5)) #ToSi converts density g/cc to kg/m3, composition as mass fraction
s316H = epq.Material(epq.Composition(map(dtsa2.element,["Mn","Cr","Mo","Ni","Fe"],),[0.016,0.169,0.022,0.119,0.667],"316H steel"),epq.ToSI.gPerCC(7.8))
# calculate electron range for one of the materials - determining range of x-ray emission images and phi-rho-z
range = dtsa2.electronRange(s316H,e0,density=None)
# set xray transitions
trs = [epq.XRayTransition(epq.Element.Ag, epq.XRayTransition.LB1),
epq.XRayTransition(epq.Element.Fe, epq.XRayTransition.KB1)]
# create samples consisting of silver film on steel (316H) substrate
film = {}
film[1] = [sAg, 0.000000020],[s316H, 0.000010] # 0.000005000 = 5 um 0.000010 = 10um Configuring multi-layers composition and thickness
film[2] = [sAg, 0.000000015],[s316H, 0.000010] # 0.000000050 = 0.05 um
film[3] = [sAg, 0.000000010],[s316H, 0.000010]
xtraP = {}
xtraP = {"Characteristic Accumulator":True, "Char Fluor Accumulator":True, "Brem Fluor Accumulator":True}
xtraP.update(mc3.configureOutput(DefaultOutput))
xtraP.update(mc3.configurePhiRhoZ(1.5*range))
xtraP.update(mc3.configureEmissionImages(trs, 1.5*range, size = 512))
xtraP.update(mc3.configureTrajectoryImage(1.5*range, size = 512))
resF = {}
for fil in film:
extension = str(film[fil][0])
extension = extension.replace("[","")
extension = extension.replace("]","")
extension = extension.replace(",","")
pathloc = 'O:\Documents\PFE_Data\Users\Charles_Younes\\041115_CarbonInSteel\\dtsa2repeat7_' + extension # Change to output folder
xtraP.update(mc3.configureOutput(pathloc))
print xtraP
resF[fil] = mc3.multiFilm(film[fil], det,e0=e0, nTraj=nE, dose=500.0, sf=True, bf=True,xtraParams=xtraP) # run simulations
tmp = str(resF[fil])
tmpx = extension + tmp
resF[fil].rename(tmpx)
resF[fil].save("%s/%s.msa" % ( pathloc, resF[fil] )) # change pathloc above to output folder ( location, name) it adds extension
resF[fil].display()