(files)
| 10 | |
| 11 | #----------------------------------------------------------------------------- |
| 12 | def main(files): |
| 13 | |
| 14 | # this returns a dict whose keys are a unique identifier (based on |
| 15 | # id and CPU) and values are the actual particle objects |
| 16 | particlesDict = parseparticles.parseParticleFile(files) |
| 17 | |
| 18 | # get just the particle objects |
| 19 | particles = particlesDict.values() |
| 20 | |
| 21 | |
| 22 | # print out some info and test the routines |
| 23 | print "number of unique particles = ", len(particles) |
| 24 | |
| 25 | |
| 26 | # output particle instance info (debugging) |
| 27 | #n = 0 |
| 28 | #while (n < len(particles)): |
| 29 | # print n |
| 30 | # print particles[n] |
| 31 | # print " " |
| 32 | # n += 1 |
| 33 | |
| 34 | |
| 35 | # dump out the data, particle-by-particle |
| 36 | n = 0 |
| 37 | while (n < len(particles)): |
| 38 | |
| 39 | # get numpy arrays containing the time and coordinate |
| 40 | # information for particle 0 |
| 41 | coords, time = particles[n].flatten() |
| 42 | dim = particles[n].dim |
| 43 | |
| 44 | # output to a file |
| 45 | of = open("particle_history.%03d" % (n), 'w') |
| 46 | |
| 47 | # header |
| 48 | # first the particle id information |
| 49 | idstuff = str(particles[n]) |
| 50 | for line in idstuff.split("\n"): |
| 51 | of.write("# %s\n" % (line)) |
| 52 | |
| 53 | # next the column labels |
| 54 | if (dim == 1): |
| 55 | of.write("# %20s %20s\n" % ("time", "x")) |
| 56 | elif (dim == 2): |
| 57 | of.write("# %20s %20s %20s\n" % ("time", "x", "y")) |
| 58 | elif (dim == 3): |
| 59 | of.write("# %20s %20s %20s %20s\n" % ("time", "x", "y", "z")) |
| 60 | |
| 61 | |
| 62 | # t, x, [y, [z]] in columns |
| 63 | i = 0 |
| 64 | while (i < len(particles[n].history)): |
| 65 | |
| 66 | if (dim == 1): |
| 67 | of.write(" %20.10f %20.10f\n" % |
| 68 | (time[i], coords[0,i])) |
| 69 | elif (dim == 2): |
no test coverage detected