{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

rdpharo - ny nx = indata.shape[1 create the output array...

Info icon This 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 [email protected] Original version 2003-02-25 0.2 [email protected] Added FILENAME to FITS header. 2007-09-30 0.3 [email protected] Converted to Python from IDL. 2007-10-15 0.4 [email protected] Fix cards with float values. 2009-10-01 0.5 [email protected] Update docstring, clean up code. ''' # read the data indata, header = pyfits.getdata(filename, header=True)
Image of page 1

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

View Full Document Right Arrow Icon
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern