# Script to interpolate extra channels in a small cube
import numpy
import pyfits
infile = 'PixCoords.fits'
outfile ='PixCoords_100.fits'
FitsFile = pyfits.open(infile)
# Factor by which to increase the number of channels
n = 10
image = FitsFile[0].data
sizez = image.shape[0]
sizey = image.shape[1]
sizex = image.shape[2]
print sizez,sizey,sizex
newimage = numpy.zeros((sizez*n,sizey,sizex))
for x in range(0, sizex):
print x
for y in range(0,sizey):
for z in range(0,sizez-1):
p1 = image[z,y,x]
p2 = image[z+1,y,x]
m = (p1-p2)/float(n)
k = 0
# Difference at each point may have a different sign !
# Have to check individual points.
for i in range((z*n),(z+1)*n):
newimage[i,y,x] = -(m*float(k)) + p1
k = k + 1
pyfits.writeto(outfile,newimage,header=None)
FitsFile.close()
#0 1 2
#0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20