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
2
votes
2 answers

Interpolation over an image for marking of bad pixels in python

Hi I have a fits image that I read in with pyfits.getdata which has heavy vignetting along in the corners of the image. I create a second numpy array with the same dimensions as the original image, having a value for a bad pixel as 1 and a usable…
2
votes
3 answers

Collapsing / Flattening a FITS data cube in python

I've looked all over the place and am not finding a solution to this issue. I feel like it should be fairly straightforward, but we'll see. I have a .FITS format data cube and I need to collapse it into a 2D FITS image. The data cube has two…
Teachey
  • 529
  • 5
  • 16
2
votes
1 answer

Using a function for multiple files

I have written a function that i need to use for multiple files. when I use it for one file it works but when i try to use it for more i get errors. I have attached my code, can anybody tell me what is wrong with it? #! /usr/bin/env python #peice of…
astrochris
  • 1,546
  • 5
  • 18
  • 35
1
vote
1 answer

Wahoo TICKR X .fit file reading/parsing and analysis in Python

Not sure if I can post a question like this here so please redirect me if I'm in the wrong place. I've bought a Wahoo TICKR X to monitor my heart rate during exercise. Also I would like to get more familiar with python so i decided I would like do…
B. Bram
  • 41
  • 5
1
vote
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
  • 75
  • 1
  • 1
  • 6
1
vote
1 answer

Get random subsample from pyfits data table

I have a very simple question, but Google does not seem to be able to help me here. I want a subsample of a pyfits table... basically just remove 90% of the rows, or something like that. I read the table with: data_table = pyfits.getdata(base_dir +…
carl
  • 3,322
  • 6
  • 32
  • 80
1
vote
1 answer

Efficient way to build a data set from fits image

I have a set of fits images: about 32000 images with resolution (256,256). The dataset that i've to build is matrix like, so the output shape is (32000, 256*256). The simple solution is a for loop, samething like: #file_names is a list of…
Giuseppe Angora
  • 740
  • 1
  • 9
  • 23
1
vote
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 =…
1
vote
0 answers

Updating pyfits bin table data

I am trying to update an existing fits table with pyfits. It is working fine for some columns of the table, unfortunately not for the first column. Here is the columns definition: ColDefs( name = 'EVENT_ID'; format = '1J'; bscale = 1; bzero =…
The hun
  • 11
  • 3
1
vote
1 answer

Write boolean structured arrays with PyFITS

I would like to write a Boolean structured array with PyFITS in a FITS file. I had some issues. Here is a simple example. I create the test dictionary and transform it into a structured array. In [241]: test =…
Cast
  • 33
  • 3
1
vote
2 answers

PyFITS: hdulist.writeto()

I'm extracting extensions from a multi-extension FITS file, manipulate the data, and save the data (with the extension's header information) to a new FITS file. To my knowledge pyfits.writeto() does the task. However, when I give it a data…
1
vote
1 answer

py2exe with import pyfits cause error

When do py2exe in py-file with import pyfits, it caused an error. How to avoid this error? I prepare test.py and test_setup.py(for py2exe), which are shown below. test.py is simple program to show data of fitsfile specified by the argument. OS :…
Mr.Gauss
  • 13
  • 2
1
vote
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
  • 13
  • 3
1
vote
2 answers

Converting ASCII Table to FITS image

I am a beginner in this domain. I have a text file having three columns: X, Y, Intensity at (X, Y). They are basically arrays (1X10000) each written out in a text files via python. To plot the dataset in python, I can simply use trisurf to achieve…
user3440489
  • 229
  • 3
  • 10
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