10
- The ``Header`` object has been significantly reworked, and ``CardList``
11
objects are now deprecated (their functionality folded into the ``Header``
12
class). See API Changes below for more details.
14
- Memory maps are now used by default to access HDU data. See API Changes
15
below for more details.
17
- Now includes a new version of the ``fitsdiff`` program for comparing two
18
FITS files, and a new FITS comparison API used by ``fitsdiff``. See New
24
- The ``Header`` class has been rewritten, and the ``CardList`` class is
25
deprecated. Most of the basic details of working with FITS headers are
26
unchanged, and will not be noticed by most users. But there are differences
27
in some areas that will be of interest to advanced users, and to application
28
developers. For full details of the changes, see the "Header Interface
29
Transition Guide" section in the PyFITS documentation. See ticket #64 on
30
the PyFITS Trac for futher details and background. Some highlights are
33
* The Header class now fully implements the Python dict interface, and can
34
be used interchangably with a dict, where the keys are header keywords.
36
* New keywords can be added to the header using normal keyword assignment
37
(previously it was necessary to use ``Header.update`` to add new
38
keywords). For example::
40
>>> header['NAXIS'] = 2
42
will update the existing 'FOO' keyword if it already exists, or add a new
43
one if it doesn't exist, just like a dict.
45
* It is possible to assign both a value and a comment at the same time using
48
>>> header['NAXIS'] = (2, 'Number of axes')
50
* To add/update a new card and ensure it's added in a specific location, use
53
>>> header.set('NAXIS', 2, 'Number of axes', after='BITPIX')
55
This works the same as the old ``Header.update()``. ``Header.update()``
56
still works in the old way too, but is deprecated.
58
* Although ``Card`` objects still exist, it generally is not necessary to
59
work with them directly. ``Header.ascardlist()``/``Header.ascard`` are
60
deprecated and should not be used. To directly access the ``Card``
61
objects in a header, use ``Header.cards``.
63
* To access card comments, it is still possible to either go through the
64
card itself, or through ``Header.comments``. For example::
66
>>> header.cards['NAXIS'].comment
68
>>> header.comments['NAXIS']
71
* ``Card`` objects can now be used interchangeably with
72
``(keyword, value, comment)`` 3-tuples. They still have ``.value`` and
73
``.comment`` attributes as well. The ``.key`` attribute has been renamed
74
to ``.keyword`` for consistency, though ``.key`` is still supported (but
77
- Memory mapping is now used by default to access HDU data. That is,
78
``pyfits.open()`` uses ``memmap=True`` as the default. This provides better
79
performance in the majority of use cases--there are only some I/O intensive
80
applications where it might not be desirable. Enabling mmap by default also
81
enabled finding and fixing a large number of bugs in PyFITS' handling of
82
memory-mapped data (most of these bug fixes were backported to PyFITS
85
* A new ``pyfits.USE_MEMMAP`` global variable was added. Set
86
``pyfits.USE_MEMMAP = False`` to change the default memmap setting for
87
opening files. This is especially useful for controlling the behavior in
88
applications where pyfits is deeply embedded.
90
* Likewise, a new ``PYFITS_USE_MEMMAP`` environment variable is supported.
91
Set ``PYFITS_USE_MEMMAP = 0`` in your environment to change the default
94
- The ``size()`` method on HDU objects is now a ``.size`` property--this
95
returns the size in bytes of the data portion of the HDU, and in most cases
96
is equivalent to ``hdu.data.nbytes`` (#83)
98
- ``BinTableHDU.tdump`` and ``BinTableHDU.tcreate`` are deprecated--use
99
``BinTableHDU.dump`` and ``BinTableHDU.load`` instead. The new methods
100
output the table data in a slightly different format from previous versions,
101
which places quotes around each value. This format is compatible with data
102
dumps from previous versions of PyFITS, but not vice-versa due to a parsing
103
bug in older versions.
105
- Likewise the ``pyfits.tdump`` and ``pyfits.tcreate`` convenience function
106
versions of these methods have been renamed ``pyfits.tabledump`` and
107
``pyfits.tableload``. The old deprecated, but currently retained for
108
backwards compatibility. (r1125)
110
- A new global variable ``pyfits.EXTENSION_NAME_CASE_SENSITIVE`` was added.
111
This serves as a replacement for ``pyfits.setExtensionNameCaseSensitive``
112
which is not deprecated and may be removed in a future version. To enable
113
case-sensitivity of extension names (i.e. treat 'sci' as distict from 'SCI')
114
set ``pyfits.EXTENSION_NAME_CASE_SENSITIVE = True``. The default is
117
- A new global configuration variable ``pyfits.STRIP_HEADER_WHITESPACE`` was
118
added. By default, if a string value in a header contains trailing
119
whitespace, that whitespace is automatically removed when the value is read.
120
Now if you set ``pyfits.STRIP_HEADER_WHITESPACE = False`` all whitespace is
123
- The old ``classExtensions`` extension mechanism (which was deprecated in
124
PyFITS 3.0) is removed outright. To our knowledge it was no longer used
127
- Warning messages from PyFITS issued through the Python warnings API are now
128
output to stderr instead of stdout, as is the default. PyFITS no longer
129
modifies the default behavior of the warnings module with respect to which
130
stream it outputs to. (r1319)
132
- The ``checksum`` argument to ``pyfits.open()`` now accepts a value of
133
'remove', which causes any existing CHECKSUM/DATASUM keywords to be ignored,
134
and removed when the file is saved.
139
- Added support for the proposed "FITS" extension HDU type. See
140
http://listmgr.cv.nrao.edu/pipermail/fitsbits/2002-April/001094.html. FITS
141
HDUs contain an entire FITS file embedded in their data section. `FitsHDU`
142
objects work like other HDU types in PyFITS. Their ``.data`` attribute
143
returns the raw data array. However, they have a special ``.hdulist``
144
attribute which processes the data as a FITS file and returns it as an
145
in-memory HDUList object. FitsHDU objects also support a
146
``FitsHDU.fromhdulist()`` classmethod which returns a new `FitsHDU` object
147
that embeds the supplied HDUList. (#80)
149
- Added a new ``.is_image`` attribute on HDU objects, which is True if the HDU
150
data is an 'image' as opposed to a table or something else. Here the
151
meaning of 'image' is fairly loose, and mostly just means a Primary or Image
152
extension HDU, or possibly a compressed image HDU (#71)
154
- Added an ``HDUList.fromstring`` classmethod which can parse a FITS file
155
already in memory and instantiate and ``HDUList`` object from it. This
156
could be useful for integrating PyFITS with other libraries that work on
157
FITS file, such as CFITSIO. It may also be useful in streaming
158
applications. The name is a slight misnomer, in that it actually accepts
159
any Python object that implements the buffer interface, which includes
160
``bytes``, ``bytearray``, ``memoryview``, ``numpy.ndarray``, etc. (#90)
162
- Added a new ``pyfits.diff`` module which contains facilities for comparing
163
FITS files. One can use the ``pyfits.diff.FITSDiff`` class to compare two
164
FITS files in their entirety. There is also a ``pyfits.diff.HeaderDiff``
165
class for just comparing two FITS headers, and other similar interfaces.
166
See the PyFITS Documentation for more details on this interface. The
167
``pyfits.diff`` module powers the new ``fitsdiff`` program installed with
168
PyFITS. After installing PyFITS, run ``fitsdiff --help`` for usage details.
170
- ``pyfits.open()`` now accepts a ``scale_back`` argument. If set to
171
``True``, this automatically scales the data using the original BZERO and
172
BSCALE parameters the file had when it was first opened, if any, as well as
173
the original BITPIX. For example, if the original BITPIX were 16, this
174
would be equivalent to calling ``hdu.scale('int16', 'old')`` just before
175
calling ``flush()`` or ``close()`` on the file. This option applies to all
176
HDUs in the file. (#120)
178
- ``pyfits.open()`` now accepts a ``save_backup`` argument. If set to
179
``True``, this automatically saves a backup of the original file before
180
flushing any changes to it (this of course only applies to update and append
181
mode). This may be especially useful when working with scaled image data.
187
- Warnings from PyFITS are not output to stderr by default, instead of stdout
188
as it has been for some time. This is contrary to most users' expectations
189
and makes it more difficult for them to separate output from PyFITS from the
190
desired output for their scripts. (r1319)
195
- Fixed ``pyfits.tcreate()`` (now ``pyfits.tableload()``) to be more robust
196
when encountering blank lines in a column definition file (#14)
198
- Fixed a fairly rare crash that could occur in the handling of CONTINUE cards
199
when using Numpy 1.4 or lower (though 1.4 is the oldest version supported by
202
- Fixed ``_BaseHDU.fromstring`` to actually correctly instantiate an HDU
203
object from a string/buffer containing the header and data of that HDU.
204
This allowed for the implementation of ``HDUList.fromstring`` described
207
- Fixed a rare corner case where, in some use cases, (mildly, recoverably)
208
malformatted float values in headers were not properly returned as floats.
211
- Fixed a corollary to the previous bug where float values with a leading zero
212
before the decimal point had the leading zero unnecessarily removed when
213
saving changes to the file (eg. "0.001" would be written back as ".001" even
214
if no changes were otherwise made to the file). (#137)
216
- When opening a file containing CHECKSUM and/or DATASUM keywords in update
217
mode, the CHECKSUM/DATASUM are updated and preserved even if the file was
218
opened with checksum=False. This change in behavior prevents checksums from
219
being unintentionally removed. (#148)
221
- Fixed a bug where ``ImageHDU.scale(option='old')`` wasn't working at all--it
222
was not restoring the image to its original BSCALE and BZERO values. (#162)
224
- Fixed a bug when writing out files containing zero-width table columns,
225
where the TFIELDS keyword would be updated incorrectly, leaving the table
226
largely unreadable. This fix will be backported to the 3.0.x series in
227
version 3.0.10. (#174)
233
This is a bug fix release for the 3.0.x series.
238
- Fixed ``Header.values()``/``Header.itervalues()`` and ``Header.items()``/
239
``Header.iteritems()`` to correctly return the different values for
240
duplicate keywords (particularly commentary keywords like HISTORY and
241
COMMENT). This makes the old Header implementation slightly more compatible
242
with the new implementation in PyFITS 3.1. (#127)
245
This fix did not change the existing behavior from earlier PyFITS
246
versions where ``Header.keys()`` returns all keywords in the header with
247
duplicates removed. PyFITS 3.1 changes that behavior, so that
248
``Header.keys()`` includes duplicates.
250
- Fixed a bug where ``ImageHDU.scale(option='old')`` wasn't working at all--it
251
was not restoring the image to its original BSCALE and BZERO values. (#162)
253
- Fixed a bug where opening a file containing compressed image HDUs in
254
'update' mode and then immediately closing it without making any changes
255
caused the file to be rewritten unncessarily. (#167)
257
- Fixed two memory leaks that could occur when writing compressed image data,
258
or in some cases when opening files containing compressed image HDUs in
259
'update' mode. (#168)
263
---------------------
7
265
Changes in Behavior
10
268
- Prior to this release, image data sections did not work with scaled
11
269
data--that is, images with non-trivial BSCALE and/or BZERO values.