Skip to content

Commit

Permalink
Fixed factor 2 issue with plotting filter profile width
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed Aug 27, 2024
1 parent 03b8bd0 commit 6fbdccb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions species/plot/plot_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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]:
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion species/read/read_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6fbdccb

Please sign in to comment.