diff --git a/astro_data/pifinder_objects.db b/astro_data/pifinder_objects.db index 742a154c7..f19e39427 100644 Binary files a/astro_data/pifinder_objects.db and b/astro_data/pifinder_objects.db differ diff --git a/python/PiFinder/catalog_imports/harris_loader.py b/python/PiFinder/catalog_imports/harris_loader.py index 158e91def..8428062f5 100644 --- a/python/PiFinder/catalog_imports/harris_loader.py +++ b/python/PiFinder/catalog_imports/harris_loader.py @@ -81,28 +81,29 @@ def read_harris_catalog(file_path: Path) -> npt.NDArray: (206, 210), # Half-mass radius (Rh) (F4.2 arcmin) ] - # Define dtype for structured array + # Define dtype for structured array. The floats are float64, so a value + # such as 6.47 stays 6.47 and not 6.46999979019165. dtype = [ ("ID", "U10"), # Cluster ID ("Name", "U12"), # Common name ("RAh", "i4"), # RA hours ("RAm", "i4"), # RA minutes - ("RAs", "f4"), # RA seconds + ("RAs", "f8"), # RA seconds ("DE_sign", "U1"), # Dec sign ("DEd", "i4"), # Dec degrees ("DEm", "i4"), # Dec minutes ("DEs", "i4"), # Dec seconds - ("GLON", "f4"), # Galactic longitude - ("GLAT", "f4"), # Galactic latitude - ("Rsun", "f4"), # Distance from Sun - ("Rgc", "f4"), # Distance from Galactic center - ("X", "f4"), # X component - ("Y", "f4"), # Y component - ("Z", "f4"), # Z component - ("Vt", "f4"), # Integrated V magnitude - ("MVt", "f4"), # Absolute magnitude - ("Rc", "f4"), # Core radius (arcmin) - ("Rh", "f4"), # Half-mass radius (arcmin) + ("GLON", "f8"), # Galactic longitude + ("GLAT", "f8"), # Galactic latitude + ("Rsun", "f8"), # Distance from Sun + ("Rgc", "f8"), # Distance from Galactic center + ("X", "f8"), # X component + ("Y", "f8"), # Y component + ("Z", "f8"), # Z component + ("Vt", "f8"), # Integrated V magnitude + ("MVt", "f8"), # Absolute magnitude + ("Rc", "f8"), # Core radius (arcmin) + ("Rh", "f8"), # Half-mass radius (arcmin) ] def parse_line(line: str) -> tuple: @@ -117,7 +118,7 @@ def parse_field(value: str, field_dtype: str) -> Any: return value elif field_dtype == "i4": return int(value) if value and value != "." else 0 - elif field_dtype == "f4": + elif field_dtype == "f8": try: return float(value) if value and value != "." else np.nan except ValueError: diff --git a/python/PiFinder/catalog_imports/lynga_loader.py b/python/PiFinder/catalog_imports/lynga_loader.py index ca196497e..f37c3c51e 100644 --- a/python/PiFinder/catalog_imports/lynga_loader.py +++ b/python/PiFinder/catalog_imports/lynga_loader.py @@ -173,33 +173,33 @@ def read_lynga_catalog(file_path: Path) -> npt.NDArray: ("ClSeq", "i4"), # Cluster Sequence code ("ClNum", "i4"), # Number inside sequence ("RA2000h", "i4"), # RA 2000 hours - ("RA2000m", "f4"), # RA 2000 minutes + ("RA2000m", "f8"), # RA 2000 minutes ("DE2000s", "U1"), # Dec 2000 sign ("DE2000d", "i4"), # Dec 2000 degrees ("DE2000m", "i4"), # Dec 2000 minutes - ("Diam", "f4"), # Angular diameter (arcmin) + ("Diam", "f8"), # Angular diameter (arcmin) ("Dist", "i4"), # Distance (pc) - ("logAge", "f4"), # log(age) years - ("FeH", "f4"), # Metallicity [Fe/H] - ("EBV", "f4"), # Reddening E(B-V) + ("logAge", "f8"), # log(age) years + ("FeH", "f8"), # Metallicity [Fe/H] + ("EBV", "f8"), # Reddening E(B-V) ("ClTyp", "U2"), # Doubtful cluster flag ("TrConc", "i4"), # Trumpler concentration class ("TrRange", "i4"), # Trumpler range class ("TrRich", "U2"), # Trumpler richness class ("TrNeb", "U1"), # Trumpler nebulosity - ("maxBr50", "f4"), # Brightest star magnitude (ref.50) - ("totMag50", "f4"), # Total magnitude (ref.50) - ("totMag422", "f4"), # Total magnitude (Skiff ref.422) - ("iBV422", "f4"), # Integrated B-V (Skiff) + ("maxBr50", "f8"), # Brightest star magnitude (ref.50) + ("totMag50", "f8"), # Total magnitude (ref.50) + ("totMag422", "f8"), # Total magnitude (Skiff ref.422) + ("iBV422", "f8"), # Integrated B-V (Skiff) ("N422", "i4"), # Number of stars (Skiff) - ("wRVel", "f4"), # Radial velocity weight + ("wRVel", "f8"), # Radial velocity weight ("RVel", "i4"), # Radial velocity (km/s) ("Cname", "U9"), # "C" designation ("DistJDL", "i4"), # jdl distance (pc) - ("turnJDL", "f4"), # jdl turn-off colour - ("AgeJDL", "f4"), # jdl age (Myr) - ("EBVJDL", "f4"), # jdl reddening - ("FeHJDL", "f4"), # jdl abundance + ("turnJDL", "f8"), # jdl turn-off colour + ("AgeJDL", "f8"), # jdl age (Myr) + ("EBVJDL", "f8"), # jdl reddening + ("FeHJDL", "f8"), # jdl abundance ] def parse_field(value: str, field_dtype: str) -> Any: @@ -208,7 +208,7 @@ def parse_field(value: str, field_dtype: str) -> Any: return value elif field_dtype == "i4": return int(value) if value and value not in (".", "-") else 0 - elif field_dtype == "f4": + elif field_dtype == "f8": try: return float(value) if value and value not in (".", "-") else np.nan except ValueError: diff --git a/python/PiFinder/catalog_imports/specialized_loaders.py b/python/PiFinder/catalog_imports/specialized_loaders.py index 6535885e5..308b34e40 100644 --- a/python/PiFinder/catalog_imports/specialized_loaders.py +++ b/python/PiFinder/catalog_imports/specialized_loaders.py @@ -663,7 +663,10 @@ def expand(name): aka_names = [row["name"]] # Start with the first name mag = row["magnitude"] if utils.is_number(mag): - mag = MagnitudeObject([float(mag)]) + # arp.sqlite stores the magnitudes as float32 values + # (13.800000190734863), so round to the two decimals of a + # catalog magnitude. + mag = MagnitudeObject([round(float(mag), 2)]) else: logging.warning( f"Invalid magnitude for Arp {row['catalog_identifier']}" diff --git a/python/tests/test_catalog_data.py b/python/tests/test_catalog_data.py index 7478cef13..71024d881 100644 --- a/python/tests/test_catalog_data.py +++ b/python/tests/test_catalog_data.py @@ -22,10 +22,10 @@ def test_object_counts(): "Ta2": 200, "H": 400, "SaA": 114, - "SaM": 2162, + "SaM": 2157, # five pairs SAC marks rejected ("STT 56 rej.") are no double star "SaR": 333, "Str": 78, - "EGC": 91, + "EGC": 102, # with the Magellanic Cloud globulars "RDS": 110, "B": 343, "Sh2": 313, @@ -34,11 +34,12 @@ def test_object_counts(): "TLK": 93, "Har": 147, "Lyn": 1151, + "Nam": 578, # every IAU-named star with a Hipparcos number } # catalog count num_catalogs = len(list(db.get_catalogs())) - assert num_catalogs == 21 + assert num_catalogs == 22 actual_catalogs = [row["catalog_code"] for row in db.get_catalogs()] expected_catalogs = list(catalog_counts.keys()) missing_catalogs = set(expected_catalogs) - set(actual_catalogs) @@ -291,8 +292,9 @@ def check_ic_objects(): "name": "Heart Nebula", "ra": 38.200, # RA = 02h 32m 48s "dec": 61.450, # Dec = +61° 27' 00" - # "obj_type": "Nb", # Emission nebula - "obj_type": "OC", # Open cluster at the heart of the nebula + # The import merges IC 1805, Sh2 190 and Lyn 77 into one object: + # the cluster with its emission nebula. + "obj_type": "C+N", "const": "Cas", # Cassiopeia }, { diff --git a/python/tests/test_catalog_matching.py b/python/tests/test_catalog_matching.py index 1d01a564e..2dd28d35c 100644 --- a/python/tests/test_catalog_matching.py +++ b/python/tests/test_catalog_matching.py @@ -11,6 +11,8 @@ import logging import sqlite3 +from pathlib import Path + import pytest import PiFinder.catalog_imports.caldwell_loader as caldwell_loader @@ -606,6 +608,17 @@ def test_harris_keeps_the_sign_of_a_declination_just_south_of_the_equator(tmp_pa ) +def test_harris_magnitudes_keep_their_two_decimals(): + from PiFinder.catalog_imports.harris_loader import read_harris_catalog + + catalog = Path(__file__).parents[2] / "astro_data" / "harris" / "catalog" + entries = {str(entry["ID"]): entry for entry in read_harris_catalog(catalog)} + m2 = entries["NGC 7089"] + # The catalog gives V = 6.47; a float32 gives 6.46999979019165. + assert m2["Vt"].item() == 6.47 + assert repr(m2["Vt"].item()) == "6.47" + + def test_lynga_keeps_the_sign_of_a_declination_just_south_of_the_equator(tmp_path): from PiFinder.catalog_imports.lynga_loader import ( create_cluster_object,