@@ -71,72 +71,40 @@ def zdim(self):
7171 zdim -= 1
7272 return zdim
7373
74- @property
75- def _lon_slice (self ):
76- return self ._croco_slice
77-
78- @property
79- def _lat_slice (self ):
80- return self ._croco_slice
81-
82- @property
83- def _depth_slice (self ):
84- return self ._croco_slice
85-
86- @property
87- def _croco_slice (self ):
88- if self .gridindexingtype in ["croco" ]:
89- return slice (None , - 1 )
90- return slice (None )
91-
9274 @property
9375 def latlon (self ):
9476 lon = self .dataset [self .dimensions ["lon" ]]
9577 lat = self .dataset [self .dimensions ["lat" ]]
9678 if self .nolonlatindices and self .gridindexingtype not in ["croco" ]:
97- if len (lon .shape ) < 3 :
98- lon_subset = lon
99- lat_subset = lat
100- elif len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
101- lon_subset = lon [0 , :, :]
102- lat_subset = lat [0 , :, :]
79+ if len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
80+ lon = lon [0 , :, :]
81+ lat = lat [0 , :, :]
10382 elif len (lon .shape ) == 4 : # some lon, lat have a time and depth dimension 1
104- lon_subset = lon [0 , 0 , :, :]
105- lat_subset = lat [0 , 0 , :, :]
83+ lon = lon [0 , 0 , :, :]
84+ lat = lat [0 , 0 , :, :]
10685 else :
10786 self .indices ["lon" ] = range (self .xdim )
10887 self .indices ["lat" ] = range (self .ydim )
109- if len (lon .shape ) == 1 :
110- lon_subset = lon [self ._lon_slice ]
111- lat_subset = lat [self ._lat_slice ]
112- elif len (lon .shape ) == 2 :
113- lon_subset = lon [self ._lat_slice , self ._lon_slice ]
114- lat_subset = lat [self ._lat_slice , self ._lon_slice ]
115- elif len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
116- lon_subset = lon [0 , self ._lat_slice , self ._lon_slice ]
117- lat_subset = lat [0 , self ._lat_slice , self ._lon_slice ]
88+ if len (lon .shape ) == 3 : # some lon, lat have a time dimension 1
89+ lon = lon [0 , :, :]
90+ lat = lat [0 , :, :]
11891 elif len (lon .shape ) == 4 : # some lon, lat have a time and depth dimension 1
119- lon_subset = lon [0 , 0 , self . _lat_slice , self . _lon_slice ]
120- lat_subset = lat [0 , 0 , self . _lat_slice , self . _lon_slice ]
92+ lon = lon [0 , 0 , :, : ]
93+ lat = lat [0 , 0 , :, : ]
12194
12295 if len (lon .shape ) > 1 :
123- if is_rectilinear (lon_subset , lat_subset ):
124- lon_subset = lon_subset [0 , :]
125- lat_subset = lat_subset [:, 0 ]
126- return lat_subset , lon_subset
96+ if is_rectilinear (lon , lat ):
97+ lon = lon [0 , :]
98+ lat = lat [:, 0 ]
99+ return lat , lon
127100
128101 @property
129102 def depth (self ):
130103 if "depth" in self .dimensions :
131104 depth = self .dataset [self .dimensions ["depth" ]]
132105 self .data_full_zdim = self .zdim
133106 self .indices ["depth" ] = range (self .zdim )
134- if len (depth .shape ) == 1 :
135- return depth [self ._depth_slice ]
136- elif len (depth .shape ) == 3 :
137- return depth [self ._depth_slice , self ._lat_slice , self ._lon_slice ]
138- elif len (depth .shape ) == 4 :
139- return depth [:, self ._depth_slice , self ._lat_slice , self ._lon_slice ]
107+ return depth
140108 else :
141109 self .indices ["depth" ] = [0 ]
142110 return np .zeros (1 )
0 commit comments