spacepy.toolbox.tOverlap

spacepy.toolbox.tOverlap(ts1, ts2, *args, **kwargs)[source]

Finds the overlapping elements in two lists of datetime objects

Parameters
ts1datetime

first set of datetime object

ts2datetime

datatime object

args

additional arguments passed to tOverlapHalf

Returns
outlist

indices of ts1 within interval of ts2, & vice versa

Examples

Given two series of datetime objects, event_dates and omni[‘Time’]:

>>> import spacepy.toolbox as tb
>>> from spacepy import omni
>>> import datetime
>>> event_dates = st.tickrange(datetime.datetime(2000, 1, 1), datetime.datetime(2000, 10, 1), deltadays=3)
>>> onni_dates = st.tickrange(datetime.datetime(2000, 1, 1), datetime.datetime(2000, 10, 1), deltadays=0.5)
>>> omni = omni.get_omni(onni_dates)
>>> [einds,oinds] = tb.tOverlap(event_dates, omni['ticks'])
>>> omni_time = omni['ticks'][oinds[0]:oinds[-1]+1]
>>> print omni_time
[datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 12, 0),
... , datetime.datetime(2000, 9, 30, 0, 0)]