Skip to content

Commit

Permalink
make float32s
Browse files Browse the repository at this point in the history
  • Loading branch information
kelle committed Nov 15, 2024
1 parent 69f9efa commit 61c3295
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sedkit/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from bokeh.plotting import figure, show
from bokeh.models import HoverTool, Range1d, ColumnDataSource
from bokeh.palettes import Category10
import itertools
from dustmaps.bayestar import BayestarWebQuery
from svo_filters import svo

Expand Down Expand Up @@ -191,16 +190,16 @@ def __init__(self, name='My Target', verbose=True, method_list=None, substellar=
self.best_fit = {}

# Make empty spectra table
spec_cols = ('name', 'spectrum', 'wave_min', 'wave_max', 'wave_bins', 'resolution', 'history', 'ref')
spec_typs = ('O', 'O', np.float16, np.float16, int, int, 'O', 'O')
self._spectra = at.QTable(names=spec_cols, dtype=spec_typs)
spec_col_names = ('name', 'spectrum', 'wave_min', 'wave_max', 'wave_bins', 'resolution', 'history', 'ref')
spec_dtypes = ('O', 'O', np.float32, np.float32, int, int, 'O', 'O')
self._spectra = at.QTable(names=spec_col_names, dtype=spec_dtypes)
for col in ['wave_min', 'wave_max']:
self._spectra[col].unit = self._wave_units

# Make empty photometry table
self.mag_system = 'Vega'
phot_cols = ('band', 'eff', 'app_magnitude', 'app_magnitude_unc', 'app_flux', 'app_flux_unc', 'abs_magnitude', 'abs_magnitude_unc', 'abs_flux', 'abs_flux_unc', 'bandpass', 'ref')
phot_typs = ('U16', np.float16, np.float32, np.float32, float, float, np.float16, np.float16, float, float, 'O', 'O')
phot_typs = ('U16', np.float32, np.float32, np.float32, float, float, np.float32, np.float32, float, float, 'O', 'O')
self._photometry = at.QTable(names=phot_cols, dtype=phot_typs)
for col in ['app_flux', 'app_flux_unc', 'abs_flux', 'abs_flux_unc']:
self._photometry[col].unit = self._flux_units
Expand Down Expand Up @@ -310,7 +309,7 @@ def add_photometry(self, band, mag, mag_unc=None, system='Vega', ref=None, **kwa
# Make a dict for the new point
mag = round(mag, 3)
mag_unc = mag_unc if np.isnan(mag_unc) else round(mag_unc, 3)
eff = bp.wave_eff.astype(np.float16)
eff = bp.wave_eff.astype(np.float32)
new_photometry = {'band': band, 'eff': eff, 'app_magnitude': mag, 'app_magnitude_unc': mag_unc, 'bandpass': bp, 'ref': ref}

# Add the kwargs
Expand Down Expand Up @@ -444,8 +443,8 @@ def add_spectrum(self, spectrum, **kwargs):
spec.flux_units = self.flux_units

# Add the spectrum object to the list of spectra
mn = spec.wave_min#.astype(np.float16)
mx = spec.wave_max#.astype(np.float16)
mn = spec.wave_min
mx = spec.wave_max
res = int(((mx - mn) / np.nanmean(np.diff(spec.wave))).value)

# Make sure it's not a duplicate
Expand Down Expand Up @@ -688,7 +687,7 @@ def calculate_synthetic_photometry(self, bandpasses=None):
if mag is not None and not np.isnan(mag):

# Make a dict for the new point
new_photometry = {'band': band, 'eff': bp.wave_eff.astype(np.float16), 'bandpass': bp, 'app_magnitude': mag, 'app_magnitude_unc': mag_unc, 'ref': 'sedkit'}
new_photometry = {'band': band, 'eff': bp.wave_eff.astype(np.float32), 'bandpass': bp, 'app_magnitude': mag, 'app_magnitude_unc': mag_unc, 'ref': 'sedkit'}

# Add it to the table
self._synthetic_photometry.add_row(new_photometry)
Expand Down

0 comments on commit 61c3295

Please sign in to comment.