-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
howto: write out a cutout subset of an image with a new header #10
Comments
On Sat, Jun 29, 2013 at 5:36 PM, richardgmcmahon
You get a numpy array from fh[ext][ymin:ymax,xmin:xmax]. The easiest
If the file already exists, that will add a new extension. You can add If you want to create a new FITS object directly, you can just do the
Note the FITS object represents file structure, not data in memory. I Also how do I write this to a new fits file?
good idea! -e
Erin Scott Sheldon |
I'm going to close this since I haven't heard any complaints. |
Hi Erin,
I want to use use fitsio to create a 'FITs object' in memory of a cutout.
With pyfits I do this:
fh = pyfits.open(filename)
head = fh[ext].header.copy()
...
various header manipulations to work out the pixel ranges
and update the new header
...
cutout = fh[ext].data[ymin:ymax,xmin:xmax]
newfh = pyfits.PrimaryHDU(data=cutout,header=head)
with fitsio I do
fh=fitsio.FITS(filename)
head = fh[ext].read_header()
....
work out the pixel range I want and update the header
....
cutout=fh[ext][ymin:ymax,xmin:xmax]
how do I make a FITs object from cutout, newhead that I can then pass out of my
function?
Also how do I write this to a new fits file?
This would be a useful example of how to create and write out a image cutout.
Thanks, r.
The text was updated successfully, but these errors were encountered: