Starlink / starlink-pyast

Python interface to the Starlink AST library
http://www.starlink.ac.uk/ast
12 stars 8 forks source link

tran() should support ND array input/output #11

Open parejkoj opened 8 years ago

parejkoj commented 8 years ago

If I want to output the transformed locations of e.g. a whole CCD, something like this is the obvious approach:

xx = np.arange(0,nx)
yy = np.arange(0,ny)
xv,yv = np.meshgrid(xx,yy)
result = frameset.tran((xv,yv))

but this doesn't work, as tran wants flattened arrays, but then the output has to be reshaped:

result = frameset.tran((xv.flatten(),yv.flatten())
result_ast = (result_ast[0].reshape(ny,nx),result_ast[1].reshape(ny,nx))

It would be useful if tran supported generic NDarrays, outputting the result in the same shape.

dsberry commented 8 years ago

The python interface is certainly something that could be smarted up. Demitri Muna had a plan for creating a more Pythonesque interface, but I'm not sure he ever got very far with it. ANy change would need to go through the whole of pyast, not just the tran function. However, for that particular example, you could do:

result = frameset.trangrid( [0,0], [nx,ny] )

see http://www.starlink.ac.uk/docs/sun211.htx/sun211ss219.html