desihub / desimeter

DESI coordinates and transformations
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Update X_FP, Y_FP for GFA pixel corners to match target_ra/dec. #150

Closed schlafly closed 3 years ago

schlafly commented 3 years ago

This PR adds a metrology 'cheat' patch, updating the corners of the GFAs in FP coordinates according to a 6 parameter scale & offset model so that the target_ra/dec match the desimeter ra/dec.

This approach makes sense if we assume that platemaker is doing a good job with the overall 'cheat' parameters, so that the actual ra & dec are good matches for the target_ra/dec, having been placed by platemaker in the right places on average for these large scale parameters.

Some important remaining issues:

An alternative would be to say that we take the PM - desimeter comparison as evidence that a temporally constant set of cheats isn't a horrible idea, but then to fit those cheats based on the three good dither sequences. Then we would be trying to come closer to "truth" than to PM. We'd only have three sequences to use in that case, though, and I haven't yet evaluated how consistent the cheat parameters are among those sequences.

For setting dx & dy, we might also want to think harder about the field model. Currently I take a catalog from a particular guide frame to set this. But we really want to be averaging over all of the relevant guide frames.

Leaving this as a draft PR until I have a DocDB file and we discuss some of these issues.

schlafly commented 3 years ago

I feel like if we have improved metrology, I'll need to refit the transform anyway, so there's no particular win there? It's not clear to me if the current approach or the approach you describe would be better behaved following updates to the metrology of things that aren't the GFA X_FP, Y_FP.

But yes, the code that writes out the patch file works by applying a simplecorr object to a subset of the metrology, so it would be easy enough to do that inside write_focal_plane_metrology. I just figured this approach was more parallel to the existing code in that script. And initially I had hoped that write_focal_plane_metrology looked for a list of patches, and it would pick up mine without any additional code---though that was obviously wrong.

julienguy commented 3 years ago

Just a confirmation that this indeed improves the results. On one dither sequence (see details below):

desi_fit_guide_star_coordinates -i guide-00055670_catalog-00001.fits --fits-header guide-00055670.fits.fz -o fm-00055670.json
INFO:fieldmodel.py:220:fit_tancorr:RMS coord. residual = 0.15 arcsec

desi_fvc_proc -i fvc-00055670.fits.fz --extname F0002 --field-model fm-00055670.json --expected coordinates-00055670.fits -o fvc-00055670.csv --zbfit
INFO:fvc2fp.py:184:fit:Mean, median, RMS distance = 7.2, 6.8, 8.2 um

plot_dither_vs_desimeter dither20200315-63224-B.fits fvc-00055670.csv fiberassign-063225.fits 55670

number of valid targets from dither analysis = 1758
residual scale along HA       = 1-5.6e-06
residual scale along Dec      = 1+1.8e-05
residual pointing offset dHA  = 0.09 arcsec
residual pointing offset dDec = -0.09 arcsec
residual rotation             = -3.70 arcsec
   desimeter(guide+fvc)-target rms 2D = 0.25 arcsec
                 dither-target rms 2D = 0.23 arcsec
   desimeter(guide+fvc)-dither rms 2D = 0.31 arcsec
transformed(desimeter) -dither rms 2D = 0.26 arcsec
schlafly commented 3 years ago

This now fits the cheat parameters to the dithers rather than to PM. So by construction there is no mean offset with respect to the dithers. It further uses Aaron's initial GFA coadds rather than just the 10th coadd guide cube frame; this looks to improve the stability of the cheat parameters appreciably.

https://data.desi.lbl.gov/desi/users/schlafly/desimeter/coadd/quivers-20200314-63159.pdf https://data.desi.lbl.gov/desi/users/schlafly/desimeter/coadd/quivers-20200314-63159-2.pdf https://data.desi.lbl.gov/desi/users/schlafly/desimeter/coadd/quivers-20200315-63224.pdf give example comparisons with dithers. Of note: the poor performance at the end of the sequence on 20200314-2 goes away; the ADC interpolation is working better. The versions with cheat parameters fit out (left) are still better than the ones without (right), though the errors bounce around over the course of the sequences, suggesting that this is an issue with the astrometry from the GFAs rather than from intrinsic variability in these parameters, maybe?

schlafly commented 3 years ago

PS: this now has a bunch of duplicative commits with https://github.com/desihub/desimeter/pull/156, so I don't know what will happen when we try to merge it. Happy to resolve the conflicts should they arise after that one goes in.

julienguy commented 3 years ago

Great. Thanks.

Now the next step may be to stack the dither offsets and see if we can adjust systematic ZB coefficient correction to the ones obtained with the ray tracing code.