Skip to content

Commit

Permalink
* simplify generation of complex log message
Browse files Browse the repository at this point in the history
* tag a couple of np.arange() calls as producing floats,
  since they are immediately used for FP arithmetic
  • Loading branch information
Jeremy Buhler committed Sep 16, 2024
1 parent e93dc5f commit c602eb5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
9 changes: 2 additions & 7 deletions py/fastspecfit/continuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,13 +1370,8 @@ def continuum_fastspec(redshift, objflam, objflamivar, CTools,
raise ValueError(errmsg)

ncam = len(data['snr'])
if ncam == 1:
snrmsg = f"Median S/N_{data['cameras']}={data['snr'][0]:.2f}"
else:
snrmsg = f"Median S/N_{data['cameras'][0]}={data['snr'][0]:.2f}"
for icam in np.arange(ncam-1)+1:
snrmsg += f" S/N_{data['cameras'][icam]}={data['snr'][icam]:.2f}"
log.info(snrmsg)
snrmsgs = [ f'Median S/N_{data["cameras"]}={data["snr"][icam]:.2f}' for icam in range(ncam) ]
log.info(' '.join(snrmgs))

if templates.use_legacy_fitting:
ebv = 0.
Expand Down
2 changes: 1 addition & 1 deletion py/fastspecfit/emlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ def emline_specfit(data, result, continuummodel, smooth_continuum,
dwave = np.round(dwave, decimals=3)

npix = int(np.round((maxwave-minwave)/dwave)) + 1
modelwave = minwave + dwave * np.arange(npix)
modelwave = minwave + dwave * np.arange(npix, dtype=np.float64)

wavesrt = np.argsort(emlinewave)
sorted_waves = emlinewave[wavesrt]
Expand Down
6 changes: 3 additions & 3 deletions py/fastspecfit/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def __init__(self, template_file=None, template_version=None, imf=None,
self.conv_pre = self.convolve_vdisp_pre(self.flux)
self.flux_nomvdisp = self.convolve_vdisp(self.flux, vdisp_nominal)

self.conv_pre_nolines = self.convolve_vdisp_pre(self.flux_nolines)
self.conv_pre_nolines = self.convolve_vdisp_pre(self.flux_nolines)
self.flux_nolines_nomvdisp = self.convolve_vdisp(self.flux_nolines, vdisp_nominal)

self.info = Table(templateinfo)
Expand All @@ -137,7 +137,7 @@ def __init__(self, template_file=None, template_version=None, imf=None,
raise ValueError(errmsg)

self.vdisp = vdisp
self.vdisp_nominal_index = np.where(vdisp == vdisp_nominal)[0]
self.vdisp_nominal_index = np.where(vdisp == vdisp_nominal)[0]
self.vdispflux = vdispflux
self.vdispwave = vdispwave
else:
Expand Down Expand Up @@ -425,7 +425,7 @@ def _gaussian_kernel1d(sigma, radius, order=0):
"""
sigma2 = sigma * sigma
x = np.arange(-radius, radius+1)
x = np.arange(-radius, radius+1, dtype=np.float64)
phi_x = np.exp(-0.5 / sigma2 * x ** 2)
phi_x /= phi_x.sum()

Expand Down

0 comments on commit c602eb5

Please sign in to comment.