Skip to content

Commit

Permalink
Fixed find_SDSS_spectra function
Browse files Browse the repository at this point in the history
  • Loading branch information
hover2pi committed Sep 20, 2024
1 parent 539ef68 commit 2b288f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sedkit/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,10 +1262,14 @@ def find_SDSS_spectra(self, surveys=['optical', 'apogee'], search_radius=None, *
"""
Search for SDSS spectra
"""
# Manual or parent radius
if search_radius is None:
search_radius = self.search_radius

if 'optical' in surveys:

# Query spectra
data, ref, header = qu.query_SDSS_optical_spectra(target=self.name, sky_coords=self.sky_coords, verbose=self.verbose, radius=search_radius or self.search_radius, **kwargs)
data, ref, header = qu.query_SDSS_optical_spectra(target=self.name, sky_coords=self.sky_coords, verbose=self.verbose, radius=search_radius, **kwargs)

# Add the spectrum to the SED
if data is not None:
Expand All @@ -1277,7 +1281,7 @@ def find_SDSS_spectra(self, surveys=['optical', 'apogee'], search_radius=None, *
if 'apogee' in surveys:

# Query spectra
data, ref, header = qu.query_SDSS_apogee_spectra(target=self.name, sky_coords=self.sky_coords, verbose=self.verbose, search_radius=search_radius or self.search_radius, **kwargs)
data, ref, header = qu.query_SDSS_apogee_spectra(target=self.name, sky_coords=self.sky_coords, verbose=self.verbose, search_radius=search_radius, **kwargs)

# Add the spectrum to the SED
if data is not None:
Expand Down Expand Up @@ -1916,7 +1920,8 @@ def infer_radius(self, radius_units=q.Rsun, infer_from=None, plot=False):
if len(infer_froms) > 0:
infer_from = infer_froms[0]
if infer_from not in infer_froms or infer_from is None:
raise ValueError("{}: Please choose valid relation to infer the radius. Try {}".format('None' if infer_from is None else infer_from, infer_froms))
self.message('Could not calculate radius without spectral_type, Lbol, M_2MASS.J, or M_2MASS.Ks')
# raise ValueError("{}: Please choose valid relation to infer the radius. Try {}".format('None' if infer_from is None else infer_from, infer_froms))

# Try model isochrones
if infer_from == 'evo_model':
Expand Down
2 changes: 2 additions & 0 deletions sedkit/tests/test_sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def test_find_SDSS_spectra(self):
s = sed.SED()
s.sky_coords = SkyCoord('0h8m05.63s +14d50m23.3s', frame='icrs')
s.find_SDSS_spectra(search_radius=20 * q.arcsec)
s.find_SDSS()
s.plot()

def test_run_methods(self):
"""Test that the method_list argument works"""
Expand Down

0 comments on commit 2b288f4

Please sign in to comment.