PVL libraries for reading PDS labels

All of the data in the Planetary Data System (PDS) have a detailed set of labels (meta-data). Sometimes these labels are in separate files (detached labels) or are embedded in the data file itself (usually as a header). The data of these labels are encoded in a text-based framework known as a parameter value language (PVL). There are several approaches to programmatically parsing and reading these PDS data in PVL format. This article discusses several of the libraries that exist in C, C++, and Java that can help you with your PDS PVL needs (reading and writing).

In the generic sense, there are many different forms of parameter value languages, each with their own levels of complexity. The PVL syntax that the PDS uses is specified by the Consultative Committee for Space Data Systems in their Blue Book publication: "Parameter Value Language Specification (CCSD0006 and CCSD0008)", June 2000 [CCSDS 641.0-B-2], and Green Book publication: "Parameter Value Language - A Tutorial", June 2000 [CCSDS 641.0-G-2]. PVL has also been accepted by the International Standards Organization (ISO), as a Final Draft International Standard (ISO 14961:2002) keyword value type language for naming and expressing data values.

One might expect that with such heritage there would be a number of software options to choose from when one is confronted with needing to parse this information into one's own program. However, such is not the case, and just blindly searching may not get you very far. People take a look at a PDS PVL file, which is quite human-readable, and decide that they can just whip up something that will pull out what they are looking for. To first order, it is quite easy to just find the name of the parameter that you are looking for and grab the value after the equals sign. You can probably do it with grep and a little shell programming, or some elementary string manipulation in the language of your choice. That kind of approach works great for snagging one value one time. However, if you're going to be needing to do more detailed parsing of PDS PVL metadata (or want to be able to easily extend your efforts in the future), then you need a more robust solution.

The first place that you might naturally turn to is the PDS itself. Under the "Tools" heading from the main PDS page, you can find a PDS Software Download section. Amidst all of that software, the PDS Label Library (lablib) and the PDS Label Library Light (lablib3) are C libraries for parsing PDS PVL. Based on the documentation, lablib3 is the more modern version.

When one attempts to download lablib3, one gets a whole PDS toolbox full of files and directories that may or may not be needed just for compilation of lablib3. The build system is rather piecemeal and I was rather unimpressed with the documentation. When I ran into problems with the compilation, I wasn't surprised. I got the feeling that this software was developed in-house for PDS usage, and wasn't really written for usability by others.

However, there are alternatives (available in C, C++, and Java flavors) written by programmers (primarily Brad Castalia) affiliated with the Lunar and Planetary Laboratory's Planetary Image Research Lab (PIRL). Each of these libraries have a robust design that not only reads PDS PVL, but is also capable of writing out conforming PDS PVL (if you need to do that kind of thing). They are also written with the user in mind, have a robust build system and lots of documentation. I'll discuss them briefly in the order in which they were developed.

The PIRL Parameter Value Logic (PPVL) library is written in C and has been around, and in use, for many years. PDS PVL has a lot of strange quirks that it has accumulated over the years, and the lead programmer has taken a strange glee in making sure that PPVL can parse any PDS PVL that can be thrown at it. As its documentation boasts, I am sure that it is quite capable of parsing any PDS PVL that you can find.

If you are writing in Java and need to parse some PDS PVL, there are several handy classes in the PIRL.PVL Java package (part of the PIRL Java Packages) ready for you to instantiate and use.

Finally, if you are writing in C++, you can use the idaeim::PVL library (part of the idaeim libraries) to parse your PDS PVL. This library provides customized parameter iterators and other solid C++ constructs which make it easy to work with.

The Java and C++ versions have the advantage of building on the robust heritage of the PPVL C version, and are capable of parsing the most gnarly PDS PVL that you can find, but are also quite suitable for well-behaved PDS PVL and everyday usage.