def _make_const_image(self, value): """ Creates a constant image """ # unlearn some iraf tasks iraf.unlearn('mkpattern') # get a random filename tmpfile1 = get_random_filename('t', '.fits') iraf.mkpattern(input=tmpfile1, output="", pattern="constant", option="replace", v1=value, v2=0.0, size=1, title="", pixtype="real", ndim=2, ncols=self.dimension[1], nlines=self.dimension[0], n3=1, n4=1, n5=1, n6=1, n7=1, header="") return tmpfile1
def makeOneImage(self, imgname, nx, ny, metadata, drzmeta=None): """ Creates one dummy image The method creates a dummy image with the given name and dimension. A list of general metadata and a list of drizzle metadata is added to the zero extension header of the image. @param imgname: name of the image to be created @type imgname: string @param nx: image dimension in x @type nx: int @param ny: image dimension in y @type ny: int @param metadata: the list of general image metadata @type metadata: [] @param drzmeta: the list of drizzle metadata @type drzmeta: [] """ from pyraf import iraf from iraf import noao, artdata # delete a previous version if os.path.isfile(imgname): os.unlink(imgname) # open a HDU-list mex_hdu = pyfits.HDUList() # create a primary HDU, # append it to the list hdrpr = pyfits.PrimaryHDU() mex_hdu.append(hdrpr) # go the the header and put # the exposure time hdr = mex_hdu[0].header hdr['EXPTIME'] = (1.0, 'dummy exposure time') if drzmeta != None: # update the header for item in drzmeta: hdr[item[0]] = (item[1], item[2]) # write the image and close it mex_hdu.writeto(imgname) mex_hdu.close() # get a random filename tmpfile = get_random_filename('t', '.fits') # create a tmp-image with the right dimension iraf.mkpattern(input=tmpfile, output="", pattern="constant", option="replace", v1=0.0, v2=0.0, size=1, title="aXeSIM simulation", pixtype="real", ndim=2, ncols=nx, nlines=ny, n3=1, n4=1, n5=1, n6=1, n7=1, header="") # copy the tmp-image to the empty dummy image # as science extension iraf.imcopy(input=tmpfile, output=(imgname + '[SCI,1,append]'), verbose='YES', Stdout=1) # open the dummy image, go to the header img = pyfits.open(imgname, 'update') hdr = img[1].header # update the header for item in metadata: hdr[item[0]] = (item[1], item[2]) # write to disk and close img.flush() img.close # delete the tmp-image if os.path.isfile(tmpfile): os.unlink(tmpfile)