Skip to content

Commit

Permalink
Merge pull request #134 from keflavich/update_history
Browse files Browse the repository at this point in the history
Add a history entry to the header when writing out a FITS file
  • Loading branch information
keflavich committed Aug 27, 2014
2 parents 1092207 + 8be7d2a commit 4463179
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions spectral_cube/io/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from astropy.io.fits.hdu.hdulist import fitsopen as fits_open

import numpy as np
import datetime
from .. import version
from .. import SpectralCube, StokesSpectralCube, LazyMask
from .. import cube_utils

Expand Down Expand Up @@ -139,12 +141,19 @@ def load_fits_cube(input, hdu=0):
return cube


def write_fits_cube(filename, cube, overwrite=False):
def write_fits_cube(filename, cube, overwrite=False,
include_origin_notes=True):
"""
Write a FITS cube with a WCS to a filename
"""

if isinstance(cube, SpectralCube):
cube.hdu.writeto(filename, clobber=overwrite)
hdu = cube.hdu
now = datetime.datetime.strftime(datetime.datetime.now(),
"%Y/%m/%d-%H:%M:%S")
hdu.header.add_history("Written by spectral_cube v{version} on "
"{date}".format(version=version.version,
date=now))
hdu.writeto(filename, clobber=overwrite)
else:
raise NotImplementedError()

0 comments on commit 4463179

Please sign in to comment.