@@ -29,10 +29,6 @@ def __init__(
2929 self .interp_method = interp_method
3030 self .gridindexingtype = gridindexingtype
3131 self .data_full_zdim = data_full_zdim
32- if ("lon" in self .indices ) or ("lat" in self .indices ):
33- self .nolonlatindices = False
34- else :
35- self .nolonlatindices = True
3632 self .netcdf_engine = netcdf_engine
3733
3834 def __enter__ (self ):
@@ -75,16 +71,7 @@ def zdim(self):
7571 def latlon (self ):
7672 lon = self .dataset [self .dimensions ["lon" ]]
7773 lat = self .dataset [self .dimensions ["lat" ]]
78- if self .nolonlatindices and self .gridindexingtype not in ["croco" ]:
79- if len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
80- lon = lon [0 , :, :]
81- lat = lat [0 , :, :]
82- elif len (lon .shape ) == 4 : # some lon, lat have a time and depth dimension 1
83- lon = lon [0 , 0 , :, :]
84- lat = lat [0 , 0 , :, :]
85- else :
86- self .indices ["lon" ] = range (self .xdim )
87- self .indices ["lat" ] = range (self .ydim )
74+ if self .gridindexingtype not in ["croco" ]:
8875 if len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
8976 lon = lon [0 , :, :]
9077 lat = lat [0 , :, :]
@@ -115,11 +102,8 @@ def depth_dimensions(self):
115102 data = self .dataset [self .name ]
116103 depthsize = data .shape [- 3 ]
117104 self .data_full_zdim = depthsize
118- self .indices ["depth" ] = self .indices ["depth" ] if "depth" in self .indices else range (depthsize )
119- if self .nolonlatindices :
120- return np .empty ((0 , self .zdim ) + data .shape [- 2 :])
121- else :
122- return np .empty ((0 , self .zdim , self .ydim , self .xdim ))
105+ self .indices ["depth" ] = range (depthsize )
106+ return np .empty ((0 , self .zdim ) + data .shape [- 2 :])
123107
124108 def _check_extend_depth (self , data , dim ):
125109 return (
@@ -132,38 +116,18 @@ def _apply_indices(self, data, ti):
132116 if len (data .shape ) == 1 :
133117 if self .indices ["depth" ] is not None :
134118 data = data [self .indices ["depth" ]]
135- elif len (data .shape ) == 2 :
136- if self .nolonlatindices :
137- pass
138- else :
139- data = data [self .indices ["lat" ], self .indices ["lon" ]]
140119 elif len (data .shape ) == 3 :
141120 if self ._check_extend_depth (data , 0 ):
142- if self .nolonlatindices :
143- data = data [self .indices ["depth" ][:- 1 ], :, :]
144- else :
145- data = data [self .indices ["depth" ][:- 1 ], self .indices ["lat" ], self .indices ["lon" ]]
121+ data = data [self .indices ["depth" ][:- 1 ], :, :]
146122 elif len (self .indices ["depth" ]) > 1 :
147- if self .nolonlatindices :
148- data = data [self .indices ["depth" ], :, :]
149- else :
150- data = data [self .indices ["depth" ], self .indices ["lat" ], self .indices ["lon" ]]
123+ data = data [self .indices ["depth" ], :, :]
151124 else :
152- if self .nolonlatindices :
153- data = data [ti , :, :]
154- else :
155- data = data [ti , self .indices ["lat" ], self .indices ["lon" ]]
125+ data = data [ti , :, :]
156126 else :
157127 if self ._check_extend_depth (data , 1 ):
158- if self .nolonlatindices :
159- data = data [ti , self .indices ["depth" ][:- 1 ], :, :]
160- else :
161- data = data [ti , self .indices ["depth" ][:- 1 ], self .indices ["lat" ], self .indices ["lon" ]]
128+ data = data [ti , self .indices ["depth" ][:- 1 ], :, :]
162129 else :
163- if self .nolonlatindices :
164- data = data [ti , self .indices ["depth" ], :, :]
165- else :
166- data = data [ti , self .indices ["depth" ], self .indices ["lat" ], self .indices ["lon" ]]
130+ data = data [ti , self .indices ["depth" ], :, :]
167131 return data
168132
169133 @property
0 commit comments