Skip to content

Commit

Permalink
mv xy2uv, uv2xy to desimeter.transform.xy2qs
Browse files Browse the repository at this point in the history
  • Loading branch information
julienguy committed Apr 6, 2020
1 parent 65ec53d commit fdfeb7f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
20 changes: 3 additions & 17 deletions bin/desi_fit_circles
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@ from scipy import optimize
import matplotlib.pyplot as plt
import argparse

# from desimeter.transform.xy2qs import xy2qs, qs2xy
from desimodel.focalplane import xy2qs, qs2xy

#- Transform between CS5 x,y and curved focal surface
def xy2uv(x, y):
q, s = xy2qs(x, y)
qrad = np.radians(q)
u = s*np.cos(qrad)
v = s*np.sin(qrad)
return u, v

def uv2xy(u, v):
s = np.sqrt(u**2 + v**2)
qrad = np.arctan2(v, u)
q = np.degrees(qrad)
x, y = qs2xy(q, s)
return x, y

from desimeter.transform.xy2qs import xy2uv, uv2xy


#- Least squares fit to circle; adapted from "Method 2b" in
#- https://scipy-cookbook.readthedocs.io/items/Least_Squares_Circle.html
Expand Down
15 changes: 15 additions & 0 deletions py/desimeter/transform/xy2qs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,18 @@ def qs2xy(q, s):
y = r*np.sin(np.radians(q))

return x, y

#- Transform between CS5 x,y and curved focal surface
def xy2uv(x, y):
q, s = xy2qs(x, y)
qrad = np.radians(q)
u = s*np.cos(qrad)
v = s*np.sin(qrad)
return u, v

def uv2xy(u, v):
s = np.sqrt(u**2 + v**2)
qrad = np.arctan2(v, u)
q = np.degrees(qrad)
x, y = qs2xy(q, s)
return x, y

0 comments on commit fdfeb7f

Please sign in to comment.