Source code for irfpy.spice.geometric_finder

""" Emulate the gf

It is not straightforward to use GF functionality.
Here is a "simplified" version.

It is crude implementation, so it could be much slower...
"""
import numpy as np

#from irfpy.util.timeinterval import timeinterval
from irfpy.util import span, utc
from irfpy.spice import spicetools as _s

[docs]def distance_below(target, origin, distance, initaial_interval, dt, correction='NONE', frame='J2000'): """ Return the time interval where (Target - Origin) distance is <=distance. :param target: Target body :param origin: Origin body :param distance: Threshold distance :param initial_interval: Initial time interval. See sample below. :type initaial_interval: :class:`irfpy.util.timeinterval.timeinterval`. :param dt: Time resolution to search for. :keyword correction: Abberation correction. :keyword frame: Frame to calculate. The distance should not depend on the selection of the frame, but still user may allow to set it. :return: Time interval that satisfy the condition. :rtype: :class:`irfpy.util.timeinterval.timeinterval` object. The time interval can be specified as follows. >>> from irfpy.util.timeinterval import timeinterval >>> import datetime >>> t0 = datetime.datetime(2010, 1, 3, 12, 0, 0) >>> t1 = datetime.datetime(2010, 1, 3, 13, 0, 0) >>> tint = timeinterval(t0, t1) # Between t0 and t1 The returned value is also for in the :class:`irfpy.util.timeinterval.timeinterval` object. """ ### Very crude implementation so far tlist = initaial_interval.sampling(dt) # Time interval is sampled by dt. distlist = np.array([_s.get_distance(t, target, origin, frame=frame, correction=correction) for t in tlist]) nearlist = np.where(distlist <= distance, True, False) interval = span.timearray2interval(nearlist, tlist) return interval