Skip to content

Commit

Permalink
Fix phoenix test warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sujay-Shankar committed May 15, 2024
1 parent e61e228 commit ca9a844
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/gollum/precomputed_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from dotenv import get_key
from logging import getLogger
from pathlib import Path
from warnings import filterwarnings
from warnings import filterwarnings, catch_warnings
from gollum.utilities import apply_numpy_mask
from scipy.ndimage import gaussian_filter1d
from scipy.signal import find_peaks
Expand Down Expand Up @@ -115,12 +115,13 @@ def rotationally_broaden(self, vsini, u1=0.0, u2=0.0):
"""
lam0 = np.median(self.wavelength.value)
x2 = (299792.458 * (self.wavelength.value - lam0) / (lam0 * vsini)) ** 2
kernel = np.where(
x2 < 1,
np.pi / 2 * u1 * (1 - x2)
+ np.sqrt(1 - x2) * (2 - 2 * u1 - 4 / 3 * u2 * u2 * x2),
0,
)
with catch_warnings(action="ignore", category=RuntimeWarning):
kernel = np.where(
x2 < 1,
np.pi / 2 * u1 * (1 - x2)
+ np.sqrt(1 - x2) * (2 - 2 * u1 - 4 / 3 * u2 * u2 * x2),
0,
)
kernel, positive_elements = kernel / np.sum(kernel, axis=0), kernel > 0
return (
self._copy(
Expand Down
12 changes: 8 additions & 4 deletions tests/test_phoenix.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from warnings import filterwarnings, catch_warnings
filterwarnings("ignore", category=DeprecationWarning)
from gollum.phoenix import PHOENIXSpectrum, PHOENIXGrid
from pytest import raises
from urllib.error import URLError
from specutils import Spectrum1D
import numpy as np
import astropy.units as u

from astropy.utils.exceptions import AstropyDeprecationWarning

def test_spectrum():
"""Testing the PHOENIXSpectrum class"""
filterwarnings("ignore", category=AstropyDeprecationWarning)
with raises(URLError):
PHOENIXSpectrum(teff=5, logg=2, Z=2.0, download=True)

Expand Down Expand Up @@ -65,9 +68,10 @@ def test_resample():
def test_grid():
"""Testing the PHOENIXGrid methods"""

grid = PHOENIXGrid(
teff_range=(5000, 5100), logg_range=(2, 2.5), Z_range=(0, 0.5), experimental=True, download=True
)
with catch_warnings(action='ignore', category=DeprecationWarning):
grid = PHOENIXGrid(
teff_range=(5000, 5100), logg_range=(2, 2.5), Z_range=(0, 0.5), experimental=True, download=True
)
assert grid
assert len(grid)
assert isinstance(grid[0], PHOENIXSpectrum)
Expand Down

0 comments on commit ca9a844

Please sign in to comment.