From 62455a7f670306673fd02e08af7301f5a6cbc22c Mon Sep 17 00:00:00 2001
From: Jesse Mapel <jmapel@usgs.gov>
Date: Wed, 10 Feb 2021 08:31:49 -0700
Subject: [PATCH] Changed old scipy rotation calls to new ones (#399)

* Changed old scipy rotation calls to new ones

* Updated scipy pinning
---
 ale/drivers/lro_drivers.py               | 4 ++--
 ale/rotation.py                          | 6 +++---
 environment.yml                          | 2 +-
 recipe/meta.yaml                         | 2 +-
 tests/pytests/test_isis_spice_drivers.py | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ale/drivers/lro_drivers.py b/ale/drivers/lro_drivers.py
index 00b6962..dd7d5e5 100644
--- a/ale/drivers/lro_drivers.py
+++ b/ale/drivers/lro_drivers.py
@@ -271,7 +271,7 @@ class LroLrocPds3LabelNaifSpiceDriver(LineScanner, NaifSpice, Pds3Label, Driver)
         position = state[:3]
         velocity = state[3:]
         rotation = frame_chain.compute_rotation(1, lro_bus_id)
-        rotated_velocity = spice.mxv(rotation._rots.as_dcm()[0], velocity)
+        rotated_velocity = spice.mxv(rotation._rots.as_matrix()[0], velocity)
         return rotated_velocity[0]
 
 
@@ -507,7 +507,7 @@ class LroLrocIsisLabelNaifSpiceDriver(LineScanner, NaifSpice, IsisLabel, Driver)
         position = state[:3]
         velocity = state[3:]
         rotation = frame_chain.compute_rotation(1, lro_bus_id)
-        rotated_velocity = spice.mxv(rotation._rots.as_dcm()[0], velocity)
+        rotated_velocity = spice.mxv(rotation._rots.as_matrix()[0], velocity)
         return rotated_velocity[0]
 
 
diff --git a/ale/rotation.py b/ale/rotation.py
index 600ca38..b746be6 100644
--- a/ale/rotation.py
+++ b/ale/rotation.py
@@ -32,7 +32,7 @@ class ConstantRotation:
         --------
         scipy.spatial.transform.Rotation.from_dcm
         """
-        rot = Rotation.from_dcm(mat)
+        rot = Rotation.from_matrix(mat)
         return ConstantRotation(rot.as_quat(), source, dest)
 
     def __init__(self, quat, source, dest):
@@ -82,7 +82,7 @@ class ConstantRotation:
         """
         The rotation matrix representation of the constant rotation
         """
-        return self._rot.as_dcm()
+        return self._rot.as_matrix()
 
     def inverse(self):
         """
@@ -370,7 +370,7 @@ class TimeDependentRotation:
             skew = np.array([[0, -avs[indx, 2], avs[indx, 1]],
                              [avs[indx, 2], 0, -avs[indx, 0]],
                              [-avs[indx, 1], avs[indx, 0], 0]])
-            rot_deriv = np.dot(skew, rots[indx].as_dcm().T).T
+            rot_deriv = np.dot(skew, rots[indx].as_matrix().T).T
             rotated_vel[indx] = rots[indx].apply(vec_vel[indx])
             rotated_vel[indx] += np.dot(rot_deriv, vec_pos[indx])
 
diff --git a/environment.yml b/environment.yml
index db30c99..b0d9bf4 100644
--- a/environment.yml
+++ b/environment.yml
@@ -14,7 +14,7 @@ dependencies:
   - pytz
   - python
   - python-dateutil
-  - scipy
+  - scipy>=1.4.0
   - spiceypy>=2.3.0
   - pyyaml
   - networkx
diff --git a/recipe/meta.yaml b/recipe/meta.yaml
index d713bb0..f535f2b 100644
--- a/recipe/meta.yaml
+++ b/recipe/meta.yaml
@@ -28,7 +28,7 @@ requirements:
     - python
     - python-dateutil
     - pytz
-    - scipy >=1.2.0
+    - scipy >=1.4.0
     - spiceypy >=2.3.0
     - pyyaml
 
diff --git a/tests/pytests/test_isis_spice_drivers.py b/tests/pytests/test_isis_spice_drivers.py
index 26a0891..afe4017 100644
--- a/tests/pytests/test_isis_spice_drivers.py
+++ b/tests/pytests/test_isis_spice_drivers.py
@@ -512,7 +512,7 @@
 #     test_cube._body_orientation_table['Rotations'] = [[1.0/np.sqrt(2), 1.0/np.sqrt(2), 0, 0]]
 #     #Overwrite the instrument pointing, which is (0, 1, 2, 3) at this point
 #     test_cube._inst_pointing_table["Rotations"] = [[1.0/np.sqrt(2), 0, 1.0/np.sqrt(2), 0]]
-#     print('inverse body rotation', test_cube._body_j2k2bf_rotation.inv().as_dcm())
+#     print('inverse body rotation', test_cube._body_j2k2bf_rotation.inv().as_matrix())
 #     np.testing.assert_almost_equal(test_cube._sensor_orientation, np.asarray([1/2, -1/2, -1/2, -1/2]))
 #
 # def test_body_orientation(test_cube):
-- 
GitLab