@@ -347,17 +347,12 @@ def get_dimension_indices_from_values(
347347 dimension_values = np .flip (dimension )
348348 dimension_indices = np .flip (dimension_indices )
349349
350- # np.interp does not throw an exception if the extents are outside dimension range
351- # It just returns the lowest index or highest index
352- if (minimum_extent < dimension_values [0 ]) and (
353- maximum_extent < dimension_values [0 ]
354- ):
355- raise InvalidRequestedRange ()
356- if (minimum_extent > dimension_values [- 1 ]) and (
357- maximum_extent > dimension_values [- 1 ]
358- ):
350+ # Check if the minimum and maximum extents are out of range of the dimension values.
351+ if minimum_extent < dimension_values [0 ] or maximum_extent > dimension_values [- 1 ]:
359352 raise InvalidRequestedRange ()
360353
354+ # np.interp does not throw an exception if the extents are outside dimension range
355+ # It just returns the lowest index or highest index.
361356 raw_indices = np .interp (dimension_range , dimension_values , dimension_indices )
362357
363358 if (raw_indices [0 ] == raw_indices [1 ]) and (raw_indices [0 ] % 1 == 0.5 ):
@@ -558,7 +553,7 @@ def get_requested_index_ranges(
558553 required_dimensions = varinfo .get_required_dimensions (required_variables )
559554
560555 dim_index_ranges = {}
561- failed_dim_variables = set ()
556+ out_of_range_dim_variables = set ()
562557 with Dataset (dimensions_path , 'r' ) as dimensions_file :
563558 for dim in harmony_message .subset .dimensions :
564559 try :
@@ -589,11 +584,11 @@ def get_requested_index_ranges(
589584 # processing the other dimensions and raise exception for all the
590585 # dimensions that are invalid.
591586 except InvalidRequestedRange :
592- failed_dim_variables .add (dim .name )
587+ out_of_range_dim_variables .add (dim .name )
593588
594- if failed_dim_variables :
589+ if out_of_range_dim_variables :
595590 raise NoDataException (
596- f'Input request outside supported dimension range for { failed_dim_variables } '
591+ f'Input request outside supported dimension range for { out_of_range_dim_variables } '
597592 )
598593
599594 return dim_index_ranges
0 commit comments