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.

86 questions
7
votes
1 answer

Cartesian projection issue in a FITS image through PyFITS / AstroPy

I've looked and looked for a solution to this problem and am turning up nothing. I'm generating rectangular FITS images through matplotlib and subsequently applying WCS coordinates to them using AstroPy (or PyFITS). My images are in galactic…
Teachey
  • 529
  • 5
  • 16
6
votes
2 answers

WCS as matplotlib projection for a data-cube slice loaded using astropy?

I have a FITS file named 'my_cube.fits' with WCS. The file has spatial information on axis 1 and 2 (X and Y) and spectral information on axis 3 (Z). When I load it using astropy.io.fits, the spectral axis is 0 and spatial axes are 1 and 2. The file…
Bruno Quint
  • 101
  • 7
4
votes
2 answers

astropy.io.fits - HIERARCH keywords don't work with CONTINUE cards: Bug or "Feature" of the FITS standard?

The astropy.io.fits manual states, that we can use header keywords longer than 8-characters. In this case HIERARCH cards will be created. The manual also states, that if we want to store keyword-value pairs longer than 80-characters, continue cards…
Christian Herenz
  • 395
  • 4
  • 13
4
votes
4 answers

How is it possible in python to convert an ascii table to a fits table?

I have a table of data in an ascii file with header and I would like to convert my ascii table to a fits file with header #ID ra dec x y Umag Bmag Vmag Rmag Imag 1.0 53.146 -27.8123 3422.98 3823.58 24.4528 24.7995 23.6266…
Dalek
  • 3,827
  • 8
  • 34
  • 78
4
votes
1 answer

Assign WCS coordinates to a FITS image

I've been searching the documentation like crazy and cannot find an answer for this one. I'm generating FITS images in python and need to assign WCS coordinates to the image. I know there are lots of ways to do this by matching up point sources…
Teachey
  • 529
  • 5
  • 16
3
votes
2 answers

How to merge two table with pyfits?

I am using Python 2.7.10 And pyfits 3.3. Earlier, I have used the following code to merge two tables. However, now I am getting some errors t1 = pyfits.open(table1)[1].columns t2 = pyfits.open(table2)[1].columns new_columns = t1 + t2 hdu =…
vinu
  • 345
  • 2
  • 7
3
votes
2 answers

vmin vmax algorithm matplotlib

I write script for calibration of image (dark frame and flat field)...Here is part of code for n in range(len(img)): with pyfits.open(img[n], mode='update', memmap=True) as im: imgg = im[0].data header = im[0].header …
Franta Konopnik
  • 169
  • 1
  • 7
  • 19
3
votes
2 answers

Adding columns to a FITS table with PyFITS

Let's assume I have a fits file with one extension, and the data consists of a table of two columns with 100 elements each data = pyfits.open('path2myfile')[1].data head = pyfits.open('path2myfile')[1].header print data['field1'] # print an array…
Cehem
  • 83
  • 1
  • 5
2
votes
0 answers

How can I write a healpix map?

I am trying to write a FITS file in the HEALPix format, using healpy and the following script: import healpy as hp fname = 'COM_CMB_IQU-100-fgsub-sevem_2048_R3.00_full.fits' map1 = hp.read_map(fname, field=[0], nest=True) map2 = hp.read_map(fname,…
2
votes
2 answers

Multiple Tables saved in the same .fits file

I have multiple tables created with astropy.table.Table, for example: from astropy.table import Table import numpy as np #table 1 ta=Table() ta["test1"]=np.arange(0,100.) #table 2 tb=Table() tb["test2"]=np.arange(0,100.) I can save them…
Julia Roquette
  • 347
  • 2
  • 15
2
votes
0 answers

FITS image data to a common image format

I would like to read FITS file image data and display it like standard image using java and nom.tam.fits library. Right now I manage to read data into two dimensional array. In my case returned 4 dimensional array with size [1][1][1024][1024]. In…
2
votes
2 answers

What can I do for my program not to throw a KeyError for a Header not existing in a .fits file?

I am making a program that searches the computer for .fts and .fits files in which it opens the file and retrieves info that corresponds to a specific keyword in the header and renames the file to that keyword. I am having a problem where i keep…
2
votes
1 answer

Python, PyFITS, cannot open file

I have problem in opening FITS file in Python. I get following error-message: File "G:\Anaconda\lib\site-packages\pyfits\file.py", line 416, in _open_filelike % self.mode) IOError: File-like object does not have a 'write' method, required for…
Ilja Kosynkin
  • 107
  • 1
  • 12
2
votes
1 answer

Faster method of scaling down image array in Python using numpy and pyfits

I'm using Python 2.7.3 with numpy and pyfits to process scientific FITS files. I would like to work on the images at half or one quarter resolution for the sake of speed, and have this code: # Read red image hdulist = pyfits.open(red_fn) img_data =…
Karl D
  • 905
  • 1
  • 6
  • 5
2
votes
2 answers

pyfits: read compressed fits file

How does one open a compressed fits file with pyfits? The code below reads in the primary hdu, which is an image. The result is a NoneType object. # read in file file_input_fit = "myfile.fits.fz" hdulist =…
Bnord
  • 41
  • 3
1
2 3 4 5 6