Skip to content

Commit

Permalink
calculateSensitivity(): Table as dict doesn't work so create as a fit…
Browse files Browse the repository at this point in the history
…s.Header
  • Loading branch information
chris-simpson committed Aug 14, 2020
1 parent 62e9d43 commit 26e7799
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
15 changes: 2 additions & 13 deletions astrodata/fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ def new_imagehdu(data, header, name=None):
def table_to_bintablehdu(table, extname=None):
"""
Convert an astropy Table object to a BinTableHDU before writing to disk.
Suitable FITS header keywords describing the column datatypes are added,
and an existing header (either a Header object or a dict) is also added.
Parameters
----------
Expand Down Expand Up @@ -284,17 +282,8 @@ def header_for_table(table):
columns.append(fits.Column(array=col.data, **descr))

fits_header = fits.BinTableHDU.from_columns(columns).header
try:
existing_header = table.meta['header']
except KeyError:
pass
else:
if isinstance(existing_header, fits.Header):
fits_header = update_header(existing_header, fits_header)
else:
existing_fits_header = fits.Header()
existing_fits_header.update(existing_header)
fits_header = update_header(existing_fits_header, fits_header)
if 'header' in table.meta:
fits_header = update_header(table.meta['header'], fits_header)
return fits_header


Expand Down
6 changes: 4 additions & 2 deletions geminidr/core/primitives_spect.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from astropy import units as u
from astropy.io.registry import IORegistryError
from astropy.io.ascii.core import InconsistentTableError
from astropy.io.fits import Header
from astropy.modeling import models, fitting, Model
from astropy.stats import sigma_clip
from astropy.table import Table
Expand Down Expand Up @@ -337,8 +338,9 @@ def calculateSensitivity(self, adinputs=None, **params):
order=order)
knots, coeffs, degree = spline.tck
sensfunc = Table([knots * wave.unit, coeffs * zpt.unit],
names=('knots', 'coefficients'))
sensfunc.meta['header'] = {'ORDER': (3, 'Order of spline fit')}
names=('knots', 'coefficients'),
meta={'header': Header()})
sensfunc.meta['header']['ORDER'] = (3, 'Order of spline fit')
ext.SENSFUNC = sensfunc
calculated = True

Expand Down

0 comments on commit 26e7799

Please sign in to comment.