cdms2.axis:FileAxis

FileAxis.mapInterval(interval, indicator='ccn', cycle=None)

Map coordinate interval to index interval. interval has one of the forms

  • (x,y)

  • (x,y,indicator): indicator overrides keywork argument

  • (x,y,indicator,cycle): indicator, cycle override keyword arguments

  • None: indicates the full interval

where x and y are the endpoints in coordinate space. indicator is a two-character string, where the first character is c if the interval is closed on the left, o if open, and the second character has the same meaning for the right-hand point. Set cycle to a nonzero value to force wraparound.

Parameters
internvaltuple of float, float, str (optional), float (optional)

(x, y) First and last value to map. (x, y, indicator) First and last value to map with indicator for handling endpoints. (x, y, indicator, cycle) First and last value to map with endpoint indicator and cycle length.

indicatorstr

String indicator describing how to handle interval endpoints.

cyclefloat

Length of cycle to use when mapping interval.

Returns
The corresponding index interval (i,j), where i<j, indicating
the half-open index interval [i,j), or None if the intersection is empty.
For an axis which is circular (self.topology == ‘circular’), [i,j)
is interpreted as follows (where N = len(self)):
  1. if j<=N, the interval does not wrap around the axis endpoint ..

  2. if j>N, the interval wraps around, and is equivalent to the two consecutive intervals [i,N), [0,j-N)

Example:

if the vector is [0,2,4,…,358] of length 180,and the coordinate interval is [-5,5), the return index interval is[178,183). This is equivalent to the two intervals [178,180) and [0,3).

Note:

if the interval is interior to the axis, but does not span any axis element, a singleton (i,i+1) indicating an adjacent index is returned.