Isis Developer Reference
Spice.h
Go to the documentation of this file.
1 #ifndef Spice_h
2 #define Spice_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <string>
11 #include <vector>
12 
13 #include <SpiceUsr.h>
14 #include <SpiceZfc.h>
15 #include <SpiceZmc.h>
16 
17 #include "Pvl.h"
18 #include "ShapeModel.h"
19 #include "SpicePosition.h"
20 #include "SpiceRotation.h"
21 
22 namespace Isis {
23  class Cube;
24  class iTime;
25  class Distance;
26  class EllipsoidShape;
27  class Longitude;
28  class Target;
29 
283  class Spice {
284  public:
285  // constructors
286  Spice(Cube &cube);
287  Spice(Pvl &lab, nlohmann::json);
288 
289  // destructor
290  virtual ~Spice();
291 
292  // Methods
293  virtual void setTime(const iTime &time);
294  void instrumentPosition(double p[3]) const;
295  virtual void instrumentBodyFixedPosition(double p[3]) const;
296  virtual void sunPosition(double p[3]) const;
297  virtual double targetCenterDistance() const;
298  virtual double sunToBodyDist() const;
299 
300  virtual Longitude solarLongitude();
301  virtual void instrumentBodyFixedVelocity(double v[3]) const;
302  iTime time() const;
303 
304  void radii(Distance r[3]) const;
305 
306  virtual void createCache(iTime startTime, iTime endTime,
307  const int size, double tol);
308  virtual iTime cacheStartTime() const;
309  virtual iTime cacheEndTime() const;
310 
311  virtual void subSpacecraftPoint(double &lat, double &lon);
312  virtual void subSolarPoint(double &lat, double &lon);
313 
314  virtual Target *target() const;
315  QString targetName() const;
316 
317  virtual iTime getClockTime(QString clockValue,
318  int sclkCode = -1,
319  bool clockTicks=false);
320  SpiceDouble getDouble(const QString &key, int index = 0);
321  SpiceInt getInteger(const QString &key, int index = 0);
322  QString getString(const QString &key, int index = 0);
323 
324  virtual SpicePosition *sunPosition() const;
325  virtual SpicePosition *instrumentPosition() const;
326  virtual SpiceRotation *bodyRotation() const;
327  virtual SpiceRotation *instrumentRotation() const;
328 
329  bool isUsingAle();
330  bool hasKernels(Pvl &lab);
331  bool isTimeSet();
332 
333  SpiceInt naifBodyCode() const;
334  SpiceInt naifSpkCode() const;
335  SpiceInt naifCkCode() const;
336  SpiceInt naifIkCode() const;
337  SpiceInt naifSclkCode() const;
338  SpiceInt naifBodyFrameCode() const;
339 
341  virtual double resolution();
342 
343  protected:
353  };
354 
355  QVariant readValue(QString key, SpiceValueType type, int index = 0);
356 
357  void storeResult(QString name, SpiceValueType type, QVariant value);
358  QVariant getStoredResult(QString name, SpiceValueType type);
359 
360  void storeValue(QString key, int index, SpiceValueType type,
361  QVariant value);
362  QVariant readStoredValue(QString key, SpiceValueType type, int index);
363  virtual void computeSolarLongitude(iTime et);
364 
365  // Leave these protected so that inheriting classes don't
366  // have to convert between double and spicedouble
367  // None of the below data elements are usable (except
368  // m_radii) until SetEphemerisTime is invoked
369  SpiceDouble m_uB[3];
374  SpiceDouble m_BJ[3][3];
384 
385  private:
386  // Don't allow copies
387  Spice(const Spice &other);
388  Spice &operator=(const Spice &other);
389 
390  void init(Pvl &pvl, bool noTables, nlohmann::json isd = NULL);
391  void csmInit(Cube &cube, Pvl label);
392  void defaultInit();
393 
394  void load(PvlKeyword &key, bool notab);
395 
396  QVector<QString> * m_kernels;
397 
398  // cache stuff
399  iTime *m_startTime;
400  iTime *m_endTime;
401  SpiceDouble *m_cacheSize;
402 
403  SpiceDouble *m_startTimePadding;
404  SpiceDouble *m_endTimePadding;
405 
406  SpicePosition *m_instrumentPosition;
407  SpiceRotation *m_instrumentRotation;
408  SpicePosition *m_sunPosition;
409  SpiceRotation *m_bodyRotation;
410 
411  bool m_allowDownsizing;
412 
413  // Constants
414  // SpiceInt *m_bodyCode; /**< The NaifBodyCode value, if it exists in the
415  // labels. Otherwise, if the target is sky,
416  // it's the SPK code and if not sky then it's
417  // calculated by the naifBodyCode() method.*/
418  SpiceInt *m_spkCode;
419  SpiceInt *m_ckCode;
420  SpiceInt *m_ikCode;
421  SpiceInt *m_sclkCode;
422  SpiceInt *m_spkBodyCode;
423  SpiceInt *m_bodyFrameCode;
427  PvlObject *m_naifKeywords;
428 
429  bool m_usingNaif;
432  bool m_usingAle;
435  };
436 }
437 
438 #endif
Isis::Spice::SpiceIntType
@ SpiceIntType
SpiceInt type.
Definition: Spice.h:351
Isis::Spice::radii
void radii(Distance r[3]) const
Returns the radii of the body in km.
Definition: Spice.cpp:930
Isis::Spice::setTime
virtual void setTime(const iTime &time)
Sets the ephemeris time and reads the spacecraft and sun position from the kernels at that instant in...
Definition: Spice.cpp:780
FileName.h
Isis::Spice::time
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition: Spice.cpp:884
Isis::Spice::m_et
iTime * m_et
Ephemeris time (read NAIF documentation for a detailed description)
Definition: Spice.h:382
Isis::SpicePosition
Obtain SPICE position information for a body.
Definition: SpicePosition.h:173
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::Spice::subSolarPoint
virtual void subSolarPoint(double &lat, double &lon)
Returns the sub-solar latitude/longitude in universal coordinates (0-360 positive east,...
Definition: Spice.cpp:1329
EllipsoidShape.h
Isis::Spice::subSpacecraftPoint
virtual void subSpacecraftPoint(double &lat, double &lon)
Returns the sub-spacecraft latitude/longitude in universal coordinates (0-360 positive east,...
Definition: Spice.cpp:1278
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::Spice::instrumentPosition
virtual SpicePosition * instrumentPosition() const
Accessor method for the instrument position.
Definition: Spice.cpp:1600
Isis::PI
const double PI
The mathematical constant PI.
Definition: Constants.h:40
Isis::Spice::naifBodyCode
SpiceInt naifBodyCode() const
This returns the NAIF body code of the target indicated in the labels.
Definition: Spice.cpp:941
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::Spice::cacheEndTime
virtual iTime cacheEndTime() const
Accessor method for the cache end time.
Definition: Spice.cpp:758
json
nlohmann::json json
This is free and unencumbered software released into the public domain.
Definition: Spice.cpp:20
Isis::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::Spice::getString
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1261
Isis::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
ShapeModel.h
Isis::PvlKeyword::addValue
void addValue(QString value, QString unit="")
Adds a value with units.
Definition: PvlKeyword.cpp:252
SpicePosition.h
Target.h
Isis::Spice::getClockTime
virtual iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition: Spice.cpp:1053
Isis::Spice::storeValue
void storeValue(QString key, int index, SpiceValueType type, QVariant value)
Definition: Spice.cpp:1190
Spice.h
Isis::Spice::readStoredValue
QVariant readStoredValue(QString key, SpiceValueType type, int index)
Definition: Spice.cpp:1221
Longitude.h
NaifStatus.h
Isis::Spice::getInteger
SpiceInt getInteger(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1025
Isis::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::Spice::sunToBodyDist
virtual double sunToBodyDist() const
Definition: Spice.cpp:1383
Isis::Spice::createCache
virtual void createCache(iTime startTime, iTime endTime, const int size, double tol)
This method creates an internal cache of spacecraft and sun positions over a specified time range.
Definition: Spice.cpp:649
Isis::Spice::sunPosition
virtual SpicePosition * sunPosition() const
Accessor method for the sun position.
Definition: Spice.cpp:1589
Isis::Spice::SpiceDoubleType
@ SpiceDoubleType
SpiceDouble type.
Definition: Spice.h:349
Isis::Spice::isUsingAle
bool isUsingAle()
Definition: Spice.cpp:1626
Isis::Spice::instrumentBodyFixedVelocity
virtual void instrumentBodyFixedVelocity(double v[3]) const
Returns the spacecraft velocity in body-fixed frame km/sec units.
Definition: Spice.cpp:853
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::Spice::targetCenterDistance
virtual double targetCenterDistance() const
Calculates and returns the distance from the spacecraft to the target center.
Definition: Spice.cpp:918
Isis::Spice::solarLongitude
virtual Longitude solarLongitude()
Returns the solar longitude.
Definition: Spice.cpp:1509
IString.h
SpiceRotation.h
Isis::Distance
Distance measurement, usually in meters.
Definition: Distance.h:34
Isis::Cube::hasBlob
bool hasBlob(const QString &name, const QString &type)
Check to see if the cube contains a BLOB.
Definition: Cube.cpp:2019
Isis::Longitude
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:40
Isis::Spice::target
virtual Target * target() const
Returns a pointer to the target object.
Definition: Spice.cpp:1368
Isis::Spice::instrumentRotation
virtual SpiceRotation * instrumentRotation() const
Accessor method for the instrument rotation.
Definition: Spice.cpp:1622
LightTimeCorrectionState.h
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::Spice::computeSolarLongitude
virtual void computeSolarLongitude(iTime et)
Computes the solar longitude for the given ephemeris time.
Definition: Spice.cpp:1400
Isis::iTime::Et
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:126
Isis::Spice::hasKernels
bool hasKernels(Pvl &lab)
Returns true if the kernel group has kernel files.
Definition: Spice.cpp:1526
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Pvl.h
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::Spice::SpiceByteCodeType
@ SpiceByteCodeType
SpiceByteCode type.
Definition: Spice.h:352
Isis::Spice::m_uB
SpiceDouble m_uB[3]
This contains the sun position (u) in the bodyfixed reference frame (B).
Definition: Spice.h:369
EndianSwapper.h
Isis::Spice::naifBodyFrameCode
SpiceInt naifBodyFrameCode() const
This returns the NAIF body frame code.
Definition: Spice.cpp:989
Isis::Spice::SpiceStringType
@ SpiceStringType
SpiceString type.
Definition: Spice.h:350
Blob.h
Isis::Spice::cacheStartTime
virtual iTime cacheStartTime() const
Accessor method for the cache start time.
Definition: Spice.cpp:743
json
nlohmann::json json
Definition: PvlObject.cpp:22
Isis::Spice::m_BJ
SpiceDouble m_BJ[3][3]
This contains the transformation matrix from J2000 (J) to Body fixed (B).
Definition: Spice.h:374
Isis::Spice::bodyRotation
virtual SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
Definition: Spice.cpp:1611
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::Spice::~Spice
virtual ~Spice()
Destroys the Spice object.
Definition: Spice.cpp:511
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Spice::m_target
Target * m_target
Target of the observation.
Definition: Spice.h:381
Isis::Spice::getStoredResult
QVariant getStoredResult(QString name, SpiceValueType type)
Definition: Spice.cpp:1169
Isis::Spice
Obtain SPICE information for a spacecraft.
Definition: Spice.h:283
Isis::Spice::resolution
virtual double resolution()
Virtual method that returns the pixel resolution of the sensor in meters/pix.
Definition: Spice.cpp:1009
SpacecraftPosition.h
Isis::Spice::naifSclkCode
SpiceInt naifSclkCode() const
This returns the NAIF SCLK code to use when reading from instrument kernels.
Definition: Spice.cpp:978
IException.h
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
std
Namespace for the standard library.
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::Spice::naifCkCode
SpiceInt naifCkCode() const
This returns the NAIF CK code to use when reading from CK kernels.
Definition: Spice.cpp:959
Isis::Spice::storeResult
void storeResult(QString name, SpiceValueType type, QVariant value)
Definition: Spice.cpp:1154
Isis::EndianSwapper
Byte swapper.
Definition: EndianSwapper.h:38
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::Spice::instrumentBodyFixedPosition
virtual void instrumentBodyFixedPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
Definition: Spice.cpp:835
Isis::Spice::isTimeSet
bool isTimeSet()
Returns true if time has been initialized.
Definition: Spice.cpp:1577
iTime.h
Constants.h
Isis::Spice::Spice
Spice(Cube &cube)
Constructs a Spice object and loads SPICE kernels using information from the label object.
Definition: Spice.cpp:64
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::Spice::targetName
QString targetName() const
Returns the QString name of the target.
Definition: Spice.cpp:1378
Distance.h
QVector< QString >
Isis::Spice::naifSpkCode
SpiceInt naifSpkCode() const
This returns the NAIF SPK code to use when reading from SPK kernels.
Definition: Spice.cpp:950
Isis::Spice::readValue
QVariant readValue(QString key, SpiceValueType type, int index=0)
This should be used for reading ALL text naif kernel values.
Definition: Spice.cpp:1093
Isis::Spice::m_solarLongitude
Longitude * m_solarLongitude
Body rotation solar longitude value.
Definition: Spice.h:383
Isis::Longitude::force360Domain
Longitude force360Domain() const
This returns a longitude that is constricted to 0-360 degrees.
Definition: Longitude.cpp:267
Isis::EndianSwapper::Double
double Double(void *buf)
Swaps a double precision value.
Definition: EndianSwapper.cpp:55
Isis::Target
This class is used to create and store valid Isis targets.
Definition: Target.h:63
Isis::Spice::SpiceValueType
SpiceValueType
NAIF value primitive type.
Definition: Spice.h:348
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Spice::getStoredNaifKeywords
PvlObject getStoredNaifKeywords() const
This returns the PvlObject that stores all of the requested Naif data and can be a replacement for fu...
Definition: Spice.cpp:998
Isis::Target::name
QString name() const
Return target name.
Definition: Target.cpp:516
Isis::SpiceRotation
Obtain SPICE rotation information for a body.
Definition: SpiceRotation.h:209