astropy/ccdproc — pull request #167 by mwcraig (2014-08-23 21:00:36+00:00)
Title: Fix a number of metadata-related issues with CCDData class

The decision to force the metadata to be an ``OrderedDict`` led to several issues that left it unable to preserve all of the metadata in FITS files (#163 and #165); an earlier incarnation, which forced the metadata to be a FITS header put unnecessary constraints on the user.

This PR relaxes the requirements on what the metadata must be. It can be anything dict-like, e.g. an ``astropy.io.fits.Header``, a python ``dict``, an ``OrderedDict`` or some custom object created by the user.

If no metadata is provided on construction it defaults to an empty python ``dict`` (see #156 for a rationale).

Part of the complication here is the need to handle a case generated by our auto-logging system: it creates keyword/value pairs in which both the keyword and the value are longer than the maximum allowed by the FITS standard. ``astropy.io.fits`` can handle one or the other, but not both. The necessary fix is applied in two places:

+ When the metadata is converted to an ``astropy.io.fits.Header`` in the ``CCDData.to_hdu`` method
+ When the autologger adds long key/value pairs to the metadata if the metadata is an ``astropy.io.fits.Header``