desihub / desimeter

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

Spotmatch #120

Closed julienguy closed 4 years ago

julienguy commented 4 years ago

Add spotmatch wrapper in desimeter.

One function in desimeter.

def spotmatch(xpix,ypix,expected_x_fp=None,expected_y_fp=None,expected_location=None,verbose=0,match_radius_pixels=70)
Wrapper to spotmatch in desimeter. Calls the C executable 'match_positions' that has to be in the path. All inputs
to match_positions are generated in this call using desimeter metrology table, the default fvc2fp transform and the inputs

Args :
   xpix : 1D numpy array with FVC image X pixel coordinates of detected spots
   ypix : 1D numpy array with FVC image Y pixel coordinates of detected spots

Optionnally :
   expected_x_fp : 1D numpy array with expected targets focal plane coordinates X in mm
   expected_y_fp : 1D numpy array with expected targets focal plane coordinates Y in mm
   expected_location :  1D numpy array with targets location index ( = petal_loc*10000+device_loc)
   verbose : 0 or 1
   match_radius_pixels : match radius in pixels

returns :
   an astropy.table.Table object with at least the columns
   LOCATION,XPIX,YPIX,FLAG,ERR,SPOTMATCH_DEVICE_TYPE,DEVICE_ID,DEVICE_TYPE,DEVICE_LOC,PETAL_LOC,PINHOLE_ID
   and possibly other columns from the input metrology table
   LOCATION = petal_loc*10000+device_loc for matched spots
   or a negative number if not matched
   PINHOLE_ID = 0 for positioners (DEVICE_TYPE="POS")
   PINHOLE_ID = 99 for fiducial centers (DEVICE_TYPE="FIF" or DEVICE_TYPE="GIF")
   PINHOLE_ID = 10, 11, 12, or 13 for fiducial pinholes (DEVICE_TYPE="FIF" or DEVICE_TYPE="GIF")
   the pinholes in a fiducial are not matched to the metrology, so only the fiducial centers (PINHOLE_ID = 99)
   can be used to fit the transform.

spotmatch can be used in place of the desimeter matching code in desi_fvc_proc when used with the option --use-spotmatch.

The spotmatch executable match_positions has to be in the path. This code is there https://desi.lbl.gov/trac/browser/code/online/FVC/spotmatch

julienguy commented 4 years ago

I won't fix this last codacy issue. I'm merging this code. Tested successfully on beyonce with petal1 data.