Skip to content

Commit

Permalink
Merge pull request #116 from p-slash/v1.1.2-dev
Browse files Browse the repository at this point in the history
v1.1.2 - remove outlier masking
  • Loading branch information
p-slash authored Jul 11, 2024
2 parents 09aca55 + 7b2f3ff commit 22246ab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion py/qsonic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = 'Naim Goksel Karacayli'
__email__ = '[email protected]'
__version__ = '1.1.1'
__version__ = '1.1.2'


class QsonicException(Exception):
Expand Down
22 changes: 9 additions & 13 deletions py/qsonic/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import numpy as np

from qsonic.mathtools import (
_zero_function, _one_function, get_smooth_ivar, get_median_outlier_mask)
from qsonic.mathtools import _zero_function, _one_function, get_smooth_ivar


def add_wave_region_parser(parser=None):
Expand Down Expand Up @@ -303,11 +302,11 @@ def slice(self, arm, i1, i2):
self.cont_params['cont'][arm][i1:i2]

def set_forest_region(self, w1, w2, lya1, lya2):
""" Sets slices for the forest region. Masks outliers in each arm
separately based on moving median statistics
(see :func:`qsonic.mathtools.get_median_outlier_mask`). Also calculates
""" Sets slices for the forest region. Also calculates
the mean SNR in the forest and an initial guess for the continuum
amplitude.
amplitude. This is currently turned off, but it can mask outliers in
each arm separately based on moving median statistics
(see :func:`qsonic.mathtools.get_median_outlier_mask`).
Arguments
---------
Expand Down Expand Up @@ -337,11 +336,6 @@ def set_forest_region(self, w1, w2, lya1, lya2):
if self.reso:
self._forestreso[arm] = self.reso[arm][:, ii1:ii2].copy()

w = get_median_outlier_mask(
self._forestflux[arm], self._forestivar[arm])
self._forestflux[arm][w] = 0
self._forestivar[arm][w] = 0

self._forestivar_sm = self._forestivar
self._forestweight = self._forestivar
self._set_forest_related_parameters()
Expand Down Expand Up @@ -611,8 +605,10 @@ def coadd_arms_forest(
min_wave = np.min([wave[0] for wave in self.forestwave.values()])
max_wave = np.max([wave[-1] for wave in self.forestwave.values()])

nwaves = int((max_wave - min_wave) / self.dwave + 0.1) + 1
coadd_wave = np.linspace(min_wave, max_wave, nwaves)
nwaves = round((max_wave - min_wave) / self.dwave + 0.1)
coadd_wave = np.linspace(
min_wave, min_wave + nwaves * self.dwave, nwaves + 1)
nwaves += 1
coadd_flux = np.zeros(nwaves)
coadd_ivar = np.zeros(nwaves)
coadd_norm = np.zeros(nwaves)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.1
current_version = 1.1.2
commit = True
tag = False
message = [skip ci] Bump version: {current_version} → {new_version}
Expand Down
7 changes: 4 additions & 3 deletions tests/test_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ def test_set_forest_region(self, setup_data):
assert ('R' not in spec.forestflux.keys())
assert (not spec.forestreso)

spec.flux['B'][10:15] = 1e2
spec.set_forest_region(3600., 6000., 1050., 1180.)
npt.assert_equal(spec.forestflux['B'][10:15], 0)
# Test outlier masking (turned off)
# spec.flux['B'][10:15] = 1e2
# spec.set_forest_region(3600., 6000., 1050., 1180.)
# npt.assert_equal(spec.forestflux['B'][10:15], 0)

def test_drop_short_arms(self, setup_data):
cat_by_survey, _, data = setup_data(1)
Expand Down

0 comments on commit 22246ab

Please sign in to comment.