desihub / desimeter

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

Add routine to print groups of ambigous positioners. #168

Closed schlafly closed 3 years ago

schlafly commented 3 years ago

Used for detangling petal 0 at Kitt Peak. Makes lists of positioner <-> centroid associations, identifying numbers of ambiguous ones, for further inspection in front-illuminated images.

Example usage: desi_print_ambigous_groups /global/cfs/cdirs/desi/spectro/desimeter/v0006/20210101/00070311/fvc-00070311.csv --petal 0

julienguy commented 3 years ago

@schlafly , can remove the 'import pdb' so I can merge this.

schlafly commented 3 years ago

Sorry, I don't follow. Do you want me to handle the impossible case with an assertion or something instead? I don't think I ever got that bit of code triggering, so it should be harmless?

julienguy commented 3 years ago

Yes I would suggest you raise an exception. In fact, I would have done it myself and not bother you, but I miss a test example to verify any change I make is not breaking anything. So what would be very useful is that you dump in this discussion (or in a rst file in the doc directory) an example one can run at nersc.

schlafly commented 3 years ago

Okay, I changed pdb.set_trace() to raise AssertionError('...'). I also added a command line script using this module, which has example usage: desi_print_ambigous_groups /global/cfs/cdirs/desi/spectro/desimeter/v0006/20210101/00070311/fvc-00070311.csv --petal 0 which has been added to the initial comment.

The present analysis is slow (probably ~20 min) if one needs to get all the alternatives for all 10 petals, because it resolves the entire 5k x 5k problem for each of the 5k fibers. I can't remember if patrol radii ever overlap between different petals. If not, this is easily resolved by doing one petal at a time. That takes a couple seconds. There are other wins to be had if we want it to be faster. The next things would be testing the sparse linear sum assignment algorithm https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.min_weight_full_bipartite_matching.html#scipy.sparse.csgraph.min_weight_full_bipartite_matching and pre-filtering out all unambiguous positioners (i.e., cases where there's only a unique 1:1 match between a centroid and a positioner).

The command line script makes up a dummy calibration structure that includes the arm lengths for all of the positioners. I couldn't find where this information actually lives in desimeter.