Skip to content

Commit

Permalink
Merge 7b1fb17 into 2d9e3da
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewAnnex committed Oct 10, 2018
2 parents 2d9e3da + 7b1fb17 commit c85194c
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 8 deletions.
83 changes: 81 additions & 2 deletions spiceypy/spiceypy.py
Expand Up @@ -5638,8 +5638,87 @@ def gfdist(target, abcorr, obsrvr, relate, refval, adjust, step, nintvls,
step, nintvls, ctypes.byref(cnfine), ctypes.byref(result))


def gfevnt():
raise NotImplementedError
@spiceErrorCheck
def gfevnt(udstep, udrefn, gquant, qnpars, lenvals, qpnams,
qcpars, qdpars, qipars, qlpars, op, refval,
tol, adjust, rpt, udrepi, udrepu, udrepf,
nintvls, bail, udbail, cnfine, result):
"""
Determine time intervals when a specified geometric quantity
satisfies a specified mathematical condition.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/gfevnt_c.html
:param udstep: Name of the routine that computes and returns a
:type udstep: spiceypy.utils.callbacks.UDSTEP
:param udrefn: Name of the routine that computes a refined time
:type udrefn: spiceypy.utils.callbacks.UDREFN
:param gquant: Type of geometric quantity
:type gquant: str
:param qnpars: Number of quantity definition parameters
:type qnpars: int
:param lenvals: Length of strings in qpnams and qcpars
:type lenvals: int
:param qpnams: Names of quantity definition parameters
:type qpnams: List
:param qcpars: Array of character quantity definition parameters
:type qcpars: List
:param qdpars: Array of double precision quantity definition
:type qdpars: N-Element Array of floats
:param qipars: Array of integer quantity definition parameters
:type qipars: N-Element Array of str
:param qlpars: Array of logical quantity definition parameters
:type qlpars: N-Element Array of int
:param op: Operator that either looks for an extreme value
:type op: str
:param refval: Reference value
:type refval: float
:param tol: Convergence tolerance in seconds
:type tol: float
:param adjust: Absolute extremum adjustment value
:type adjust: float
:param rpt: Progress reporter on TRUE or off FALSE
:type rpt: int
:param udrepi: Function that initializes progress reporting
:type udrepi: spiceypy.utils.callbacks.UDREPI
:param udrepu: Function that updates the progress report
:type udrepu: spiceypy.utils.callbacks.UDREPU
:param udrepf: Function that finalizes progress reporting
:type udrepf: spiceypy.utils.callbacks.UDREPF
:param nintvls: Workspace window interval count
:type nintvls: int
:param bail: Logical indicating program interrupt monitoring
:type bail: int
:param udbail: Name of a routine that signals a program interrupt
:type udbail: spiceypy.utils.callbacks.UDBAIL
:param cnfine: SPICE window to which the search is restricted
:type cnfine: spiceypy.utils.support_types.SpiceCell
:param result: SPICE window containing results
:type result: spiceypy.utils.support_types.SpiceCell
"""
assert isinstance(cnfine, stypes.SpiceCell)
assert cnfine.is_double()
assert isinstance(result, stypes.SpiceCell)
assert result.is_double()
gquant = stypes.stringToCharP(gquant)
qnpars = ctypes.c_int(qnpars)
lenvals = ctypes.c_int(lenvals)
qpnams = stypes.listToCharArrayPtr(qpnams, xLen=lenvals, yLen=qnpars)
qcpars = stypes.listToCharArrayPtr(qcpars, xLen=lenvals, yLen=qnpars)
qdpars = stypes.toDoubleVector(qdpars)
qipars = stypes.toIntVector(qipars)
qlpars = stypes.toIntVector(qlpars)
op = stypes.stringToCharP(op)
refval = ctypes.c_double(refval)
tol = ctypes.c_double(tol)
adjust = ctypes.c_double(adjust)
rpt = ctypes.c_int(rpt)
nintvls = ctypes.c_int(nintvls)
bail = ctypes.c_int(bail)
libspice.gfevnt_c(udstep, udrefn, gquant, qnpars, lenvals, qpnams, qcpars,
qdpars, qipars, qlpars, op, refval, tol,
adjust, rpt, udrepi, udrepu, udrepf, nintvls, bail,
udbail, ctypes.byref(cnfine), ctypes.byref(result))


@spiceErrorCheck
Expand Down
42 changes: 40 additions & 2 deletions spiceypy/tests/test_wrapper.py
Expand Up @@ -3172,8 +3172,46 @@ def test_gfdist():


def test_gfevnt():
with pytest.raises(NotImplementedError):
spice.gfevnt()
spice.kclear()
spice.furnsh(CoreKernels.testMetaKernel)
#
et_start = spice.str2et("2001 jan 01 00:00:00.000")
et_end = spice.str2et("2001 dec 31 00:00:00.000")
cnfine = spice.stypes.SPICEDOUBLE_CELL(2)
spice.wninsd(et_start, et_end, cnfine)
result = spice.stypes.SPICEDOUBLE_CELL(1000)
qpnams = ["TARGET", "OBSERVER", "ABCORR"]
qcpars = ["MOON ", "EARTH ", "LT+S "]
# Set the step size to 1/1000 day and convert to seconds
spice.gfsstp(0.001 * spice.spd())
# setup callbacks
udstep = spiceypy.utils.callbacks.SpiceUDSTEP(spice.gfstep)
udrefn = spiceypy.utils.callbacks.SpiceUDREFN(spice.gfrefn)
udrepi = spiceypy.utils.callbacks.SpiceUDREPI(spice.gfrepi)
udrepu = spiceypy.utils.callbacks.SpiceUDREPU(spice.gfrepu)
udrepf = spiceypy.utils.callbacks.SpiceUDREPF(spice.gfrepf)
udbail = spiceypy.utils.callbacks.SpiceUDBAIL(spice.gfbail)
qdpars = np.zeros(10, dtype=np.float)
qipars = np.zeros(10, dtype=np.int32)
qlpars = np.zeros(10, dtype=np.int32)
# call gfevnt
spice.gfevnt(udstep, udrefn, 'DISTANCE', 3, 81, qpnams, qcpars,
qdpars, qipars, qlpars, 'LOCMAX', 0, 1.e-6, 0,
True, udrepi, udrepu, udrepf, 10000,
True, udbail, cnfine, result)

# Verify the expected results
assert len(result) == 26
sTimout = "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND"
assert spice.timout(result[0], sTimout) == '2001-JAN-24 19:22:01.418715 (TDB)'
assert spice.timout(result[1], sTimout) == '2001-JAN-24 19:22:01.418715 (TDB)'
assert spice.timout(result[2], sTimout) == '2001-FEB-20 21:52:07.900872 (TDB)'
assert spice.timout(result[3], sTimout) == '2001-FEB-20 21:52:07.900872 (TDB)'
# Cleanup
if spice.gfbail():
spice.gfclrh()
spice.gfsstp(0.5)
spice.kclear()


def test_gffove():
Expand Down
8 changes: 4 additions & 4 deletions spiceypy/utils/libspicehelper.py
Expand Up @@ -334,10 +334,10 @@
libspice.gfclrh_c.argtypes = None
libspice.gfdist_c.argtypes = [c_char_p, c_char_p, c_char_p, c_char_p, c_double, c_double, c_double, c_int,
s_cell_p, s_cell_p]
# libspice.gfevnt_c.argtypes = [callbacks.UDSTEP, callbacks.UDREFN, c_char_p, c_int, c_int,
# c_void_p, c_void_p, c_double_p, c_int_p, POINTER(c_int),
# c_char_p, c_double, c_double, c_double, c_int, callbacks.UDREPI, callbacks.UDREPU,
# callbacks.UDREPF, c_int, c_int, callbacks.UDBAIL, s_cell_p, s_cell_p]
libspice.gfevnt_c.argtypes = [callbacks.UDSTEP, callbacks.UDREFN, c_char_p, c_int, c_int,
c_void_p, c_void_p, c_double_p, c_int_p, c_int_p, c_char_p,
c_double, c_double, c_double, c_int, callbacks.UDREPI, callbacks.UDREPU,
callbacks.UDREPF, c_int, c_int, callbacks.UDBAIL, s_cell_p, s_cell_p]

libspice.gffove_c.argtypes = [c_char_p, c_char_p, (c_double*3),
c_char_p, c_char_p, c_char_p, c_char_p, c_double,
Expand Down

0 comments on commit c85194c

Please sign in to comment.