zwicker-group / py-pde

Python package for solving partial differential equations using finite differences.
https://py-pde.readthedocs.io
MIT License
393 stars 50 forks source link

Add tracker that directly writes all data to video #544

Closed david-zwicker closed 3 months ago

david-zwicker commented 3 months ago

This would allow to write data in a much more compressed format during the simulation. The idea would work best for 2d simulations of a single scalar field (but could probably be extended to more complicated cases, e.g. using colors for three fields). The idea is to have a tracker that converts a scalar field to a numpy array of dtype uint8 using a given value range and pushes this to ffmpeg, which encodes everything in a video. A useful package with an example is this. We might also need to store meta information about the underlying grid and particular the color scale to be able to revert this later again (using a special readonly storage class).

david-zwicker commented 3 months ago

An alternative python package might be ffmpeg-python, but it's not clear whether it supports the required online update: https://github.com/jonghwanhyeon/python-ffmpeg/issues/47.

david-zwicker commented 3 months ago

A more flexible solution might be to simply implement a MovieStorage, which uses a movie as a backend. This might obviously only offer limited possibilities (e.g. only tracker with fixed time intervals).

david-zwicker commented 3 months ago

A first version has been implemented by #545