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
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
  • 14
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
  • 1,295
  • 2
  • 8
  • 5
2
votes
1 answer

Adding a new column to a FITS file via python

I have created an array named distance that contains 1242 values. I want to add this array as the 11th column in an already existing FITS file that contains 10 columns. I am using pyfits. I tried pyfits.append(filename, distance) which showed no…
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
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
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
  • 549
  • 7
  • 18
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,756
  • 5
  • 20
  • 42
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
  • 51
  • 7
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
  • 4,216
  • 9
  • 55
  • 103
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
  • 833
  • 1
  • 10
  • 25
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
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
  • 259
  • 1
  • 4
  • 13