# Color TemporalParticlesToPathlines by velocity as in StreamTracer

**URL:** https://discourse.paraview.org/t/color-temporalparticlestopathlines-by-velocity-as-in-streamtracer/4243
**Category:** ParaView Support
**Created:** [May 3, 2020, 9:27pm UTC](https://discourse.paraview.org/t/color-temporalparticlestopathlines-by-velocity-as-in-streamtracer/4243 "2020-05-03T21:27:14Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![kaiser](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@kaiser](https://discourse.paraview.org/u/kaiser)
#### Post date: [May 3, 2020, 9:27pm UTC](https://discourse.paraview.org/t/color-temporalparticlestopathlines-by-velocity-as-in-streamtracer/4243/1 "2020-05-03T21:27:14Z")

</div>

Hello, when using TemporalParticlesToPathlines, is there a way to color the pathlines by velocity, as is an option for the StreamTracer filter?

The paths are pre-computed by the solver, so only their positions are read by paraview. The local velocity field is available if interpolating it is an option. It also would be easy to compute the local velocity with finite differences, but then I would need to somehow assign that velocity to the pathline.

Thank you,  
Alex

---

<div class="post-metadata">

### Author: ![kaiser](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@kaiser](https://discourse.paraview.org/u/kaiser)
#### Post date: [May 8, 2020, 1:23am UTC](https://discourse.paraview.org/t/color-temporalparticlestopathlines-by-velocity-as-in-streamtracer/4243/2 "2020-05-08T01:23:22Z")

</div>

Hi all,

This can be accomplished with python vtk by adding the velocity field to particle data using a snippet like the following. After reading the files that contain positions to data1 and data2, call

```
coords1 = data1.GetPoints().GetData()
coords2 = data2.GetPoints().GetData()

```

to load their coordinates, then

```
velocity = numpy_support.numpy_to_vtk((1.0/dt) * (np.array(coords2)-np.array(coords1)), deep=True, array_type=vtk.VTK_DOUBLE)
velocity.SetName("velocity")
data2.GetPointData().AddArray(velocity)

```

to add a field “velocity” to the data. Here this is a simple first order finite difference for the time derivative, but more sophisticated options could also be used. Then write a new vtu with data2, and upon reading in Paraview, the magnitude of velocity can be used to color the pathlines. Note that “numpy\_support” is loaded from with “from vtk.util import numpy\_support”.
