Astro Data Lab Home
Astro Data Lab User Forum
Toggle navigation
Username
Password
Remember
Login
Register
|
I forgot my password
Forum home
All Activity
Questions
Unanswered
Tags
Categories
Users
Ask a Question
Hi. I have found that sometimes (I have tried 76 searches and this happens 4 times) using cos(x) or sin(pi/2-x) in tap.like queries produces different results. One of them gives results and the other gives errors. Include two examples:
0
votes
242
views
http://datalab.noao.edu/tap/sync?REQUEST=doQuery&LANG=ADQL&QUERY=SELECT+TOP+5+*,(180/3.14159)*acos(sin((des_sva1.gold_catalog.dec_j2000)*3.14159/180)*sin(((-43.147769))*3.14159/180)%2Bcos((des_sva1.gold_catalog.dec_j2000)*3.14159/180)*cos(((-43.147769))*3.14159/180)*cos((des_sva1.gold_catalog.ra_j2000-(6.928423))*3.14159/180))+as+pdis+FROM+des_sva1.gold_catalog+WHERE+des_sva1.gold_catalog.ra_j2000+BETWEEN+6.9270341111111+AND+6.9298118888889+AND+des_sva1.gold_catalog.dec_j2000+BETWEEN+-43.149157888889+AND+-43.146380111111+order+by+pdis
http://datalab.noao.edu/tap/sync?REQUEST=doQuery&LANG=ADQL&QUERY=SELECT+TOP+5+*,(180/3.14159)*acos(cos((90-des_sva1.gold_catalog.dec_j2000)*3.14159/180)*cos((90-(-43.147769))*3.14159/180)%2Bsin((90-des_sva1.gold_catalog.dec_j2000)*3.14159/180)*sin((90-(-43.147769))*3.14159/180)*cos((des_sva1.gold_catalog.ra_j2000-(6.928423))*3.14159/180))+as+pdis+FROM+des_sva1.gold_catalog+WHERE+des_sva1.gold_catalog.ra_j2000+BETWEEN+6.9270341111111+AND+6.9298118888889+AND+des_sva1.gold_catalog.dec_j2000+BETWEEN+-43.149157888889+AND+-43.146380111111+order+by+pdis
they should be the same query (I hope I didn't make a mistake writing them). One produces results and the other returns an error.
i understand that this type of operations can be tricky and sometimes internal calculations generate these errors. I just tell you to know or to point me to what error I am making (please :)
asked
Mar 5, 2020
by
Carlos
|
242
views
answer
comment
flag
Please
log in
or
register
to add a comment.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or
register
.
Add answer
Cancel
2 Answers
0
votes
Hi Carlos,
thank you for your question. Taking a look at this now.
When I remove the acos() it is returning a result, will keep looking.
answered
Mar 5, 2020
by
ascottdemo
(
1,280
points)
comment
flag
ask related question
Hi Carlos,
a little more digging and you got "lucky" to run across a number that looks like 1 but is actually a little more than 1. We use double precision numbers that can be inexact (
https://www.postgresql.org/docs/11/datatype-numeric.html
) due to the nature of floating point numbers.
Try this query
SELECT acos( sin( (des_sva1.gold_catalog.dec_j2000)*3.14159/180) *
sin(((-43.147769))*3.14159/180) +
cos( (des_sva1.gold_catalog.dec_j2000)*3.14159/180) *
cos(((-43.147769))*3.14159/180) *
cos((des_sva1.gold_catalog.ra_j2000-(6.928423))*3.14159/180) - 0.0000000000001 )
as pdis FROM des_sva1.gold_catalog WHERE des_sva1.gold_catalog.ra_j2000 BETWEEN 6.9270341111111 AND 6.9298118888889 AND des_sva1.gold_catalog.dec_j2000 BETWEEN -43.149157888889 AND -43.146380111111 ;
Please
log in
or
register
to add a comment.
0
votes
Thanks for your answer.
Actually this is a useful trick. I am going to use it.
Thanks again :)
answered
Mar 5, 2020
by
Carlos
comment
flag
ask related question
Please
log in
or
register
to add a comment.
359
questions
372
answers
385
comments
2,451
users
Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.