TimeSeries.retrieve() interpolation

Issue #827 wontfix
David created an issue

Hello,

  1. according to the docs, in FEniCS 2016.2.0, TimeSeries.retrieve() can be called with an optional argument, interpolate=True/False. This does not work:

    ts.retrieve(p.vector(), t, interpolate=False)

    TypeError: TimeSeries_retrieve() takes no keyword arguments

    edit : this works if the keyword is ommited, ts.retrieve(p.vector(), t, False).

  2. If i read all stored timestamps from a TimeSeries with vector_times(), and then retrieve the vectors at the corresponding timestamps, no interpolation should be necessary, the values should be read directly. This is not the case in the following example:

from dolfin import *
import numpy as np

set_log_level(PROGRESS)

mesh = UnitSquareMesh(8, 8)
V = FunctionSpace(mesh, FiniteElement('P', mesh.ufl_cell(), 1))
ex = Expression("t", degree=1, t=0.)
u = Function(V)

# store data
ts = TimeSeries('test_series')
times = np.arange(0, 1, 0.1)
for t in times:
    ex.t = t
    u = interpolate(ex, V)
    ts.store(u.vector(), t)

# retrieve data
ts = TimeSeries('test_series')
times = ts.vector_times()
print(times)
for t in times:
    ts.retrieve(u.vector(), t)

The times should probably be rounded when they are compared.

Regards, David

Comments (10)

  1. Jan Blechta

    this works if the keyword is ommited, ts.retrieve(p.vector(), t, False)

    Yes. Should be just a simple fix in a SWIG interface file.

    The times should probably be rounded when they are compared.

    I don't agree.

  2. David reporter

    The times should probably be rounded when they are compared.

    I don't agree.

    Don't you agree that in the example,

    times = ts.vector_times()
    for t in times:
        ts.retrieve(u.vector(), t)
    

    no interpolation should be necessary? With rounding I meant something à la np.allclose(), standard floats comparison.

  3. Jan Blechta

    Is fixed in new Python interface generated by pybind11 which will be released experimentally with 2017.2.0 and as a default with 2018.1.0.

  4. Jan Blechta

    The problem in accepting kwarg fixed in pybind11 DOLFIN.

    The feature request for avoiding interpolation is already present:

    >>> ts.retrieve(u.vector(), 0.84, interpolate=False)
    Reading vector at t = 0.8 (close to t = 0.84).
    
  5. Log in to comment