From 6fbdccb9091691a25f795102422413d30f07fbe5 Mon Sep 17 00:00:00 2001 From: Tomas Stolker Date: Tue, 27 Aug 2024 09:34:28 +0200 Subject: [PATCH] Fixed factor 2 issue with plotting filter profile width --- species/plot/plot_spectrum.py | 28 ++++++++++++++-------------- species/read/read_filter.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/species/plot/plot_spectrum.py b/species/plot/plot_spectrum.py index f78ad28..4e4c95e 100644 --- a/species/plot/plot_spectrum.py +++ b/species/plot/plot_spectrum.py @@ -944,7 +944,7 @@ def plot_spectrum( data_out = convert_units(data_in, units, convert_from=False) # Absolute value because could be negative when frequency - fwhm_up = np.abs(data_out[0, 0] - wavelength[0]) + hwhm_up = np.abs(data_out[0, 0] - wavelength[0]) # Convert FWHM of filter to requested units data_in = np.column_stack( @@ -953,14 +953,14 @@ def plot_spectrum( data_out = convert_units(data_in, units, convert_from=False) # Absolute value because could be negative when frequency - fwhm_down = np.abs(data_out[0, 0] - wavelength[0]) + hwhm_down = np.abs(data_out[0, 0] - wavelength[0]) - # Calculate the average, which will be identical - # to fwhm_up and fwhm_down when working with - # wavelengths but fwhm_up and fwhm_down will - # be different when convertin a FWHM from + # Calculate the FWHM, which will be identical + # to 2*hwhm_up and 2*hwhm_down when working with + # wavelengths but hwhm_up and hwhm_down will + # be different when converting a FWHM from # wavelength to frequency - fwhm = (fwhm_up + fwhm_down) / 2.0 + fwhm = (hwhm_up + hwhm_down) if not plot_kwargs[j] or filter_item not in plot_kwargs[j]: if not plot_kwargs[j]: @@ -1112,7 +1112,7 @@ def plot_spectrum( data_out = convert_units(data_in, units, convert_from=False) # Absolute value because could be negative when frequency - fwhm_up = np.abs(data_out[0, 0] - wavelength[0]) + hwhm_up = np.abs(data_out[0, 0] - wavelength[0]) # Convert FWHM of filter to requested units data_in = np.column_stack( @@ -1121,14 +1121,14 @@ def plot_spectrum( data_out = convert_units(data_in, units, convert_from=False) # Absolute value because could be negative when frequency - fwhm_down = np.abs(data_out[0, 0] - wavelength[0]) + hwhm_down = np.abs(data_out[0, 0] - wavelength[0]) - # Calculate the average, which will be identical - # to fwhm_up and fwhm_down when working with - # wavelengths but fwhm_up and fwhm_down will - # be different when convertin a FWHM from + # Calculate the FWHM, which will be identical + # to 2*hwhm_up and 2*hwhm_down when working with + # wavelengths but hwhm_up and hwhm_down will + # be different when converting a FWHM from # wavelength to frequency - fwhm = (fwhm_up + fwhm_down) / 2.0 + fwhm = (hwhm_up + hwhm_down) if quantity == "flux": flux_scaling = wavelength diff --git a/species/read/read_filter.py b/species/read/read_filter.py index e955d6c..41be7d6 100644 --- a/species/read/read_filter.py +++ b/species/read/read_filter.py @@ -206,7 +206,7 @@ def filter_fwhm(self) -> float: return root2 - root1 @typechecked - def effective_width(self) -> np.float32: + def effective_width(self) -> Union[np.float32, np.float64]: """ Calculate the effective width of the filter profile. The effective width is equivalent to the horizontal size of a