Mercurial > repos > astroteam > crbeam_astro_tool
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f40d05521dca |
---|---|
1 import numpy as np | |
2 from astroquery.ipac.ned import Ned | |
3 | |
4 | |
5 def find_redshift(src_name: str): | |
6 result_table = Ned.query_object(src_name) | |
7 # Check if there are results | |
8 if result_table is not None: | |
9 # Extract the redshift from the result table | |
10 z = float(result_table["Redshift"].data[0]) | |
11 if np.isnan(z): | |
12 raise NotImplementedError( | |
13 f"Failed to find redshift for {src_name}") | |
14 else: | |
15 raise ValueError(f"Object named {src_name} not found in NED database") | |
16 return z |