# Adds flux into a cube import math import numpy import pyfits import os infile = '7448Group_blank.fits' outfile = str(infile.split('.fits')[0])+str('_addedflux')+str('.fits') os.system('cls') # Changes to the directory where the script is located abspath = os.path.abspath(__file__) dname = os.path.dirname(abspath) os.chdir(dname) FitsFile = pyfits.open(infile) image = FitsFile[0].data header =FitsFile[0].header sizez = image.shape[0] sizey = image.shape[1] sizex = image.shape[2] print sizez,sizey,sizex # Create an array to hold the channel numbers #channel = numpy.array([i for i in range(0,sizez)]) for xp in range(20,30): for yp in range(20,30): for zp in range(20,21): image[zp,yp,xp] = image[zp,yp,xp] + 1.0 FitsFile = pyfits.writeto(outfile, image, header=header)