diff utils.py @ 0:f40d05521dca draft default tip

planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools commit de01e3c02a26cd6353a6b9b6f8d1be44de8ccd54
author astroteam
date Fri, 25 Apr 2025 19:33:20 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils.py	Fri Apr 25 19:33:20 2025 +0000
@@ -0,0 +1,16 @@
+import numpy as np
+from astroquery.ipac.ned import Ned
+
+
+def find_redshift(src_name: str):
+    result_table = Ned.query_object(src_name)
+    # Check if there are results
+    if result_table is not None:
+        # Extract the redshift from the result table
+        z = float(result_table["Redshift"].data[0])
+        if np.isnan(z):
+            raise NotImplementedError(
+                f"Failed to find redshift for {src_name}")
+    else:
+        raise ValueError(f"Object named {src_name} not found in NED database")
+    return z