Questions tagged [pyfits]

PyFITS provides an interface to FITS formatted files in the Python scripting language.

Note: PyFITS has been superseded by Astropy via the astropy.io.fits package. Please only the tag for questions that involve directly using older versions of PyFITS, as opposed to Astropy (in which case the tag should be used).

PyFITS provides an interface to FITS formatted files in the Python scripting language. It is useful both for interactive data analysis and for writing analysis scripts in Python using FITS files as either input or output. PyFITS was a development project of the Science Software Branch at the Space Telescope Science Institute.

88 questions
1
vote
2 answers

Pyfits : change column name/format

I'm trying to concatenate files in pyfits. Because they weren't done correctly, one of the column name and one of the column format are not the same between my input files, so I can't concatenate the ndarray using np.concatenate ... I'd like to…
Herr
  • 11
  • 1
1
vote
4 answers

Aggregating table rows by values in multiple columns in a FITS file

I have a FITS file with many columns. A part of a simplified example of the file looks like this: A B C 100 1 90 100 2 90 100 3 90 100 4 90 211 40 70 211 41 70 …
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
1
vote
1 answer

How could I convert a contour plot (matplotlib) to FITS format with header?

I need to make a contour plot and overlie the contours on the image. I have used aplpy library to overlie the contours on an astronomical image. I have downloaded the 2MASS data in APlpy…
Dalek
  • 4,168
  • 11
  • 48
  • 100
1
vote
3 answers

change keyword value in the header of a FITS file

I am trying to change the value of a keyword in the header of a FITS file. Quite simple, this is the code: import pyfits hdulist = pyfits.open('test.fits') # open a FITS file prihdr = hdulist[1].header print prihdr['AREASCAL'] effarea =…
Py-ser
  • 1,860
  • 9
  • 32
  • 58
1
vote
1 answer

Cannot open file with PyFITS

I've got some .fit files containing images from a CCD camera and I can't seem to open them using PyFITS. I'm a complete newbie with PyFITS so I don't know what (if any) options I have. Here's what I'm trying: import pyfits hdulist =…
liamvharris
  • 350
  • 3
  • 16
1
vote
3 answers

PyFITS: File already exists

I'm really close to completing a large code, but the final segment of it seems to be failing and I don't know why. What I'm trying to do here is take an image-array, compare it to a different image array, and wherever the initial image array equals…
vdogsandman
  • 5,289
  • 8
  • 21
  • 21
1
vote
2 answers

Python 2D array -- How to plug in x and retrieve y value?

I have been looking for an answer since yesterday but no luck. So I have a 1D spectrum (.fits) file with flux value at each wavelength. I have converted them into a 2D array (x,y)=(wavelength, flux) and want to write a program which will return…
N.K.
  • 733
  • 1
  • 5
  • 9
1
vote
1 answer

Conversion of a .fits file

I've got a .fits file and I want to read the data, unfortunately I'm not at all familiar with this format type. Is there a way to convert it to a table (.txt file?) so that I can work with it using pandas? I just found pyfits and read some of the…
Matt
  • 3,508
  • 6
  • 38
  • 66
1
vote
1 answer

Finding a position in an array of a maxmum point from a fits file, pyfits

I have a Fits file with 12 different arrays of information about the image. I can find the maximum value of the array I want to look at, MAG_AUTO, by using the line. a=pyfits.getdata(data1).MAG_AUTO Where data1 is my data set from the fits file.…
astrochris
  • 1,756
  • 5
  • 20
  • 42
1
vote
2 answers

FITS file change

I have some data given to me by my mentor. The data consists of thousands of .fits files. Some of the .fits files are older versions of the others and the way the data tables are constructed are different. Here is what I mean: Let's say I have two…
Dax Feliz
  • 12,220
  • 8
  • 30
  • 33
0
votes
0 answers

Error in CompImageHDU FITS file reading from pyfits

I am getting this error trying to read data from a FITS file. I can see that the file contains the correct data because DS9 viewer shows the image I would expect. The error I'm getting is below. Can anyone help me? Thanks so much. Error I tried…
0
votes
0 answers

Read, walk and print a .fits dataset with a few hundred file

I'm new to python implementation and would like to do the following process. Read a set of data from .fits files, go through all of them (a few hundred .fits files) and present in a dataframe (preferably) the following HEADERS: File, IMAGE, OBJECT,…
0
votes
1 answer

Reading Table from FITS format file with many dimensions in header?

I have a FITS format file which I can read the headers (hdu) using astropy: from astropy.table import Table from astropy.io import fits fits.info('file.fits') Filename: file.fits No. Name Ver Type Cards Dimensions Format 0 …
0
votes
1 answer

Is there any way to use arithmetic ops on FITS files in Python?

I'm fairly new to Python, and I have been trying to recreate a working IDL program to Python, but I'm stuck and keep getting errors. I haven't been able to find a solution yet. The program requires 4 FITS files in total (img and correctional images…
apoorva_9
  • 13
  • 4
0
votes
2 answers

How to save and add new fits header in fits file

i have a fits file and i want to add a new header to the fits file. I've actually added a new fits header but it didn't save it. How to save and add new fits header? Codes here: from astropy.io import fits hdul =…
SAFAK
  • 3
  • 1
  • 5