def getPTop(h5pFile, pId): t, x = lfmpp.getH5pid(h5pFile, "x", pId) t, y = lfmpp.getH5pid(h5pFile, "y", pId) t, Om = lfmpp.getH5pid(h5pFile, "Om", pId) t, Op = lfmpp.getH5pid(h5pFile, "Op", pId) Omp = (Om + Op) return x, y, Omp
def getP(h5pDir, h5pStub, pId, vId="kev", tCut=1.0e+8): h5pFile = h5pDir + "/" + h5pStub t, x = lfmpp.getH5pid(h5pFile, "x", pId) t, y = lfmpp.getH5pid(h5pFile, "y", pId) t, V = lfmpp.getH5pid(h5pFile, vId, pId) t, al = lfmpp.getH5pid(h5pFile, "alpha", pId) A0 = al[0] t0 = t[0] Ind = (t <= t0 + tCut) return x[Ind], y[Ind], V[Ind], A0
def getKM(h5pDir, h5pStub, pId, Sk=1): h5pFile = h5pDir + "/" + h5pStub t, K = lfmpp.getH5pid(h5pFile, "kev", pId) t, Mu = lfmpp.getH5pid(h5pFile, "Mu", pId) #Cut out bad values Ind = (Mu > 1.0e-8) & (~np.isnan(Mu)) Mu = Mu[Ind] K = K[Ind] Kp = K / K[0] Mp = Mu / Mu[0] Kp = Kp[0:-1:Sk] Mp = Mp[0:-1:Sk] return K / K[0], Mu / Mu[0]
def getMPX(h5pFile, IDs): Np = len(IDs) tSlcs = np.zeros(Np, dtype=np.int) for n in range(Np): pID = IDs[n] t, tCr = lfmpp.getH5pid(h5pFile, "tCr", pID) I = (tCr > 0).argmax() tSlcs[n] = I return tSlcs
#How many fields to trace NumT = 30 #How many to trace tRadFld = 0.00125 #Field line thickness tRadTrj = 0.0025 #Particle trajectory thickness FldCmap = "Autumn" #Winter,YlGnBu,YlGn SlcCmap = "viridis" #Read some data from file pId = 0 #Only using single particle H5ps # t,tCr = lfmpp.getH5pid(SrcP,"tCr",pId) # t,xCr = lfmpp.getH5pid(SrcP,"xCr",pId) # t,yCr = lfmpp.getH5pid(SrcP,"yCr",pId) # t,zCr = lfmpp.getH5pid(SrcP,"zCr",pId) t, xP = lfmpp.getH5pid(SrcP, "x", pId) t, yP = lfmpp.getH5pid(SrcP, "y", pId) t, zP = lfmpp.getH5pid(SrcP, "z", pId) t, mp = lfmpp.getH5pid(SrcP, "mp", pId) #Pick trajectory points to trace at i0 = 0 #First step i1 = mp.argmax() #Last step before loss from sim print(i0, i1) # I = random.sample(range(i0,i1),NumT) # I.sort() Ns = len(I) #Number of seeds print("Particle alive between %f and %f" % (t[i0], t[i1])) print("Using %d seeds from crossings" % (Ns))
Np = len(pIDs[0]) fig, Ax = plt.subplots(figsize=figSize, nrows=3, sharex=False) #Ax2 = Ax1.twinx() Ax1 = Ax[0] Ax2 = Ax[1] Ax3 = Ax[2] ns = 0 for s in range(Ns): h5P = Base + h5Ps[s] ids = pIDs[s] for n in range(Np): idn = ids[n] t, K = lfmpp.getH5pid(h5P, "kev", idn) t, xeq = lfmpp.getH5pid(h5P, "xeq", idn) t, yeq = lfmpp.getH5pid(h5P, "yeq", idn) t, Mu = lfmpp.getH5pid(h5P, "Mu", idn) dMu = (Mu - Mu[0]) / Mu[0] L = np.sqrt(xeq**2.0 + yeq**2.0) pT = pC[ns] Lab = "%s (%d)" % (sLab[s], idn) Ax1.plot(t, K, pT, label=Lab, linewidth=LW) Ax2.plot(t, L, pT, linewidth=LW) Ax3.plot(t, dMu, pT, linewidth=LW) ns = ns + 1 Ax1.legend(loc="lower right", fontsize="small", ncol=2)
doProd = True Quiet = False User = True SrcF = "fld.vti" #SrcF = "fldLorez.vti" if (doSingle): SrcP = "pZoom.h5part" #SrcP = "../H100/H.100keV.ZoomID.000010.h5part" SrcP = "../H100/H.100keV.ZoomID." + "%06d" % pId + ".h5part" pId = 0 else: SrcP = "prt.h5part" t, tCr = lfmpp.getH5pid(SrcP, "tCr", pId) t, xCr = lfmpp.getH5pid(SrcP, "xCr", pId) t, yCr = lfmpp.getH5pid(SrcP, "yCr", pId) t, zCr = lfmpp.getH5pid(SrcP, "zCr", pId) t, xP = lfmpp.getH5pid(SrcP, "x", pId) t, yP = lfmpp.getH5pid(SrcP, "y", pId) t, zP = lfmpp.getH5pid(SrcP, "z", pId) t, mp = lfmpp.getH5pid(SrcP, "mp", pId) #Find unique MP crossings mpT, I = np.unique(tCr, return_index=True) print("Found %d MP crossings" % (len(I) - 1)) #Ix = I[1::Nstrd] #Remove null point #i0 = Ix[0] #Use first MPX