In function traceray(), the reference velocity is calculated as (int)(img[im].nchan/2.). However, in function writefits(), the WCS keyword CRPIX3 is set to img[im].nchan/2.+1, with no cast to int. These definitions are inconsistent when nchan is an odd number, and in this case results in the lines being offset by velres/2. The cast to int in traceray() seems to be unnecessary.
In function traceray(), the reference velocity is calculated as (int)(img[im].nchan/2.). However, in function writefits(), the WCS keyword CRPIX3 is set to img[im].nchan/2.+1, with no cast to int. These definitions are inconsistent when nchan is an odd number, and in this case results in the lines being offset by velres/2. The cast to int in traceray() seems to be unnecessary.