@@ -1006,22 +1006,28 @@ def _search_indices_vertical_z(self, z):
1006
1006
if self .gridindexingtype in ["croco" ] and z < 0 :
1007
1007
return (- 2 , 1 )
1008
1008
raise FieldOutOfBoundError (z , 0 , 0 , field = self )
1009
- depth_indices = grid .depth <= z
1009
+ depth_indices = grid .depth < z
1010
1010
if z >= grid .depth [- 1 ]:
1011
1011
zi = len (grid .depth ) - 2
1012
1012
else :
1013
- zi = depth_indices .argmin () - 1 if z >= grid .depth [0 ] else 0
1013
+ zi = depth_indices .argmin () - 1 if z > grid .depth [0 ] else 0
1014
1014
else :
1015
1015
if z > grid .depth [0 ]:
1016
1016
raise FieldOutOfBoundSurfaceError (z , 0 , 0 , field = self )
1017
1017
elif z < grid .depth [- 1 ]:
1018
1018
raise FieldOutOfBoundError (z , 0 , 0 , field = self )
1019
- depth_indices = grid .depth >= z
1019
+ depth_indices = grid .depth > z
1020
1020
if z <= grid .depth [- 1 ]:
1021
1021
zi = len (grid .depth ) - 2
1022
1022
else :
1023
- zi = depth_indices .argmin () - 1 if z <= grid .depth [0 ] else 0
1023
+ zi = depth_indices .argmin () - 1 if z < grid .depth [0 ] else 0
1024
1024
zeta = (z - grid .depth [zi ]) / (grid .depth [zi + 1 ] - grid .depth [zi ])
1025
+ while zeta > 1 :
1026
+ zi += 1
1027
+ zeta = (z - grid .depth [zi ]) / (grid .depth [zi + 1 ] - grid .depth [zi ])
1028
+ while zeta < 0 :
1029
+ zi -= 1
1030
+ zeta = (z - grid .depth [zi ]) / (grid .depth [zi + 1 ] - grid .depth [zi ])
1025
1031
return (zi , zeta )
1026
1032
1027
1033
@deprecated_made_private # TODO: Remove 6 months after v3.1.0
@@ -1065,26 +1071,32 @@ def _search_indices_vertical_s(
1065
1071
z = np .float32 (z ) # type: ignore # TODO: remove type ignore once we migrate to float64
1066
1072
1067
1073
if depth_vector [- 1 ] > depth_vector [0 ]:
1068
- depth_indices = depth_vector <= z
1074
+ if z < depth_vector [0 ]:
1075
+ raise FieldOutOfBoundSurfaceError (z , 0 , 0 , field = self )
1076
+ elif z > depth_vector [- 1 ]:
1077
+ raise FieldOutOfBoundError (z , y , x , field = self )
1078
+ depth_indices = depth_vector < z
1069
1079
if z >= depth_vector [- 1 ]:
1070
1080
zi = len (depth_vector ) - 2
1071
1081
else :
1072
- zi = depth_indices .argmin () - 1 if z >= depth_vector [0 ] else 0
1073
- if z < depth_vector [zi ]:
1082
+ zi = depth_indices .argmin () - 1 if z > depth_vector [0 ] else 0
1083
+ else :
1084
+ if z > depth_vector [0 ]:
1074
1085
raise FieldOutOfBoundSurfaceError (z , 0 , 0 , field = self )
1075
- elif z > depth_vector [zi + 1 ]:
1086
+ elif z < depth_vector [- 1 ]:
1076
1087
raise FieldOutOfBoundError (z , y , x , field = self )
1077
- else :
1078
- depth_indices = depth_vector >= z
1088
+ depth_indices = depth_vector > z
1079
1089
if z <= depth_vector [- 1 ]:
1080
1090
zi = len (depth_vector ) - 2
1081
1091
else :
1082
- zi = depth_indices .argmin () - 1 if z <= depth_vector [0 ] else 0
1083
- if z > depth_vector [zi ]:
1084
- raise FieldOutOfBoundSurfaceError (z , 0 , 0 , field = self )
1085
- elif z < depth_vector [zi + 1 ]:
1086
- raise FieldOutOfBoundError (z , y , x , field = self )
1092
+ zi = depth_indices .argmin () - 1 if z < depth_vector [0 ] else 0
1087
1093
zeta = (z - depth_vector [zi ]) / (depth_vector [zi + 1 ] - depth_vector [zi ])
1094
+ while zeta > 1 :
1095
+ zi += 1
1096
+ zeta = (z - depth_vector [zi ]) / (depth_vector [zi + 1 ] - depth_vector [zi ])
1097
+ while zeta < 0 :
1098
+ zi -= 1
1099
+ zeta = (z - depth_vector [zi ]) / (depth_vector [zi + 1 ] - depth_vector [zi ])
1088
1100
return (zi , zeta )
1089
1101
1090
1102
@deprecated_made_private # TODO: Remove 6 months after v3.1.0
0 commit comments