Exemple #1
0
def anaMcNiCuKa(spc, det, stdBase, maxCh=1200):
  props=spc.getProperties()
  e0 = props.getNumericProperty(epq.SpectrumProperties.BeamEnergy)
  lt = props.getNumericProperty(epq.SpectrumProperties.LiveTime)
  pc = props.getNumericProperty(epq.SpectrumProperties.FaradayBegin)
  wkDst = props.getNumericProperty(epq.SpectrumProperties.WorkingDistance)
  spc = jmg.cropSpec(spc, end=maxCh)
  unSpc = jmg.updateCommonSpecProps(spc, det, liveTime=lt, probeCur=pc, e0=e0, wrkDist=wkDst)
  dt2.display(unSpc)
  
  # define the transitions I want to measure
  tsNiKa = epq.XRayTransitionSet(epq.Element.Ni, epq.XRayTransitionSet.K_FAMILY)
  tsCuKa = epq.XRayTransitionSet(epq.Element.Cu, epq.XRayTransitionSet.K_FAMILY)
  trs = [tsNiKa, tsCuKa]
  relStd = "/%gkV/" % (e0)
  stdDir = stdBase + relStd
  niFile = stdDir + "Ni-sim.msa"
  cuFile = stdDir + "Cu-sim.msa"

  spc = dt2.wrap(ept.SpectrumFile.open(niFile)[0])
  props=spc.getProperties()
  e0 = props.getNumericProperty(epq.SpectrumProperties.BeamEnergy)
  lt = props.getNumericProperty(epq.SpectrumProperties.LiveTime)
  pc = props.getNumericProperty(epq.SpectrumProperties.FaradayBegin)
  wkDst = props.getNumericWithDefault(epq.SpectrumProperties.WorkingDistance, wkDst)
  spc = jmg.cropSpec(spc, end=maxCh)
  niSpc = jmg.updateCommonSpecProps(spc, det, liveTime=lt, probeCur=pc, e0=e0, wrkDist=wkDst)
  dt2.display(niSpc)

  spc = dt2.wrap(ept.SpectrumFile.open(cuFile)[0])
  props=spc.getProperties()
  e0 = props.getNumericProperty(epq.SpectrumProperties.BeamEnergy)
  lt = props.getNumericProperty(epq.SpectrumProperties.LiveTime)
  pc = props.getNumericProperty(epq.SpectrumProperties.FaradayBegin)
  wkDst = props.getNumericWithDefault(epq.SpectrumProperties.WorkingDistance, wkDst)
  spc = jmg.cropSpec(spc, end=maxCh)
  cuSpc = jmg.updateCommonSpecProps(spc, det, liveTime=lt, probeCur=pc, e0=e0, wrkDist=wkDst)
  dt2.display(cuSpc)
  niStd = {"El":dt2.element("Ni"), "Spc":niSpc}
  cuStd = {"El":dt2.element("Cu"), "Spc":cuSpc}
  stds  = [niStd, cuStd]
  theKR = jmg.compKRs(unSpc, stds, trs, det, e0)
  krNiCalc = theKR[0]
  krCuCalc = theKR[1]
  return [krNiCalc, krCuCalc]
Exemple #2
0
lNm=[]
lKCK=[]
lKCuL=[]

for i in range(500):
    tNmC = float(i+1)
    lNm.append(tNmC)
    sLay = [[c, tNmC/1.0e9], [cu, 100.0]]
    sSpc = mc3.multiFilm(sLay, det, e0=e0, withPoisson=True, nTraj=nTraj, dose=dose, sf=charF, bf=bremF, xtraParams={})
    sp=sSpc.getProperties()
    sp.setTextProperty(epq.SpectrumProperties.SpectrumDisplayName,"%g-nm-C-on-Cu"% tNmC)
    sp.setNumericProperty(epq.SpectrumProperties.LiveTime, lt)
    sp.setNumericProperty(epq.SpectrumProperties.FaradayBegin, dose)
    sp.setNumericProperty(epq.SpectrumProperties.FaradayEnd, dose)
    # display(sSpc)
    a = jmg.compKRs(sSpc, stds, trs, det, e0)
    lKCK.append(a[0])
    lKCuL.append(a[1])
    print (i+1)

# prepare the output file
csvPath = csvDir + "/sim-C-on-Cu-%gkV.csv" % e0
f=open(csvPath, 'w')
strLine = 'tNm, kCKa, kCuLa\n'
f.write(strLine)
l = len(lNm)
for i in range(l):
    strLine = '%.1f, %.5f, %.5f\n' % (lNm[i], lKCK[i], lKCuL[i])
    f.write(strLine)

f.close()
Exemple #3
0
def simLineInMatrix(lin,
                    linMat,
                    blk,
                    blkMat,
                    nmLinWid,
                    umBlock,
                    nPts,
                    trs,
                    outDir,
                    hdr,
                    det,
                    e0,
                    lt,
                    pc,
                    withPoisson=True,
                    nTraj=100,
                    sf=True,
                    bf=True,
                    iDigits=5,
                    bVerbose=False,
                    xtraParams={}):
    """simLineInMatrix(lin, linMat, blk, blkMat, nmLinWid, umBlock, 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 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 for nPts+1 from
	-nPts/2 ... 0 ...nPts/2 times the block size. 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
    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
    # start clean
    dt2.DataManager.clearSpectrumList()
    # create the standards
    linStd = simulateBulkStandard(lin,
                                  linMat,
                                  det,
                                  e0,
                                  lt,
                                  pc,
                                  withPoisson=True,
                                  nTraj=nTraj,
                                  sf=True,
                                  bf=True,
                                  xtraParams={})
    dt2.display(linStd)
    blkStd = simulateBulkStandard(blk,
                                  blkMat,
                                  det,
                                  e0,
                                  lt,
                                  pc,
                                  withPoisson=True,
                                  nTraj=nTraj,
                                  sf=True,
                                  bf=True,
                                  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):
        xv = sc * x * umBlock / nPts
        lX.append(round(x * umBlock / nPts, iDigits))
        monte = nm.MonteCarloSS()
        monte.setBeamEnergy(epq.ToSI.keV(e0))
        # use a 1 nm probe
        beam = nm.GaussianBeam(1.0e-9)
        monte.setElectronGun(beam)
        beam.setCenter([xv, 0.0, -0.05])
        # createBlock(double[] dims, double[] point, double phi, double theta, double psi)
        # createBlock - Create a block of:
        #		  dimensions specified in dims,
        #		  centered at point,
        #		  then rotated by the euler angles phi, theta, psi.
        block = nm.MultiPlaneShape.createBlock(
            [umBlock * 1.0e-6, umBlock * 1.0e-6, umBlock * 1.0e-6],
            [0.0, 0.0, 0.5 * umBlock * 1.0e-6], 0.0, 0.0, 0.0)
        matrix = monte.addSubRegion(monte.getChamber(), blk, block)
        monte.addSubRegion(
            matrix, lin,
            nm.MultiPlaneShape.createBlock(
                [1.0e-9 * nmLinWid, umBlock * 1.0e-6, umBlock * 1.0e-6],
                [0.0, 0.0, 0.5 * umBlock * 1.0e-6], 0.0, 0.0, 0.0))
        det.reset()
        # Add event listeners to model characteristic radiation
        chXR = nm3.CharacteristicXRayGeneration3.create(monte)
        xrel = nm3.XRayTransport3.create(monte, det, chXR)
        brXR = nm3.BremsstrahlungXRayGeneration3.create(monte)
        brem = nm3.XRayTransport3.create(monte, det, brXR)
        fxg3 = nm3.FluorescenceXRayGeneration3.create(monte, chXR)
        chSF = nm3.XRayTransport3.create(monte, det, fxg3)
        brSF = nm3.XRayTransport3.create(
            monte, det, nm3.FluorescenceXRayGeneration3.create(monte, brXR))
        # here is where we run the simulation
        monte.runMultipleTrajectories(nTraj)
        spec = det.getSpectrum((lt * pc * 1.0e-9) /
                               (nTraj * epq.PhysicalConstants.ElectronCharge))
        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)
        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 = "%.5f" % lX[i] + ","
        strLine = strLine + "%.5f" % lKlin[i] + ","
        strLine = strLine + "%.5f" % lKblk[i] + "\n"
        f.write(strLine)
    f.close()
Exemple #4
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()
Exemple #5
0
                         det,
                         e0=e0,
                         withPoisson=True,
                         nTraj=nTraj,
                         dose=dose,
                         sf=charF,
                         bf=bremF,
                         xtraParams={})
    sp = sSpc.getProperties()
    sp.setTextProperty(epq.SpectrumProperties.SpectrumDisplayName,
                       "%g-nm-Au-on-Cu" % tNmAu)
    sp.setNumericProperty(epq.SpectrumProperties.LiveTime, lt)
    sp.setNumericProperty(epq.SpectrumProperties.FaradayBegin, dose)
    sp.setNumericProperty(epq.SpectrumProperties.FaradayEnd, dose)
    display(sSpc)
    a = jmg.compKRs(sSpc, stds, trs, det, e0)
    print(a[0])
    print(a[1])
    lKAuL.append(a[0])
    lKCuK.append(a[1])
    print(i + 1)

# prepare the output file
csvPath = csvDir + "/sim-Au-on-Cu-%g-kV-%g-steps-%g-nm.csv" % (e0, nSteps,
                                                               tNmStep)
f = open(csvPath, 'w')
strLine = 'tNm, kAuLaMu, kAuLaStd, kCuKaMu, kCuKaStd\n'
f.write(strLine)
l = len(lNm)
for i in range(l):
    strLine = '%.1f, %.5f, %.5f, %.5f, %.5f\n' % (
    msg = "Simulating %g nm C on Fe at %g kV %g traj" % (tc, e0, nTraj)
    print(msg)
    spc = sim_amc_coated_mat(fe, det, e0, nTraj, lt=lt, pc=pc, tc=tc)
    display(spc)
    sName = "%g-nm-C-on-Fe-%g-kV-%g-traj" % (tc, e0, nTraj)
    fi =  datDir + "/"
    fi += sName
    fi += ".msa"
    if bSaveSpc == True:
        spc.save(fi)
    endCycle = time.time()
    delta = (endCycle-startCycle)/60
    tod = datetime.datetime.now().time()
    msg = "C layer %g of %g required %.3f min %s" % (i, nSpec, delta, tod)
    print msg
    res = jmg.compKRs(spc, stds, trs, det, e0)
    print(res)
    lNmC.append(tc)
    lkC.append(round(res[0], 5))
    lkFe.append(round(res[1], 5))

nMeas = len(lkFe)
f = open(csvFil, 'w')
strLine = 't.nm, kC, kFe\n'
f.write(strLine)
for i in range(nMeas):
    strLine = "%g" % lNmC[i] + ","
    strLine = strLine + "%.5f" % lkC[i] + ","
    strLine = strLine + "%.5f" % lkFe[i] + "\n"
    f.write(strLine)  
f.close()
Exemple #7
0
l_nm_C = []
l_kC_mu  = []
l_kC_unc  = []
l_kFe_mu = []
l_kFe_unc = []

for tc in lNmCsim:
    sName = "%g-nm-C-on-Fe-%g-kV-%g-traj" % (tc, e0, nTraj)
    fi =  datDir + "/"
    fi += sName
    fi += ".msa"
    # print(fi)
    spc = readSpectrum(fi)
    display(spc)
    kr = jmg.compKRs(spc, stds, trs, det, e0, digits=5)
    l_nm_C.append(tc)
    l_kC_mu.append(kr[0][0])
    l_kC_unc.append(kr[0][1])
    l_kFe_mu.append(kr[1][0])
    l_kFe_unc.append(kr[1][1])
    # print(kr)

f=open(csvFil, 'w')
strLine = 'nm_c,c_ka_mu,c_ka_unc,fe_la_mu,fe_la_unc\n'
f.write(strLine)
for i in range(nSpec):
    strLine = "%g" % l_nm_C[i] + ","
    strLine = strLine + "%.5f" % l_kC_mu[i] + ","
    strLine = strLine + "%.5f" % l_kC_unc[i] + ","
    strLine = strLine + "%.5f" % l_kFe_mu[i] + ","
Exemple #8
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()
Exemple #9
0
def simLineInMatrix(lin, linMat, blk, blkMat, nmLinWid, umBlock, nPts, trs, outDir, hdr, det, e0, lt, pc, withPoisson=True, nTraj=100, sf=True, bf=True, iDigits=5, bVerbose=False, xtraParams={}):
    """simLineInMatrix(lin, linMat, blk, blkMat, nmLinWid, umBlock, 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 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 for nPts+1 from
    -nPts/2 ... 0 ...nPts/2 times the block size. 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
    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
    # start clean
    dt2.DataManager.clearSpectrumList()
    # create the standards
    linStd = simulateBulkStandard(lin, linMat, det, e0, lt, pc, withPoisson=True, nTraj=nTraj, sf=True, bf=True, xtraParams={})
    dt2.display(linStd)
    blkStd = simulateBulkStandard(blk, blkMat, det, e0, lt, pc, withPoisson=True, nTraj=nTraj, sf=True, bf=True, 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):
        xv = sc*x*umBlock/nPts
        lX.append(round(x*umBlock/nPts, iDigits))
        monte=nm.MonteCarloSS()
        monte.setBeamEnergy(epq.ToSI.keV(e0))
        # use a 1 nm probe
        beam=nm.GaussianBeam(1.0e-9) 
        monte.setElectronGun(beam)
        beam.setCenter([xv, 0.0,-0.05])
        # createBlock(double[] dims, double[] point, double phi, double theta, double psi)
        # createBlock - Create a block of:
        #          dimensions specified in dims,
        #          centered at point,
        #          then rotated by the euler angles phi, theta, psi.
        block = nm.MultiPlaneShape.createBlock([umBlock*1.0e-6, umBlock*1.0e-6, umBlock*1.0e-6],[0.0,0.0, 0.5*umBlock*1.0e-6],0.0,0.0,0.0)
        matrix = monte.addSubRegion(monte.getChamber(), blk, block)
        monte.addSubRegion(matrix, lin, nm.MultiPlaneShape.createBlock([1.0e-9*nmLinWid, umBlock*1.0e-6, umBlock*1.0e-6],[0.0, 0.0, 0.5*umBlock*1.0e-6],0.0,0.0,0.0))
        det.reset()
        # Add event listeners to model characteristic radiation
        chXR = nm3.CharacteristicXRayGeneration3.create(monte)
        xrel = nm3.XRayTransport3.create(monte, det, chXR)
        brXR = nm3.BremsstrahlungXRayGeneration3.create(monte)
        brem = nm3.XRayTransport3.create(monte, det, brXR)
        fxg3 = nm3.FluorescenceXRayGeneration3.create(monte, chXR)
        chSF = nm3.XRayTransport3.create(monte, det, fxg3)
        brSF = nm3.XRayTransport3.create(monte, det, nm3.FluorescenceXRayGeneration3.create(monte, brXR))
        # here is where we run the simulation
        monte.runMultipleTrajectories(nTraj)
        spec = det.getSpectrum((lt*pc*1.0e-9) / (nTraj * epq.PhysicalConstants.ElectronCharge))
        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)
        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 = "%.5f" % lX[i] + ","
        strLine = strLine + "%.5f" % lKlin[i] + ","
        strLine = strLine + "%.5f" % lKblk[i] + "\n" 
        f.write(strLine)  
    f.close()
    msg = "Simulating %g nm C on Fe3C at %g kV %g traj" % (tc, e0, nTraj)
    print(msg)
    spc = sim_amc_coated_mat(fe3c, det, e0, nTraj, lt=lt, pc=pc, tc=tc)
    display(spc)
    sName = "%g-nm-C-on-Fe3C-%g-kV-%g-traj" % (tc, e0, nTraj)
    fi = basePath + "/"
    fi += sName
    fi += ".msa"
    if bSaveSpc == True:
        spc.save(fi)
    endCycle = time.time()
    delta = (endCycle - startCycle) / 60
    tod = datetime.datetime.now().time()
    msg = "C layer %g of %g required %.3f min %s" % (i, nSpec, delta, tod)
    print msg
    res = jmg.compKRs(spc, stds, trs, det, e0)
    if (bVerbose):
        print(res)
    kc = res[0]
    kcMu = kc[0]
    if (bVerbose):
        print(kcMu)
    kfe = res[1]
    kfeMu = kfe[0]

    if (bVerbose):
        print(kfeMu)
        print(kc)
        print(kfe)
    lNmC.append(tc)
    lkC.append(kcMu)