From 2b288f4659fff861a286a2fd4ab8dc7afc1cfe41 Mon Sep 17 00:00:00 2001 From: Joe Filippazzo Date: Fri, 20 Sep 2024 15:06:42 -0400 Subject: [PATCH] Fixed find_SDSS_spectra function --- sedkit/sed.py | 11 ++++++++--- sedkit/tests/test_sed.py | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sedkit/sed.py b/sedkit/sed.py index 3ea77f76..40bae51b 100644 --- a/sedkit/sed.py +++ b/sedkit/sed.py @@ -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: @@ -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: @@ -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': diff --git a/sedkit/tests/test_sed.py b/sedkit/tests/test_sed.py index 1eec5b3a..e30b36ae 100644 --- a/sedkit/tests/test_sed.py +++ b/sedkit/tests/test_sed.py @@ -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"""