I wrote what I think are working functions getQvecGrid and paddedDoubledData in /julia/.