Index Module Index Search Page

qnd.pdbf module

Pure python QnD wrapper for PDB files.

Information on the PDB file format is somewhat hard to come by. Try the SILO github repo https://github.com/LLNL/Silo esp. src/pdb/ and src/score/ dirs. Also the end of the QND file pdbparse.py has a long comment with a detailed description.

Note that yorick-generated PDB files are version II, not version III. Also, yorick pointers are written (by default) in a yorick-specific format. Since yorick readability has held back many application codes (the LEOS library and LLNL rad-hydro codes used for ICF design), most of the dwindling legacy PDB files are version II. Hence, this implementation focuses on the version III format, and the version I format is supported only for reading.

Furthermore, this implementation only supports IEEE 754 4 and 8 byte floating point formats, since those are the only unambiguous floating point formats supported by numpy. Fortunately, this covers all modern PDB files likely to show up in practice, so we have no significant incentive to do the work required to support exotic formats.

qnd.pdbf.openpdb(filename, mode='r', auto=1, **kwargs)[source]

Open PDB file or family, and wrap it in a QnD QGroup.

Parameters:
  • filename (str) – Name of file to open. See notes below for file family.
  • mode (str) – One of ‘r’ (default, read-only), ‘r+’ (read-write, must exist), ‘a’ (read-write, create if does not exist), ‘w’ (create, clobber if exists), ‘w-’ (create, fail if exists).
  • auto (int) – The intial state of auto-read mode. If the QGroup handle returned by openh5 is f, then f.varname reads an array variable, but not a subgroup when auto=1, the default. With auto=0, the variable reference reads neither (permitting later partial reads in the case of array variables). With auto=2, a variable reference recursively reads subgroups, bringing a whole tree into memory.
  • **kwargs – Other keywords. The maxsize keyword sets the size of files in a family generated in recording==1 mode; a new file will begin when the first item in a new record would begin beyond maxsize. The default maxsize is 128 MiB (134 MB). The order keyword can be ‘>’ or ‘<’ to force the byte order in a new file; by default the byte order is the native order. File families always have the same order for every file, so order is ignored if any files exist.
Returns:

f – A file handle implementing the QnD interface.

Return type:

QGroup

Notes

The filename may be an iterable, one string per file in order. The sequence may extend beyond the files which actually exist for ‘r+’, ‘a’, ‘w’, or ‘w-’ modes.

Alternatively filename specifies a family if it contains shell globbing wildcard characters. Existing matching files are sorted first by length, then alphabetically (ensuring that ‘file100’ comes after ‘file99’, for example). If there is only a single wildcard group, it also serves to define a sequence of future family names beyond those currently existing for ‘r+’, ‘a’, ‘w’, or ‘w-’ modes. A ‘?’ pattern is treated the same as a ‘[0-9]’ pattern if all its matches are digits or if the pattern matches no existing files. Similarly, a ‘*’ acts like the minimum number of all-digit matches, or three digits if there are no matches.