Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _insert_in_metadata_fits_safe(meta, key, value):
- """Helper function to insert key-value pair into metadata in a way that
- FITS can serialize
- Parameters
- ----------
- key : str
- Key to be inserted in the dictionary
- value : str or None
- Value to be inserted
- Notes
- -----
- This addresses a shortcoming of the FITS standard. There are length
- restrictions on both the ``key`` (8 characters) and ``value`` (72
- characters) in the FITS standard. There is a convention for handling
- long keywords and a convention for handling long values, but the
- two conventions cannot be used at the same time.
- This addresses that case by checking the length of the ``key`` and
- ``value`` and, if necessary, shortening the key.
- Reference
- ---------
- This helper method is taken from `astropy.nddata.cddata`. Not imported
- as this is a private method, subject to change
- """
- if len(key) > 8 and len(value) > 72:
- short_name = key[:8]
- meta['HIERARCH {0}'.format(key.upper())] = (short_name, "Shortened name for {}".format(key))
- meta[short_name] = value
- else:
- meta[key] = value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement