@@ -127,18 +127,13 @@ def ArrayClass_init(self, *args, **kwargs):
127127 type(self ).ngrids .initial = numgrids
128128 self .ngrids = type (self ).ngrids .initial
129129 if self .ngrids >= 0 :
130- for index in ["xi" , "yi" , "zi" , "ti" ]:
131- if index != "ti" :
132- setattr (self , index , np .zeros (self .ngrids , dtype = np .int32 ))
133- else :
134- setattr (self , index , - 1 * np .ones (self .ngrids , dtype = np .int32 ))
130+ self .ei = np .zeros (self .ngrids , dtype = np .int32 )
131+ self .ti = - 1 * np .ones (self .ngrids , dtype = np .int32 )
135132 super (type (self ), self ).__init__ (* args , ** kwargs )
136133
137134 array_class_vdict = {
138135 "ngrids" : Variable ("ngrids" , dtype = np .int32 , to_write = False , initial = - 1 ),
139- "xi" : Variable ("xi" , dtype = np .int32 , to_write = False ),
140- "yi" : Variable ("yi" , dtype = np .int32 , to_write = False ),
141- "zi" : Variable ("zi" , dtype = np .int32 , to_write = False ),
136+ "ei" : Variable ("ei" , dtype = np .int32 , to_write = False ),
142137 "ti" : Variable ("ti" , dtype = np .int32 , to_write = False , initial = - 1 ),
143138 "__init__" : ArrayClass_init ,
144139 }
@@ -436,7 +431,7 @@ def _neighbors_by_coor(self, coor):
436431
437432 # TODO: This method is only tested in tutorial notebook. Add unit test?
438433 def populate_indices (self ):
439- """Pre-populate guesses of particle xi/yi indices using a kdtree.
434+ """Pre-populate guesses of particle ei (element id) indices using a kdtree.
440435
441436 This is only intended for curvilinear grids, where the initial index search
442437 may be quite expensive.
@@ -454,10 +449,8 @@ def populate_indices(self):
454449 _ , idx_nan = tree .query (pts .astype (tree_data .dtype ))
455450
456451 idx = np .where (IN )[0 ][idx_nan ]
457- yi , xi = np .unravel_index (idx , grid .lon .shape )
458452
459- self .particledata .data ["xi" ][:, i ] = xi
460- self .particledata .data ["yi" ][:, i ] = yi
453+ self .particledata .data ["ei" ][:, i ] = idx # assumes that we are in the surface layer (zi=0)
461454
462455 @classmethod
463456 def from_list (
@@ -725,9 +718,7 @@ def from_particlefile(
725718 elif (
726719 v .name
727720 not in [
728- "xi" ,
729- "yi" ,
730- "zi" ,
721+ "ei" ,
731722 "ti" ,
732723 "dt" ,
733724 "depth" ,
0 commit comments