read in all the particle data from a file and add each particle instance to the _particleDict dictionary, grouping all of the history for a unique particle (identified by the pid and originCPU) together in a particle object in the dictionary
(maestroParticleFiles)
| 293 | |
| 294 | #----------------------------------------------------------------------------- |
| 295 | def parseParticleFile(maestroParticleFiles): |
| 296 | """ |
| 297 | read in all the particle data from a file and add each particle |
| 298 | instance to the _particleDict dictionary, grouping all of the |
| 299 | history for a unique particle (identified by the pid and |
| 300 | originCPU) together in a particle object in the dictionary |
| 301 | """ |
| 302 | |
| 303 | haveHeader = 0 |
| 304 | |
| 305 | for maestroParticleFile in ensure_list(maestroParticleFiles): |
| 306 | |
| 307 | # read the file line by line |
| 308 | mf = open(maestroParticleFile, "r") |
| 309 | |
| 310 | for line in mf: |
| 311 | |
| 312 | # skip blank lines |
| 313 | if line.isspace(): continue |
| 314 | |
| 315 | # look for a header information |
| 316 | if (line.startswith("#")): |
| 317 | |
| 318 | # store old header, if it exists |
| 319 | if (haveHeader == 1): |
| 320 | oldHeader = list(dataNames) # list() makes a copy |
| 321 | |
| 322 | |
| 323 | fields = string.split(line[1:]) |
| 324 | |
| 325 | # make sure we know what we are doing -- the first 2 |
| 326 | # fields should be the particle ID and origin CPU |
| 327 | if (fields[0] == "part-ID" and fields[1] == "origin-CPU"): |
| 328 | ipid = 0 |
| 329 | ioCPU = 1 |
| 330 | |
| 331 | else: |
| 332 | print "ERROR: particle file columns not in expected order" |
| 333 | sys.exit(2) |
| 334 | |
| 335 | |
| 336 | # the next fields should be x, y, and z, depending on the |
| 337 | # dimensionality |
| 338 | if (fields[2] == "x" and fields[3] == "y" and |
| 339 | fields[4] == "z"): |
| 340 | dim = 3 |
| 341 | ix = 2 |
| 342 | |
| 343 | elif (fields[2] == "x" and fields[3] == "y"): |
| 344 | dim = 2 |
| 345 | ix = 2 |
| 346 | |
| 347 | elif (fields[2] == "x"): |
| 348 | dim = 1 |
| 349 | ix = 2 |
| 350 | |
| 351 | else: |
| 352 | print "ERROR: particle file columns not in expected order" |
nothing calls this directly
no test coverage detected