sot / chandra_aca

Chandra Aspect Camera Tools
https://sot.github.io/chandra_aca
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Some confusion working in absolute coordinates in ACAImage #39

Open jeanconn opened 7 years ago

jeanconn commented 7 years ago

Reviewing the docs:

>>> from chandra_aca.aca_image import ACAImage
>>> im4 = np.arange(16).reshape(4, 4)
>>> a = ACAImage(im4, row0=10, col0=20) 
>>> a
<ACAImage row0=10 col0=20
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])>
>>> a[3, 3]
15
>>> a.aca[13, 23]
15

That's fine. Here's where I get a little confused:

In [90]: a.aca[13, 16]
Out[90]: 12
In [91]: a.aca[13, 20]
Out[91]: 12
In [92]: a.aca[9, 16]
Out[92]: 12

It seems like these mappings back into the original array aren't quite absolute? I expect an error somewhere here.

jeanconn commented 7 years ago

Ah, I think I get it... the aca_coords are subtracting off row0, col0, so my examples are just benefiting from negative indexing back in to the original array. It might be good to check the bounds on the aca coordinates of the ACAImage in question and throw an error instead of allowing the negative indexing.

taldcroft commented 7 years ago

Agreed an exception for out-of-bounds absolute indexing makes sense. Not sure if practical issues will come up (performance or other cases like slicing that goes out of bounds).