Skip to content

Commit

Permalink
Catalogs: SDSS now has max radius
Browse files Browse the repository at this point in the history
of 3 arcmin in the pre-release of astroquery 0.4.7.dev.

Also make Catalog to not crash horribly when query fails.

Update catalogs test results.
  • Loading branch information
pllim committed Feb 7, 2023
1 parent eafa22a commit 7985bf8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 18 additions & 2 deletions jdaviz/configs/imviz/plugins/catalogs/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import numpy as np
import numpy.ma as ma
from astropy import units as u
from astropy.table import QTable
from astropy.coordinates import SkyCoord
from traitlets import List, Unicode, Bool, Int, observe

from jdaviz.configs.default.plugins.data_tools.file_chooser import FileChooser
from jdaviz.core.events import SnackbarMessage
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import (PluginTemplateMixin, ViewerSelectMixin,
SelectPluginComponent)
Expand Down Expand Up @@ -127,11 +129,25 @@ def search(self):
# conducts search based on SDSS
if self.catalog_selected == "SDSS":
from astroquery.sdss import SDSS
r_max = 3 * u.arcmin

# queries the region (based on the provided center point and radius)
# finds all the sources in that region
query_region_result = SDSS.query_region(skycoord_center, radius=zoom_radius,
data_release=17)
try:
if zoom_radius > r_max: # SDSS now has radius max limit
self.hub.broadcast(SnackbarMessage(
f"Radius for {self.catalog_selected} has max radius of {r_max} but got "
f"{zoom_radius.to(u.arcmin)}, using {r_max}.",
color='warning', sender=self))
zoom_radius = r_max
query_region_result = SDSS.query_region(skycoord_center, radius=zoom_radius,
data_release=17)
except Exception as e: # nosec
self.hub.broadcast(SnackbarMessage(
f"Failed to query {self.catalog_selected} with c={skycoord_center} and "
f"r={zoom_radius}: {repr(e)}", color='error', sender=self))
query_region_result = None

if query_region_result is None:
self.results_available = True
self.number_of_results = 0
Expand Down
6 changes: 3 additions & 3 deletions jdaviz/configs/imviz/tests/test_catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def test_plugin_image_with_result(self, imviz_helper, tmp_path):
catalogs_plugin.vue_do_search()

# number of results should be > 0
# '2473' was determined by running the search with the image in the notebook
# Answer was determined by running the search with the image in the notebook.
assert catalogs_plugin.results_available
assert catalogs_plugin.number_of_results == 2473
assert catalogs_plugin.number_of_results == 668

# testing that every variable updates accordingly when markers are cleared
catalogs_plugin.vue_do_clear()
Expand All @@ -116,7 +116,7 @@ def test_plugin_image_with_result(self, imviz_helper, tmp_path):
assert catalogs_plugin.catalog.selected == 'From File...'
catalogs_plugin.vue_do_search()
assert catalogs_plugin.results_available
assert catalogs_plugin.number_of_results == 2473
assert catalogs_plugin.number_of_results == 668


def test_from_file_parsing(imviz_helper, tmp_path):
Expand Down

0 comments on commit 7985bf8

Please sign in to comment.