# vtkHDFWriter for temporal PDS Collection

**URL:** https://discourse.vtk.org/t/vtkhdfwriter-for-temporal-pds-collection/15774
**Category:** Support
**Created:** [June 30, 2025, 6:09am UTC](https://discourse.vtk.org/t/vtkhdfwriter-for-temporal-pds-collection/15774 "2025-06-30T06:09:59Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![citronella3alain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/citronella3alain/32/10080_2.png) [@citronella3alain](https://discourse.vtk.org/u/citronella3alain)
#### Post date: [July 23, 2025, 11:15pm UTC](https://discourse.vtk.org/t/vtkhdfwriter-for-temporal-pds-collection/15774/9 "2025-07-23T23:15:59Z")

</div>

OK thanks for the reply @Louis_Gombert @lgivord

- As for creating a Python filter, do you have an example? I followed [this tutorial](https://adamdjellouli.com/articles/vtk_examples/09_custom_filters_and_algorithms) but it doesn’t seem to work. I opened a new discourse thread for this: [Creating custom filter in Python - Support - VTK](https://discourse.vtk.org/t/creating-custom-filter-in-python/15854)
- In the meantime, I wanted to know what was wrong with my earlier example of writing a temporal polydata (sphere) to vtkhdf. Here’s the code:

```auto
def write_simple_temporal_sphere(output_path: str):
    # 1. Create a basic sphere
    sphere = vtkSphereSource()
    sphere.SetRadius(10)
    sphere.SetThetaResolution(30)
    sphere.SetPhiResolution(30)

    # 2. Generate 2 time steps (e.g., t = 0 and pi)
    time_gen = vtkGenerateTimeSteps()
    time_gen.SetInputConnection(sphere.GetOutputPort())
    time_gen.SetTimeStepValues(2, [0.0, np.pi])

    # 3. Add time-varying field with one harmonic
    harmonics = vtkSpatioTemporalHarmonicsAttribute()
    harmonics.SetInputConnection(time_gen.GetOutputPort())
    harmonics.AddHarmonic(1, 0, 0.5, 0.5, 0.5, 0.0) # magnitude, frequency, direction, phase

    # 4. Warp the mesh using the harmonic field
    warp = vtkWarpScalar()
    warp.SetInputConnection(harmonics.GetOutputPort())
    warp.SetInputArrayToProcess(0, 0, 0, vtkDataObject.FIELD_ASSOCIATION_POINTS, "SpatioTemporalHarmonics")

    # 5. Write to .vtkhdf with all timesteps
    writer = vtkHDFWriter()
    writer.SetInputConnection(warp.GetOutputPort())
    writer.SetFileName(output_path)
    writer.SetWriteAllTimeSteps(True)
    writer.Write()

```

While reading the file will tell me that it is temporal and there are 2 timesteps, the points don’t seem to differ between the two timesteps. Is there something wrong with my pipeline?

Thanks!

---

_[View the full topic](https://discourse.vtk.org/t/vtkhdfwriter-for-temporal-pds-collection/15774)._
