... | @@ -4,26 +4,31 @@ Logger reader |
... | @@ -4,26 +4,31 @@ Logger reader |
|
Here we will describe quickly the API that we wish to provide for the logger.
|
|
Here we will describe quickly the API that we wish to provide for the logger.
|
|
|
|
|
|
```python
|
|
```python
|
|
# Read some fields for some particles.
|
|
|
|
|
|
|
|
# We go to the last index file, find the correct ids -> offset
|
|
with logger.Reader(basename, use_cache=False) as f:
|
|
# then we read the logfile.
|
|
# Activate the cache
|
|
positions, velocities = logger.loadFieldsFromParticles(
|
|
f.use_cache = True
|
|
basename, ["Coordinates", "Velocities"], time, particle_ids)
|
|
|
|
|
|
|
|
# Read a given set of fields.
|
|
# At the end of each function, we store in f an array of (k?) offset / time in order
|
|
|
|
# to quickly access the records next time.
|
|
|
|
|
|
# Same as before, but we use all the ids from the index file.
|
|
# Read some fields for some particles.
|
|
positions, velocities = logger.loadFields(basename, ["Coordinates", "Velocities"], time)
|
|
positions, velocities = f.getParticleData(
|
|
|
|
fields=["Coordinates", "Velocities"], time=time, ids=particle_ids)
|
|
|
|
|
|
# Read all the fields of all the particles in the logfile.
|
|
# Same as before, but we use all the ids from the index file.
|
|
|
|
positions, velocities = logger.getParticleData(
|
|
|
|
fields=["Coordinates", "Velocities"], time=time, ids=None)
|
|
|
|
|
|
# Same as before, but we read all the fields.
|
|
# Same as before, but we read all the fields.
|
|
parts = logger.loadSnapshotAtTime(basename, t[0])
|
|
# here we should be fast thanks to the cache.
|
|
|
|
parts = logger.loadSnapshotAtTime(time)
|
|
|
|
print(parts["Coordinates"])
|
|
|
|
|
|
# Move a set of particles forward in time.
|
|
# Move a set of particles forward in time.
|
|
|
|
# here we should be fast thanks to the cache.
|
|
|
|
positions = f.getParticleData(fields=["Coordinates"],
|
|
|
|
time=time + 1, ids=None)
|
|
|
|
|
|
# We use previous offsets in order to move forwards the fields.
|
|
# here we close the logfile and cleanup everything
|
|
interp = logger.moveForwardInTime(basename, parts, time)
|
|
|
|
|
|
|
|
``` |
|
``` |
|
|
|
\ No newline at end of file |