From ff61eadeabbb06f3c17459c1a12d9895253f5801 Mon Sep 17 00:00:00 2001 From: Benjamin Alan Weaver Date: Fri, 10 Jan 2025 09:15:28 -0700 Subject: [PATCH] explicitly add precision to zero-padding --- py/desiutil/names.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/py/desiutil/names.py b/py/desiutil/names.py index 6874d6d..79d93a9 100644 --- a/py/desiutil/names.py +++ b/py/desiutil/names.py @@ -65,17 +65,17 @@ def radec_to_desiname(target_ra, target_dec): # IAU compliant term desinames = [] for ra, dec in zip(ratrunc, dectrunc): - zra = ra.zfill(7) + zra = ra.zfill(3 + precision) # RA always has 3 leading digits. desiname = 'DESI J' + zra[:-precision] + '.' + zra[-precision:] # Positive numbers need an explicit "+" while negative numbers # already have a "-". - # zfill works properly with '-' but counts it in number of characters - # so need one more + # zfill works properly with '-' but counts it in the number of characters + # so need one extra character is needed. if dec.startswith('-'): - zdec = dec.zfill(7) + zdec = dec.zfill(3 + precision) # 2 leading digits plus space for '-'. desiname += zdec[:-precision] + '.' + zdec[-precision:] else: - zdec = dec.zfill(6) + zdec = dec.zfill(2 + precision) # 2 leading digits and the '+' is added explicitly. desiname += '+' + zdec[:-precision] + '.' + zdec[-precision:] desinames.append(desiname)