spice.basic
Class GFPositionCoordinateSearch
java.lang.Object
spice.basic.GF
spice.basic.GFNumericSearch
spice.basic.GFPositionCoordinateSearch
public class GFPositionCoordinateSearch
- extends GFNumericSearch
Class GFPositionCoordinateSearch supports searches for
position coordinate events.
Code Examples
The numerical results shown for these examples may differ across
platforms. The results depend on the SPICE kernels used as
input, the compiler and supporting libraries, and the machine
specific arithmetic implementation.
1) Find times during the year 2009 when the Earth-Moon
distance attains a local maximum.
//
// Find times during the year 2009 when the Earth-Moon
// distance attains a local maximum.
//
import spice.basic.*;
import static spice.basic.GFConstraint.*;
class GFPositionSearchEx1
{
//
// Load the JNISpice shared object library
// at initialization time.
//
static { System.loadLibrary( "JNISpice" ); }
//
// Class constants
//
private final static String TIMFMT =
"YYYY MON DD HR:MN:SC.###### (TDB)::TDB";
public static void main ( String[] args )
{
try {
System.out.format ( "%nGFPositionCoordinateSearch test:" );
//
// Constants
//
final int NINTVLS = 10000;
//
// Declare and assign values to variables required to
// specify the geometric condition to search for.
//
AberrationCorrection
abcorr = new AberrationCorrection( "NONE" );
Body target = new Body ( "Moon" );
Body observer = new Body ( "Earth" );
ReferenceFrame frame = new ReferenceFrame( "J2000" );
String coordSys = Coordinates.LATITUDINAL;
String coordinate = Coordinates.RADIUS;
//
// Load kernels via a meta-kernel.
//
final String META = "standard.tm";
KernelDatabase.load ( META );
//
// Create a GF position coordinate search instance.
// This instance specifies the geometric condition
// to be found.
//
GFPositionCoordinateSearch PositionSearch =
new GFPositionCoordinateSearch ( target, frame,
abcorr, observer,
coordSys, coordinate );
//
// Set up the GF search constraint.
//
GFConstraint locMaxCon =
createExtremumConstraint ( GFConstraint.LOCAL_MAXIMUM );
//
// Set up a simple confinement window.
//
TDBTime et0 = new TDBTime ( "2009 Jan 1 00:00:00 TDB" );
TDBTime et1 = new TDBTime ( "2010 Jan 1 00:00:00 TDB" );
SpiceWindow confine = new SpiceWindow ();
confine.insert( et0.getTDBSeconds(),
et1.getTDBSeconds() );
//
// Select a search step size. Units are TDB seconds.
//
double step = 300.0;
//
// Run the search over a specified confinement
// window, using a specified constraint and search step.
//
// Specify the maximum number of intervals in the result
// window.
//
SpiceWindow result =
PositionSearch.run( confine, locMaxCon, step, NINTVLS );
//
// Display results, along with the distance maxima.
//
int wncard = result.card();
double[] interval = new double[2];
TDBTime start;
System.out.format( "%n" );
if ( wncard == 0 )
{
System.out.println ( "Result window is empty" );
}
else
{
for ( int i = 0; i < wncard; i++ )
{
interval = result.getInterval( i );
//
// The interval start and stop times will be
// the same; so we use only the start time.
//
start = new TDBTime( interval[0] );
PositionVector pos =
new PositionVector( target, start,
frame, abcorr, observer );
System.out.format ( "[%3d] Time = %s; Distance (km) = %f%n",
i, start, pos.norm() );
}
}
}
catch ( SpiceException exc ) {
exc.printStackTrace();
}
}
}
When run on a PC/Linux/java 1.6.0_14/gcc platform, the output
from this program was:
GFPositionCoordinateSearch test:
[ 0] Time = 2009 JAN 23 00:11:27.349 (TDB); Distance (km) = 406118.280521
[ 1] Time = 2009 FEB 19 17:00:27.766 (TDB); Distance (km) = 405129.319072
[ 2] Time = 2009 MAR 19 13:16:31.265 (TDB); Distance (km) = 404299.012195
[ 3] Time = 2009 APR 16 09:16:32.424 (TDB); Distance (km) = 404231.558212
[ 4] Time = 2009 MAY 14 02:58:21.798 (TDB); Distance (km) = 404915.320536
[ 5] Time = 2009 JUN 10 16:04:39.215 (TDB); Distance (km) = 405786.712801
[ 6] Time = 2009 JUL 07 21:39:54.041 (TDB); Distance (km) = 406231.773499
[ 7] Time = 2009 AUG 04 00:42:47.614 (TDB); Distance (km) = 406028.070923
[ 8] Time = 2009 AUG 31 11:03:00.455 (TDB); Distance (km) = 405269.213190
[ 9] Time = 2009 SEP 28 03:33:32.530 (TDB); Distance (km) = 404432.011671
[ 10] Time = 2009 OCT 25 23:18:56.423 (TDB); Distance (km) = 404166.446368
[ 11] Time = 2009 NOV 22 20:07:24.518 (TDB); Distance (km) = 404732.974282
[ 12] Time = 2009 DEC 20 14:54:35.508 (TDB); Distance (km) = 405730.572479
Version 1.0.0 29-DEC-2009 (NJB)
Fields inherited from class spice.basic.GF |
ADDWIN, ANNULR, ANY, CIRFOV, CNVTOL, EDSHAP, ELLFOV, FULL, MARGIN, MAXVRT, PARTL, POLFOV, PTSHAP, RECFOV, RYSHAP, SPSHAP |
Method Summary |
SpiceWindow |
run(SpiceWindow confinementWindow,
GFConstraint constraint,
double step,
int maxWorkspaceIntervals)
Run a search over a specified confinement window, using
a specified step size (units are TDB seconds). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GFPositionCoordinateSearch
public GFPositionCoordinateSearch(Body target,
ReferenceFrame frame,
AberrationCorrection abcorr,
Body observer,
java.lang.String coordinateSystem,
java.lang.String coordinate)
run
public SpiceWindow run(SpiceWindow confinementWindow,
GFConstraint constraint,
double step,
int maxWorkspaceIntervals)
throws SpiceException
- Run a search over a specified confinement window, using
a specified step size (units are TDB seconds).
- Specified by:
run
in class GFNumericSearch
- Throws:
SpiceException
JNISpice Alpha Test Version 2.0.0 28-JAN-2017 (NJB)