pyfits

Copy header into new file astropy

你。 提交于 2019-12-25 18:27:14
问题 I have this script that makes a file with multiple extensions, but I would like to add headers from the old files to the extensions. new_hdul = fits.HDUList() new_hdul.append(fits.PrimaryHDU(header=headermain)) new_hdul.append(fits.ImageHDU(nod1, header=header1, name='Chop1')) new_hdul.append(fits.ImageHDU(nod2, header=header2, name='Chop2')) new_hdul.append(fits.ImageHDU(diff1, name='Dif')) Now I have tried: headermain = fits.getheader(file,0) and headermain = fits.open(file).header.copy()

How to merge two table with pyfits?

淺唱寂寞╮ 提交于 2019-12-23 19:52:06
问题 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 = pyfits.BinTableHDU.from_columns(new_columns) hdu.writeto(outtable) The error is: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/vvikraman/anaconda2/lib/python2.7/site-packages/pyfits/hdu/table.py", line 116, in from

vmin vmax algorithm matplotlib

好久不见. 提交于 2019-12-22 11:18:06
问题 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 imgg.astype(float) imgg = (imgg - dd) / df imgg[np.isnan(imgg)] = 1 imgg.astype(int) plt.imshow(imgg, cmap=plt.cm.Greys_r, vmin=0.5, vmax=1.5) plt.show() This part of code make calibration of image with dark frame and flat field... When I use at the plotting vmin and vmax , I get

operations on column length

穿精又带淫゛_ 提交于 2019-12-13 08:47:07
问题 Firstly, sorry if I have used the wrong language to explain what I'm operating on, I'm pretty new to python and still far from being knowledgeable about it. I'm currently trying to do operations on the length of a column of data however I'm running into a few problems. These columns are from a .fit file from the 7th sdss data dump. When I run the code each value for x1, x2, x3 is printed according to the boundary conditions. x1 = o3[(03 >= y1)] print len(x1) x2 = o3[(o3 < y2) & (o3 < y1)]

Converting ASCII Table to FITS image

可紊 提交于 2019-12-13 00:31:02
问题 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 this. But for further processing, I need to create a fits image from it. How do I make FITS image (and NOT a simple FITS table) out of the this text file (through python or matlab will be preferable). 回答1: You should be able to do this mostly with

pyfits not working for windows 64 bit

浪子不回头ぞ 提交于 2019-12-11 18:06:59
问题 I am using windows 7 home basic 64 bit . I wanted to work with FITS file in python 3.3 so downloaded pyfits and numpy for 64 bit. When I import pyfits I get the following error: Traceback (most recent call last): File "", line 1, in import pyfits as py File "C:\Python33\lib\site-packages\pyfits__init__.py", line 26, in import pyfits.core File "C:\Python33\lib\site-packages\pyfits\core.py", line 38, in import pyfits.py3compat File "C:\Python33\lib\site-packages\pyfits\py3compat.py", line 12,

Adding a new column to a FITS file via python

若如初见. 提交于 2019-12-04 05:29:06
问题 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 errors but did not add my column to the FITS file. Any suggestions?? 回答1: Finally they released an updated library that allows the modification of a table extension in a human way! Last release of FITSIO. You can easily add a column with a code

Unwanted extra dimensions in numpy array

爷,独闯天下 提交于 2019-12-01 15:09:29
I've opened a .fits image: scaled_flat1 = pyfits.open('scaled_flat1.fit') scaled_flat1a = scaled_flat1[0].data and when I print its shape: print scaled_flat1a.shape I get the following: (1, 1, 510, 765) I want it to read: (510,765) How do I get rid of the two ones before it? I'm assuming scaled_flat1a is a numpy array? In that case, it should be as simple as a reshape command. import numpy as np a = np.array([[[[1, 2, 3], [4, 6, 7]]]]) print(a.shape) # (1, 1, 2, 3) a = a.reshape(a.shape[2:]) # You can also use np.reshape() print(a.shape) # (2, 3) There is the method called squeeze which does

Unwanted extra dimensions in numpy array

孤者浪人 提交于 2019-12-01 14:00:47
问题 I've opened a .fits image: scaled_flat1 = pyfits.open('scaled_flat1.fit') scaled_flat1a = scaled_flat1[0].data and when I print its shape: print scaled_flat1a.shape I get the following: (1, 1, 510, 765) I want it to read: (510,765) How do I get rid of the two ones before it? 回答1: I'm assuming scaled_flat1a is a numpy array? In that case, it should be as simple as a reshape command. import numpy as np a = np.array([[[[1, 2, 3], [4, 6, 7]]]]) print(a.shape) # (1, 1, 2, 3) a = a.reshape(a.shape