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
7
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
  • 111
  • 1
  • 7
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
  • 549
  • 7
  • 18
5
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
  • 549
  • 7
  • 18
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
  • 505
  • 5
  • 18
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
  • 4,168
  • 11
  • 48
  • 100
3
votes
1 answer

Writing a new FITS file from old data with astropy

I have a very simple operation to perform on a FITS file (data is numpy array format) but I cannot get astropy to either save it as a new file or overwrite the existing one. I'm re-writing some old code that used the numpy pyfits module to work with…
Rhysy
  • 115
  • 1
  • 2
  • 7
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
  • 457
  • 4
  • 11
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
  • 189
  • 2
  • 9
  • 20
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
  • 537
  • 1
  • 6
  • 17
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
1 answer

How can I combine two FITS tables into a single table in new fits file?

I have two fits file data (file1.fits and file2.fits). The first one (file1.fits) consists of 80,700 important rows of data and another one is 140,000 rows. The both of them have the same Header. $ python >>> import pyfits >>> f1 =…
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

How to Use Pixel Coordinates with the imshow() command in order to make images from specific sections of a fits image in python?

I have a fits image with many astronomical objects in it. I am trying to create small 4x4 "stamps" (sections/images around the objects) from the objects that interest me. I have already calculated the pixel coordinates for the objects in the…
Seadrow
  • 23
  • 3
1
2 3 4 5 6