diff --git a/Convert_Matlab/inst_eddies_v6.py b/Convert_Matlab/inst_eddies_v6.py
index 3134f868cc72e19f55c3dbf5a29f9a30034c1481..71dad06936fc3e19ce58856f97380c4f25246209 100755
--- a/Convert_Matlab/inst_eddies_v6.py
+++ b/Convert_Matlab/inst_eddies_v6.py
@@ -42,14 +42,16 @@ def define_fields(writers):
     writers["max_speed"].field("days_1950", "N", 5)
     writers["max_speed"].field("eddy_index", "N", 5)
 
-def write(writers, cell, cyclone):
+def write(writers, cell, X, Y, ADT, cyclone):
     """Write to shapefiles eddies with a given orientation, at a given
     date.
 
     writers is a dictionary. cell is a numpy.ndarray with shape
-    (number of eddies, 21). cyclone is a boolean. The eddy
-    identification numbers start at 1 and increment by 1 for each eddy
-    in cell.
+    (number of eddies, 21). X and Y are numpy one-dimensional arrays
+    containing longitudes and latitudes of the SSH grid. ADT is a
+    numpy two-dimensional array containing SSH. cyclone is a
+    boolean. The eddy identification numbers start at 1 and increment
+    by 1 for each eddy in cell.
 
     """
     eddy_index = 0
@@ -63,17 +65,16 @@ def write(writers, cell, cyclone):
         eddy_index += 1
 
         writers["extr"].point(eddy[0], eddy[1])
-        i = np.argwhere(matlab_data["X"] == eddy[0]).item()
-        j = np.argwhere(matlab_data["Y"] == eddy[1]).item()
+        i = np.argwhere(X == eddy[0]).item()
+        j = np.argwhere(Y == eddy[1]).item()
         speed = 1e4 if np.isnan(eddy[12]) else eddy[12]
-        writers["extr"].record(ssh = matlab_data["ADT"][i, j], valid = 1,
-                               days_1950 = d, eddy_index = eddy_index,
-                               speed = speed)
+        writers["extr"].record(ssh = ADT[i, j], valid = 1, days_1950 = d,
+                               eddy_index = eddy_index, speed = speed)
 
         if cyclone:
-            ssh = matlab_data["ADT"][i, j] + eddy[7]
+            ssh = ADT[i, j] + eddy[7]
         else:
-            ssh =  matlab_data["ADT"][i, j] - eddy[7]
+            ssh =  ADT[i, j] - eddy[7]
 
         writers["centroid"].point(eddy[2], eddy[3])
         writers["centroid"].record(days_1950 = d, eddy_index = eddy_index)
@@ -84,9 +85,9 @@ def write(writers, cell, cyclone):
         writers["outer"].poly([polyline])
 
         if cyclone:
-            ssh = matlab_data["ADT"][i, j] + eddy[11]
+            ssh = ADT[i, j] + eddy[11]
         else:
-            ssh =  matlab_data["ADT"][i, j] - eddy[11]
+            ssh =  ADT[i, j] - eddy[11]
 
         writers["max_speed"].record(r_eq_area = eddy[10], ssh = ssh,
                                     days_1950 = d, eddy_index = eddy_index)
@@ -163,6 +164,7 @@ while True:
 
         for factory in factories:
             write(factory["writers"], matlab_data[factory["cell_name"]],
+                  matlab_data["X"], matlab_data["Y"], matlab_data["ADT"],
                   factory["cyclone"])
 
         os.remove("adt.mat")