Exemplo n.º 1
0
def simLineInMatrixLimScan(lin,
                           linMat,
                           blk,
                           blkMat,
                           nmLinWid,
                           umBlock,
                           nmScan,
                           nPts,
                           trs,
                           outDir,
                           hdr,
                           det,
                           e0,
                           lt,
                           pc,
                           withPoisson=True,
                           nTraj=100,
                           sf=True,
                           bf=True,
                           iDigits=5,
                           bVerbose=False,
                           xtraParams={}):
    """simLineInMatrixLimScan(lin, linMat, blk, blkMat, nmLinWid, umBlock,
	nmScan, nPts, trs, outDir, hdr, det, e0, lt, pc, withPoisson=True,
	nTraj=nTraj, sf=True, bf=True, iDigits=5, bVerbose=False,
	xtraParams={})

	Simulate a line of width `nmLinWid' nm at the center of a block of
	`umBlock' microns. The line is of material `lin' with a name `linMat'.
	The block is of material `blk' with a name `blkMat'. We step a total
	distance of nmScan across the center of the line.

	We analyze an list `trs' of transitions, writing the K-ratios to a
	.csv file with a header `hdr'. We use the detector `det', voltage `e0'
	(kV) and live time `lt' sec and probe current  `pc' nA. This will
	compute the standard spectra, compute the spectra the scanned
	region. It will then compute the K-ratios for each spectrum and write
	them to a file `name' in outDir with a header `hdr' that matches the
	transition order.
	"""
    # order is order of trs..
    sc = 1.0e-6  # scale from microns to meters for positions
    dose = lt * pc
    lX = []  # an array for postions
    lKlin = []  # an array for the K-ratio of the line
    lKblk = [
    ]  # an array for the K-ratio of the block. Title correspond to hdr string
    umLine = nmLinWid * 1.0e-3
    # start clean
    dt2.DataManager.clearSpectrumList()
    # create the standards
    linStd = simulateBulkStandard(lin,
                                  linMat,
                                  det,
                                  e0,
                                  lt,
                                  pc,
                                  withPoisson=withPoisson,
                                  nTraj=nTraj,
                                  sf=sf,
                                  bf=bf,
                                  xtraParams={})
    dt2.display(linStd)
    blkStd = simulateBulkStandard(blk,
                                  blkMat,
                                  det,
                                  e0,
                                  lt,
                                  pc,
                                  withPoisson=withPoisson,
                                  nTraj=nTraj,
                                  sf=sf,
                                  bf=sf,
                                  xtraParams={})
    dt2.display(blkStd)
    lStd = {"El": dt2.element(linMat), "Spc": linStd}
    bStd = {"El": dt2.element(blkMat), "Spc": blkStd}
    stds = [lStd, bStd]  # note: put the transitions in this order
    iCount = 0
    for x in range(-nPts / 2, (nPts / 2) + 1, 1):
        xPosNm = x * nmScan / nPts
        lX.append(round(xPosNm, iDigits))
        xtraParams = {}
        xtraParams.update(
            mc3.configureXRayAccumulators(trs,
                                          charAccum=sf,
                                          charFluorAccum=sf,
                                          bremFluorAccum=bf))
        xtraParams.update(mc3.configureOutput(outDir))
        xtraParams.update(mc3.configureBeam(xPosNm * 1.0e-09, 0, -0.099, 1.0))
        spec = mc3.embeddedRectangle(lin,
                                     [umLine * sc, umBlock * sc, umBlock * sc],
                                     blk,
                                     0,
                                     det,
                                     e0,
                                     withPoisson=withPoisson,
                                     nTraj=nTraj,
                                     dose=dose,
                                     sf=sf,
                                     bf=bf,
                                     xtraParams=xtraParams)
        props = spec.getProperties()
        props.setNumericProperty(epq.SpectrumProperties.LiveTime, lt)
        props.setNumericProperty(epq.SpectrumProperties.FaradayBegin, pc)
        props.setNumericProperty(epq.SpectrumProperties.FaradayEnd, pc)
        props.setNumericProperty(epq.SpectrumProperties.BeamEnergy, e0)
        spcName = "x = %.3f um" % x
        epq.SpectrumUtils.rename(spec, spcName)
        spec = epq.SpectrumUtils.addNoiseToSpectrum(spec, 1.0)
        # display(spec)
        a = jmg.compKRs(spec, stds, trs, det, e0)
        iCount += 1
        print(iCount, xPosNm)
        lKlin.append(round(a[0], iDigits))
        lKblk.append(round(a[1], iDigits))

    basFile = "%gnm-%s-in-%gum-%s-%gkV-%g-Traj.csv" % (
        nmLinWid, linMat, umBlock, blkMat, e0, nTraj)
    strOutFile = outDir + "/" + basFile
    f = open(strOutFile, 'w')
    strLine = hdr + '\n'
    f.write(strLine)
    for i in range(iCount):
        strLine = "%.3f" % lX[i] + ","
        strLine = strLine + "%.5f" % lKlin[i] + ","
        strLine = strLine + "%.5f" % lKblk[i] + "\n"
        f.write(strLine)
    f.close()
Exemplo n.º 2
0
wd = homDir + relPrj + "/py/dtsa"
os.chdir(wd)
pyrDir = wd + "/simPdLineInCuMatrix Results"

#start clean
DataManager.clearSpectrumList()


# xrts=mc3.suggestTransitions("PdCu")

xrts = [epq.XRayTransition(epq.Element.Cu, epq.XRayTransition.LA1), epq.XRayTransition(epq.Element.Pd, epq.XRayTransition.LA1)]

xtraParams={}
xtraParams.update(mc3.configureXRayAccumulators(xrts, charAccum=charF, charFluorAccum=charF, bremFluorAccum=bremF))
xtraParams.update(mc3.configureOutput(simDir))
xtraParams.update(mc3.configureBeam(0.5*nmLinWid*1.0e-9, 0, -0.099, 1.0))
# xtraParams.update(mc3.configureGun(gun))
# mc3.useHeatMapPalette()

print(xtraParams)

# spc = jm3.lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0, withPoisson=True, nTraj=nTraj, dose=dose, sf=charF, bf=bremF, xtraParams=xtraParams)
# spc = jm3.lineInMatrix(lin, blk, nmLinWid, umBlock, det, e0, poisN, nTraj, dose, charF, bremF, xtraParams)
#e0=20.0, dose=defaultDose, withPoisson=poisN, nTraj=defaultNumTraj, sf=defaultCharFluor, bf=defaultBremFluor, xtraParams=defaultXtraParams):
# spc = mc3.simulate(blk, det, e0, dose, poisN, nTraj, charF, bremF, xtraParams)
#
# Embedded Rectangle
#
# This works as expected.
# spc = mc3.embeddedRectangle(lin, [umLine*sc, umBlock*sc, umBlock*sc], blk, 0, det, e0, withPoisson=poisN, nTraj=nTraj, dose=dose, sf=charF, bf=bremF, xtraParams=xtraParams)
# 
Exemplo n.º 3
0
def simLineInMatrixLimScan(lin, linMat, blk, blkMat, nmLinWid, umBlock,nmScan, nPts, trs, outDir, hdr, det, e0, lt, pc, withPoisson=True, nTraj=100, sf=True, bf=True, iDigits=5, bVerbose=False, xtraParams={}):
    """simLineInMatrixLimScan(lin, linMat, blk, blkMat, nmLinWid, umBlock,
    nmScan, nPts, trs, outDir, hdr, det, e0, lt, pc, withPoisson=True,
    nTraj=nTraj, sf=True, bf=True, iDigits=5, bVerbose=False,
    xtraParams={})

    Simulate a line of width `nmLinWid' nm at the center of a block of
    `umBlock' microns. The line is of material `lin' with a name `linMat'.
    The block is of material `blk' with a name `blkMat'. We step a total
    distance of nmScan across the center of the line.

    We analyze an list `trs' of transitions, writing the K-ratios to a
    .csv file with a header `hdr'. We use the detector `det', voltage `e0'
    (kV) and live time `lt' sec and probe current  `pc' nA. This will
    compute the standard spectra, compute the spectra the scanned
    region. It will then compute the K-ratios for each spectrum and write
    them to a file `name' in outDir with a header `hdr' that matches the
    transition order.
    """
    # order is order of trs..
    sc = 1.0e-6 # scale from microns to meters for positions
    dose = lt*pc
    lX = [] # an array for postions
    lKlin = [] # an array for the K-ratio of the line
    lKblk = [] # an array for the K-ratio of the block. Title correspond to hdr string
    umLine = nmLinWid * 1.0e-3
    # start clean
    dt2.DataManager.clearSpectrumList()
    # create the standards
    linStd = simulateBulkStandard(lin, linMat, det, e0, lt, pc, withPoisson=withPoisson, nTraj=nTraj, sf=sf, bf=bf, xtraParams={})
    dt2.display(linStd)
    blkStd = simulateBulkStandard(blk, blkMat, det, e0, lt, pc, withPoisson=withPoisson, nTraj=nTraj, sf=sf, bf=sf, xtraParams={})
    dt2.display(blkStd)
    lStd = {"El":dt2.element(linMat), "Spc":linStd}
    bStd = {"El":dt2.element(blkMat), "Spc":blkStd}
    stds = [lStd, bStd] # note: put the transitions in this order
    iCount = 0
    for x in range(-nPts/2, (nPts/2)+1, 1):
        xPosNm = x * nmScan / nPts
        lX.append(round(xPosNm, iDigits))
        xtraParams={}
        xtraParams.update(mc3.configureXRayAccumulators(trs, charAccum=sf, charFluorAccum=sf, bremFluorAccum=bf))
        xtraParams.update(mc3.configureOutput(outDir))
        xtraParams.update(mc3.configureBeam(xPosNm*1.0e-09, 0, -0.099, 1.0))
        spec = mc3.embeddedRectangle(lin, [umLine*sc, umBlock*sc, umBlock*sc], blk, 0, det, e0, withPoisson=withPoisson, nTraj=nTraj, dose=dose, sf=sf, bf=bf, xtraParams=xtraParams)
        props = spec.getProperties()
        props.setNumericProperty(epq.SpectrumProperties.LiveTime, lt)
        props.setNumericProperty(epq.SpectrumProperties.FaradayBegin, pc)
        props.setNumericProperty(epq.SpectrumProperties.FaradayEnd, pc)
        props.setNumericProperty(epq.SpectrumProperties.BeamEnergy, e0)
        spcName = "x = %.3f um" % x
        epq.SpectrumUtils.rename(spec, spcName)
        spec = epq.SpectrumUtils.addNoiseToSpectrum(spec, 1.0)
        # display(spec)
        a = jmg.compKRs(spec, stds, trs, det, e0)
        iCount += 1
        print(iCount, xPosNm)
        lKlin.append(round(a[0], iDigits))
        lKblk.append(round(a[1], iDigits))

    basFile ="%gnm-%s-in-%gum-%s-%gkV-%g-Traj.csv" % (nmLinWid, linMat, umBlock, blkMat, e0, nTraj)
    strOutFile = outDir + "/" + basFile
    f=open(strOutFile, 'w')
    strLine = hdr + '\n'
    f.write(strLine)
    for i in range(iCount):
        strLine = "%.3f" % lX[i] + ","
        strLine = strLine + "%.5f" % lKlin[i] + ","
        strLine = strLine + "%.5f" % lKblk[i] + "\n" 
        f.write(strLine)  
    f.close()