diff --git a/docs/change_history.rst b/docs/change_history.rst index e771e3d8..d7aa96bd 100644 --- a/docs/change_history.rst +++ b/docs/change_history.rst @@ -3,12 +3,15 @@ Change History .. _v1.3.5: -V1.3.5 Not Released -^^^^^^^^^^^^^^^^^^^ +V1.3.5 24-11-2021 +^^^^^^^^^^^^^^^^^ - Created `--target-min-width` and `--target-max-width` flags to allow extraction of extended sources. - Replaced coveralls with codecov for code coverage. - Documentation improvements and updates. +- Fixed issue with extracted spectrum that where masked in 2D. +- Code style improvements. + .. _v1.3.4: diff --git a/goodman_pipeline/core/__init__.py b/goodman_pipeline/core/__init__.py index 5e748da3..32698dc8 100644 --- a/goodman_pipeline/core/__init__.py +++ b/goodman_pipeline/core/__init__.py @@ -42,7 +42,7 @@ identify_technique, image_overscan, image_trim, - interpolate, + interpolate_spectrum, is_file_saturated, linearize_spectrum, name_master_flats, diff --git a/goodman_pipeline/core/core.py b/goodman_pipeline/core/core.py index b29eaef5..ff54d0ba 100644 --- a/goodman_pipeline/core/core.py +++ b/goodman_pipeline/core/core.py @@ -13,7 +13,6 @@ import pandas import random import re -import scipy import subprocess import sys import time @@ -30,7 +29,7 @@ from astropy.time import Time from astroscrappy import detect_cosmics from matplotlib import pyplot as plt -from scipy import signal +from scipy import signal, interpolate from threading import Timer from . import check_version @@ -1296,6 +1295,8 @@ def extract_fractional_pixel(ccd, target_trace, target_fwhm, extraction_width, new_ccd = ccd.copy() new_ccd.data = np.asarray(extracted_spectrum) + log.warning("Setting mask to None, otherwise saving will fail.") + new_ccd.mask = None if new_ccd.header['NAXIS'] != 1: for i in range(int(new_ccd.header['NAXIS']), 1, -1): new_ccd.header.remove(keyword="NAXIS{:d}".format(i)) @@ -2062,7 +2063,7 @@ def image_trim(ccd, trim_section, trim_type='trimsec', add_keyword=False): return ccd -def interpolate(spectrum, interpolation_size): +def interpolate_spectrum(spectrum, interpolation_size): """Creates an interpolated version of the input spectrum This method creates an interpolated version of the input array, it is @@ -2089,8 +2090,8 @@ def interpolate(spectrum, interpolation_size): last_x, spectrum.size * interpolation_size) - tck = scipy.interpolate.splrep(x_axis, spectrum, s=0) - new_spectrum = scipy.interpolate.splev(new_x_axis, tck, der=0) + tck = interpolate.splrep(x_axis, spectrum, s=0) + new_spectrum = interpolate.splev(new_x_axis, tck, der=0) return [new_x_axis, new_spectrum] @@ -2169,10 +2170,8 @@ def linearize_spectrum(data, wavelength_solution, plots=False): except TypeError: pass new_x_axis = np.linspace(x_axis[0], x_axis[-1], len(data)) - tck = scipy.interpolate.splrep(x_axis, data, s=0) - linearized_data = scipy.interpolate.splev(new_x_axis, - tck, - der=0) + tck = interpolate.splrep(x_axis, data, s=0) + linearized_data = interpolate.splev(new_x_axis, tck, der=0) smoothed_linearized_data = signal.medfilt(linearized_data) if plots: # pragma: no cover diff --git a/goodman_pipeline/core/tests/test_core.py b/goodman_pipeline/core/tests/test_core.py index 53636df5..2708489e 100644 --- a/goodman_pipeline/core/tests/test_core.py +++ b/goodman_pipeline/core/tests/test_core.py @@ -62,7 +62,7 @@ identify_targets, image_overscan, image_trim, - interpolate, + interpolate_spectrum, is_file_saturated, linearize_spectrum, name_master_flats, @@ -821,6 +821,7 @@ def setUp(self): self.fake_image = CCDData(data=np.ones((100, 100)), meta=fits.Header(), unit='adu') + self.fake_image.mask = np.zeros((100, 100), dtype=bool) self.fake_image.header.set('NAXIS', value=2) self.fake_image.header.set('NAXIS1', value=100) self.fake_image.header.set('NAXIS2', value=100) @@ -1259,12 +1260,12 @@ def test__get_spectral_characteristics(self): class InterpolationTest(TestCase): - def test_interpolate(self): + def test_interpolate_spectrum(self): initial_array = np.sin(np.arange(0, 3 * np.pi)) initial_length = len(initial_array) - new_x_axis, new_array = interpolate(spectrum=initial_array, - interpolation_size=100) + new_x_axis, new_array = interpolate_spectrum(spectrum=initial_array, + interpolation_size=100) self.assertEqual(len(new_x_axis), len(new_array)) self.assertEqual(len(new_array), initial_length * 100) diff --git a/goodman_pipeline/spectroscopy/wavelength.py b/goodman_pipeline/spectroscopy/wavelength.py index c974e566..d57739ad 100644 --- a/goodman_pipeline/spectroscopy/wavelength.py +++ b/goodman_pipeline/spectroscopy/wavelength.py @@ -337,7 +337,7 @@ def _automatic_wavelength_solution(self, except NoMatchFound as error: raise NoMatchFound(error) except NotImplementedError as error: - raise NotImplemented(error) + raise NotImplementedError(error) # TODO (simon): Evaluate possibility to read iraf wcs. [#304] diff --git a/goodman_pipeline/version.py b/goodman_pipeline/version.py index 89c1d616..9b0b86cf 100644 --- a/goodman_pipeline/version.py +++ b/goodman_pipeline/version.py @@ -1,2 +1,2 @@ # This is an automatic generated file please do not edit -__version__ = '1.3.5.dev2' \ No newline at end of file +__version__ = '1.3.5' \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 7cb81006..8db36907 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,4 +32,4 @@ install_requires = ccdproc astroplan # version should be PEP440 compatible (http://www.python.org/dev/peps/pep-0440) -version = 1.3.5.dev2 +version = 1.3.5