Repository: feder-observatory/stellarphot

Issue:
Current `apass_dr9` implementation does not change passbands to the AAVSO standard
The `apass_dr9` implementation does not change the passbands present in the Vizier catalog to the AAVSO standard names. It should.

Discussion:

Patch:
diff --git a/stellarphot/core.py b/stellarphot/core.py
index 9675d99..4d69df5 100644
--- a/stellarphot/core.py
+++ b/stellarphot/core.py
@@ -9,7 +9,7 @@ from astropy.time import Time
 from astropy.wcs import WCS
 from astroquery.vizier import Vizier
 
-from .settings import Camera, Observatory
+from .settings import Camera, Observatory, PassbandMap
 
 __all__ = [
     "BaseEnhancedTable",
@@ -290,7 +290,7 @@ class PhotometryData(BaseEnhancedTable):
         AAVSO passband names. This is used to automatically
         update the passband column to AAVSO standard names if desired. See
         the documentation for `stellarphot.settings.PassbandMap` for more
-        information. The object behaves like a dictinoary when accessing it.
+        information. The object behaves like a dictionary when accessing it.
 
     retain_user_computed: bool, optional (Default: False)
         If True, any computed columns (see USAGE NOTES below) that already
@@ -611,7 +611,7 @@ class CatalogData(BaseEnhancedTable):
         AAVSO passband names. This is used to automatically
         update the passband column to AAVSO standard names if desired. See
         the documentation for `stellarphot.settings.PassbandMap` for more
-        information. The object behaves like a dictinoary when accessing it.
+        information. The object behaves like a dictionary when accessing it.
 
     Attributes
     ----------
@@ -622,6 +622,13 @@ class CatalogData(BaseEnhancedTable):
         User readable designation for the source of the catalog (could be a
         URL or a journal reference).
 
+    passband_map: `stellarphot.settings.PassbandMap`
+        An object containing a mapping from instrumental passband names to
+        AAVSO passband names. This is used to automatically
+        update the passband column to AAVSO standard names if desired. See
+        the documentation for `stellarphot.settings.PassbandMap` for more
+        information. The object behaves like a dictionary when accessing it.
+
     Notes
     -----
     For validation of inputs, you must provide input_data, catalog_name, and
@@ -697,6 +704,14 @@ class CatalogData(BaseEnhancedTable):
     def catalog_source(self):
         return self.meta["catalog_source"]
 
+    @property
+    def passband_map(self):
+        return self._passband_map
+
+    @passband_map.setter
+    def passband_map(self, value):
+        self._passband_map = value
+
     @staticmethod
     def _tidy_vizier_catalog(data, mag_column_regex, color_column_regex):
         """
@@ -1017,6 +1032,21 @@ def apass_dr9(field_center, radius=1 * u.degree, clip_by_frame=False, padding=10
 
     # IAU says there is a space between the acronym and the coordinates.
     raw_catalog["id"] = [f"{designation_acronym} {coord}" for coord in coord_string]
+
+    # Translate the passbands to AAVSO standard names.
+    # No need to change B and V since those are already correct.
+    # Do this *after* initialization so that the original APASS band names
+    # are used for the tidy-ification operation.
+    raw_catalog.passband_map = PassbandMap(
+        name="APASS",
+        your_filter_names_to_aavso={
+            "g": "SG",
+            "r": "SR",
+            "i": "SI",
+        },
+    )
+    raw_catalog._update_passbands()
+
     return raw_catalog
 
 
diff --git a/stellarphot/utils/comparison_utils.py b/stellarphot/utils/comparison_utils.py
index 99cb310..56ff244 100644
--- a/stellarphot/utils/comparison_utils.py
+++ b/stellarphot/utils/comparison_utils.py
@@ -116,7 +116,7 @@ def crossmatch_APASS2VSX(CCD, RD, vsx):
 
 
 def mag_scale(
-    cmag, apass, v_angle, RD_angle, brighter_dmag=0.44, dimmer_dmag=0.75, passband="r"
+    cmag, apass, v_angle, RD_angle, brighter_dmag=0.44, dimmer_dmag=0.75, passband="SR"
 ):
     """
     Select comparison stars that are 1) not close the VSX stars or to other


Test patch:
diff --git a/stellarphot/tests/test_core.py b/stellarphot/tests/test_core.py
index 66ec08c..77980ae 100644
--- a/stellarphot/tests/test_core.py
+++ b/stellarphot/tests/test_core.py
@@ -760,6 +760,9 @@ def test_catalog_bandpassmap():
     assert catalog_dat.catalog_name == "VSX"
     assert catalog_dat.catalog_source == "Vizier"
 
+    # Also test that we can read the bandpass map
+    assert catalog_dat.passband_map["g"] == "SG"
+
 
 def test_catalog_recursive():
     # Construct good objects
@@ -1015,6 +1018,11 @@ def test_find_apass():
     # so just check the RAs.
     assert set(ra.value for ra in all_apass["ra"]) == set(expected_all["RAJ2000"])
 
+    # The passbands ought to have been translated to the AAVSO standard names.
+    # This is a regression test for #439.
+    for band in ["B", "V", "SG", "SR", "SI"]:
+        assert band in all_apass["passband"]
+
 
 # Load test apertures
 test_sl_data = ascii.read(