0 votes
223 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 :)
by | 223 views

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.
by ascottdemo (1.3k points)
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 ;
0 votes
Thanks for your answer.

Actually this is a useful trick. I am going to use it.

Thanks again :)
by

418 questions

435 answers

440 comments

637 users

Welcome to Data Lab Help Desk, where you can ask questions and receive answers from other members of the community.

Categories