PyFITS release notes
PyFITS is being used within the STScI
operations pipelines and is a supported product. Currently
PyFITS takes a fairly strict interpretation of FITS files.
There are likely to be problems with FITS data that do not
strictly conform to the standard. Undoubtedly, use with a
wider variety of files and uses will uncover problems;
please contact
help@stsci.edu when such problems are encountered.
We intend to accomodate such variances, particularly if they
involve widely used or available data (so please let us know
when such problems occur).
PyFITS requires numpy (or numarray) to be installed.
Version 2.2.2; October 12 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following bugs were fixed:
- Corrected a bug that caused an exception to be raised when creating
a CompImageHDU using an initial header that does not match the image data
in terms of the number of axis.
Version 2.2.1; October 6 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following bugs were fixed:
- Corrected a bug that prevented the opening of a fits file
where a header contained a CHECKSUM card but no DATASUM card.
- Corrected a bug that caused NULLs to be written instead
of blanks when an ASCII table was created using a numpy chararray
in which the original data contained trailing blanks.
(CNSHD695419)
Version 2.2; September 23 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- Provide support for the FITS Checksum Keyword Convention.
(CNSHD754301)
- Adding the checksum=True keyword argument to the open
convenience function will cause checksums to be verified
on file open.
hdul=pyfits.open('in.fits',checksum=True)
- On output, CHECKSUM and DATASUM cards may be output to
all HDU's in a fits file by using the keyword argument
checksum=True in calls to the writeto convenience function,
the HDUList.writeto method, the writeto methods of all of
the HDU classes, and the append convenience function.
hdul.writeto('out.fits',checksum=True)
- Implemented a new insert method to the HDUList class that
allows for the insertion of a HDU into a HDUList at a
given index.
hdul.insert(2,hdu)
- Provided the capability to handle unicode input for file
names.
- Provided support for integer division required by
Python 3.0.
- The following bugs were fixed:
- Corrected a bug that caused an index out of bounds exception
to be raised when iterating over the rows of a binary table
HDU using the syntax " for row in tbhdu.data: ".
(CNSHD748609)
- Corrected a bug that prevented the use of the writeto
convenience function for writing table data to a file.
(CNSHD749024)
- Modified the code to raise an IOError exception with the
comment "Header missing END card." when pyfits can't
find a valid END card for a header when opening a file.
- Corrected a bug that prevented the use of StringIO objects
as fits files when reading and writing table data.
Previously, only image data was supported. (CNSHD753698)
- Corrected a bug that caused a bus error to be generated
when compressing image data using GZIP_1 under the
Solaris operating system.
- Corrected bugs that prevented pyfits from properly reading
Random Groups HDU's using numpy. (CNSHD756570)
- Corrected a bug that can occur when writing a fits file.
(CNSHD757508)
- If no default SIGINT signal handler has not been assigned,
before the write, a TypeError exception is raised in the
_File.flush() method when attempting to return the signal
handler to its previous state. Notably this occurred when
using mod_python. The code was changed to use SIG_DFL
when no old handler was defined.
- Corrected a bug in CompImageHDU that prevented rescaling
the image data using hdu.scale(option='old').
Version 2.1.1; April 22 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following bugs were fixed:
- Corrected a bug that caused an exception to be raised when
closing a file opened for append, where an HDU was appended
to the file, after data was accessed from the file. This
exception was only raised when running on a Windows
platform.
- Updated the installation scripts, compression source code,
and benchmark test scripts to properly install, build, and
execute on a Windows platform.
Version 2.1; April 14 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- Added new tdump and tcreate capabilities to pyfits.
- The new tdump convenience function allows the
contents of a binary table HDU to be dumped to a set of
three files in ASCII format. One file will contain
column definitions, the second will contain header
parameters, and the third will contain header data.
- The new tcreate convenience function allows the
creation of a binary table HDU from the three files dumped
by the tdump convenience function.
- The primary use for the tdump/tcreate methods are to
allow editing in a standard text editor of the binary table
data and parameters.
- Added support for case sensitive values of the EXTNAME
card in an extension header. (CNSHD745784)
- Added support for reading and writing FITS files in which
the value of the first card in the header is 'SIMPLE=F'.
In this case, the pyfits open function returns an HDUList
object that contains a single HDU of the new type
_NonstandardHDU. The header for this HDU is like a normal
header (with the exception that the first card contains
SIMPLE=F instead of SIMPLE=T). Like normal HDU's the
reading of the data is delayed until actually requested.
The data is read from the file into a string starting from
the first byte after the header END card and continuing till
the end of the file. When written, the header is written,
followed by the data string. No attempt is made to pad the
data string so that it fills into a standard 2880 byte FITS block.
(CNSHD744730)
- Added support for FITS files containing extensions with
unknown XTENSION card values. (CNSHD744730) Standard FITS
files support extension HDU's of types TABLE, IMAGE,
BINTABLE, and A3DTABLE. Accessing a nonstandard extension
from a FITS file will now create a _NonstandardExtHDU object.
Accessing the data of this object will cause the data to be
read from the file into a string. If the HDU is written back
to a file the string data is written after the Header and
padded to fill a standard 2880 byte FITS block.
- The following bugs were fixed:
- Extensive changes were made to the tiled image compression
code to support the latest enhancements made in CFITSIO
version 3.13 to support this convention.
- Eliminated a memory leak in the tiled image compression code.
- Corrected a bug in the FITS_record.__setitem__ method which
raised a NameError exception when attempting to set a value
in a FITS_record object. (CNSHD745844)
- Corrected a bug that caused a TypeError exception to be
raised when reading fits files containing large table HDU's
(>2Gig). (CNSHD745522)
- Corrected a bug that caused a TypeError exception to be
raised for all calls to the warnings module when running
under Python 2.6. The formatwarning method in the warnings
module was changed in Python 2.6 to include a new argument.
(CNSHD746592)
- Corrected the behavior of the membership (in) operator in
the Header class to check against header card keywords
instead of card values. (CNSHD744730)
- Corrected the behavior of iteration on a Header object.
The new behavior iterates over the unique card keywords
instead of the card values.
Version 2.0.1; February 3 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following bugs were fixed:
- Eliminated a memory leak when reading Table HDU's from a
fits file. (CNSHD741877)
Version 2.0; January 30 2009
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- Provide initial support for an image compression convention
known as the
"Tiled Image Compression Convention".
- The principle used in this convention is to first
divide the n-dimensional image into a rectangular grid
of subimages or "tiles". Each tile is then compressed
as a continuous block of data, and the resulting
compressed byte stream is stored in a row of a
variable length column in a FITS binary table.
Several commonly used algorithms for compressing image
tiles are supported. These include, GZIP, RICE,
H-Compress and IRAF pixel list (PLIO).
- Support for compressed image data is provided using
the optional "pyfitsComp" module contained in a C
shared library (pyfitsCompmodule.so).
- The header of a compressed image HDU appears to the
user like any image header. The actual header stored
in the FITS file is that of a binary table HDU with
a set of special keywords, defined by the convention,
to describe the structure of the compressed image.
The conversion between binary table HDU header and
image HDU header is all performed behind the scenes.
Since the HDU is actually a binary table, it may not
appear as a primary HDU in a FITS file.
- The data of a compressed image HDU appears to the
user as standard uncompressed image data. The actual
data is stored in the fits file as Binary Table data
containing at least one column (COMPRESSED_DATA).
Each row of this variable-length column contains the
byte stream that was generated as a result of
compressing the corresponding image tile. Several
optional columns may also appear. These include,
UNCOMPRESSED_DATA to hold the uncompressed pixel
values for tiles that cannot be compressed, ZSCALE
and ZZERO to hold the linear scale factor and zero
point offset which may be needed to transform the
raw uncompressed values back to the original image
pixel values, and ZBLANK to hold the integer value
used to represent undefined pixels (if any) in the
image.
- To create a compressed image HDU from scratch, simply
construct a CompImageHDU object from an uncompressed
image data array and its associated image header.
From there, the HDU can be treated just like any
image HDU.
>>> hdu=pyfits.CompImageHDU(imageData,imageHeader)
>>> hdu.writeto('compressed_image.fits')
- The signature for the CompImageHDU initializer method
describes the possible options for constructing a
CompImageHDU object:
def __init__(self, data=None, header=None, name=None,
compressionType='RICE_1',
tileSize=None,
hcompScale=0.,
hcompSmooth=0,
quantizeLevel=16.):
"""data: data of the image
header: header to be associated with the
image
name: the EXTNAME value; if this value
is None, then the name from the
input image header will be used;
if there is no name in the input
image header then the default name
'COMPRESSED_IMAGE' is used
compressionType: compression algorithm 'RICE_1',
'PLIO_1', 'GZIP_1', 'HCOMPRESS_1'
tileSize: compression tile sizes default
treats each row of image as a tile
hcompScale: HCOMPRESS scale parameter
hcompSmooth: HCOMPRESS smooth parameter
quantizeLevel: floating point quantization level;
"""
- Added two new convenience functions. The setval function
allows the setting of the value of a single header card in
a fits file. The delval function allows the deletion of
a single header card in a fits file.
- A modification was made to allow the reading of data from a
fits file containing a Table HDU that has duplicate field
names. It is normally a requirement that the field names
in a Table HDU be unique. Prior to this change a ValueError
was raised, when the data was accessed, to indicate that the
HDU contained duplicate field names. Now, a warning is
issued and the field names are made unique in the internal
record array. This will not change the TTYPEn header card
values. You will be able to get the data from all fields
using the field name, including the first field containing
the name that is duplicated. To access the data of the
other fields with the duplicated names you will need to
use the field number instead of the field name.
(CNSHD737193)
- An enhancement was made to allow the reading of unsigned
integer 16 values from an ImageHDU when the data is
signed integer 16 and BZERO is equal to 32784 and BSCALE
is equal to 1 (the standard way for scaling unsigned integer
16 data). A new optional keyword argument (uint16) was
added to the open convenience function. Supplying a value
of True for this argument will cause data of this type to
be read in and scaled into an unsigned integer 16 array,
instead of a float 32 array. If a HDU associated with a
file that was opened with the uint16 option and containing
unsigned integer 16 data is written to a file, the data will
be reverse scaled into an integer 16 array and written out to
the file and the BSCALE/BZERO header cards will be written
with the values 1 and 32768 respectively. (CHSHD736064)
Reference the following example:
>>> import pyfits
>>> hdul=pyfits.open('o4sp040b0_raw.fits',uint16=1)
>>> hdul[1].data
array([[1507, 1509, 1505, ..., 1498, 1500, 1487],
[1508, 1507, 1509, ..., 1498, 1505, 1490],
[1505, 1507, 1505, ..., 1499, 1504, 1491],
...,
[1505, 1506, 1507, ..., 1497, 1502, 1487],
[1507, 1507, 1504, ..., 1495, 1499, 1486],
[1515, 1507, 1504, ..., 1492, 1498, 1487]], dtype=uint16)
>>> hdul.writeto('tmp.fits')
>>> hdul1=pyfits.open('tmp.fits',uint16=1)
>>> hdul1[1].data
array([[1507, 1509, 1505, ..., 1498, 1500, 1487],
[1508, 1507, 1509, ..., 1498, 1505, 1490],
[1505, 1507, 1505, ..., 1499, 1504, 1491],
...,
[1505, 1506, 1507, ..., 1497, 1502, 1487],
[1507, 1507, 1504, ..., 1495, 1499, 1486],
[1515, 1507, 1504, ..., 1492, 1498, 1487]], dtype=uint16)
>>> hdul1=pyfits.open('tmp.fits')
>>> hdul1[1].data
array([[ 1507., 1509., 1505., ..., 1498., 1500., 1487.],
[ 1508., 1507., 1509., ..., 1498., 1505., 1490.],
[ 1505., 1507., 1505., ..., 1499., 1504., 1491.],
...,
[ 1505., 1506., 1507., ..., 1497., 1502., 1487.],
[ 1507., 1507., 1504., ..., 1495., 1499., 1486.],
[ 1515., 1507., 1504., ..., 1492., 1498., 1487.]], dtype=float32)
- Enhanced the message generated when a ValueError exception
is raised when attempting to access a header card with an
unparsable value. The message now includes the Card name.
- The following bugs were fixed:
- Corrected a bug that occurs when appending a binary table
HDU to a fits file. Data was not being byteswapped on
little endian machines. (CNSHD737243)
- Corrected a bug that occurs when trying to write an ImageHDU
that is missing the required PCOUNT card in the header. An
UnboundLocalError exception complaining that the local
variable 'insert_pos' was referenced before assignment was
being raised in the method _ValidHDU.req_cards. The code
was modified so that it would properly issue a more
meaningful ValueError exception with a description of what
required card is missing in the header.
- Eliminated a redundant warning message about the PCOUNT
card when validating an ImageHDU header with a PCOUNT
card that is missing or has a value other than 0.
Version 1.4.1; November 4 2008
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- Enhanced the way import errors are reported to provide more
information.
- The following bugs were fixed:
- Corrected a bug that occurs when a card value is a string
and contains a colon but is not a record-valued keyword card.
- Corrected a bug where pyfits fails to properly handle a
record-valued keyword card with values using exponential
notation and trailing blanks.
Version 1.4; July 7 2008
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- Added support for file objects and file like objects.
- All convenience functions and class methods that take a file name
will now also accept a file object or file like object. File like
objects supported are StringIO and GzipFile objects. Other file like
objects will work only if they implement all of the standard file
object methods.
- For the most part, file or file like objects may be either opened
or closed at function call. An opened object must be opened with the
proper mode depending on the function or method called. Whenever possible,
if the object is opened before the method is called, it will remain open
after the call. This will not be possible when writing a HDUList that
has been resized or when writing to a GzipFile object regardless of
whether it is resized. If the object is closed at the time of the function
call, only the name from the object is used, not the object itself. The
pyfits code will extract the file name used by the object and use that to
create an underlying file object on which the function will be performed.
- Added support for record-valued keyword cards as introduced in the
"FITS WCS Paper IV proposal for representing a more general distortion
model".
- Record-valued keyword cards are string-valued cards where the string
is interpreted as a definition giving a record field name, and its floating
point value. In a FITS header they have the following syntax:
keyword= 'field-specifier: float'
where keyword is a standard eight-character FITS keyword name, float is the
standard FITS ASCII representation of a floating point number, and these are
separated by a colon followed by a single blank.
The grammer for field-specifier is:
field-specifier:
field
field-specifier.field
field:
identifier
identifier.index
where identifier is a sequence of letters (upper or lower case), underscores,
and digits of which the first character must not be a digit, and index is a
sequence of digits. No blank characters may occur in the field-specifier. The
index is provided primarily for defining array elements though it need not be
used for that purpose.
Multiple record-valued keywords of the same name but differing values may be
present in a FITS header. The field-specifier may be viewed as part of the
keyword name.
Some examples follow:
DP1 = 'NAXIS: 2'
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
DP1 = 'NAUX: 2'
DP1 = 'AUX.1.COEFF.0: 0'
DP1 = 'AUX.1.POWER.0: 1'
DP1 = 'AUX.1.COEFF.1: 0.00048828125'
DP1 = 'AUX.1.POWER.1: 1'
- As with standard header cards, the value of a
record-valued keyword card can be accessed using
either the index of the card in a HDU's header or via
the keyword name. When accessing using the keyword
name, the user may specify just the card keyword or
the card keyword followed by a period followed by the
field-specifier. Note that while the card keyword is
case insensitive, the field-specifier is not. Thus,
hdu['abc.def'], hdu['ABC.def'], or hdu['aBc.def'] are
all equivalent but hdu['ABC.DEF'] is not.
- When accessed using the card index of the HDU's
header the value returned will be the entire string
value of the card. For example:
>>> print hdr[10]
NAXIS: 2
>>> print hdr[11]
AXIS.1: 1
- When accessed using the keyword name exclusive of the
field-specifier, the entire string value of the
header card with the lowest index having that keyword
name will be returned. For example:
>>> print hdr['DP1']
NAXIS: 2
- When accessing using the keyword name and the
field-specifier, the value returned will be the
floating point value associated with the
record-valued keyword card. For example:
>>> print hdr['DP1.NAXIS']
2.0
- Any attempt to access a non-existent record-valued
keyword card value will cause an exception to be
raised (IndexError exception for index access or
KeyError for keyword name access).
- Updating the value of a record-valued keyword card
can also be accomplished using either index or
keyword name. For example:
>>> print hdr['DP1.NAXIS']
2.0
>>> hdr['DP1.NAXIS'] = 3.0
>>> print hdr['DP1.NAXIS']
3.0
- Adding a new record-valued keyword card to an
existing header is accomplished using the
Header.update() method just like any other card.
For example:
>>> hdr.update('DP1', 'AXIS.3: 1', 'a comment', after='DP1.AXIS.2')
- Deleting a record-valued keyword card from an
existing header is accomplished using the standard
list deletion syntax just like any other card. For
example:
>>> del hdr['DP1.AXIS.1']
- In addition to accessing record-valued keyword cards
individually using a card index or keyword name,
cards can be accessed in groups using a set of
special pattern matching keys. This access is made
available via the standard list indexing operator
providing a keyword name string that contains one or
more of the special pattern matching keys. Instead
of returning a value, a CardList object will be
returned containing shared instances of the Cards in
the header that match the given keyword specification.
- There are three special pattern matching keys. The
first key '*' will match any string of zero or more
characters within the current level of the
field-specifier. The second key '?' will match a
single character. The third key '...' must appear at
the end of the keyword name string and will match all
keywords that match the preceding pattern down all
levels of the field-specifier. All combinations of
?, *, and ... are permitted (though ... is only
permitted at the end). Some examples follow:
>>> cl=hdr['DP1.AXIS.*']
>>> print cl
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
>>> cl=hdr['DP1.*']
>>> print cl
DP1 = 'NAXIS: 2'
DP1 = 'NAUX: 2'
>>> cl=hdr['DP1.AUX...']
>>> print cl
DP1 = 'AUX.1.COEFF.0: 0'
DP1 = 'AUX.1.POWER.0: 1'
DP1 = 'AUX.1.COEFF.1: 0.00048828125'
DP1 = 'AUX.1.POWER.1: 1'
>>> cl=hdr['DP?.NAXIS']
>>> print cl
DP1 = 'NAXIS: 2'
DP2 = 'NAXIS: 2'
DP3 = 'NAXIS: 2'
>>> cl=hdr['DP1.A*S.*']
>>> print cl
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
- The use of the special pattern matching keys for
adding or updating header cards in an existing header
is not allowed. However, the deletion of cards from
the header using the special keys is allowed. For
example:
>>> del hdr['DP3.A*...']
- As noted above, accessing pyfits Header object using
the special pattern matching keys will return a
CardList object. This CardList object can itself be
searched in order to further refine the list of
Cards. For example:
>>> cl=hdr['DP1...']
>>> print cl
DP1 = 'NAXIS: 2'
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
DP1 = 'NAUX: 2'
DP1 = 'AUX.1.COEFF.1: 0.000488'
DP1 = 'AUX.2.COEFF.2: 0.00097656'
>>> cl1=cl['*.*AUX...']
>>> print cl1
DP1 = 'NAUX: 2'
DP1 = 'AUX.1.COEFF.1: 0.000488'
DP1 = 'AUX.2.COEFF.2: 0.00097656'
- The CardList keys() method will allow the retrivial
of all of the key values in the CardList. For
example:
>>> cl=hdr['DP1.AXIS.*']
>>> print cl
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
>>> cl.keys()
['DP1.AXIS.1', 'DP1.AXIS.2']
- The CardList values() method will allow the retrivial
of all of the values in the CardList. For example:
>>> cl=hdr['DP1.AXIS.*']
>>> print cl
DP1 = 'AXIS.1: 1'
DP1 = 'AXIS.2: 2'
>>> cl.values()
[1.0, 2.0]
- Individual cards can be retrieved from the list using
standard list indexing. For example:
>>> cl=hdr['DP1.AXIS.*']
>>> c=cl[0]
>>> print c
DP1 = 'AXIS.1: 1'
>>> c=cl['DP1.AXIS.2']
>>> print c
DP1 = 'AXIS.2: 2'
- Individual card values can be retrieved from the list
using the value attribute of the card. For example:
>>> cl=hdr['DP1.AXIS.*']
>>> cl[0].value
1.0
- The cards in the CardList are shared instances of the
cards in the source header. Therefore, modifying a
card in the CardList also modifies it in the source
header. However, making an addition or a deletion to
the CardList will not affect the source header. For
example:
>>> hdr['DP1.AXIS.1']
1.0
>>> cl=hdr['DP1.AXIS.*']
>>> cl[0].value = 4.0
>>> hdr['DP1.AXIS.1']
4.0
>>> del cl[0]
>>> print cl['DP1.AXIS.1']
Traceback (most recent call last):
File "", line 1, in
File "NP_pyfits.py", line 977, in __getitem__
return self.ascard[key].value
File "NP_pyfits.py", line 1258, in __getitem__
_key = self.index_of(key)
File "NP_pyfits.py", line 1403, in index_of
raise KeyError, 'Keyword %s not found.' % `key`
KeyError: "Keyword 'DP1.AXIS.1' not found."
>>> hdr['DP1.AXIS.1']
4.0
- A FITS header consists of card images. In pyfits
each card image is manifested by a Card object.
A pyfits Header object contains a list of Card
objects in the form of a CardList object. A
record-valued keyword card image is represented in
pyfits by a RecordValuedKeywordCard object. This
object inherits from a Card object and has all of the
methods and attributes of a Card object.
- A new RecordValuedKeywordCard object is created with
the RecordValuedKeywordCard constructor:
RecordValuedKeywordCard(key, value, comment). The
key and value arguments may be specified in two ways.
The key value may be given as the 8 character keyword
only, in which case the value must be a character
string containing the field-specifier, a colon
followed by a space, followed by the actual value.
The second option is to provide the key as a string
containing the keyword and field-specifier, in which
case the value must be the actual floating point
value. For example:
>>> c1 = pyfits.RecordValuedKeywordCard('DP1', 'NAXIS: 2', 'Number of variables')
>>> c2 = pyfits.RecordValuedKeywordCard('DP1.AXIS.1', 1.0, 'Axis number')
- RecordValuedKeywordCards have attributes .key,
.field_specifier, .value, and .comment. Both .value
and .comment can be changed but not .key or
.field_specifier. The constructor will extract the
field-specifier from the input key or value,
whichever is appropriate. The .key attribute is the
8 character keyword.
- Just like standard Cards, a RecordValuedKeywordCard
may be constructed from a string using the
fromstring() method or verified using the verify()
method. For example:
>>> c1 = pyfits.RecordValuedKeywordCard().fromstring(
"DP1 = 'NAXIS: 2' / Number of independent variables")
>>> c2 = pyfits.RecordValuedKeywordCard().fromstring(
"DP1 = 'AXIS.1: X' / Axis number")
>>> print c1; print c2
DP1 = 'NAXIS: 2' / Number of independent variables
DP1 = 'AXIS.1: X' / Axis number
>>> c2.verify()
Output verification result:
Card image is not FITS standard (unparsable value string).
- A standard card that meets the criteria of a
RecordValuedKeywordCard may be turned into a
RecordValuedKeywordCard using the class method coerce.
If the card object does not meet the required
criteria then the original card object is just
returned.
>>> c1 = pyfits.Card('DP1','AUX: 1','comment')
>>> c2 = pyfits.RecordValuedKeywordCard.coerce(c1)
>>> print type(c2)
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
- Two other card creation methods are also available as
RecordVauedKeywordCard class methods. These are
createCard() which will create the appropriate card
object (Card or RecordValuedKeywordCard) given input
key, value, and comment, and createCardFromString
which will create the appropriate card object given
an input string. These two methods are also available
as convenience functions.
>>> c1 = pyfits.RecordValuedKeywordCard.createCard('DP1','AUX: 1','comment)
or
>>> c1 = pyfits.createCard('DP1','AUX: 1','comment)
>>> print type(c1)
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
>>> c1 = pyfits.RecordValuedKeywordCard.createCard('DP1','AUX 1','comment)
or
>>> c1 = pyfits.createCard('DP1','AUX 1','comment)
>>> print type(c1)
<class 'pyfits.NP_pyfits.Card'>
>>> c1 = pyfits.RecordValuedKeywordCard.createCardFromString \
("DP1 = 'AUX: 1.0' / comment")
or
>>> c1 = pyfits.createCardFromString("DP1 = 'AUX: 1.0' / comment")
>>> print type(c1)
<class 'pyfits.NP_pyfits.RecordValuedKeywordCard'>
- The following bugs were fixed:
- Corrected a bug that occurs when writing a HDU out to a
file. During the write, any Keyboard Interrupts are trapped
so that the write completes before the interrupt is handled.
Unfortunately, the Keyboard Interrupt was not properly
reinstated after the write completed. This was fixed.
(CNSHD711138)
- Corrected a bug when using ipython, where temporary files
created with the tempFile.NamedTemporaryFile method are not
automatically removed. This can happen for instance when
opening a Gzipped fits file or when open a fits file over
the internet. The files will now be removed. (CNSHD718307)
- Corrected a bug in the append convenience function's call to
the writeto convenience function. The classExtensions
argument must be passed as a keyword argument.
- Corrected a bug that occurs when retrieving variable length
character arrays from binary table HDUs (PA() format) and
using slicing to obtain rows of data containing variable
length arrays. The code issued a TypeError exception. The
data can now be accessed with no exceptions. (CNSHD718749)
- Corrected a bug that occurs when retrieving data from a
fits file opened in memory map mode when the file contains
multiple image extensions or ASCII table or binary table
HDUs. The code issued a TypeError exception. The data can
now be accessed with no exceptions. (CNSHD707426)
- Corrected a bug that occurs when attempting to get a subset
of data from a Binary Table HDU and then use the data to
create a new Binary Table HDU object. A TypeError exception
was raised. The data can now be subsetted and used to
create a new HDU. (CNSHD723761)
- Corrected a bug that occurs when attempting to scale an
Image HDU back to its original data type using the
_ImageBaseHDU.scale method. The code was not resetting the
BITPIX header card back to the original data type. This
has been corrected.
- Changed the code to issue a KeyError exception instead of a
NameError exception when accessing a non-existent field in
a table.
Version 1.3; February 22 2008
- Updates described in this release are only supported in the NUMPY
version of pyfits.
- The following enhancements were made:
- The following performance improvements were made:
- Modified the import logic to dramatically decrease the time it takes
to import pyfits.
- Modified the code to provide performance improvements when copying and
examining header cards.
- The following bugs were fixed:
- Corrected a bug that occurs when reading the data from a fits file that
includes BZERO/BSCALE scaling. When the data is read in from the file, pyfits
automatically scales the data using the BZERO/BSCALE values in the header. In
the previous release, pyfits created a 32 bit floating point array to hold the
scaled data. This could cause a problem when the value of BZERO is so large
that the scaled value will not fit into the float 32. For this release, when
the input data is 32 bit integer, a 64 bit floating point array is used for
the scaled data.
- Corrected a bug that caused an exception to be raised when attempting to
scale image data using the ImageHDU.scale method.
- Corrected a bug in the new_table convenience function that occurred when a
binary table was created using a ColDefs object as input and supplying an nrows
argument for a number of rows that is greater than the number of rows present
in the input ColDefs object. The previous version of pyfits failed to allocate
the necessary memory for the additional rows.
- Corrected a bug in the new_table convenience function that caused an exception
to be thrown when creating an ASCII table.
- Corrected a bug in the new_table convenience function that will allow the input
of a ColDefs object that was read from a file as a binary table with a data value
equal to None.
- Corrected a bug in the construction of ASCII tables from Column objects that
are created with noncontinuous start columns.
- Corrected bugs in a number of areas that would sometimes cause a failure to
improperly raise an exception when an error occurred.
- Corrected a bug where attempting to open a non-existent fits file on a windows
platform using a drive letter in the file specification caused a misleading
IOError exception to be raised.
Version 1.1; June 15 2007
- Modified to use either NUMPY or NUMARRAY.
- New file writing modes have been provided to allow streaming data
to extensions without requiring the whole output extension image in
memory. See documentation on StreamingHDU.
- Improvements to minimize byteswapping and memory usage by byteswapping in place.
- Now supports ':' characters in filenames.
- Handles keyboard interrupts during long operations.
- Preserves the byte order of the input image arrays.
Version 1.0.1; March 24 2006
The changes to PyFITS were primarily to improve the docstrings and to
reclassify some public functions and variables as private. Readgeis and
fitsdiff which were distributed with PyFITS in previous releases were
moved to pytools. This release of PyFITS is v1.0.1. The next release of
PyFITS will support both numarray and numpy (and will be available separately
from stsci_python, as are all the python packages contained within stsci_python).
An alpha release for PyFITS numpy support will be made around the time of this
stsci_python release.
- Updated docstrings for public functions.
- Made some previously public functions private.
Version 1.0; November 1 2005
Major Changes since v0.9.6:
- Added support for the HEIRARCH convention
- Added support for iteration and slicing for HDU lists
- PyFITS now uses the standard setup.py installation script
- Add utility functions at the module level, they include:
- getheader
- getdata
- getval
- writeto
- append
- update
- info
Minor changes since v0.9.6:
- Fix a bug to make single-column ASCII table work.
- Fix a bug so a new table constructed from an existing table with
X-formatted columns will work.
- Fix a problem in verifying HDUList right after the open statement.
- Verify that elements in an HDUList, besides the first one, are
ExtensionHDU.
- Add output verification in methods flush() and close().
- Modify the the design of the open() function to remove the
output_verify argument.
- Remove the groups argument in GroupsHDU's contructor.
- Redesign the column definition class to make its column components
more accessible. Also to make it conducive for higher level
functionalities, e.g. combining two column definitions.
- Replace the Boolean class with the Python Boolean type.
The old TRUE/FALSE will still work.
- Convert classes to the new style.
- Better format when printing card or card list.
- Add the optional argument clobber to all writeto() functions and
methods.
- If adding a blank card, will not use existing blank card's space.
PyFITS Version 1.0 REQUIRES Python 2.3 or later.
Version 0.9.6; 11 November 2004
Major changes since v0.9.3:
-
Support for variable length array tables.
-
Support for writing ASCII table extensions.
-
Support for random groups, both reading and writing.
Some minor changes:
-
Support for numbers with leading zeros in an ASCII table extension.
-
Changed scaled columns' data type from Float32 to Float64 to preserve
precision.
-
Made Column constructor more flexible in accepting format specification.
Version 0.9.3; 2 July 2004
Changes since v0.9.0:
-
Lazy instanciation of full Headers/Cards for all HDU's when the file is
opened. At the open, only extracts vital info (e.g. NAXIS's) from the
header parts. This change will speed up the performance if the user only
needs to access one extension in a multi-extension FITS file.
- Support the X format (bit flags) columns, both reading and writing,
in a binary table. At the user interface, they are converted to Boolean
arrays for easy manipulation. For example, if the column's TFORM is "11X",
internally the data is stored in 2 bytes, but the user will see, at each
row of this column, a Boolean array of 11 elements.
- Fix a bug such that when a table extension has no data, it will not try
to scale the data when updating/writing the HDU list.
Version 0.9; 27 April 2004
Changes since v0.8.0:
- Rewriting of the Card class to separate the parsing and
verification of header cards
- Restructure the keyword indexing scheme which speed up certain
applications (update large number of new keywords and reading a header
with larger numbers of cards) by a factor of 30 or more
- Change the default to be lenient FITS standard checking on input and
strict FITS standard checking on output
- Support CONTINUE cards, both reading and writing
- Verification can now be performed at any of the HDUList, HDU,
and Card levels
- Support (contiguous) subsection (attribute .section) of images
to reduce memory usage for large images
Version 0.8.0; August 19, 2003
NOTE: This version will only work with
numarray Version 0.6. In addition, earlier versions of
PyFITS will not work with numarray 0.6. Therefore, both
must be updated simultaneously.
Changes since 0.7.6:
- Compatible with numarray 0.6/records 2.0
- For binary tables, now it is possible to update the original array if a
scaled field is updated.
- Support of complex columns
- Modify the __getitem__ method in FITS_rec. In order to make sure the
scaled quantities are also viewing ths same data as the original FITS_rec, all
fields need to be "touched" when __getitem__ is called.
- Add a new attribute mmobject for HDUList, and close the memmap object
when close HDUList object. Earlier version does not close memmap object
and can cause memory lockup.
- Enable 'update' as a legitimate memmap mode.
- Do not print message when closing an HDUList object which is not
created from reading a FITS file. Such message is confusing.
- remove the internal attribute "closed" and related method (__getattr__ in HDUList). It is redundant.
Version 0.7.6; November 22, 2002
NOTE: This version will only work with
numarray Version 0.4.
Changes since 0.7.5:
- Change x*=n to numarray.multiply(x, n, x) where n is a
floating number, in order to make pyfits to work under Python
2.2. (2 occurrences)
- Modify the "update" method in the Header class to use the
"fixed-format" card even if the card already exists. This is
to avoid the mis-alignment as shown below:
After running drizzle on ACS images it creates a CD matrix
whose elements have very many digits, e.g.:
CD1_1 = 1.1187596304411E-05 / partial of first axis coordinate w.r.t. x
CD1_2 = -8.502767249350019E-06 / partial of first axis coordinate w.r.t. y
with pyfits, an "update" on these header items and write in new
values which has fewer digits, e.g.:
CD1_1 = 1.0963011E-05 / partial of first axis coordinate w.r.t. x
CD1_2 = -8.527229E-06 / partial of first axis coordinate w.r.t. y
- Change some internal variables to make their appearance
more consistent:
old name new name
__octalRegex _octalRegex
__readblock() _readblock()
__formatter() _formatter().
__value_RE _value_RE
__numr _numr
__comment_RE _comment_RE
__keywd_RE _keywd_RE
__number_RE _number_RE.
tmpName() _tmpName()
dimShape _dimShape
ErrList _ErrList
- Move up the module description. Move the copywright
statement to the bottom and assign to the variable __credits__.
- change the following line:
self.__dict__ = input.__dict__
to
self.__setstate__(input.__getstate__())
in order for pyfits to run under numarray 0.4.
- edit _readblock to add the (optional) firstblock argument
and raise IOError if the the first 8 characters in the first
block is not 'SIMPLE ' or 'XTENSION'. Edit the function open
to check for IOError to skip the last null filled block(s).
Edit readHDU to add the firstblock argument.
Version 0.7.5; 16 August 2002
Changes since v0.7.3:
- Memory mapping now works for readonly mode, both for
images and binary tables.
Usage: pyfits.open('filename', memmap=1)
- Edit the field method in FITS_rec class to make the
column scaling for numbers use less temporary memory.
(does not work under 2.2, due to Python "bug" of array
*=)
- Delete bscale/bzero in the ImageBaseHDU
constructor.
- Update bitpix in BaseImageHDU.__getattr__ after
deleting bscale/bzero. (bug fix)
- In BaseImageHDU.__getattr__ point self.data to
raw_data if float and if not memmap. (bug fix).
- Change the function get_tbdata() to private:
_get_tbdata().
Version 0.7.3; 12 July 2002
Changes since v0.7.2:
- It will scale all integer image data to Float32, if
BSCALE/BZERO != 1/0. It will also expunge the BSCALE/BZERO
keywords.
- Add the scale() method for ImageBaseHDU, so data can be
scaled just before being written to the file. It has the
following arguments:
- type:
- destination data type (string), e.g. Int32,
Float32, UInt8, etc.
- option:
- scaling scheme. if 'old', use the old BSCALE/BZERO
values. if 'minmax', use the data range to fit into the
full range of specified integer type. Float destination
data type will not be scaled for this option.
- bscale/bzero:
- user specifiable BSCALE/BZERO values. They overwrite
the "option".
- Deal with data area resizing in 'update' mode.
- Make the data scaling (both input and output) faster and
use less memory.
- Bug fix to make column name change takes effect for
field.
- Bug fix to avoid exception if the key is not present in
the header already. This affects (fixes) add_history(),
add_comment(), and add_blank().
- Bug fix in __getattr__() in Card class. The change made
in 0.7.2 to rstrip the comment must be string type to avoid
exception.
Version 0.7.2.1; June 25, 2002
A couple of bugs were addressed in this version.
- Fix a bug in _add_commentary(). Due to a change in
index_of() during version 0.6.5.5, _add_commentary needs to
be modified to avoid exception if the key is not present in
the header already. This affects (fixes) add_history(),
add_comment(), and add_blank().
- Fix a bug in __getattr__() in Card class. The change
made in 0.7.2 to rstrip the comment must be string type to
avoid exception.
Version 0.7.2; June 19, 2002
The two major improvements from Version 0.6.2 are:
- support reading tables with "scaled" columns (e.g.
tscal/tzero, Boolean, and ASCII tables)
- a prototype output verification.
This version of PyFITS requires numarray version 0.3.4.
Other changes include:
- Implement the new HDU hierarchy proposed earlier this
year. This in turn reduces some of the redundant methods
common to several HDU classes.
- Add 3 new methods to the Header class: add_history,
add_comment, and add_blank.
- The table attributes _columns are now .columns and the
attributes in ColDefs are now all without the underscores.
So, a user can get a list of column names by:
hdu.columns.names.
- The "fill" argument in the new_table method now has a
new meaning:
If set to true (=1), it will fill the entire new table with
zeros/blanks. Otherwise (=0), just the extra rows/cells
are filled with zeros/blanks. Fill values other than
zero/blank are now not possible.
-
Add the argument output_verify to the open method and
writeto method. Not in the flush or close methods yet, due
to possible complication.
-
A new copy method for tables, the copy is totally
independent from the table it copies from.
-
The tostring() call in writeHDUdata takes up extra space to
store the string object. Use tofile() instead, to save
space.
-
Make changes from _byteswap to _byteorder, following
corresponding changes in numarray and recarray.
-
Insert(update) EXTEND in PrimaryHDU only when header is
None.
-
Strip the trailing blanks for the comment value of a card.
-
Add seek(0) right after the __buildin__.open(0), because
for the 'ab+' mode, the pointer is at the end after open
in Linux, but it is at the beginning in Solaris.
-
Add checking of data against header, update header keywords
(NAXIS's, BITPIX) when they don't agree with the data.
-
change version to __version__.
There are also many other minor internal bug fixes and
technical changes.
Version 0.6.2; February 12, 2002
This version requires numarray version 0.2.
Things not yet supported but are part of future development:
- Verification and/or correction of FITS objects being
written to disk so that they are legal FITS. This is being
added now and should be available in about a month.
Currently, one may construct FITS headers that are
inconsistent with the data and write such FITS objects to
disk. Future versions will provide options to either a)
correct discrepancies and warn, b) correct discrepancies
silently, c) throw a Python exception, or d) write illegal
FITS (for test purposes!).
-
Support for ascii tables or random groups format. Support
for ASCII tables will be done soon (~1 month). When random
group support is added is uncertain.
-
Support for memory mapping FITS data (to reduce memory
demands). We expect to provide this capability in about 3
months.
-
Support for columns in binary tables having scaled values
(e.g. BSCALE or BZERO) or boolean values. Currently
booleans are stored as Int8 arrays and users must
explicitly convert them into a boolean array. Likewise,
scaled columns must be copied with scaling and offset by
testing for those attributes explicitly. Future versions
will produce such copies automatically.
-
Support for tables with TNULL values. This awaits an
enhancement to numarray to support mask arrays (planned).
(At least a couple of months off).
|
 |
|