3
PyFITS is being used within the STScI operations pipelines and is a
4
supported product. Currently PyFITS takes a fairly strict
5
interpretation of FITS files. There are likely to be problems with FITS
6
data that do not strictly conform to the standard. Undoubtedly, use
7
with a wider variety of files and uses will uncover problems; please
8
contact [2]help@stsci.edu when such problems are encountered.
10
We intend to accomodate such variances, particularly if they involve
11
widely used or available data (so please let us know when such problems
14
PyFITS requires numpy to be installed.
15
__________________________________________________________________
17
Version 2.3.1; June 3 2010
19
* The following bugs were fixed:
20
+ Replaced code in the Compressed Image HDU extension which was
21
covered under a GNU General Public License with code that is
22
covered under a BSD License. This change allows the
23
distribution of pyfits under a BSD License.
24
__________________________________________________________________
26
Version 2.3; May 11 2010
28
* The following enhancements were made:
29
+ Completely eliminate support for numarray.
30
+ Rework pyfits documention to use Sphinx.
31
+ Support python 2.6 and future division.
32
+ Added a new method to get the file name associated with an
33
HDUList object. The method HDUList.filename() returns the name
34
of an associated file. It returns None if no file is
35
associated with the HDUList.
36
+ Support the python 2.5 'with' statement when opening fits
37
files. (CNSHD766308) It is now possible to use the following
39
>>> from __future__ import with_statement
41
>>> with pyfits.open("input.fits") as hdul:
45
+ Extended the support for reading unsigned integer 16 values
46
from an ImageHDU to include unsigned integer 32 and unsigned
47
integer 64 values. ImageHDU data is considered to be unsigned
48
integer 16 when the data type is signed integer 16 and BZERO
49
is equal to 2**15 (32784) and BSCALE is equal to 1. ImageHDU
50
data is considered to be unsigned integer 32 when the data
51
type is signed integer 32 and BZERO is equal to 2**31 and
52
BSCALE is equal to 1. ImageHDU data is considered to be
53
unsigned integer 64 when the data type is signed integer 64
54
and BZERO is equal to 2**63 and BSCALE is equal to 1. An
55
optional keyword argument (uint) was added to the open
56
convenience function for this purpose. Supplying a value of
57
True for this argument will cause data of any of these types
58
to be read in and scaled into the appropriate unsigned integer
59
array (uint16, uint32, or uint64) instead of into the normal
60
float 32 or float 64 array. If an HDU associated with a file
61
that was opened with the 'int' option and containing unsigned
62
integer 16, 32, or 64 data is written to a file, the data will
63
be reverse scaled into a signed integer 16, 32, or 64 array
64
and written out to the file along with the appropriate
65
BSCALE/BZERO header cards. Note that for backward
66
compatability, the 'uint16' keyword argument will still be
67
accepted in the open function when handling unsigned integer
69
+ Provided the capability to access the data for a column of a
70
fits table by indexing the table using the column name. This
71
is consistent with Record Arrays in numpy (array with fields).
72
(CNSHD763378) The following example will illustrate this:
74
>>> hdul = pyfits.open('input.fits')
75
>>> table = hdul[1].data
78
>>> print table.field('c2') # this is the data for column 2
80
>>> print table['c2'] # this is also the data for column 2
83
>>> print table[1] # this is the data for row 1
84
(2, 'xy', 6.6999997138977054, True)
86
+ Provided capabilities to create a BinaryTableHDU directly from
87
a numpy Record Array (array with fields). The new capabilities
88
include table creation, writing a numpy Record Array directly
89
to a fits file using the pyfits.writeto and pyfits.append
90
convenience functions. Reading the data for a BinaryTableHDU
91
from a fits file directly into a numpy Record Array using the
92
pyfits.getdata convenience function. (CNSHD749034) Thanks to
93
Erin Sheldon at Brookhaven National Laboratory for help with
95
The following should illustrate these new capabilities:
99
>>> t=numpy.zeros(5,dtype=[('x','f4'),('y','2i4')]) \
100
... # Create a numpy Record Array with fields
102
>>> hdu = pyfits.BinTableHDU(t) \
103
... # Create a Binary Table HDU directly from the Record Array
105
[(0.0, array([0, 0], dtype=int32))
106
(0.0, array([0, 0], dtype=int32))
107
(0.0, array([0, 0], dtype=int32))
108
(0.0, array([0, 0], dtype=int32))
109
(0.0, array([0, 0], dtype=int32))]
111
>>> hdu.writeto('test1.fits',clobber=True) \
112
... # Write the HDU to a file
113
>>> pyfits.info('test1.fits')
115
No. Name Type Cards Dimensions Format
116
0 PRIMARY PrimaryHDU 4 () uint8
117
1 BinTableHDU 12 5R x 2C [E, 2J]
119
>>> pyfits.writeto('test.fits', t, clobber=True) \
120
... # Write the Record Array directly to a file
122
>>> pyfits.append('test.fits', t) \
123
... # Append another Record Array to the file
124
>>> pyfits.info('test.fits')
126
No. Name Type Cards Dimensions Format
127
0 PRIMARY PrimaryHDU 4 () uint8
128
1 BinTableHDU 12 5R x 2C [E, 2J]
129
2 BinTableHDU 12 5R x 2C [E, 2J]
131
>>> d=pyfits.getdata('test.fits',ext=1) \
132
... # Get the first extension from the file as a FITS_rec
136
[(0.0, array([0, 0], dtype=int32))
137
(0.0, array([0, 0], dtype=int32))
138
(0.0, array([0, 0], dtype=int32))
139
(0.0, array([0, 0], dtype=int32))
140
(0.0, array([0, 0], dtype=int32))]
142
>>> d=pyfits.getdata('test.fits',ext=1,view=numpy.ndarray) \
143
... # Get the first extension from the file as a numpy Record
148
[(0.0, [0, 0]) (0.0, [0, 0]) (0.0, [0, 0]) (0.0, [0, 0])
151
[('x', '>f4'), ('y', '>i4', 2)]
153
>>> d=pyfits.getdata('test.fits',ext=1,upper=True,
154
... view=pyfits.FITS_rec) \
155
... # Force the Record Array field names to be in upper case
156
regardless of how they are stored in the file
158
[('X', '>f4'), ('Y', '>i4', 2)]
160
+ Provided support for writing fits data to file-like objects
161
that do not support the random access methods seek() and
162
tell(). Most pyfits functions or methods will treat these
163
file-like objects as an empty file that cannot be read, only
164
written. It is also expected that the file-like object is in a
165
writable condition (ie. opened) when passed into a pyfits
166
function or method. The following methods and functions will
167
allow writing to a non-random access file-like object:
168
HDUList.writeto(), HDUList.flush(), pyfits.writeto(), and
169
pyfits.append(). The pyfits.open() convenience function may be
170
used to create an HDUList object that is associated with the
171
provided file-like object. (CNSHD770036)
172
An illustration of the new capabilities follows. In this
173
example fits data is written to standard output which is
174
associated with a file opened in write-only mode:
176
>>> import numpy as np
179
>>> hdu = pyfits.PrimaryHDU(np.arange(100,dtype=np.int32))
180
>>> hdul = pyfits.HDUList()
182
>>> tmpfile = open('tmpfile.py','w')
183
>>> sys.stdout = tmpfile
184
>>> hdul.writeto(sys.stdout, clobber=True)
185
>>> sys.stdout = sys.__stdout__
187
>>> pyfits.info('tmpfile.py')
189
No. Name Type Cards Dimensions Format
190
0 PRIMARY PrimaryHDU 5 (100,) int32
193
+ Provided support for slicing a FITS_record object. The
194
FITS_record object represents the data from a row of a table.
195
Pyfits now supports the slice syntax to retrieve values from
196
the row. The following illustrates this new syntax:
197
>>> hdul = pyfits.open('table.fits')
198
>>> row = hdul[1].data[0]
200
('clear', 'nicmos', 1, 30, 'clear', 'idno= 100')
201
>>> a, b, c, d, e = row[0:5]
214
+ Allow the assignment of a row value for a pyfits table using a
215
tuple or a list as input. The following example illustrates
217
>>> c1=pyfits.Column(name='target',format='10A')
218
>>> c2=pyfits.Column(name='counts',format='J',unit='DN')
219
>>> c3=pyfits.Column(name='notes',format='A10')
220
>>> c4=pyfits.Column(name='spectrum',format='5E')
221
>>> c5=pyfits.Column(name='flag',format='L')
222
>>> coldefs=pyfits.ColDefs([c1,c2,c3,c4,c5])
224
>>> tbhdu=pyfits.new_table(coldefs, nrows = 5)
226
>>> # Assigning data to a table's row using a tuple
227
>>> tbhdu.data[2] = ('NGC1',312,'A Note',
228
... num.array([1.1,2.2,3.3,4.4,5.5],dtype=num.float32),
231
>>> # Assigning data to a tables row using a list
232
>>> tbhdu.data[3] = ['JIM1','33','A Note',
233
... num.array([1.,2.,3.,4.,5.],dtype=num.float32),True]
235
+ Allow the creation of a Variable Length Format (P format)
236
column from a list of data. The following example illustrates
238
>>> a = [num.array([7.2e-20,7.3e-20]),num.array([0.0]),
239
... num.array([0.0])]
240
>>> acol = pyfits.Column(name='testa',format='PD()',array=a)
242
_VLF([[ 7.20000000e-20 7.30000000e-20], [ 0.], [ 0.]],
246
+ Allow the assignment of multiple rows in a table using the
247
slice syntax. The following example illustrates this new
249
>>> counts = num.array([312,334,308,317])
250
>>> names = num.array(['NGC1','NGC2','NGC3','NCG4'])
251
>>> c1=pyfits.Column(name='target',format='10A',array=names)
252
>>> c2=pyfits.Column(name='counts',format='J',unit='DN',
254
>>> c3=pyfits.Column(name='notes',format='A10')
255
>>> c4=pyfits.Column(name='spectrum',format='5E')
256
>>> c5=pyfits.Column(name='flag',format='L',array=[1,0,1,1])
257
>>> coldefs=pyfits.ColDefs([c1,c2,c3,c4,c5])
259
>>> tbhdu1=pyfits.new_table(coldefs)
261
>>> counts = num.array([112,134,108,117])
262
>>> names = num.array(['NGC5','NGC6','NGC7','NCG8'])
263
>>> c1=pyfits.Column(name='target',format='10A',array=names)
264
>>> c2=pyfits.Column(name='counts',format='J',unit='DN',
266
>>> c3=pyfits.Column(name='notes',format='A10')
267
>>> c4=pyfits.Column(name='spectrum',format='5E')
268
>>> c5=pyfits.Column(name='flag',format='L',array=[0,1,0,0])
269
>>> coldefs=pyfits.ColDefs([c1,c2,c3,c4,c5])
271
>>> tbhdu=pyfits.new_table(coldefs)
272
>>> tbhdu.data[0][3] = num.array([1.,2.,3.,4.,5.],
273
... dtype=num.float32)
275
>>> tbhdu2=pyfits.new_table(tbhdu1.data, nrows=9)
277
>>> # Assign the 4 rows from the second table to rows 5 thru
278
... 8 of the new table. Note that the last row of the new
279
... table will still be initialized to the default values.
280
>>> tbhdu2.data[4:] = tbhdu.data
282
>>> print tbhdu2.data
283
[ ('NGC1', 312, '0.0', array([ 0., 0., 0., 0., 0.],
284
dtype=float32), True)
285
('NGC2', 334, '0.0', array([ 0., 0., 0., 0., 0.],
286
dtype=float32), False)
287
('NGC3', 308, '0.0', array([ 0., 0., 0., 0., 0.],
288
dtype=float32), True)
289
('NCG4', 317, '0.0', array([ 0., 0., 0., 0., 0.],
290
dtype=float32), True)
291
('NGC5', 112, '0.0', array([ 1., 2., 3., 4., 5.],
292
dtype=float32), False)
293
('NGC6', 134, '0.0', array([ 0., 0., 0., 0., 0.],
294
dtype=float32), True)
295
('NGC7', 108, '0.0', array([ 0., 0., 0., 0., 0.],
296
dtype=float32), False)
297
('NCG8', 117, '0.0', array([ 0., 0., 0., 0., 0.],
298
dtype=float32), False)
299
('0.0', 0, '0.0', array([ 0., 0., 0., 0., 0.],
300
dtype=float32), False)]
303
* The following bugs were fixed:
304
+ Corrected bugs in HDUList.append and HDUList.insert to
305
correctly handle the situation where you want to insert or
306
append a Primary HDU as something other than the first HDU in
307
an HDUList and the situation where you want to insert or
308
append an Extension HDU as the first HDU in an HDUList.
309
+ Corrected a bug involving scaled images (both compressed and
310
not compressed) that include a BLANK, or ZBLANK card in the
311
header. When the image values match the BLANK or ZBLANK value,
312
the value should be replaced with NaN after scaling. Instead,
313
pyfits was scaling the BLANK or ZBLANK value and returning it.
315
+ Corrected a byteswapping bug that occurs when writing certain
316
column data. (CNSHD763307)
317
+ Corrected a bug that occurs when creating a column from a
318
chararray when one or more elements are shorter than the
319
specified format length. The bug wrote nulls instead of spaces
320
to the file. (CNSHD695419)
321
+ Corrected a bug in the HDU verification software to ensure
322
that the header contains no NAXISn cards where n > NAXIS.
323
+ Corrected a bug involving reading and writing compressed image
324
data. When written, the header keyword card ZTENSION will
325
always have the value 'IMAGE' and when read, if the ZTENSION
326
value is not 'IMAGE' the user will receive a warning, but the
327
data will still be treated as image data.
328
+ Corrected a bug that restricted the ability to create a custom
329
HDU class and use it with pyfits. The bug fix will allow
332
>>> class MyPrimaryHDU(pyfits.PrimaryHDU):
333
... def __init__(self, data=None, header=None):
334
... pyfits.PrimaryHDU.__init__(self, data, header)
336
... def _summary(self):
338
... Reimplement a method of the class.
340
... s = pyfits.PrimaryHDU._summary(self)
341
... # change the behavior to suit me.
342
... s1 = 'MyPRIMARY ' + s[11:]
345
>>> hdul=pyfits.open("pix.fits",
346
... classExtensions={pyfits.PrimaryHDU: MyPrimaryHDU})
350
No. Name Type Cards Dimensions Format
351
0 MyPRIMARY MyPrimaryHDU 59 (512, 512) int16
354
+ Modified ColDefs.add_col so that instead of returning a new
355
ColDefs object with the column added to the end, it simply
356
appends the new column to the current ColDefs object in place.
358
+ Corrected a bug in ColDefs.del_col which raised a KeyError
359
exception when deleting a column from a ColDefs object.
360
+ Modified the open convenience function so that when a file is
361
opened in readonly mode and the file contains no HDU's an
363
+ Modified _TableBaseHDU to ensure that all locations where data
364
is referenced in the object actually reference the same
365
ndarray, instead of copies of the array.
366
+ Corrected a bug in the Column class that failed to initialize
367
data when the data is a boolean array. (CNSHD779136)
368
+ Corrected a bug that caused an exception to be raised when
369
creating a variable length format column from character data
371
__________________________________________________________________
373
Version 2.2.2; October 12 2009
375
* Updates described in this release are only supported in the NUMPY
377
* The following bugs were fixed:
378
+ Corrected a bug that caused an exception to be raised when
379
creating a CompImageHDU using an initial header that does not
380
match the image data in terms of the number of axis.
381
__________________________________________________________________
383
Version 2.2.1; October 6 2009
385
* Updates described in this release are only supported in the NUMPY
387
* The following bugs were fixed:
388
+ Corrected a bug that prevented the opening of a fits file
389
where a header contained a CHECKSUM card but no DATASUM card.
390
+ Corrected a bug that caused NULLs to be written instead of
391
blanks when an ASCII table was created using a numpy chararray
392
in which the original data contained trailing blanks.
394
__________________________________________________________________
396
Version 2.2; September 23 2009
398
* Updates described in this release are only supported in the NUMPY
400
* The following enhancements were made:
401
+ Provide support for the FITS Checksum Keyword Convention.
403
o Adding the checksum=True keyword argument to the open
404
convenience function will cause checksums to be verified
406
hdul=pyfits.open('in.fits',checksum=True)
408
o On output, CHECKSUM and DATASUM cards may be output to
409
all HDU's in a fits file by using the keyword argument
410
checksum=True in calls to the writeto convenience
411
function, the HDUList.writeto method, the writeto methods
412
of all of the HDU classes, and the append convenience
414
hdul.writeto('out.fits',checksum=True)
416
+ Implemented a new insert method to the HDUList class that
417
allows for the insertion of a HDU into a HDUList at a given
421
+ Provided the capability to handle unicode input for file
423
+ Provided support for integer division required by Python 3.0.
424
* The following bugs were fixed:
425
+ Corrected a bug that caused an index out of bounds exception
426
to be raised when iterating over the rows of a binary table
427
HDU using the syntax " for row in tbhdu.data: ". (CNSHD748609)
428
+ Corrected a bug that prevented the use of the writeto
429
convenience function for writing table data to a file.
431
+ Modified the code to raise an IOError exception with the
432
comment "Header missing END card." when pyfits can't find a
433
valid END card for a header when opening a file.
434
o This change addressed a problem with a non-standard fits
435
file that contained several new-line characters at the
436
end of each header and at the end of the file. However,
437
since some people want to be able to open these
438
non-standard files anyway, an option was added to the
439
open convenience function to allow these files to be
440
opened without exception.
441
pyfits.open('infile.fits',ignore_missing_end=True)
443
+ Corrected a bug that prevented the use of StringIO objects as
444
fits files when reading and writing table data. Previously,
445
only image data was supported. (CNSHD753698)
446
+ Corrected a bug that caused a bus error to be generated when
447
compressing image data using GZIP_1 under the Solaris
449
+ Corrected bugs that prevented pyfits from properly reading
450
Random Groups HDU's using numpy. (CNSHD756570)
451
+ Corrected a bug that can occur when writing a fits file.
453
o If no default SIGINT signal handler has not been
454
assigned, before the write, a TypeError exception is
455
raised in the _File.flush() method when attempting to
456
return the signal handler to its previous state. Notably
457
this occurred when using mod_python. The code was changed
458
to use SIG_DFL when no old handler was defined.
459
+ Corrected a bug in CompImageHDU that prevented rescaling the
460
image data using hdu.scale(option='old').
461
__________________________________________________________________
463
Version 2.1.1; April 22 2009
465
* Updates described in this release are only supported in the NUMPY
467
* The following bugs were fixed:
468
+ Corrected a bug that caused an exception to be raised when
469
closing a file opened for append, where an HDU was appended to
470
the file, after data was accessed from the file. This
471
exception was only raised when running on a Windows platform.
472
+ Updated the installation scripts, compression source code, and
473
benchmark test scripts to properly install, build, and execute
474
on a Windows platform.
475
__________________________________________________________________
477
Version 2.1; April 14 2009
479
* Updates described in this release are only supported in the NUMPY
481
* The following enhancements were made:
482
+ Added new tdump and tcreate capabilities to pyfits.
483
o The new tdump convenience function allows the contents of
484
a binary table HDU to be dumped to a set of three files
485
in ASCII format. One file will contain column
486
definitions, the second will contain header parameters,
487
and the third will contain header data.
488
o The new tcreate convenience function allows the creation
489
of a binary table HDU from the three files dumped by the
490
tdump convenience function.
491
o The primary use for the tdump/tcreate methods are to
492
allow editing in a standard text editor of the binary
493
table data and parameters.
494
+ Added support for case sensitive values of the EXTNAME card in
495
an extension header. (CNSHD745784)
496
o By default, pyfits converts the value of EXTNAME cards to
497
upper case when reading from a file. A new convenience
498
function (setExtensionNameCaseSensitive) was implemented
499
to allow a user to circumvent this behavior so that the
500
EXTNAME value remains in the same case as it is in the
502
o With the following function call, pyfits will maintain
503
the case of all characters in the EXTNAME card values of
504
all extension HDU's during the entire python session, or
505
until another call to the function is made:
507
>>> pyfits.setExtensionNameCaseSensitive()
509
o The following function call will return pyfits to its
510
default (all upper case) behavior:
511
>>> pyfits.setExtensionNameCaseSensitive(False)
513
+ Added support for reading and writing FITS files in which the
514
value of the first card in the header is 'SIMPLE=F'. In this
515
case, the pyfits open function returns an HDUList object that
516
contains a single HDU of the new type _NonstandardHDU. The
517
header for this HDU is like a normal header (with the
518
exception that the first card contains SIMPLE=F instead of
519
SIMPLE=T). Like normal HDU's the reading of the data is
520
delayed until actually requested. The data is read from the
521
file into a string starting from the first byte after the
522
header END card and continuing till the end of the file. When
523
written, the header is written, followed by the data string.
524
No attempt is made to pad the data string so that it fills
525
into a standard 2880 byte FITS block. (CNSHD744730)
526
+ Added support for FITS files containing extensions with
527
unknown XTENSION card values. (CNSHD744730) Standard FITS
528
files support extension HDU's of types TABLE, IMAGE, BINTABLE,
529
and A3DTABLE. Accessing a nonstandard extension from a FITS
530
file will now create a _NonstandardExtHDU object. Accessing
531
the data of this object will cause the data to be read from
532
the file into a string. If the HDU is written back to a file
533
the string data is written after the Header and padded to fill
534
a standard 2880 byte FITS block.
535
* The following bugs were fixed:
536
+ Extensive changes were made to the tiled image compression
537
code to support the latest enhancements made in CFITSIO
538
version 3.13 to support this convention.
539
+ Eliminated a memory leak in the tiled image compression code.
540
+ Corrected a bug in the FITS_record.__setitem__ method which
541
raised a NameError exception when attempting to set a value in
542
a FITS_record object. (CNSHD745844)
543
+ Corrected a bug that caused a TypeError exception to be raised
544
when reading fits files containing large table HDU's (>2Gig).
546
+ Corrected a bug that caused a TypeError exception to be raised
547
for all calls to the warnings module when running under Python
548
2.6. The formatwarning method in the warnings module was
549
changed in Python 2.6 to include a new argument. (CNSHD746592)
550
+ Corrected the behavior of the membership (in) operator in the
551
Header class to check against header card keywords instead of
552
card values. (CNSHD744730)
553
+ Corrected the behavior of iteration on a Header object. The
554
new behavior iterates over the unique card keywords instead of
556
__________________________________________________________________
558
Version 2.0.1; February 3 2009
560
* Updates described in this release are only supported in the NUMPY
562
* The following bugs were fixed:
563
+ Eliminated a memory leak when reading Table HDU's from a fits
565
__________________________________________________________________
567
Version 2.0; January 30 2009
569
* Updates described in this release are only supported in the NUMPY
571
* The following enhancements were made:
572
+ Provide initial support for an image compression convention
573
known as the [3]"Tiled Image Compression Convention".
574
o The principle used in this convention is to first divide
575
the n-dimensional image into a rectangular grid of
576
subimages or "tiles". Each tile is then compressed as a
577
continuous block of data, and the resulting compressed
578
byte stream is stored in a row of a variable length
579
column in a FITS binary table. Several commonly used
580
algorithms for compressing image tiles are supported.
581
These include, GZIP, RICE, H-Compress and IRAF pixel list
583
o Support for compressed image data is provided using the
584
optional "pyfitsComp" module contained in a C shared
585
library (pyfitsCompmodule.so).
586
o The header of a compressed image HDU appears to the user
587
like any image header. The actual header stored in the
588
FITS file is that of a binary table HDU with a set of
589
special keywords, defined by the convention, to describe
590
the structure of the compressed image. The conversion
591
between binary table HDU header and image HDU header is
592
all performed behind the scenes. Since the HDU is
593
actually a binary table, it may not appear as a primary
595
o The data of a compressed image HDU appears to the user as
596
standard uncompressed image data. The actual data is
597
stored in the fits file as Binary Table data containing
598
at least one column (COMPRESSED_DATA). Each row of this
599
variable-length column contains the byte stream that was
600
generated as a result of compressing the corresponding
601
image tile. Several optional columns may also appear.
602
These include, UNCOMPRESSED_DATA to hold the uncompressed
603
pixel values for tiles that cannot be compressed, ZSCALE
604
and ZZERO to hold the linear scale factor and zero point
605
offset which may be needed to transform the raw
606
uncompressed values back to the original image pixel
607
values, and ZBLANK to hold the integer value used to
608
represent undefined pixels (if any) in the image.
609
o To create a compressed image HDU from scratch, simply
610
construct a CompImageHDU object from an uncompressed
611
image data array and its associated image header. From
612
there, the HDU can be treated just like any image HDU.
613
>>> hdu=pyfits.CompImageHDU(imageData,imageHeader)
614
>>> hdu.writeto('compressed_image.fits')
616
o The signature for the CompImageHDU initializer method
617
describes the possible options for constructing a
619
def __init__(self, data=None, header=None, name=None,
620
compressionType='RICE_1',
625
"""data: data of the image
626
header: header to be associated with the
628
name: the EXTNAME value; if this value
629
is None, then the name from the
630
input image header will be used;
631
if there is no name in the input
632
image header then the default name
633
'COMPRESSED_IMAGE' is used
634
compressionType: compression algorithm 'RICE_1',
635
'PLIO_1', 'GZIP_1', 'HCOMPRESS_1'
636
tileSize: compression tile sizes default
637
treats each row of image as a tile
638
hcompScale: HCOMPRESS scale parameter
639
hcompSmooth: HCOMPRESS smooth parameter
640
quantizeLevel: floating point quantization level;
643
+ Added two new convenience functions. The setval function
644
allows the setting of the value of a single header card in a
645
fits file. The delval function allows the deletion of a single
646
header card in a fits file.
647
+ A modification was made to allow the reading of data from a
648
fits file containing a Table HDU that has duplicate field
649
names. It is normally a requirement that the field names in a
650
Table HDU be unique. Prior to this change a ValueError was
651
raised, when the data was accessed, to indicate that the HDU
652
contained duplicate field names. Now, a warning is issued and
653
the field names are made unique in the internal record array.
654
This will not change the TTYPEn header card values. You will
655
be able to get the data from all fields using the field name,
656
including the first field containing the name that is
657
duplicated. To access the data of the other fields with the
658
duplicated names you will need to use the field number instead
659
of the field name. (CNSHD737193)
660
+ An enhancement was made to allow the reading of unsigned
661
integer 16 values from an ImageHDU when the data is signed
662
integer 16 and BZERO is equal to 32784 and BSCALE is equal to
663
1 (the standard way for scaling unsigned integer 16 data). A
664
new optional keyword argument (uint16) was added to the open
665
convenience function. Supplying a value of True for this
666
argument will cause data of this type to be read in and scaled
667
into an unsigned integer 16 array, instead of a float 32
668
array. If a HDU associated with a file that was opened with
669
the uint16 option and containing unsigned integer 16 data is
670
written to a file, the data will be reverse scaled into an
671
integer 16 array and written out to the file and the
672
BSCALE/BZERO header cards will be written with the values 1
673
and 32768 respectively. (CHSHD736064) Reference the following
676
>>> hdul=pyfits.open('o4sp040b0_raw.fits',uint16=1)
678
array([[1507, 1509, 1505, ..., 1498, 1500, 1487],
679
[1508, 1507, 1509, ..., 1498, 1505, 1490],
680
[1505, 1507, 1505, ..., 1499, 1504, 1491],
682
[1505, 1506, 1507, ..., 1497, 1502, 1487],
683
[1507, 1507, 1504, ..., 1495, 1499, 1486],
684
[1515, 1507, 1504, ..., 1492, 1498, 1487]], dtype=uint16)
685
>>> hdul.writeto('tmp.fits')
686
>>> hdul1=pyfits.open('tmp.fits',uint16=1)
688
array([[1507, 1509, 1505, ..., 1498, 1500, 1487],
689
[1508, 1507, 1509, ..., 1498, 1505, 1490],
690
[1505, 1507, 1505, ..., 1499, 1504, 1491],
692
[1505, 1506, 1507, ..., 1497, 1502, 1487],
693
[1507, 1507, 1504, ..., 1495, 1499, 1486],
694
[1515, 1507, 1504, ..., 1492, 1498, 1487]], dtype=uint16)
695
>>> hdul1=pyfits.open('tmp.fits')
697
array([[ 1507., 1509., 1505., ..., 1498., 1500., 1487.],
698
[ 1508., 1507., 1509., ..., 1498., 1505., 1490.],
699
[ 1505., 1507., 1505., ..., 1499., 1504., 1491.],
701
[ 1505., 1506., 1507., ..., 1497., 1502., 1487.],
702
[ 1507., 1507., 1504., ..., 1495., 1499., 1486.],
703
[ 1515., 1507., 1504., ..., 1492., 1498., 1487.]], dtype=float32)
705
+ Enhanced the message generated when a ValueError exception is
706
raised when attempting to access a header card with an
707
unparsable value. The message now includes the Card name.
708
* The following bugs were fixed:
709
+ Corrected a bug that occurs when appending a binary table HDU
710
to a fits file. Data was not being byteswapped on little
711
endian machines. (CNSHD737243)
712
+ Corrected a bug that occurs when trying to write an ImageHDU
713
that is missing the required PCOUNT card in the header. An
714
UnboundLocalError exception complaining that the local
715
variable 'insert_pos' was referenced before assignment was
716
being raised in the method _ValidHDU.req_cards. The code was
717
modified so that it would properly issue a more meaningful
718
ValueError exception with a description of what required card
719
is missing in the header.
720
+ Eliminated a redundant warning message about the PCOUNT card
721
when validating an ImageHDU header with a PCOUNT card that is
722
missing or has a value other than 0.
723
__________________________________________________________________
725
Version 1.4.1; November 4 2008
727
* Updates described in this release are only supported in the NUMPY
729
* The following enhancements were made:
730
+ Enhanced the way import errors are reported to provide more
732
* The following bugs were fixed:
733
+ Corrected a bug that occurs when a card value is a string and
734
contains a colon but is not a record-valued keyword card.
735
+ Corrected a bug where pyfits fails to properly handle a
736
record-valued keyword card with values using exponential
737
notation and trailing blanks.
738
__________________________________________________________________
740
Version 1.4; July 7 2008
742
* Updates described in this release are only supported in the NUMPY
744
* The following enhancements were made:
745
+ Added support for file objects and file like objects.
746
o All convenience functions and class methods that take a
747
file name will now also accept a file object or file like
748
object. File like objects supported are StringIO and
749
GzipFile objects. Other file like objects will work only
750
if they implement all of the standard file object
752
o For the most part, file or file like objects may be
753
either opened or closed at function call. An opened
754
object must be opened with the proper mode depending on
755
the function or method called. Whenever possible, if the
756
object is opened before the method is called, it will
757
remain open after the call. This will not be possible
758
when writing a HDUList that has been resized or when
759
writing to a GzipFile object regardless of whether it is
760
resized. If the object is closed at the time of the
761
function call, only the name from the object is used, not
762
the object itself. The pyfits code will extract the file
763
name used by the object and use that to create an
764
underlying file object on which the function will be
766
+ Added support for record-valued keyword cards as introduced in
767
the "FITS WCS Paper IV proposal for representing a more
768
general distortion model".
769
o Record-valued keyword cards are string-valued cards where
770
the string is interpreted as a definition giving a record
771
field name, and its floating point value. In a FITS
772
header they have the following syntax:
773
keyword= 'field-specifier: float'
775
where keyword is a standard eight-character FITS keyword
776
name, float is the standard FITS ASCII representation of
777
a floating point number, and these are separated by a
778
colon followed by a single blank.
779
The grammer for field-specifier is:
782
field-specifier.field
788
where identifier is a sequence of letters (upper or lower
789
case), underscores, and digits of which the first
790
character must not be a digit, and index is a sequence of
791
digits. No blank characters may occur in the
792
field-specifier. The index is provided primarily for
793
defining array elements though it need not be used for
795
Multiple record-valued keywords of the same name but
796
differing values may be present in a FITS header. The
797
field-specifier may be viewed as part of the keyword
799
Some examples follow:
804
DP1 = 'AUX.1.COEFF.0: 0'
805
DP1 = 'AUX.1.POWER.0: 1'
806
DP1 = 'AUX.1.COEFF.1: 0.00048828125'
807
DP1 = 'AUX.1.POWER.1: 1'
809
o As with standard header cards, the value of a
810
record-valued keyword card can be accessed using either
811
the index of the card in a HDU's header or via the
812
keyword name. When accessing using the keyword name, the
813
user may specify just the card keyword or the card
814
keyword followed by a period followed by the
815
field-specifier. Note that while the card keyword is case
816
insensitive, the field-specifier is not. Thus,
817
hdu['abc.def'], hdu['ABC.def'], or hdu['aBc.def'] are all
818
equivalent but hdu['ABC.DEF'] is not.
819
o When accessed using the card index of the HDU's header
820
the value returned will be the entire string value of the
827
o When accessed using the keyword name exclusive of the
828
field-specifier, the entire string value of the header
829
card with the lowest index having that keyword name will
830
be returned. For example:
834
o When accessing using the keyword name and the
835
field-specifier, the value returned will be the floating
836
point value associated with the record-valued keyword
838
>>> print hdr['DP1.NAXIS']
841
o Any attempt to access a non-existent record-valued
842
keyword card value will cause an exception to be raised
843
(IndexError exception for index access or KeyError for
844
keyword name access).
845
o Updating the value of a record-valued keyword card can
846
also be accomplished using either index or keyword name.
848
>>> print hdr['DP1.NAXIS']
850
>>> hdr['DP1.NAXIS'] = 3.0
851
>>> print hdr['DP1.NAXIS']
854
o Adding a new record-valued keyword card to an existing
855
header is accomplished using the Header.update() method
856
just like any other card. For example:
857
>>> hdr.update('DP1', 'AXIS.3: 1', 'a comment', after='DP1.AXIS.2')
859
o Deleting a record-valued keyword card from an existing
860
header is accomplished using the standard list deletion
861
syntax just like any other card. For example:
862
>>> del hdr['DP1.AXIS.1']
864
o In addition to accessing record-valued keyword cards
865
individually using a card index or keyword name, cards
866
can be accessed in groups using a set of special pattern
867
matching keys. This access is made available via the
868
standard list indexing operator providing a keyword name
869
string that contains one or more of the special pattern
870
matching keys. Instead of returning a value, a CardList
871
object will be returned containing shared instances of
872
the Cards in the header that match the given keyword
874
o There are three special pattern matching keys. The first
875
key '*' will match any string of zero or more characters
876
within the current level of the field-specifier. The
877
second key '?' will match a single character. The third
878
key '...' must appear at the end of the keyword name
879
string and will match all keywords that match the
880
preceding pattern down all levels of the field-specifier.
881
All combinations of ?, *, and ... are permitted (though
882
... is only permitted at the end). Some examples follow:
883
>>> cl=hdr['DP1.AXIS.*']
891
>>> cl=hdr['DP1.AUX...']
893
DP1 = 'AUX.1.COEFF.0: 0'
894
DP1 = 'AUX.1.POWER.0: 1'
895
DP1 = 'AUX.1.COEFF.1: 0.00048828125'
896
DP1 = 'AUX.1.POWER.1: 1'
897
>>> cl=hdr['DP?.NAXIS']
902
>>> cl=hdr['DP1.A*S.*']
907
o The use of the special pattern matching keys for adding
908
or updating header cards in an existing header is not
909
allowed. However, the deletion of cards from the header
910
using the special keys is allowed. For example:
911
>>> del hdr['DP3.A*...']
913
o As noted above, accessing pyfits Header object using the
914
special pattern matching keys will return a CardList
915
object. This CardList object can itself be searched in
916
order to further refine the list of Cards. For example:
923
DP1 = 'AUX.1.COEFF.1: 0.000488'
924
DP1 = 'AUX.2.COEFF.2: 0.00097656'
925
>>> cl1=cl['*.*AUX...']
928
DP1 = 'AUX.1.COEFF.1: 0.000488'
929
DP1 = 'AUX.2.COEFF.2: 0.00097656'
931
o The CardList keys() method will allow the retrivial of
932
all of the key values in the CardList. For example:
933
>>> cl=hdr['DP1.AXIS.*']
938
['DP1.AXIS.1', 'DP1.AXIS.2']
940
o The CardList values() method will allow the retrivial of
941
all of the values in the CardList. For example:
942
>>> cl=hdr['DP1.AXIS.*']
949
o Individual cards can be retrieved from the list using
950
standard list indexing. For example:
951
>>> cl=hdr['DP1.AXIS.*']
955
>>> c=cl['DP1.AXIS.2']
959
o Individual card values can be retrieved from the list
960
using the value attribute of the card. For example:
961
>>> cl=hdr['DP1.AXIS.*']
965
o The cards in the CardList are shared instances of the
966
cards in the source header. Therefore, modifying a card
967
in the CardList also modifies it in the source header.
968
However, making an addition or a deletion to the CardList
969
will not affect the source header. For example:
970
>>> hdr['DP1.AXIS.1']
972
>>> cl=hdr['DP1.AXIS.*']
973
>>> cl[0].value = 4.0
974
>>> hdr['DP1.AXIS.1']
977
>>> print cl['DP1.AXIS.1']
978
Traceback (most recent call last):
980
File "NP_pyfits.py", line 977, in __getitem__
981
return self.ascard[key].value
982
File "NP_pyfits.py", line 1258, in __getitem__
983
_key = self.index_of(key)
984
File "NP_pyfits.py", line 1403, in index_of
985
raise KeyError, 'Keyword %s not found.' % `key`
986
KeyError: "Keyword 'DP1.AXIS.1' not found."
987
>>> hdr['DP1.AXIS.1']
990
o A FITS header consists of card images. In pyfits each
991
card image is manifested by a Card object. A pyfits
992
Header object contains a list of Card objects in the form
993
of a CardList object. A record-valued keyword card image
994
is represented in pyfits by a RecordValuedKeywordCard
995
object. This object inherits from a Card object and has
996
all of the methods and attributes of a Card object.
997
o A new RecordValuedKeywordCard object is created with the
998
RecordValuedKeywordCard constructor:
999
RecordValuedKeywordCard(key, value, comment). The key and
1000
value arguments may be specified in two ways. The key
1001
value may be given as the 8 character keyword only, in
1002
which case the value must be a character string
1003
containing the field-specifier, a colon followed by a
1004
space, followed by the actual value. The second option is
1005
to provide the key as a string containing the keyword and
1006
field-specifier, in which case the value must be the
1007
actual floating point value. For example:
1008
>>> c1 = pyfits.RecordValuedKeywordCard('DP1', 'NAXIS: 2', 'Number of variables'
1010
>>> c2 = pyfits.RecordValuedKeywordCard('DP1.AXIS.1', 1.0, 'Axis number')
1012
o RecordValuedKeywordCards have attributes .key,
1013
.field_specifier, .value, and .comment. Both .value and
1014
.comment can be changed but not .key or .field_specifier.
1015
The constructor will extract the field-specifier from the
1016
input key or value, whichever is appropriate. The .key
1017
attribute is the 8 character keyword.
1018
o Just like standard Cards, a RecordValuedKeywordCard may
1019
be constructed from a string using the fromstring()
1020
method or verified using the verify() method. For
1022
>>> c1 = pyfits.RecordValuedKeywordCard().fromstring(
1023
"DP1 = 'NAXIS: 2' / Number of independent variables")
1024
>>> c2 = pyfits.RecordValuedKeywordCard().fromstring(
1025
"DP1 = 'AXIS.1: X' / Axis number")
1026
>>> print c1; print c2
1027
DP1 = 'NAXIS: 2' / Number of independent variables
1028
DP1 = 'AXIS.1: X' / Axis number
1030
Output verification result:
1031
Card image is not FITS standard (unparsable value string).
1033
o A standard card that meets the criteria of a
1034
RecordValuedKeywordCard may be turned into a
1035
RecordValuedKeywordCard using the class method coerce. If
1036
the card object does not meet the required criteria then
1037
the original card object is just returned.
1038
>>> c1 = pyfits.Card('DP1','AUX: 1','comment')
1039
>>> c2 = pyfits.RecordValuedKeywordCard.coerce(c1)
1041
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
1043
o Two other card creation methods are also available as
1044
RecordVauedKeywordCard class methods. These are
1045
createCard() which will create the appropriate card
1046
object (Card or RecordValuedKeywordCard) given input key,
1047
value, and comment, and createCardFromString which will
1048
create the appropriate card object given an input string.
1049
These two methods are also available as convenience
1051
>>> c1 = pyfits.RecordValuedKeywordCard.createCard('DP1','AUX: 1','comment)
1053
>>> c1 = pyfits.createCard('DP1','AUX: 1','comment)
1055
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
1057
>>> c1 = pyfits.RecordValuedKeywordCard.createCard('DP1','AUX 1','comment)
1059
>>> c1 = pyfits.createCard('DP1','AUX 1','comment)
1061
<class 'pyfits.NP_pyfits.Card'>
1063
>>> c1 = pyfits.RecordValuedKeywordCard.createCardFromString \
1064
("DP1 = 'AUX: 1.0' / comment")
1066
>>> c1 = pyfits.createCardFromString("DP1 = 'AUX: 1.0' / comment")
1068
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
1070
* The following bugs were fixed:
1071
+ Corrected a bug that occurs when writing a HDU out to a file.
1072
During the write, any Keyboard Interrupts are trapped so that
1073
the write completes before the interrupt is handled.
1074
Unfortunately, the Keyboard Interrupt was not properly
1075
reinstated after the write completed. This was fixed.
1077
+ Corrected a bug when using ipython, where temporary files
1078
created with the tempFile.NamedTemporaryFile method are not
1079
automatically removed. This can happen for instance when
1080
opening a Gzipped fits file or when open a fits file over the
1081
internet. The files will now be removed. (CNSHD718307)
1082
+ Corrected a bug in the append convenience function's call to
1083
the writeto convenience function. The classExtensions argument
1084
must be passed as a keyword argument.
1085
+ Corrected a bug that occurs when retrieving variable length
1086
character arrays from binary table HDUs (PA() format) and
1087
using slicing to obtain rows of data containing variable
1088
length arrays. The code issued a TypeError exception. The data
1089
can now be accessed with no exceptions. (CNSHD718749)
1090
+ Corrected a bug that occurs when retrieving data from a fits
1091
file opened in memory map mode when the file contains multiple
1092
image extensions or ASCII table or binary table HDUs. The code
1093
issued a TypeError exception. The data can now be accessed
1094
with no exceptions. (CNSHD707426)
1095
+ Corrected a bug that occurs when attempting to get a subset of
1096
data from a Binary Table HDU and then use the data to create a
1097
new Binary Table HDU object. A TypeError exception was raised.
1098
The data can now be subsetted and used to create a new HDU.
1100
+ Corrected a bug that occurs when attempting to scale an Image
1101
HDU back to its original data type using the
1102
_ImageBaseHDU.scale method. The code was not resetting the
1103
BITPIX header card back to the original data type. This has
1105
+ Changed the code to issue a KeyError exception instead of a
1106
NameError exception when accessing a non-existent field in a
1108
__________________________________________________________________
1110
Version 1.3; February 22 2008
1112
* Updates described in this release are only supported in the NUMPY
1114
* The following enhancements were made:
1115
+ Provided support for a new extension to pyfits called
1117
o The stpyfits module is a wrapper around pyfits. It
1118
provides all of the features and functions of pyfits
1119
along with some STScI specific features. Currently, the
1120
only new feature supported by stpyfits is the ability to
1121
read and write fits files that contain image data quality
1122
extensions with constant data value arrays. See
1123
[4]stpyfits for more details on stpyfits.
1124
+ Added a new feature to allow trailing HDUs to be deleted from
1125
a fits file without actually reading the data from the file.
1126
o This supports a JWST requirement to delete a trailing HDU
1127
from a file whose primary Image HDU is too large to be
1128
read on a 32 bit machine.
1129
+ Updated pyfits to use the warnings module to issue warnings.
1130
All warnings will still be issued to stdout, exactly as they
1131
were before, however, you may now suppress warnings with the
1132
-Wignore command line option. For example, to run a script
1133
that will ignore warnings use the following command line
1135
python -Wignore yourscript.py
1137
+ Updated the open convenience function to allow the input of an
1138
already opened file object in place of a file name when
1139
opening a fits file.
1140
+ Updated the writeto convenience function to allow it to accept
1141
the output_verify option.
1142
o In this way, the user can use the argument
1143
output_verify='fix' to allow pyfits to correct any errors
1144
it encounters in the provided header before writing the
1146
+ Updated the verification code to provide additional detail
1147
with a VerifyError exception.
1148
+ Added the capability to create a binary table HDU directly
1149
from a numpy.ndarray. This may be done using either the
1150
new_table convenience function or the BinTableHDU constructor.
1151
* The following performance improvements were made:
1152
+ Modified the import logic to dramatically decrease the time it
1153
takes to import pyfits.
1154
+ Modified the code to provide performance improvements when
1155
copying and examining header cards.
1156
* The following bugs were fixed:
1157
+ Corrected a bug that occurs when reading the data from a fits
1158
file that includes BZERO/BSCALE scaling. When the data is read
1159
in from the file, pyfits automatically scales the data using
1160
the BZERO/BSCALE values in the header. In the previous
1161
release, pyfits created a 32 bit floating point array to hold
1162
the scaled data. This could cause a problem when the value of
1163
BZERO is so large that the scaled value will not fit into the
1164
float 32. For this release, when the input data is 32 bit
1165
integer, a 64 bit floating point array is used for the scaled
1167
+ Corrected a bug that caused an exception to be raised when
1168
attempting to scale image data using the ImageHDU.scale
1170
+ Corrected a bug in the new_table convenience function that
1171
occurred when a binary table was created using a ColDefs
1172
object as input and supplying an nrows argument for a number
1173
of rows that is greater than the number of rows present in the
1174
input ColDefs object. The previous version of pyfits failed to
1175
allocate the necessary memory for the additional rows.
1176
+ Corrected a bug in the new_table convenience function that
1177
caused an exception to be thrown when creating an ASCII table.
1178
+ Corrected a bug in the new_table convenience function that
1179
will allow the input of a ColDefs object that was read from a
1180
file as a binary table with a data value equal to None.
1181
+ Corrected a bug in the construction of ASCII tables from
1182
Column objects that are created with noncontinuous start
1184
+ Corrected bugs in a number of areas that would sometimes cause
1185
a failure to improperly raise an exception when an error
1187
+ Corrected a bug where attempting to open a non-existent fits
1188
file on a windows platform using a drive letter in the file
1189
specification caused a misleading IOError exception to be
1191
__________________________________________________________________
1193
Version 1.1; June 15 2007
1195
* Modified to use either NUMPY or NUMARRAY.
1196
* New file writing modes have been provided to allow streaming data
1197
to extensions without requiring the whole output extension image in
1198
memory. See documentation on StreamingHDU.
1199
* Improvements to minimize byteswapping and memory usage by
1200
byteswapping in place.
1201
* Now supports ':' characters in filenames.
1202
* Handles keyboard interrupts during long operations.
1203
* Preserves the byte order of the input image arrays.
1204
__________________________________________________________________
1206
Version 1.0.1; March 24 2006
1208
The changes to PyFITS were primarily to improve the docstrings and to
1209
reclassify some public functions and variables as private. Readgeis and
1210
fitsdiff which were distributed with PyFITS in previous releases were
1211
moved to pytools. This release of PyFITS is v1.0.1. The next release of
1212
PyFITS will support both numarray and numpy (and will be available
1213
separately from stsci_python, as are all the python packages contained
1214
within stsci_python). An alpha release for PyFITS numpy support will be
1215
made around the time of this stsci_python release.
1216
* Updated docstrings for public functions.
1217
* Made some previously public functions private.
1218
__________________________________________________________________
1220
Version 1.0; November 1 2005
1222
Major Changes since v0.9.6:
1224
* Added support for the HEIRARCH convention
1225
* Added support for iteration and slicing for HDU lists
1226
* PyFITS now uses the standard setup.py installation script
1227
* Add utility functions at the module level, they include:
1237
Minor changes since v0.9.6:
1239
* Fix a bug to make single-column ASCII table work.
1240
* Fix a bug so a new table constructed from an existing table with
1241
X-formatted columns will work.
1242
* Fix a problem in verifying HDUList right after the open statement.
1243
* Verify that elements in an HDUList, besides the first one, are
1245
* Add output verification in methods flush() and close().
1246
* Modify the the design of the open() function to remove the
1247
output_verify argument.
1248
* Remove the groups argument in GroupsHDU's contructor.
1249
* Redesign the column definition class to make its column components
1250
more accessible. Also to make it conducive for higher level
1251
functionalities, e.g. combining two column definitions.
1252
* Replace the Boolean class with the Python Boolean type. The old
1253
TRUE/FALSE will still work.
1254
* Convert classes to the new style.
1255
* Better format when printing card or card list.
1256
* Add the optional argument clobber to all writeto() functions and
1258
* If adding a blank card, will not use existing blank card's space.
1260
PyFITS Version 1.0 REQUIRES Python 2.3 or later.
1261
__________________________________________________________________
1263
Version 0.9.6; 11 November 2004
1265
Major changes since v0.9.3:
1267
* Support for variable length array tables.
1268
* Support for writing ASCII table extensions.
1269
* Support for random groups, both reading and writing.
1273
* Support for numbers with leading zeros in an ASCII table extension.
1274
* Changed scaled columns' data type from Float32 to Float64 to
1276
* Made Column constructor more flexible in accepting format
1278
__________________________________________________________________
1280
Version 0.9.3; 2 July 2004
1282
Changes since v0.9.0:
1284
* Lazy instanciation of full Headers/Cards for all HDU's when the
1285
file is opened. At the open, only extracts vital info (e.g.
1286
NAXIS's) from the header parts. This change will speed up the
1287
performance if the user only needs to access one extension in a
1288
multi-extension FITS file.
1289
* Support the X format (bit flags) columns, both reading and writing,
1290
in a binary table. At the user interface, they are converted to
1291
Boolean arrays for easy manipulation. For example, if the column's
1292
TFORM is "11X", internally the data is stored in 2 bytes, but the
1293
user will see, at each row of this column, a Boolean array of 11
1295
* Fix a bug such that when a table extension has no data, it will not
1296
try to scale the data when updating/writing the HDU list.
1297
__________________________________________________________________
1299
Version 0.9; 27 April 2004
1301
Changes since v0.8.0:
1303
* Rewriting of the Card class to separate the parsing and
1304
verification of header cards
1305
* Restructure the keyword indexing scheme which speed up certain
1306
applications (update large number of new keywords and reading a
1307
header with larger numbers of cards) by a factor of 30 or more
1308
* Change the default to be lenient FITS standard checking on input
1309
and strict FITS standard checking on output
1310
* Support CONTINUE cards, both reading and writing
1311
* Verification can now be performed at any of the HDUList, HDU, and
1313
* Support (contiguous) subsection (attribute .section) of images to
1314
reduce memory usage for large images
1316
Version 0.8.0; August 19, 2003
1318
NOTE: This version will only work with numarray Version 0.6. In
1319
addition, earlier versions of PyFITS will not work with numarray 0.6.
1320
Therefore, both must be updated simultaneously.
1322
Changes since 0.7.6:
1323
* Compatible with numarray 0.6/records 2.0
1324
* For binary tables, now it is possible to update the original array
1325
if a scaled field is updated.
1326
* Support of complex columns
1327
* Modify the __getitem__ method in FITS_rec. In order to make sure
1328
the scaled quantities are also viewing ths same data as the
1329
original FITS_rec, all fields need to be "touched" when __getitem__
1331
* Add a new attribute mmobject for HDUList, and close the memmap
1332
object when close HDUList object. Earlier version does not close
1333
memmap object and can cause memory lockup.
1334
* Enable 'update' as a legitimate memmap mode.
1335
* Do not print message when closing an HDUList object which is not
1336
created from reading a FITS file. Such message is confusing.
1337
* remove the internal attribute "closed" and related method
1338
(__getattr__ in HDUList). It is redundant.
1340
Version 0.7.6; November 22, 2002
1342
NOTE: This version will only work with numarray Version 0.4.
1344
Changes since 0.7.5:
1345
* Change x*=n to numarray.multiply(x, n, x) where n is a floating
1346
number, in order to make pyfits to work under Python 2.2. (2
1348
* Modify the "update" method in the Header class to use the
1349
"fixed-format" card even if the card already exists. This is to
1350
avoid the mis-alignment as shown below:
1351
After running drizzle on ACS images it creates a CD matrix whose
1352
elements have very many digits, e.g.:
1353
CD1_1 = 1.1187596304411E-05 / partial of first axis coordinate w.r.t. x
1354
CD1_2 = -8.502767249350019E-06 / partial of first axis coordinate w.r.t. y
1356
with pyfits, an "update" on these header items and write in new
1357
values which has fewer digits, e.g.:
1358
CD1_1 = 1.0963011E-05 / partial of first axis coordinate w.r.t. x
1359
CD1_2 = -8.527229E-06 / partial of first axis coordinate w.r.t. y
1361
* Change some internal variables to make their appearance more
1365
__octalRegex _octalRegex
1366
__readblock() _readblock()
1367
__formatter() _formatter().
1368
__value_RE _value_RE
1370
__comment_RE _comment_RE
1371
__keywd_RE _keywd_RE
1372
__number_RE _number_RE.
1373
tmpName() _tmpName()
1377
* Move up the module description. Move the copywright statement to
1378
the bottom and assign to the variable __credits__.
1379
* change the following line:
1380
self.__dict__ = input.__dict__
1383
self.__setstate__(input.__getstate__())
1385
in order for pyfits to run under numarray 0.4.
1386
* edit _readblock to add the (optional) firstblock argument and raise
1387
IOError if the the first 8 characters in the first block is not
1388
'SIMPLE ' or 'XTENSION'. Edit the function open to check for
1389
IOError to skip the last null filled block(s). Edit readHDU to add
1390
the firstblock argument.
1391
__________________________________________________________________
1393
Version 0.7.5; 16 August 2002
1395
Changes since v0.7.3:
1396
1. Memory mapping now works for readonly mode, both for images and
1398
Usage: pyfits.open('filename', memmap=1)
1399
2. Edit the field method in FITS_rec class to make the column scaling
1400
for numbers use less temporary memory. (does not work under 2.2,
1401
due to Python "bug" of array *=)
1402
3. Delete bscale/bzero in the ImageBaseHDU constructor.
1403
4. Update bitpix in BaseImageHDU.__getattr__ after deleting
1404
bscale/bzero. (bug fix)
1405
5. In BaseImageHDU.__getattr__ point self.data to raw_data if float
1406
and if not memmap. (bug fix).
1407
6. Change the function get_tbdata() to private: _get_tbdata().
1408
__________________________________________________________________
1410
Version 0.7.3; 12 July 2002
1412
Changes since v0.7.2:
1413
1. It will scale all integer image data to Float32, if BSCALE/BZERO !=
1414
1/0. It will also expunge the BSCALE/BZERO keywords.
1415
2. Add the scale() method for ImageBaseHDU, so data can be scaled just
1416
before being written to the file. It has the following arguments:
1419
destination data type (string), e.g. Int32, Float32,
1423
scaling scheme. if 'old', use the old BSCALE/BZERO values.
1424
if 'minmax', use the data range to fit into the full range
1425
of specified integer type. Float destination data type
1426
will not be scaled for this option.
1429
user specifiable BSCALE/BZERO values. They overwrite the
1432
3. Deal with data area resizing in 'update' mode.
1433
4. Make the data scaling (both input and output) faster and use less
1435
5. Bug fix to make column name change takes effect for field.
1436
6. Bug fix to avoid exception if the key is not present in the header
1437
already. This affects (fixes) add_history(), add_comment(), and
1439
7. Bug fix in __getattr__() in Card class. The change made in 0.7.2 to
1440
rstrip the comment must be string type to avoid exception.
1441
______________________________________________________________
1443
Version 0.7.2.1; June 25, 2002
1444
A couple of bugs were addressed in this version.
1445
+ Fix a bug in _add_commentary(). Due to a change in index_of()
1446
during version 0.6.5.5, _add_commentary needs to be modified
1447
to avoid exception if the key is not present in the header
1448
already. This affects (fixes) add_history(), add_comment(),
1450
+ Fix a bug in __getattr__() in Card class. The change made in
1451
0.7.2 to rstrip the comment must be string type to avoid
1453
______________________________________________________________
1455
Version 0.7.2; June 19, 2002
1456
The two major improvements from Version 0.6.2 are:
1457
+ support reading tables with "scaled" columns (e.g.
1458
tscal/tzero, Boolean, and ASCII tables)
1459
+ a prototype output verification.
1460
This version of PyFITS requires numarray version 0.3.4.
1461
Other changes include:
1463
1. Implement the new HDU hierarchy proposed earlier this year. This in
1464
turn reduces some of the redundant methods common to several HDU
1466
2. Add 3 new methods to the Header class: add_history, add_comment,
1468
3. The table attributes _columns are now .columns and the attributes
1469
in ColDefs are now all without the underscores. So, a user can get
1470
a list of column names by: hdu.columns.names.
1471
4. The "fill" argument in the new_table method now has a new meaning:
1472
If set to true (=1), it will fill the entire new table with
1473
zeros/blanks. Otherwise (=0), just the extra rows/cells are filled
1474
with zeros/blanks. Fill values other than zero/blank are now not
1476
5. Add the argument output_verify to the open method and writeto
1477
method. Not in the flush or close methods yet, due to possible
1479
6. A new copy method for tables, the copy is totally independent from
1480
the table it copies from.
1481
7. The tostring() call in writeHDUdata takes up extra space to store
1482
the string object. Use tofile() instead, to save space.
1483
8. Make changes from _byteswap to _byteorder, following corresponding
1484
changes in numarray and recarray.
1485
9. Insert(update) EXTEND in PrimaryHDU only when header is None.
1486
10. Strip the trailing blanks for the comment value of a card.
1487
11. Add seek(0) right after the __buildin__.open(0), because for the
1488
'ab+' mode, the pointer is at the end after open in Linux, but it
1489
is at the beginning in Solaris.
1490
12. Add checking of data against header, update header keywords
1491
(NAXIS's, BITPIX) when they don't agree with the data.
1492
13. change version to __version__.
1494
There are also many other minor internal bug fixes and technical
1496
__________________________________________________________________
1498
Version 0.6.2; February 12, 2002
1500
This version requires numarray version 0.2.
1502
Things not yet supported but are part of future development:
1504
* Verification and/or correction of FITS objects being written to
1505
disk so that they are legal FITS. This is being added now and
1506
should be available in about a month. Currently, one may construct
1507
FITS headers that are inconsistent with the data and write such
1508
FITS objects to disk. Future versions will provide options to
1509
either a) correct discrepancies and warn, b) correct discrepancies
1510
silently, c) throw a Python exception, or d) write illegal FITS
1511
(for test purposes!).
1512
* Support for ascii tables or random groups format. Support for ASCII
1513
tables will be done soon (~1 month). When random group support is
1515
* Support for memory mapping FITS data (to reduce memory demands). We
1516
expect to provide this capability in about 3 months.
1517
* Support for columns in binary tables having scaled values (e.g.
1518
BSCALE or BZERO) or boolean values. Currently booleans are stored
1519
as Int8 arrays and users must explicitly convert them into a
1520
boolean array. Likewise, scaled columns must be copied with scaling
1521
and offset by testing for those attributes explicitly. Future
1522
versions will produce such copies automatically.
1523
* Support for tables with TNULL values. This awaits an enhancement to
1524
numarray to support mask arrays (planned). (At least a couple of