Skip to content

Commit

Permalink
Merge abfce6f into 97492f0
Browse files Browse the repository at this point in the history
  • Loading branch information
profxj committed Jul 11, 2018
2 parents 97492f0 + abfce6f commit 2fb441f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions linetools/isgm/abssystem.py
Expand Up @@ -620,9 +620,10 @@ def to_dict(self):
outdict['components'] = {}
for component in self._components:
outdict['components'][component.name] = ltu.jsonify(component.to_dict())
# Spectrum file?
if hasattr(self, 'spec_file'):
outdict['spec_file'] = self.spec_file
# Extras
for eattr in ['spec_file', 'kin']:
if hasattr(self, eattr):
outdict[eattr] = getattr(self,eattr)
# Polish
outdict = ltu.jsonify(outdict)
# Return
Expand Down
2 changes: 1 addition & 1 deletion linetools/spectra/io.py
Expand Up @@ -517,7 +517,7 @@ def parse_FITS_binary_table(hdulist, exten=None, wave_tag=None, flux_tag=None,
if sig_tag is None:
sig_tags = ['ERROR','ERR','SIGMA_FLUX','ERR_FLUX', 'ENORM', 'FLAM_SIG', 'SIGMA_UP',
'ERRSTIS', 'FLUXERR', 'SIGMA', 'sigma', 'sigma_flux',
'er', 'err', 'error', 'sig', 'fluxerror']
'er', 'err', 'error', 'sig', 'fluxerror', 'FLUX_ERROR']
else:
sig_tags = [sig_tag]
sig, sig_tag = get_table_column(sig_tags, hdulist, idx=exten)
Expand Down
12 changes: 9 additions & 3 deletions linetools/spectra/xspectrum1d.py
Expand Up @@ -830,7 +830,7 @@ def relative_vel(self, wv_obs):
return velo

# Box car smooth
def box_smooth(self, nbox, preserve=True, **kwargs):
def box_smooth(self, nbox, preserve=True, scale_sig=True, **kwargs):
""" Box car smooth the spectrum
Parameters
Expand All @@ -840,6 +840,8 @@ def box_smooth(self, nbox, preserve=True, **kwargs):
preserve: bool, optional
If True, perform a convolution to ensure the new spectrum
has the same number of pixels as the original.
scale_sig : bool, optional
If True, scale the smoothed sig array down by np.sqrt(nbox)
**kwargs: dict
If preserve=True, these keywords are passed on to
astropy.convoution.convolve
Expand All @@ -853,7 +855,9 @@ def box_smooth(self, nbox, preserve=True, **kwargs):
from astropy.convolution import convolve, Box1DKernel
new_fx = convolve(self.flux, Box1DKernel(nbox), **kwargs)
if self.sig_is_set:
new_sig = convolve(self.sig, Box1DKernel(nbox), **kwargs) / np.sqrt(nbox)
new_sig = convolve(self.sig, Box1DKernel(nbox), **kwargs)
if scale_sig:
new_sig /= np.sqrt(nbox)
else:
new_sig = None
if self.co_is_set:
Expand All @@ -876,7 +880,9 @@ def box_smooth(self, nbox, preserve=True, **kwargs):
new_fx = ltu.scipy_rebin(self.flux[orig_pix_trunc], new_npix)
if self.sig_is_set:
new_sig = ltu.scipy_rebin(
self.sig[orig_pix_trunc], new_npix) / np.sqrt(nbox)
self.sig[orig_pix_trunc], new_npix)
if scale_sig:
new_sig /= np.sqrt(nbox)
else:
new_sig = None
if self.co_is_set:
Expand Down

0 comments on commit 2fb441f

Please sign in to comment.