This seems like a good starting point, even though the code is messy and the deformation routine has some numerical quirks. Note that the translation direction is mixed up: the keys are for x, but the velocity field is for z.