lightkurve / lkprf

Repository for working with PRF files
4 stars 3 forks source link

challenges for ccd pixel coordinates #4

Closed keatonb closed 1 month ago

keatonb commented 2 months ago

Thanks for putting this together. I think a point of confusion for users will be that source positions and tpf "origins" have to be given in row,column number in the overall CCD, not relative to the corner of the TPF. This isn't clear yet from the documentation, especially with the examples using origin=(0,0).

Considering this example

image

the origin would be (1755,1104) and source locations would be in the shown range of rows and columns.

I anticipate this being confusing because this is not how the tpf.wcs functions return pixel locations. For this example, the row and column returned by tpf.wcs.all_world2pix([[tpf.ra,tpf.dec]], 0) returns array([[4.47254282, 4.89740099]]) relative to the corner of the postage stamp, and not in overall CCD coordinates. Such positions need to be added to the origin that also must be provided to the prf function, which is fine but not obvious, and a clearer example that shows how to sample a PRF at the location of a star in a real TPF would be helpful. It would also be helpful if the lightkurve TPF objects had a tpf.origin attribute you could simply pass to the origin arg of lkprf (or even could pass the TPF to automatically determine the origin).

Nschanche commented 1 month ago

Hey @keatonb, great idea. I've added a tutorial notebook showing how to create a PRF model based on a TPF in PR #10.

I also ran a test to check how well the PRF model matches observations. For 173 relatively isolated stars, I measured how close the pixel coordinates given in the TPF header match the centroid of the PRF model for lkprf and TESS_PRF. This is an imperfect measure as I didn't take things like proper motion into account, and only used the 'quadratic' centroid method for the PRF models. However, the good news is that lkprf and TESS_PRF agree nicely with each other, and both of them match the header target location to within ~.1 pixels.

TESS_offset_hist

Nschanche commented 1 month ago

Hi @keatonb, in the latest release (v1.1.0) I've added some clarification related to the origin parameter. I've also added a jupyter notebook found in docs/tutorials that demonstrates how to use keywords from a TPF to generate a PRF model. I think this addresses this issue, but if you have any questions or find any of the updated documentation clear, please do open another issue!

keatonb commented 1 month ago

Great, Nicole! I looked at the example notebook and I think it makes it quite clear how to set the origin. I should have known that info would be in the fits headers..