Isis 3 Programmer Reference
|
#include <KernelDb.h>
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. More... | |
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. More... | |
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. More... | |
~KernelDb () | |
Destructs KernelDb object. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Kernel | frame (Pvl &lab) |
This method finds the highest version of all Frame kernels (fk) identified by the database and the allowed kernel types. More... | |
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. More... | |
Kernel | dem (Pvl &lab) |
This method finds the highest version of all Digital Terrain Models (DEMs) found that match the criteria in the database. More... | |
Kernel | findLast (const QString &entry, Pvl &lab) |
Finds the highest priority Kernel object for the given entry based on the allowed Kernel types. More... | |
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. More... | |
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. More... | |
QList< FileName > | kernelDbFiles () |
Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() is called. More... | |
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. More... | |
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. More... | |
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. More... | |
QStringList | files (PvlGroup &grp) |
This method retrieves the values of all of the "File" keywords in the given PvlGroup. More... | |
Private Attributes | |
QString | m_filename |
The name of the kernel database file. More... | |
QList< FileName > | m_kernelDbFiles |
List of the kernel database file names that were read in when the loadSystemDb() method is called. More... | |
unsigned int | m_allowedKernelTypes |
This integer value represents which Kernel::Types are allowed. More... | |
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. More... | |
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);
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 113 of file KernelDb.h.
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.
allowedKernelTypes | Integer value representing Kernel::Type enumerations that are allowed. |
Definition at line 61 of file KernelDb.cpp.
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.
dbName | String containing the name of the kernel database |
allowedKernelTypes | Integer value representing Kernel::Type enumerations that are allowed. |
Definition at line 89 of file KernelDb.cpp.
References m_allowedKernelTypes, m_filename, and m_kernelDbFiles.
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.
dbStream | An input stream containing kernel database Pvl objects |
allowedKernelTypes | Integer value representing Kernel::Type enumerations that are allowed. |
Definition at line 118 of file KernelDb.cpp.
References m_allowedKernelTypes, m_filename, m_kernelData, and m_kernelDbFiles.
Isis::KernelDb::~KernelDb | ( | ) |
Destructs KernelDb object.
Definition at line 128 of file KernelDb.cpp.
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 334 of file KernelDb.cpp.
References findLast().
|
private |
This method retrieves the values of all of the "File" keywords in the given PvlGroup.
grp | The PvlGroup that containing file names to be retrieved |
Definition at line 887 of file KernelDb.cpp.
References _FILEINFO_, Isis::FileName::highestVersion(), Isis::FileName::isVersioned(), Isis::PvlContainer::keywords(), m_filename, Isis::PvlContainer::name(), Isis::PvlKeyword::name(), Isis::FileName::name(), Isis::FileName::originalPath(), Isis::PvlKeyword::size(), and Isis::IException::Unknown.
Referenced by findAll().
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.
entry | The name of the kernel, dem, or entry that will be searched for |
lab | The Pvl label containing an IsisCube object with times and instrument ID. |
Definition at line 378 of file KernelDb.cpp.
References Isis::CameraFactory::CameraVersion(), files(), Isis::PvlObject::findGroup(), Isis::PvlObject::findObject(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlObject::hasGroup(), Isis::PvlContainer::hasKeyword(), Isis::PvlObject::hasObject(), Isis::PvlContainer::isNamed(), Isis::PvlKeyword::isNamed(), Isis::PvlContainer::keywords(), m_allowedKernelTypes, m_kernelData, matches(), Isis::PvlObject::object(), Isis::PvlObject::objects(), and Isis::Kernel::typeEnum().
Referenced by findLast(), and spacecraftPointing().
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.
entry | The name of the kernel, dem, or other entry that will be searched for |
lab | The label containing the IsisCube object with times and instrument ID. |
Definition at line 351 of file KernelDb.cpp.
References findAll().
Referenced by dem(), frame(), instrument(), instrumentAddendum(), leapSecond(), spacecraftClock(), spacecraftPosition(), targetAttitudeShape(), and targetPosition().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 293 of file KernelDb.cpp.
References findLast().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 272 of file KernelDb.cpp.
References findLast().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 313 of file KernelDb.cpp.
References findLast().
Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() is called.
Definition at line 873 of file KernelDb.cpp.
References m_kernelDbFiles.
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 147 of file KernelDb.cpp.
References findLast().
|
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().
dataDir | The PvlGroup found in the Preferences DataDirectory group |
directory | The full directory path of the kernel (or dem) whose kernel database file(s) will be read. |
lab | Reference to the labels of a cube. This is used to the match the appropriate InstrumentId value, if needed. |
Definition at line 791 of file KernelDb.cpp.
References Isis::FileName::expanded(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::FileName::highestVersion(), Isis::PvlContainer::isNamed(), Isis::PvlKeyword::isNamed(), Isis::PvlContainer::keywords(), m_kernelDbFiles, and matches().
Referenced by 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:
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:
The following are always found in the base directory
To check which kernel database files have been loaded, file names may be accessed by calling kernelDbFiles().
mission | A QString containing the name of the mission whose kernel database files will be loaded. |
lab | Reference to the labels of a cube. This is used match the appropriate InstrumentId value, if needed. |
Definition at line 719 of file KernelDb.cpp.
References Isis::FileName::fileExists(), loadKernelDbFiles(), and readKernelDbFiles().
|
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.
lab | The labels of an IsisCube to be searched, usually for times and InstrumentId. |
grp | A PvlGroup from the kernel database containing values to compare to the labels |
timeToMatch | The time value (if time is not being compared, "iTime()" may be passed in for this value) |
cameraVersion | The camera version to be matched with the cube labels (if camera version is not being compared, "1" may be passed in for this parameter) |
Definition at line 583 of file KernelDb.cpp.
References Isis::PvlObject::findGroup(), Isis::PvlObject::findObject(), Isis::PvlContainer::hasKeyword(), Isis::PvlKeyword::isNamed(), Isis::PvlContainer::keywords(), Isis::PvlKeyword::size(), Isis::IString::ToInteger(), and Isis::IString::Token().
Referenced by findAll(), and loadKernelDbFiles().
|
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().
dataDir | The PvlGroup found in the Preferences DataDirectory group |
directory | The full directory path of the kernel (or dem) whose kernel database file(s) will be read. |
lab | Reference to the labels of a cube. This is used to the match the appropriate InstrumentId value, if needed. |
Definition at line 852 of file KernelDb.cpp.
References _FILEINFO_, Isis::FileName::expanded(), m_kernelData, m_kernelDbFiles, Isis::Pvl::read(), and Isis::IException::Unknown.
Referenced by loadSystemDb().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 230 of file KernelDb.cpp.
References findLast().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 210 of file KernelDb.cpp.
References findAll().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 251 of file KernelDb.cpp.
References findLast().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 168 of file KernelDb.cpp.
References findLast().
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.
lab | Pvl label containing an IsisCube with needed times and IDs. |
Definition at line 189 of file KernelDb.cpp.
References findLast().
|
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 157 of file KernelDb.h.
Referenced by findAll(), and KernelDb().
|
private |
The name of the kernel database file.
This may be set to "None" or "internal stream".
Definition at line 152 of file KernelDb.h.
Referenced by files(), and KernelDb().
|
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 165 of file KernelDb.h.
Referenced by findAll(), KernelDb(), and readKernelDbFiles().
List of the kernel database file names that were read in when the loadSystemDb() method is called.
Definition at line 154 of file KernelDb.h.
Referenced by KernelDb(), kernelDbFiles(), loadKernelDbFiles(), and readKernelDbFiles().