cleanup of manta loader demo
@@ -3,7 +3,7 @@ import os
# this example tries to load "pressure_XXXXXX.npz" and "vel_XXXXXX.npz" files
-# from the simulations sim_XXXXXX in the given directory
+# from all simulations sim_XXXXXX in the given directory
scene_path = sys.argv[1] if len(sys.argv) >= 2 else '~/phi/data/simpleplume'
scene_path = os.path.expanduser(scene_path)
@@ -29,19 +29,23 @@ class DataLoader(TFModel):
reader = BatchReader( Dataset.load(scene_path) , (MantaScalar('pressure'), 'vel') )
i = 0
+ m = []
for batch in reader.all_batches(batch_size=1):
# batch[0] is a numpy array with pressure now, batch[1] has the velocities
# could be modified here; warning - note uses pressure to density here...
state = smoke.copied_with(density=batch[0], velocity=batch[1])
- self.session.run(state_out, {state_in: state}) # give to TF
+ # collect some statistics
+ m.append( [np.mean(np.abs(state.density.data)) , np.mean(np.abs(state.velocity.staggered_tensor()))] )
+
+ self.session.run(state_out, {state_in: state}) # pass to TF
#self.session.run(state_out, {state_in: (batch[0], batch[1]) }) # alternative, without state copy
- # now we have tensor version in state_out
+ # now we have the tensor version in state_out
i = i + 1
- print("MantaScalar demo done, %d batches read " % i)
+ print("MantaScalar demo done, %d batches read, abs-mean %f " % (i, np.mean(np.asarray(m)) ) )
exit(1)
