Navigation and Ancillary Information Facility NIF Matlab Interface to CSPICE “Mice” How to Access the CSPICE library Using Matlab © November 2014 © The.

Slides:



Advertisements
Similar presentations
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats March 2006.
Advertisements

Navigation and Ancillary Information Facility NIF SPICE Conventions A summary of many “standards,” lingo and common usage within SPICE April 2006.
Navigation and Ancillary Information Facility NIF SPICE Conventions A summary of many “standards,” lingo and common usage within SPICE October 2007.
Navigation and Ancillary Information Facility NIF Writing an Icy Based Program June 2004.
Navigation and Ancillary Information Facility NIF Writing an Mice (MATLAB) Based Program November 2014.
Navigation and Ancillary Information Facility NIF Shape Model Subsystem Preview (DSK) November 2014.
Navigation and Ancillary Information Facility NIF Time Conversion and Formats June 2004.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats January 2009.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats November 2014.
Navigation and Ancillary Information Facility NIF Getting and Installing the SPICE Toolkit October 2014.
Navigation and Ancillary Information Facility NIF Leapseconds and Spacecraft Clock Kernels LSK and SCLK November 2014.
Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE “Mice” How to Access the CSPICE library Using MATLAB © October 2007 © The.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Navigation and Ancillary Information Facility NIF “Comments” In SPICE Kernels Also known as “meta-data” November 2014.
Navigation and Ancillary Information Facility NIF SPICE Conventions A summary of standards, lingo and common usage within SPICE November 2014.
Navigation and Ancillary Information Facility NIF JNISPICE March 2006.
Navigation and Ancillary Information Facility NIF Preview of a Web-based GUI Interface to SPICE “WebGeocalc” The NAIF and UCD Teams August 22, 2011 SPICE.
Navigation and Ancillary Information Facility NIF Preparing for Programming Using the SPICE Toolkits November 2014.
Navigation and Ancillary Information Facility NIF SPICE Conventions A summary of standards, lingo and common usage within SPICE November 2014.
Navigation and Ancillary Information Facility NIF Leapseconds and Spacecraft Clock Kernels LSK and SCLK April 2006.
Navigation and Ancillary Information Facility NIF Summary of Key Points January 2009.
Navigation and Ancillary Information Facility NIF Summary of Key Points October 2014.
Navigation and Ancillary Information Facility NIF Writing a CSPICE (C) Based Program November 2014.
Navigation and Ancillary Information Facility NIF Toolkit Applications March 2006.
Navigation and Ancillary Information Facility NIF Event Finding Subsystem Preview Capabilities, Current Status and Plans January 2009.
Navigation and Ancillary Information Facility NIF IDL Interface to CSPICE “Icy” How to Access the CSPICE library Using Interactive Data Language (IDL)
Navigation and Ancillary Information Facility NIF IDL Interface to CSPICE “Icy” How to Access the CSPICE library Using Interactive Data Language (IDL)
Navigation and Ancillary Information Facility NIF Planetary Constants Kernel PCK November 2014.
Page 1 TOOLKIT / HDF-EOS Status and Development Abe Taaheri, Raytheon IIS Aura DSWG meeting October 2007.
Navigation and Ancillary Information Facility NIF Leapseconds and Spacecraft Clock Kernels LSK and SCLK June 2004.
Copyright © 2012 UNICOM Systems, Inc. Confidential Information z/Ware Product Overview illustro Systems International A Division of UNICOM Global.
Navigation and Ancillary Information Facility NIF Exception Handling November 2014.
Navigation and Ancillary Information Facility NIF IDL Interface to CSPICE “Icy” How to Access the CSPICE library Using Interactive Data Language (IDL)
Navigation and Ancillary Information Facility NIF IDL Interface to CSPICE “Icy” How to Access the CSPICE library from the Interactive Data Language (IDL)
Navigation and Ancillary Information Facility NIF Exception Handling October 2014.
Navigation and Ancillary Information Facility NIF Using C-kernels to Capture Instrument Articulation June 28, 2002 Scott Turner
Navigation and Ancillary Information Facility NIF Introduction to WebGeocalc October 2014 SPICE components and services are not restricted under ITAR and.
Navigation and Ancillary Information Facility NIF Introduction to the SPICE Toolkit March 2006.
Navigation and Ancillary Information Facility NIF Writing a CSPICE Based Program October 2007.
Navigation and Ancillary Information Facility NIF Getting Started Using SPICE April 2006.
Navigation and Ancillary Information Facility NIF Writing an Icy (IDL) Based Program January 2009.
Navigation and Ancillary Information Facility NIF SPICE System Development Plans March 2006.
Navigation and Ancillary Information Facility NIF Introduction to the SPICE Toolkit April 2006.
Navigation and Ancillary Information Facility NIF Introduction to the SPICE Toolkit June 2004.
Navigation and Ancillary Information Facility NIF Planetary Constants Kernel PCK October 2014.
Navigation and Ancillary Information Facility NIF SPICE Toolkit Common Problems November 2014.
Navigation and Ancillary Information Facility NIF Using Module Headers April 2006.
Navigation and Ancillary Information Facility NIF Frames Kernel FK March 2006.
Navigation and Ancillary Information Facility NIF Porting SPICE Kernels Between Computers June 2004.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats March 2010.
Navigation and Ancillary Information Facility NIF Time Conversion and Time Formats January 2008.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Navigation and Ancillary Information Facility NIF Writing a SPICE (FORTRAN) Based Program November 2014.
Navigation and Ancillary Information Facility NIF SPICE Toolkit Common Problems October 2007.
Navigation and Ancillary Information Facility NIF Getting and Installing the SPICE Toolkit November 2014.
Navigation and Ancillary Information Facility NIF Instrument Kernel IK June 2004.
Navigation and Ancillary Information Facility NIF SPICE Development Plans and Possibilities October 2007.
Navigation and Ancillary Information Facility NIF “Metadata” In SPICE Kernels a.k.a. “comments” March 2006.
Navigation and Ancillary Information Facility NIF SPICE Conventions A summary of many “standards,” lingo and common usage within SPICE June 2004.
Navigation and Ancillary Information Facility NIF “Metadata” In SPICE Kernels Also known as “comments” January 2009.
Navigation and Ancillary Information Facility NIF Using the Frames Subsystem April 2016.
Navigation and Ancillary Information Facility NIF Frames Kernel FK March 2010.
Navigation and Ancillary Information Facility NIF Writing an Mice (MATLAB) Based Program October 2007.
Navigation and Ancillary Information Facility NIF Writing a SPICE-based Fortran Program October 2007.
Navigation and Ancillary Information Facility NIF Getting and Installing the SPICE Toolkit January 2008.
Navigation and Ancillary Information Facility NIF Getting and Installing the SPICE Toolkit April 2006.
Navigation and Ancillary Information Facility NIF “Metadata” In SPICE Kernels Also known as “comments” October 2007.
Preparing for Programming Using the SPICE Toolkits
IDL Interface to CSPICE “Icy”
Frames Kernel FK October 2007.
Presentation transcript:

Navigation and Ancillary Information Facility NIF Matlab Interface to CSPICE “Mice” How to Access the CSPICE library Using Matlab © November 2014 © The MathWorks Inc.

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 2 Topics Mice Benefits How does it work? Distribution Mice Operation Vectorization Simple Mice Examples

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 3 Mice operates as an extension to the Matlab environment. All Mice calls are functions regardless of the call format of the underlying CSPICE routine, returning Matlab native data types. Mice has some capability not available in CSPICE such as vectorization. CSPICE error messages return to Matlab in the form usable by the try...catch construct. Mice Benefits

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 4 The Matlab environment includes an intrinsic capability to use external routines. –Mice functions as a Matlab Executable, MEX, consisting of the Mice MEX shared object library and a set of.m wrapper files. » The Mice library contains the Matlab callable C interface routines that wrap a subset of CSPICE wrapper calls. »The wrapper files, named cspice_*.m and mice_*.m, provide the Matlab calls to the interface functions. »A function prefixed with ‘cspice_’ retains essentially the same argument list as the CSPICE counterpart. »An interface prefixed with ‘mice_’ returns a structure, with the fields of the structure corresponding to the output arguments of the CSPICE counterpart. »The wrappers include a header section describing the function call, displayable by the Matlab help command. How Does It Work? (1)

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 5 When a user invokes a call to a Mice function: 1. Matlab calls… 2. the function's wrapper, which calls… 3. the Mice MEX shared object library, which performs its function then returns the result… 4. to the wrapper, which… 5. returns the result to the user … transparent from the user’s perspective. How Does It Work? (2)

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 6 Mice Distribution NAIF distributes Mice as a complete, standalone package. The package includes: –the CSPICE source files –the Mice interface source code –platform specific build scripts for Mice and CSPICE –Matlab versions of the SPICE cookbook programs, states, tictoc, subpt, and simple –an HTML based help system for both Mice and CSPICE, with the Mice help cross-linked to CSPICE –the Mice MEX shared library and the M wrapper files. The system is ready for use after installation of the the library and wrapper files. Note: You do not need a C compiler to use Mice.

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 7 Mice Operation (1) A possible irritant exists in loading kernels using the cspice_furnsh function. –Kernels load into your Matlab session, not into your Matlab scripts. This means: »loaded binary kernels remain accessible (“active”) throughout your Matlab session »data from loaded text kernels remain in the kernel pool (in the memory space used by CSPICE) throughout your Matlab session –Consequence: some kernel data may be available to one of your scripts even though not intended to be so. »You could get incorrect results! »If you run only one script during your Matlab session, there’s no problem. continued on next page

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 8 Mice Operation (2) Mitigation: two approaches –Load all needed SPICE kernels for your Matlab session at the beginning of the session, paying careful attention to the files loaded and the loading order (loading order affects precedence) »Convince yourself that this approach will provide ALL of the scripts you will run during this Matlab session with the appropriate SPICE data –At or near the end of every Matlab script: »include a call to cspice_unload for each kernel loaded using cspice_furnsh »or include a call to cspice_kclear to remove ALL kernel data from the kernel pool loaded using cspice_furnsh

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 9 Most Mice functions include use of vectorized arguments, a capability not available in C or Fortran toolkits. Example: use Mice to retrieve state vectors and light-time values for 1000 ephemeris times. –Create the array of 1000 ephemeris times in steps of 10 hours, starting from July 1, 2005: start = cspice_str2et('July '); et = (0:999)* start; –Retrieve the state vectors and corresponding light times from Mars to earth at each et in the J2000 frame with LT+S aberration correction: [state, ltime] = cspice_spkezr( 'Earth', et, 'J2000', 'LT+S', 'MARS'); or starg = mice_spkezr( 'Earth', et, 'J2000', 'LT+S', 'MARS'); Mice Vectorization (1) continued on next page

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 10 –Access the ith state 6-vector (6x1 array) corresponding to the ith ephemeris time with the expression state_i = state(:,i) or state_i = starg(i).state Convert the ephemeris time vector et from the previous example to UTC calendar strings with three decimal places of precision in the seconds field. format = 'C'; prec = 3; utcstr = cspice_et2utc( et, format, prec ); –The call returns utcstr, an array of 1000 strings (dimensioned 1000x24), where each ith string is the calendar date corresponding to et(i). Mice Vectorization (2) continued on next page

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 11 –Access the ith string of utcstr corresponding to the ith ephemeris time with the expression utcstr_i = utcstr(i,:) Convert the position components (the first three components in a state vector) of the N state vectors returned in state by the cspice_spkezr function to latitudinal coordinates. [radius, latitude, longitude] = cspice_reclat( state(1:3,:) ); –The call returns three double precision 1x1000 arrays (vectorized scalars): radius, latitude, longitude. Mice Vectorization (3)

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 12 Simple Mice Example (1) As an example of using Mice, calculate and plot the trajectory of the Cassini spacecraft, in the J2000 inertial frame, from June to December This example uses the cspice_spkpos function to retrieve position data. % Define the number of divisions of the time interval. STEP = 1000; % Construct a meta kernel, "standard.tm”, which will be used to load the needed % generic kernels: "naif0009.tls," "de421.bsp,” and "pck00009.tpc.” % Load the generic kernels using the meta kernel, and a Cassini spk. cspice_furnsh( { 'standard.tm', '/kernels/cassini/spk/030201AP_SK_SM546_T45.bsp'} ) et = cspice_str2et( {'Jun 20, 2004', 'Dec 1, 2005'} ); times = (0:STEP-1) * ( et(2) - et(1) )/STEP + et(1); [pos,ltime]= cspice_spkpos( 'Cassini', times, 'J2000', 'NONE', 'SATURN BARYCENTER' ); % Plot the resulting trajectory. x = pos(1,:); y = pos(2,:); z = pos(3,:); plot3(x,y,z) cspice_kclear continued on next page

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 13 Simple Mice Example (2) Repeat the example of the previous page, except use the mice_spkezr function to retrieve full state vectors. % Define the number of divisions of the time interval. STEP = 1000; % Construct a meta kernel, "standard.tm”, which will be used to load the needed % generic kernels: "naif0009.tls," "de421.bsp,” and "pck00009.tpc.” % Load the generic kernels using the meta kernel, and a Cassini spk. cspice_furnsh( { 'standard.tm', '/kernels/cassini/spk/030201AP_SK_SM546_T45.bsp'} ) et = cspice_str2et( {'Jun 20, 2004', 'Dec 1, 2005'} ); times = (0:STEP-1) * ( et(2) - et(1) )/STEP + et(1); ptarg = mice_spkpos( 'Cassini', times, 'J2000', 'NONE', 'SATURN BARYCENTER' ); pos = [ptarg.pos]; % Plot the resulting trajectory. x = pos(1,:); y = pos(2,:); z = pos(3,:); plot3(x,y,z) cspice_kclear continued on next page

Navigation and Ancillary Information Facility NIF MATLAB Interface to CSPICE 14 Mice Example Graphic Output Trajectory of the Cassini spacecraft, in the J2000 frame, from June to Dec