desihub / desimeter

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

Add turbulence correction mode using stationary positioners #186

Closed schlafly closed 3 years ago

schlafly commented 3 years ago

This PR adds functionality for performing turbulence correction using stationary positioners to measure the turbulence in the volume of air between the FVC and the focal plane. The main feature is a new correct_using_stationary routine that specifies which positioners are stationary and the locations at which turbulence predictions are desired.

In order to make the turbulence correction faster and more robust, by default this mode does not fit for the covariance matrix in each image, but instead fixes the covariance matrix. An additonal option scales the covariance matrix by a constant, essentially allowing the expected positions to be specified in different units---for example, in FVC pixels rather than in microns in the focal plane.

Given the expected use in the online system, the module now tries to use the online logger if available. Otherwise it defaults to the desimeter logger.

schlafly commented 3 years ago

@julienguy, I think this looks fine, but you may object to looking for the DOSLib logger before the desimeter logger. This is to make life easier for Klaus, but let me know if you prefer another solution.

schlafly commented 3 years ago

Here's an example invocation:

cd /global/cfs/cdirs/desi/users/jguy/focalplane/petal1-at-lbl/turbulence/challenge
measured = ascii.read('measured.csv')
expected = ascii.read('expected.csv')
data = turbulence.make_data(expected, measured)
xm, ym = data['x']+data['dx'], data['y']+data['dy']
mstationary = np.random.rand(len(data)) < 0.1
xc, yc = turbulence.correct_using_stationary(xm[mstationary], ym[mstationary], data['x'][mstationary], data['y'][mstationary], xm[~mstationary], ym[~mstationary])
clf() ; quiver(data['x'][~mstationary], data['y'][~mstationary], xc-xm[~mstationary], yc-ym[~mstationary])

This is a bit messy since there isn't a command line interface and we don't have expected positions in general for the non-moving positioners, so I go and use the old measured / expected positioners.