match

match(*args)[source]

Return the overlapping segment from a series of vectors with common coordinate spacings but different start or end points. Useful e.g. for matching the time dimensions of variables collected over different but overlapping date ranges.

Parameters

v1, v2, … (ndarray) – The coordinate vectors.

Returns

i1, i2, …, v (ndarray) – The slice objects that index matching coordinate ranges for each vector, and a vector containing these coordinates.

Examples

>>> import pandas as pd
>>> import climopy as climo
>>> v1 = pd.date_range('2000-01-01', '2000-01-10')
>>> v2 = pd.date_range('2000-01-05', '2000-01-15')
>>> i1, i2, v = climo.match(v1, v2)
>>> v
DatetimeIndex(['2000-01-05', '2000-01-06', '2000-01-07', '2000-01-08',
               '2000-01-09', '2000-01-10'],
              dtype='datetime64[ns]', freq='D')
>>> np.all(v1[i1] == v2[i2])
True
>>> np.all(v1[i1] == v)
True