OpenPTV / postptv

Post processing routines for analysing PTV data.
GNU General Public License v3.0
14 stars 13 forks source link

Iterate ptv_is trajectories instead of reading entire list at once. #4

Closed yosefm closed 10 years ago

yosefm commented 10 years ago

Default for trajectories() and trajectories_ptvis() is still to read everything to memory, but now you can use iter_trajectories_ptvis() or trajectories(..., iter_allowed=True) to get an iterator. Then when you iterate over trajectories in a for loop, they are read only when needed and forgotten immediately after. See this used in save_particles_table().

Also in: finally, a test for reading ptv_is files.

alexlib commented 10 years ago

In order to run nosetests I had to add the tests/ to the directory on line 18 in test_io.py

self.tmpl = "tests/testing_fodder/ptvis/ptv_is.%d"

Patch is here:

http://pastebin.com/YKfdEwXV

alexlib commented 10 years ago

the tmp.py fails on the line that uses forward difference, when the traj_len is not defined. it's possible to default the traj_min_len = 2

The patch is here:

http://pastebin.com/y6cRVG2b

and fixed in my branch.

yosefm commented 10 years ago

Alex, what is tmp.py? At any rate, since we don't do the forward-difference thing for xuap files, a better solution would be to default it to None, then select based on the format. I'll do a commit implementing this in a sec.

yosefm commented 10 years ago

Ok, please test the two new commits and if everything is ok, I'll merge.

alexlib commented 10 years ago

I added this failing test to tests_io.py the problem is with reading the xuap files as there we estimate acceleration, and then the traj_min_length shall not be None, but at least 2

diff --git a/tests/test_io.py b/tests/test_io.py index c37ab94..c3de99a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -49,4 +49,15 @@ class TestPtvis(unittest.TestCase): nptest.assert_array_almost_equal(trj.accel(), correct.accel()) nptest.assert_array_almost_equal(trj.time(), correct.time()) self.failUnlessEqual(trj.trajid(), correct.trajid())

alexlib commented 10 years ago

The following patch resolves the problem with the xuap files:

diff --git a/flowtracks/io.py b/flowtracks/io.py index 31759fe..9e87d91 100644 --- a/flowtracks/io.py +++ b/flowtracks/io.py @@ -247,7 +247,7 @@ def iter_trajectories_ptvis(fname, first=None, last=None, frate=1., xuap=False, ('pos_int', '3f8'), ('vel', '3f8'), ('acc', '3f8')]) skip = 0 count_base = 1

alexlib commented 10 years ago

created a separate pull request from my branch to your branch.

yosefm commented 10 years ago

Ok, I see that the problem was with the acceleration calculation, so xuap also needs 2 frames min. Merged with your fix. Thanks for the test!