Isis 3 Programmer Reference
Isis::KernelDb Class Reference

KernelDb class. More...

#include <KernelDb.h>

Collaboration diagram for Isis::KernelDb:
Collaboration graph

Public Member Functions

 KernelDb (const unsigned int allowedKernelTypes)
 Constructs a new KernelDb object with a given integer value representing the Kernel::Type enumerations that are allowed.
 
 KernelDb (const QString &dbName, const unsigned int allowedKernelTypes)
 Constructs a new KernelDb object with the given file name and integer value representing the Kernel::Type enumerations that are allowed.
 
 KernelDb (std::istream &dbStream, const unsigned int allowedKernelTypes)
 Constructs a new KernelDb object from the given stream and integer value representing the Kernel::Type enumerations that are allowed.
 
 ~KernelDb ()
 Destructs KernelDb object.
 
Kernel leapSecond (Pvl &lab)
 This method finds the top priority of all Leap Second kernels (lsk) identified by the database and the allowed kernel types.
 
Kernel targetAttitudeShape (Pvl &lab)
 This method finds the highest version of all Target Attitude Shape kernels (pck) identified by the database and the allowed kernel types.
 
Kernel targetPosition (Pvl &lab)
 This method finds the highest version of all Target Position kernels (tspk) identified by the database and the allowed kernel types.
 
QList< std::priority_queue< Kernel > > spacecraftPointing (Pvl &lab)
 This method finds a list of the highest versions of all Spacecraft Pointing kernels (ck) identified by the databases and the allowed Kernel types.
 
Kernel spacecraftClock (Pvl &lab)
 This method finds the highest version of all Spacecraft Clock kernels (sclk) identified by the database and the allowed kernel types.
 
Kernel spacecraftPosition (Pvl &lab)
 This method finds the highest version of all Spacecraft Position kernels (spk) identified by the database and the allowed kernel types.
 
Kernel instrument (Pvl &lab)
 This method finds the last Instrument kernel found that matches the (ik) criteria in the database and the allowed kernel types.
 
Kernel frame (Pvl &lab)
 This method finds the highest version of all Frame kernels (fk) identified by the database and the allowed kernel types.
 
Kernel instrumentAddendum (Pvl &lab)
 This method finds the highest version of all Instrument Addendum kernels (iak) identified by the database and the allowed kernel types.
 
Kernel dem (Pvl &lab)
 This method finds the highest version of all Digital Terrain Models (DEMs) found that match the criteria in the database.
 
Kernel findLast (const QString &entry, Pvl &lab)
 Finds the highest priority Kernel object for the given entry based on the allowed Kernel types.
 
QList< std::priority_queue< Kernel > > findAll (const QString &entry, Pvl &lab)
 Finds all of the Kernel objects for the given entry value based on the allowed Kernel types.
 
void loadSystemDb (const QString &mission, const Pvl &lab)
 Loads the appropriate kernel database files with the defined BASE and MISSION info for each type of kernel.
 
QList< FileNamekernelDbFiles ()
 Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() is called.
 

Static Public Member Functions

static bool matches (const Pvl &lab, PvlGroup &kernelDbGrp, iTime timeToMatch, int cameraVersion)
 This static method determines whether the given cube label matches the given criteria.
 

Private Member Functions

void loadKernelDbFiles (PvlGroup &dataDir, QString directory, const Pvl &lab)
 This method is called by loadSystemDb() to create a list of all appropriate kernel database files to be read.
 
void readKernelDbFiles ()
 This method is called by loadSystemDb() to read kernel database file list compiled by loadKernelDbFiles() and add the contents of these database files to the kernelData pvl.
 
QStringList files (PvlGroup &grp)
 This method retrieves the values of all of the "File" keywords in the given PvlGroup.
 

Private Attributes

QString m_filename
 The name of the kernel database file.
 
QList< FileNamem_kernelDbFiles
 List of the kernel database file names that were read in when the loadSystemDb() method is called.
 
unsigned int m_allowedKernelTypes
 This integer value represents which Kernel::Types are allowed.
 
Pvl m_kernelData
 Pvl containing the information in the kernel database(s) that is read in from the constructor and whenever the loadSystemDb() method is called.
 

Friends

class ::KernelDbFixture_TestKernelsSmithOffset_Test
 

Detailed Description

KernelDb class.

This class handles kernel database files. Once the database files have been loaded into a Pvl, the highest version of each kernel can be found by calling methods with corresponding kernel names, as shown below.

KernelDb baseKernels(0);

baseKernels.loadSystemDb(mission, lab);

Kernel lk, pck, targetSpk, fk, ik, sclk, spk, iak, dem, exk; priority_queue< Kernel > ck; lk = baseKernels.leapSecond(lab); pck = baseKernels.targetAttitudeShape(lab); targetSpk = baseKernels.targetPosition(lab); ik = baseKernels.instrument(lab); sclk = baseKernels.spacecraftClock(lab); iak = baseKernels.instrumentAddendum(lab); fk = ckKernels.frame(lab); ck = ckKernels.spacecraftPointing(lab); spk = spkKernels.spacecraftPosition(lab);

Author
????-??-?? Unknown
History

2005-12-27 Jacob Danton - Added support for multiple files and fixed a bug in SearchMatch.

2007-07-09 Steven Lambright - Removed inheritance from PVL

2007-10-25 Steven Koechle - Corrected Smithed Enum fixed search methods.

2007-07-09 Steven Lambright - Added Kernel class and multiple-ck return

2009-05-12 Steven Lambright - Added Camera Version Checking

2010-07-19 Steven Lambright - Added kernel selection merging

2011-10-05 Jacob Danton - The placement of int cameraVersion = CameraFactory::CameraVersion(lab); was the reason that spiceinit ran so slowly. Its placement in the "Matches" function resulted in CameraFactory reading in the "Camera.plugin" file for every single kernel in both the CK and SPK kernels.????.db files. That means, for LRO, it was read in around 2100 times. By moving this line of code out of the "Matches" function and into the "FindAll" function (the only one that calls "Matches") and then passing it as a parameter, I was able to reduce the time to about 5% (from almost 4 minutes to under 15 seconds).

2013-02-26 Jeannie Backer - Modified loadSystemDb() to check kernel directories first for config files that are mission specific and/or point to multiple db files. If the config files do not exist, then the newest db file from that kernel directory is read. Added m_kernelDbFiles, kernelDbFiles(), and readKernelDbFiles(). Moved Kernel class from the KernelDb header file into it's own directory. Moved the KernelType enumeration from a global "spiceInit" namespace in this header file into the Kernel class and renamed it Type. Changed method names to lower camel case and changed member variable prefix to m_ to comply with Isis3 standards. Documented methods, member variables. Added cases to unitTest.Fixes #924.

2013-02-27 Steven Lambright - This class no longer requires the Instrument group (or camera version information) to be present in order to enumerate kernels. This was done so that the 'shadow' program could find a PCK and SPK to load despite not having a cube with camera information. References #1232.

Definition at line 102 of file KernelDb.h.

Constructor & Destructor Documentation

◆ KernelDb() [1/3]

Isis::KernelDb::KernelDb ( const unsigned int allowedKernelTypes)

Constructs a new KernelDb object with a given integer value representing the Kernel::Type enumerations that are allowed.

The filename is set to "None" if this constructor is used.

The allowed kernel types is stored as the sum of the enumerations of the allowed Kernel Types. The following enumeriations currently exist: 0001 = 1 = Predicted 0010 = 2 = Nadir 0100 = 4 = Reconstructed 1000 = 8 = Smithed

So, for example, if allowedKernelTypes is 11, then we can represent it as 1011. In this case, Predicted, Nadir, and Smithed kernels are allowed, but not Reconstructed.

Parameters
allowedKernelTypesInteger value representing Kernel::Type enumerations that are allowed.

Definition at line 48 of file KernelDb.cpp.

References m_allowedKernelTypes, m_filename, and m_kernelDbFiles.

◆ KernelDb() [2/3]

Isis::KernelDb::KernelDb ( const QString & dbName,
const unsigned int allowedKernelTypes )

Constructs a new KernelDb object with the given file name and integer value representing the Kernel::Type enumerations that are allowed.

The allowed kernel types is stored as the sum of the enumerations of the allowed Kernel Types. The following enumeriations currently exist: 0001 = 1 = Predicted 0010 = 2 = Nadir 0100 = 4 = Reconstructed 1000 = 8 = Smithed

So, for example, if allowedKernelTypes is 11, then we can represent it as 1011. In this case, Predicted, Nadir, and Smithed kernels are allowed, but not Reconstructed.

Parameters
dbNameString containing the name of the kernel database
allowedKernelTypesInteger value representing Kernel::Type enumerations that are allowed.
See also
KernelDb(int)

Definition at line 76 of file KernelDb.cpp.

References m_allowedKernelTypes, m_filename, and m_kernelDbFiles.

◆ KernelDb() [3/3]

Isis::KernelDb::KernelDb ( std::istream & dbStream,
const unsigned int allowedKernelTypes )

Constructs a new KernelDb object from the given stream and integer value representing the Kernel::Type enumerations that are allowed.

The filename is set to "internal stream" if this constructor is used.

The allowed kernel types is stored as the sum of the enumerations of the allowed Kernel Types. The following enumeriations currently exist: 0001 = 1 = Predicted 0010 = 2 = Nadir 0100 = 4 = Reconstructed 1000 = 8 = Smithed

So, for example, if allowedKernelTypes is 11, then we can represent it as 1011. In this case, Predicted, Nadir, and Smithed kernels are allowed, but not Reconstructed.

Parameters
dbStreamAn input stream containing kernel database Pvl objects
allowedKernelTypesInteger value representing Kernel::Type enumerations that are allowed.
See also
KernelDb(int)

Definition at line 105 of file KernelDb.cpp.

References m_allowedKernelTypes, m_filename, m_kernelData, and m_kernelDbFiles.

◆ ~KernelDb()

Isis::KernelDb::~KernelDb ( )

Destructs KernelDb object.

Definition at line 115 of file KernelDb.cpp.

Member Function Documentation

◆ dem()

Kernel Isis::KernelDb::dem ( Pvl & lab)

This method finds the highest version of all Digital Terrain Models (DEMs) found that match the criteria in the database.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no DEM is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all DEMs

Definition at line 321 of file KernelDb.cpp.

References findLast().

◆ files()

QStringList Isis::KernelDb::files ( PvlGroup & grp)
private

This method retrieves the values of all of the "File" keywords in the given PvlGroup.

Parameters
grpThe PvlGroup that containing file names to be retrieved
Returns
QStringList A list containing the file names found in the given group.

Definition at line 900 of file KernelDb.cpp.

References files(), Isis::FileName::highestVersion(), Isis::FileName::isVersioned(), m_filename, Isis::FileName::name(), Isis::FileName::originalPath(), and Isis::IException::Unknown.

Referenced by files(), and findAll().

◆ findAll()

QList< std::priority_queue< Kernel > > Isis::KernelDb::findAll ( const QString & entry,
Pvl & lab )

Finds all of the Kernel objects for the given entry value based on the allowed Kernel types.

This method returns a list of priority queues. Each priority queue corresponds to a kernel db file object of the same name as the entry in the kernelData pvl.

Parameters
entryThe name of the kernel, dem, or entry that will be searched for
labThe Pvl label containing an IsisCube object with times and instrument ID.
Returns
QList< priority_queue<Kernel> > List of queues of Kernel objects for the given entry

Definition at line 365 of file KernelDb.cpp.

References Isis::CameraFactory::CameraVersion(), files(), Isis::PvlObject::findGroup(), Isis::PvlObject::findObject(), Isis::PvlObject::hasGroup(), Isis::PvlObject::hasObject(), Isis::PvlContainer::isNamed(), Isis::PvlKeyword::isNamed(), m_allowedKernelTypes, m_kernelData, matches(), Isis::PvlObject::object(), Isis::PvlObject::objects(), and Isis::Kernel::typeEnum().

Referenced by findLast(), and spacecraftPointing().

◆ findLast()

Kernel Isis::KernelDb::findLast ( const QString & entry,
Pvl & lab )

Finds the highest priority Kernel object for the given entry based on the allowed Kernel types.

This method calls findAll() to get a list of priority queues. The top priority of the first queue is returned, if it exists. If not, an empty Kernel object is returned.

Parameters
entryThe name of the kernel, dem, or other entry that will be searched for
labThe label containing the IsisCube object with times and instrument ID.
Returns
Kernel Highest version of the given kernel or DEM entry

Definition at line 338 of file KernelDb.cpp.

References findAll().

Referenced by dem(), frame(), instrument(), instrumentAddendum(), leapSecond(), spacecraftClock(), spacecraftPosition(), targetAttitudeShape(), and targetPosition().

◆ frame()

Kernel Isis::KernelDb::frame ( Pvl & lab)

This method finds the highest version of all Frame kernels (fk) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no FK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all frame kernels

Definition at line 280 of file KernelDb.cpp.

References findLast().

◆ instrument()

Kernel Isis::KernelDb::instrument ( Pvl & lab)

This method finds the last Instrument kernel found that matches the (ik) criteria in the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no IK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all instrument kernels

Definition at line 259 of file KernelDb.cpp.

References findLast().

Referenced by matches().

◆ instrumentAddendum()

Kernel Isis::KernelDb::instrumentAddendum ( Pvl & lab)

This method finds the highest version of all Instrument Addendum kernels (iak) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no IAK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all instrument addendum kernels

Definition at line 300 of file KernelDb.cpp.

References findLast().

◆ kernelDbFiles()

QList< FileName > Isis::KernelDb::kernelDbFiles ( )

Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() is called.

Returns
QList<FileName> A list containing the kernel database file names

Definition at line 886 of file KernelDb.cpp.

References m_kernelDbFiles.

◆ leapSecond()

Kernel Isis::KernelDb::leapSecond ( Pvl & lab)

This method finds the top priority of all Leap Second kernels (lsk) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no LSK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all leap second kernels

Definition at line 134 of file KernelDb.cpp.

References findLast().

◆ loadKernelDbFiles()

void Isis::KernelDb::loadKernelDbFiles ( PvlGroup & dataDir,
QString directory,
const Pvl & lab )
private

This method is called by loadSystemDb() to create a list of all appropriate kernel database files to be read.

The method first checks whether the directory contains a config file of the form kernels.????.conf

If not, the highest version of the database file of the form kernels.????.db file is read in.

A config file will exist if this mission requires multiple kernel database files or instrument dependent database files. The kernel data base files listed in the highest version of the config file group will be read in. The "Match" keyword maybe used in this config file for a particular Instrument, if required.

To check which kernel database files have been loaded, file names may be accessed by calling kernelDbFiles().

Parameters
dataDirThe PvlGroup found in the Preferences DataDirectory group
directoryThe full directory path of the kernel (or dem) whose kernel database file(s) will be read.
labReference to the labels of a cube. This is used to the match the appropriate InstrumentId value, if needed.
See also
loadSystemDb()
kernelDbFiles()

Definition at line 804 of file KernelDb.cpp.

References Isis::PvlObject::findObject(), Isis::PvlKeyword::isNamed(), m_kernelDbFiles, and matches().

Referenced by loadSystemDb().

◆ loadSystemDb()

void Isis::KernelDb::loadSystemDb ( const QString & mission,
const Pvl & lab )

Loads the appropriate kernel database files with the defined BASE and MISSION info for each type of kernel.

This method always gets the following from the mission directory:

  • ck
  • fk
  • ik
  • sclk
  • spk
  • iak

For the following, this method looks for appropriate kernels in the mission directory first, then if not found, uses the kernels in the base directory:

  • pck
  • tspk

The following are always found in the base directory

  • lsk
  • dems

To check which kernel database files have been loaded, file names may be accessed by calling kernelDbFiles().

Parameters
missionA QString containing the name of the mission whose kernel database files will be loaded.
labReference to the labels of a cube. This is used match the appropriate InstrumentId value, if needed.
See also
readKernelDbFiles()
kernelDbFiles()

Definition at line 731 of file KernelDb.cpp.

References loadKernelDbFiles(), and readKernelDbFiles().

◆ matches()

bool Isis::KernelDb::matches ( const Pvl & lab,
PvlGroup & grp,
iTime timeToMatch,
int cameraVersion )
static

This static method determines whether the given cube label matches the given criteria.

The method can check for three criteria types: (1) Time, (2) CameraVersion, and/or (3) the Match keyword values in the given PvlGroup. All three are optional. If any of the given criteria are not met, the method will return false.

(1) If the given PvlGroup does not have a "Time" keyword, then the time will not be compared.

(2) If the given PvlGroup does not have a "CameraTime" keyword, then the time will not be compared.

(3) If the given PvlGroup does not have a "Match" keyword, then individual keywords will not be compared. If the "Match" keyword exists in the given PvlGroup, it will have the form:

Object = ObjectName Group = grp Match = (MatchGroup, MatchKeyword, MatchKeywordValue) EndGroup EndObject

The first entry of the vector passed into the Match keyword of this Pvl represents the name of a group in the labels. This group will be searched for the keyword name passed in as the second entry of the Match keyword. This criteria is met if the keyword value in the labels matches the third entry of the Match keyword.

Parameters
labThe labels of an IsisCube to be searched, usually for times and InstrumentId.
grpA PvlGroup from the kernel database containing values to compare to the labels
timeToMatchThe time value (if time is not being compared, "iTime()" may be passed in for this value)
cameraVersionThe camera version to be matched with the cube labels (if camera version is not being compared, "1" may be passed in for this parameter)
Returns
bool Indicates whether all of the given criteria was matched.

Definition at line 571 of file KernelDb.cpp.

References Isis::PvlObject::findGroup(), Isis::PvlContainer::findKeyword(), Isis::PvlObject::findObject(), instrument(), Isis::PvlKeyword::isNamed(), Isis::PvlKeyword::size(), Isis::IString::ToInteger(), Isis::IString::Token(), and Isis::PvlObject::Traverse.

Referenced by findAll(), and loadKernelDbFiles().

◆ readKernelDbFiles()

void Isis::KernelDb::readKernelDbFiles ( )
private

This method is called by loadSystemDb() to read kernel database file list compiled by loadKernelDbFiles() and add the contents of these database files to the kernelData pvl.

To check which kernel database files will be read in by this method, file names may be accessed by calling kernelDbFiles().

Parameters
dataDirThe PvlGroup found in the Preferences DataDirectory group
directoryThe full directory path of the kernel (or dem) whose kernel database file(s) will be read.
labReference to the labels of a cube. This is used to the match the appropriate InstrumentId value, if needed.
See also
loadSystemDb()
kernelDbFiles()

Definition at line 865 of file KernelDb.cpp.

References m_kernelData, m_kernelDbFiles, Isis::Pvl::read(), and Isis::IException::Unknown.

Referenced by loadSystemDb().

◆ spacecraftClock()

Kernel Isis::KernelDb::spacecraftClock ( Pvl & lab)

This method finds the highest version of all Spacecraft Clock kernels (sclk) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no SCLK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all spacecraft clock kernels

Definition at line 217 of file KernelDb.cpp.

References findLast().

◆ spacecraftPointing()

QList< std::priority_queue< Kernel > > Isis::KernelDb::spacecraftPointing ( Pvl & lab)

This method finds a list of the highest versions of all Spacecraft Pointing kernels (ck) identified by the databases and the allowed Kernel types.

If no database file or stream was provided ot the constructor, the loadSystemDb() method should be called prior to this accessor.

If no CKs are found, and a list with one empty queue will be returned.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
QList< priority_queue<Kernel> > List of queues of Kernel objects for the given entry

Definition at line 197 of file KernelDb.cpp.

References findAll().

◆ spacecraftPosition()

Kernel Isis::KernelDb::spacecraftPosition ( Pvl & lab)

This method finds the highest version of all Spacecraft Position kernels (spk) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no SPK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all spacecraft position kernels

Definition at line 238 of file KernelDb.cpp.

References findLast().

◆ targetAttitudeShape()

Kernel Isis::KernelDb::targetAttitudeShape ( Pvl & lab)

This method finds the highest version of all Target Attitude Shape kernels (pck) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no PCK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all target attitude shape kernels

Definition at line 155 of file KernelDb.cpp.

References findLast().

◆ targetPosition()

Kernel Isis::KernelDb::targetPosition ( Pvl & lab)

This method finds the highest version of all Target Position kernels (tspk) identified by the database and the allowed kernel types.

If no database file or stream was provided to the constructor, the loadSystemDb() method should be called prior to this accessor.

If no TSPK is found, this method will return an empty Kernel object.

Parameters
labPvl label containing an IsisCube with needed times and IDs.
Returns
Kernel Highest version of all target position kernels

Definition at line 176 of file KernelDb.cpp.

References findLast().

Friends And Related Symbol Documentation

◆ ::KernelDbFixture_TestKernelsSmithOffset_Test

friend class ::KernelDbFixture_TestKernelsSmithOffset_Test
friend

Definition at line 135 of file KernelDb.h.

Member Data Documentation

◆ m_allowedKernelTypes

unsigned int Isis::KernelDb::m_allowedKernelTypes
private

This integer value represents which Kernel::Types are allowed.

It is the sum of the enumeration values of the allowed Kernel::Types. When this integer value and the enumeration types are expressed binary numbers, it is clear which types are allowed.

Definition at line 148 of file KernelDb.h.

Referenced by findAll(), KernelDb(), KernelDb(), and KernelDb().

◆ m_filename

QString Isis::KernelDb::m_filename
private

The name of the kernel database file.

This may be set to "None" or "internal stream".

Definition at line 143 of file KernelDb.h.

Referenced by files(), KernelDb(), KernelDb(), and KernelDb().

◆ m_kernelData

Pvl Isis::KernelDb::m_kernelData
private

Pvl containing the information in the kernel database(s) that is read in from the constructor and whenever the loadSystemDb() method is called.

Definition at line 156 of file KernelDb.h.

Referenced by findAll(), KernelDb(), and readKernelDbFiles().

◆ m_kernelDbFiles

QList<FileName> Isis::KernelDb::m_kernelDbFiles
private

List of the kernel database file names that were read in when the loadSystemDb() method is called.

Definition at line 145 of file KernelDb.h.

Referenced by KernelDb(), KernelDb(), KernelDb(), kernelDbFiles(), loadKernelDbFiles(), and readKernelDbFiles().


The documentation for this class was generated from the following files: