Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odd (wrong?) desiname #211

Closed
moustakas opened this issue Jan 10, 2025 · 5 comments · Fixed by #212
Closed

odd (wrong?) desiname #211

moustakas opened this issue Jan 10, 2025 · 5 comments · Fixed by #212
Labels

Comments

@moustakas
Copy link
Member

@akremin

>>> from desiutil.names import radec_to_desiname
>>> radec_to_desiname(40.669625, -0.013277777)
array(['DESI J040.6696000.-132'], dtype='<U22')

I think we've hit a corner-case that the algorithm gets wrong. Haven't checked any catalogs yet; I came across this in the wild.

@weaverba137
Copy link
Member

When the numbers are truncated, precision == 4:

>>> dectrunc = np.trunc((10 ** precision) * target_dec).astype(int).astype(str)
>>> dectrunc
'-132'

which isn't enough characters to properly handle the zero-padding below that point. If the zero-padding were performed immediately after, then it might work.

>>> dectrunc.zfill(7)
'-000132'
>>> dectrunc.zfill(7)[:-precision] + '.' + dectrunc.zfill(7)[-precision:]
'-00.0132'

@weaverba137
Copy link
Member

Please take a look at this updated code. I've added some tests for when RA or Dec are very close to zero.

@moustakas
Copy link
Member Author

That update looks great, @weaverba137, thanks for the quick turn-around.

@moustakas moustakas added the bug label Jan 10, 2025
@akremin
Copy link
Member

akremin commented Jan 10, 2025

Thank you for the quick update, Ben. A very nice and clean solution! I think that the solution using 7 and 6 zero padding is specific to precision=4. The level of precision is a variable but is not an input argument, so this is a very minor issue. At some point we should update it though.

@weaverba137
Copy link
Member

@akremin, I agree, I'll make the padding a function of precision to make that explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants