@@ -133,9 +133,7 @@ def geodesic_to_lambert_conformal(lat, lon, projection_variable, x_units="m"):
133133 lon_radians = math .radians (lon % 360 )
134134
135135 lat_origin = math .radians (float (projection_variable .latitude_of_projection_origin ))
136- lon_origin = math .radians (
137- float (projection_variable .longitude_of_central_meridian )
138- )
136+ lon_origin = math .radians (float (projection_variable .longitude_of_central_meridian ))
139137
140138 standard_parallel = projection_variable .standard_parallel
141139 if np .ndim (standard_parallel ) == 0 :
@@ -157,9 +155,7 @@ def geodesic_to_lambert_conformal(lat, lon, projection_variable, x_units="m"):
157155 f_const = (math .cos (phi_1 ) * math .tan (math .pi / 4 + phi_1 / 2 ) ** n ) / n
158156
159157 rho = earth_radius * f_const / (math .tan (math .pi / 4 + lat_radians / 2 ) ** n )
160- rho_origin = (
161- earth_radius * f_const / (math .tan (math .pi / 4 + lat_origin / 2 ) ** n )
162- )
158+ rho_origin = earth_radius * f_const / (math .tan (math .pi / 4 + lat_origin / 2 ) ** n )
163159 theta = n * (lon_radians - lon_origin )
164160
165161 x_meters = rho * math .sin (theta )
@@ -229,7 +225,7 @@ def mask_and_clean_dataset(*args):
229225 return data_array
230226
231227
232- def find_longitude_index (longitude , lon_list ):
228+ def find_longitude_index (longitude , lon_list ): # pylint: disable=too-many-statements
233229 """Finds the index of the given longitude in a list of longitudes.
234230
235231 Parameters
@@ -249,6 +245,7 @@ def find_longitude_index(longitude, lon_list):
249245 ValueError
250246 If the longitude is not within the range covered by the list.
251247 """
248+
252249 def _coord_value (source , index ):
253250 return float (source [index ])
254251
@@ -286,7 +283,7 @@ def _coord_value(source, index):
286283 if lon_index == lon_len and _coord_value (lon_list , lon_index - 1 ) == lon :
287284 lon_index -= 1
288285 # Check if longitude value is inside the grid
289- if lon_index == 0 or lon_index == lon_len :
286+ if lon_index in ( 0 , lon_len ) :
290287 raise ValueError (
291288 f"Longitude { lon } not inside region covered by file, which is "
292289 f"from { lon_start } to { lon_end } ."
@@ -315,6 +312,7 @@ def find_latitude_index(latitude, lat_list):
315312 ValueError
316313 If the latitude is not within the range covered by the list.
317314 """
315+
318316 def _coord_value (source , index ):
319317 return float (source [index ])
320318
@@ -338,15 +336,15 @@ def _coord_value(source, index):
338336 if lat_index == lat_len and _coord_value (lat_list , lat_index - 1 ) == latitude :
339337 lat_index -= 1
340338 # Check if latitude value is inside the grid
341- if lat_index == 0 or lat_index == lat_len :
339+ if lat_index in ( 0 , lat_len ) :
342340 raise ValueError (
343341 f"Latitude { latitude } not inside region covered by file, "
344342 f"which is from { lat_start } to { lat_end } ."
345343 )
346344 return latitude , lat_index
347345
348346
349- def find_time_index (datetime_date , time_array ):
347+ def find_time_index (datetime_date , time_array ): # pylint: disable=too-many-statements
350348 """Finds the index of the given datetime in a netCDF4 time array.
351349
352350 Parameters
@@ -382,7 +380,11 @@ def find_time_index(datetime_date, time_array):
382380 while low < high :
383381 mid = (low + high ) // 2
384382 mid_time_num = float (time_array [mid ])
385- if (mid_time_num < input_time_num ) if is_ascending else (mid_time_num > input_time_num ):
383+ if (
384+ (mid_time_num < input_time_num )
385+ if is_ascending
386+ else (mid_time_num > input_time_num )
387+ ):
386388 low = mid + 1
387389 else :
388390 high = mid
0 commit comments