Eitan Rapaport
Eitan Rapaport

Reputation: 13

Making a new FITS file from a slice of data

So I have a FITS file and I need to create a new FITS file but with only a select portion of the data. I'm fairly new to Python and Astropy and I don't know what I can use to accomplish this. The FITS file only has one HDU and it is 3 dimensional (181, 91, 1). Thank you for your help.

Upvotes: 1

Views: 287

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207465

Be warned that there may be other tools that are considerably more appropriate to your needs, as I know nothing about astronomy. I would just like to make you aware that ImageMagick is able to read, process and write FITS files. It is installed on most Linux distros and is available for macOS and Windows.

So, if you have a file called image.fits, you can crop out a region that is 128 pixels wide by 100 pixels tall, starting at coordinates [20,10] and save it as a new file in Terminal like this:

magick image.fits -crop 128x100+20+10 result.fits

Please check that other meta-data possibly contained within the input file is not lost, and please check for more appropriate tools first.

Upvotes: 1

Related Questions