runtraj.Bounds.contains#

Bounds.contains(longitude, latitude)[source]#

Return whether each point is in the box, counting longitudes modulo 360.

A longitude is in the box when, counted east from xmin, it is within the box’s width, so a box may cross the dateline (xmin=170, xmax=-170) or reach past 180 (xmax=190), and -175 and 185 are the same meridian. A box 360 degrees wide or more holds every longitude. Points on an edge are inside; the longitude edges allow 1e-9 degree for rounding, since a sum such as 184.7 + 175.3 need not give exactly 360. A point with a missing coordinate is not in the box.

Parameters:
  • longitude (ArrayLike) – Degrees. Scalars or arrays, broadcast against each other.

  • latitude (ArrayLike) – Degrees. Scalars or arrays, broadcast against each other.

Returns:

One value per point (a 0-d array for scalars).

Return type:

ndarray

Examples

>>> import runtraj
>>> utah = runtraj.Bounds(xmin=-114, xmax=-109, ymin=37, ymax=42)
>>> bool(utah.contains(-111.9, 40.8))
True
>>> bool(utah.contains(-111.9, 45.0))
False

A box may cross the dateline, and -175 and 185 are one meridian:

>>> pacific = runtraj.Bounds(xmin=170, xmax=-170, ymin=-10, ymax=10)
>>> pacific.contains([175, -175, 185, 0], 0).tolist()
[True, True, True, False]