Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pysiaf/aperture.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,8 @@ def idl_to_tel(self, x_idl, y_idl, V3IdlYAngle_deg=None, V2Ref_arcsec=None, V3Re
if input_coordinates == 'cartesian':
# define cartesian unit vector as in JWST-PLAN-006166, Section 5.7.1.1
# then apply 3D rotation matrix to tel
unit_vector_idl = rotations.unit_vector_from_cartesian(x=x_idl*u.arcsec, y=y_idl*u.arcsec)
unit_vector_idl = rotations.unit_vector_from_cartesian(y=x_idl*u.arcsec, z=y_idl*u.arcsec)
unit_vector_idl[1] = aperture.VIdlParity * unit_vector_idl[1]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aperture.VIdlParity should be self.VIdlParity


if input_coordinates == 'polar':
# interpret idl coordinates as spherical, i.e. distortion polynomial includes deprojection
Expand Down Expand Up @@ -1175,8 +1176,9 @@ def tel_to_idl(self, v2_arcsec, v3_arcsec, V3IdlYAngle_deg=None, V2Ref_arcsec=No
unit_vector_idl = np.dot(l_matrix, unit_vector_tel)

if output_coordinates == 'cartesian':
x_idl_arcsec, y_idl_arcsec = unit_vector_idl[0] * u.rad.to(u.arcsec), unit_vector_idl[
1] * u.rad.to(u.arcsec)
unit_vector_idl[1] = aperture.VIdlParity * unit_vector_idl[1]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aperture.VIdlParity should be self.VIdlParity

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanjibs Would you be able to change these and resubmit the PR? (Sorry, I'm not familiar enough to do this from my end).

x_idl_arcsec, y_idl_arcsec = unit_vector_idl[1] * u.rad.to(u.arcsec), unit_vector_idl[
2] * u.rad.to(u.arcsec)
elif output_coordinates == 'polar':
unit_vector_idl[1] = self.VIdlParity * unit_vector_idl[1]
x_idl, y_idl = rotations.polar_angles(unit_vector_idl)
Expand Down Expand Up @@ -2620,4 +2622,4 @@ class RomanAperture(Aperture):

def __init__(self):
super(RomanAperture, self).__init__()
self.observatory = 'Roman'
self.observatory = 'Roman'
6 changes: 3 additions & 3 deletions pysiaf/utils/rotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,11 @@ def unit_vector_from_cartesian(x=None, y=None, z=None):
z_rad = z

# handle array and scalar inputs
if np.array([x_rad]).all() and np.array([y_rad]).all():
if z is None:
unit_vector = np.array([x_rad, y_rad, np.sqrt(1-(x_rad**2+y_rad**2))])
elif np.array([y_rad]).all() and np.array([z_rad]).all():
elif x is None:
unit_vector = np.array([np.sqrt(1-(y_rad**2+z_rad**2)), y_rad, z_rad])
elif np.array([x_rad]).all() and np.array([z_rad]).all():
elif y is None:
unit_vector = np.array([x_rad, np.sqrt(1-(x_rad**2+z_rad**2)), z_rad])

if np.any(np.isnan(unit_vector)):
Expand Down
Loading