astroufsc / chimera

Chimera - Observatory Automation System
http://chimera.sf.net/
GNU General Public License v2.0
36 stars 19 forks source link

Coord sum adds to invalid coordinates #157

Open wschoenell opened 7 years ago

wschoenell commented 7 years ago

Coord package behavior when summing outside limits is wrong...

from chimera.util.coord import Coord

ra = Coord.fromHMS('23:59:59') + Coord.fromAS(100)
print ra.__str__()   # gives: 24:00:05.667
dec = Coord.fromDMS('359:59:59') + Coord.fromAS(100)
print dec.__str__() # gives: +360:01:39.000
wschoenell commented 7 years ago

I added a check for the coordinates to be within 0-360 deg interval.

Now the results are:

from chimera.util.coord import Coord

ra = Coord.fromHMS('23:59:59') + Coord.fromAS(100)
print ra.__str__()   # gives: 00:00:05.667
dec = Coord.fromDMS('359:59:59') + Coord.fromAS(100)
print dec.__str__() # gives: +00:01:39.000
wschoenell commented 7 years ago

Ok... So as @tribeiro noted on a private conversation, the idea of Coord is not to do any check on coordinates at all. Those must be done on higher level classes such as Position. https://github.com/astroufsc/chimera/blob/b5da4343fb375a7ecce2962de365fd07c5b665e0/src/chimera/util/coord.py#L450-L452

So, I will roll back all this changes and enforce the 0-360 boundaries on FakeTelescope which is where the problem was first seen.

wschoenell commented 7 years ago

Ran some tests on the last commit and things seems to work as expected:

$ chimera-tel --slew --ra 23:59:59 --dec 359:59:59
======================================== 
current position ra/dec: 01:49:13.099 -03:00:00.000 
current position alt/az: +51:27:03.930 +346:32:21.392 
======================================== 
slewing to 23:59:59.000 +359:59:59.000 (J2000.0)...  OK. 
======================================== 
new position ra/dec: 23:59:59.000 +359:59:59.000 
new position alt/az: +37:56:24.088 +312:18:13.450 

$ chimera-tel -N 1000
======================================== 
current position ra/dec: 23:59:59.000 +359:59:59.000 
current position:alt/az: +37:55:31.614 +312:16:35.006 
======================================== 
moving 1000.0 arcseconds (+00:16:40.000) North at CENTER rate...  OK 
======================================== 
new position ra/dec: 23:59:59.000 +00:00:17.436 
new position:alt/az: +37:55:16.230 +312:16:47.888 
======================================== 

$ chimera-tel -S 2000
======================================== 
current position ra/dec: 23:59:59.000 +00:00:17.436 
current position:alt/az: +37:54:08.446 +312:14:40.840 
======================================== 
moving 2000.0 arcseconds (+00:33:20.000) South at CENTER rate...  OK 
======================================== 
new position ra/dec: 23:59:59.000 +359:26:57.436 
new position:alt/az: +38:21:41.840 +311:50:50.229 
======================================== 

$ chimera-tel -E 1000
======================================== 
current position ra/dec: 23:59:59.000 +359:26:57.436 
current position:alt/az: +38:21:08.380 +311:49:47.748 
======================================== 
moving 1000.0 arcseconds (+00:16:40.000) East at CENTER rate...  OK 
======================================== 
new position ra/dec: 00:01:05.667 +359:26:57.436 
new position:alt/az: +38:30:28.602 +312:07:18.236 
======================================== 

$ chimera-tel -W 2000
======================================== 
current position ra/dec: 00:01:05.667 +359:26:57.436 
current position:alt/az: +38:30:05.547 +312:06:34.821 
======================================== 
moving 2000.0 arcseconds (+00:33:20.000) West at CENTER rate...  OK 
======================================== 
new position ra/dec: 23:58:52.333 +359:26:57.436 
new position:alt/az: +38:11:12.579 +311:31:20.644 
========================================