rdpharo - ny, nx = indata.shape[1:] # create the output...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import numpy as np import pyfits import time import os import pwd def rdpharo(filename): ''' This function reads a PHARO FITS image and reconstructs the data array. Parameters ---------- filename: string The name of the FITS file to read. Returns ------- header: PyFITS header object The FITS header of the data file. data: ndarray The reconstructed data array. Notes ----- Reorders array from 512x512x4 -> 1024x1024. Updates header. Examples -------- Read and re-order file 'pharofile.fits', return its header and data in variables so named: >>> header, data = rdpharo('pharofile.fits') Revisions --------- 2003-02-19 0.1 jh@oobleck.astro.cornell.edu Original version 2003-02-25 0.2 jh@oobleck.astro.cornell.edu Added FILENAME to FITS header. 2007-09-30 0.3 jh@physics.ucf.edu Converted to Python from IDL. 2007-10-15 0.4 jh@physics.ucf.edu Fix cards with float values. 2009-10-01 0.5 jh@physics.ucf.edu Update docstring, clean up code. ''' # read the data indata, header = pyfits.getdata(filename, header=True)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ny, nx = indata.shape[1:] # create the output array, with the same type as the input data = np.zeros(np.array(2) * (ny, nx), dtype=indata.dtype) # the hardwired numbers are peculiar to PHARO data[ : ny, : nx] = indata[1, :, :] data[ : ny, nx: ] = indata[0, :, :] data[ ny: , : nx] = indata[2, :, :] data[ ny: , nx: ] = indata[3, :, :] # update the header header['NAXIS'] = 2 header['NAXIS1'] = 2 * nx header['NAXIS2'] = 2 * ny del header['NAXIS3'] # fix broken cards for card in header.ascardlist(): if type(card.value) == float: card.verify(option='silentfix') # update the header history header.add_history( 'rdpharo: ' + time.strftime('%a %b %d %H:%M:%S %Z %Y') + ' ' + pwd.getpwuid(os.getuid())[0]) header.add_history('Unpacked 512x512x4 array into 1024x1024 array') header.update('FILENAME', filename, ' image filename') return (header, data)...
View Full Document

This note was uploaded on 11/09/2009 for the course AST 4762 taught by Professor Harrington during the Fall '09 term at University of Central Florida.

Page1 / 2

rdpharo - ny, nx = indata.shape[1:] # create the output...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online