vibrav.base module¶
Base module¶
Handles the resource files.
- vibrav.base.list_resource(full_path=False, return_both=False, search_string='', rel_path=False)[source]¶
Get all of the available resource files in the static directory.
- Parameters:
full_path (
bool
, optional) – Return the absolute path of the resource files. Defaults toFalse
.return_both (
bool
, optional) – Return both the absolute paths and resource files. Defaults toFalse
.search_string (
str
, optional) – Regex string to limit the number of entries to return. Defaults to''
.rel_path (
bool
, optional) – Return the relative path instead of the absolute path to resource files. Good for testing code. Defaults toFalse
.
- Returns:
resource_files (
list
) – Resource file list depending on the input parameters.
Examples
The usage of the this function is as follows.
For a simple list of all the available resource files.
>>> print(list_resource()) ['adf-ch4-atom.csv.xz', 'adf-ch4-freq.t21.ascii.xz', 'adf-ch4-frequency.csv.xz', 'adf-ethane-atom.csv.xz', 'adf-ethane-frequency.csv.xz', 'adf-ethane-ts-freq.t21.ascii.xz', 'g16-nitromalonamide-freq.out.xz', 'g16-nitromalonamide-zpvc-data.tar.xz', 'boltz-dist-full-test.csv.xz', 'nien3-1-0.02-delta.dat.xz', 'nien3-1-0.02-freq.dat.xz', 'nien3-1-0.04-delta.dat.xz', 'nien3-1-0.04-freq.dat.xz', 'nien3-1-0.08-delta.dat.xz', 'nien3-1-0.08-freq.dat.xz', 'nien3-2-0.02-delta.dat.xz', 'nien3-2-0.02-freq.dat.xz', 'nien3-2-0.04-delta.dat.xz', 'nien3-2-0.04-freq.dat.xz', 'nien3-2-0.08-delta.dat.xz', 'nien3-2-0.08-freq.dat.xz', 'nien3-frequency-data.csv.xz', 'nitromalonamide-zpvc-config.conf', 'nitromalonamide-zpvc-dat-files.tar.xz', 'nitromalonamide-zpvc-geometry.csv.xz', 'nitromalonamide-zpvc-grad.dat.xz', 'nitromalonamide-zpvc-prop.dat.xz', 'nitromalonamide-zpvc-results.csv.xz', 'molcas-rassi-nien-degen-so-energy.csv.xz', 'molcas-rassi-nien-energy.csv.xz', 'molcas-rassi-nien-oscillators.csv.xz', 'molcas-rassi-nien-sf-angmom.csv.xz', 'molcas-rassi-nien-sf-dipole.csv.xz', 'molcas-rassi-nien-sf-quadrupole.csv.xz', 'molcas-rassi-nien.out.xz', 'molcas-ucl6-2minus-eigvectors.txt.xz', 'molcas-ucl6-2minus-energies.txt.xz', 'molcas-ucl6-2minus-oscillators.txt.xz', 'molcas-ucl6-2minus-sf-dipole-1.txt.xz', 'molcas-ucl6-2minus-so-dipole-1.txt.xz', 'molcas-ucl6-2minus-vibronic-config', 'molcas-ucl6-2minus-vibronic-coupling.tar.xz']
Options have been implemented in this function to make it easier to see what resource files there are for a particular type of resource list. Below we show how to get all the resource files that are linked to an ADF calculation.
>>> print(list_resource(search_string='adf')) ['adf-ch4-atom.csv.xz', 'adf-ch4-freq.t21.ascii.xz', 'adf-ch4-frequency.csv.xz', 'adf-ethane-atom.csv.xz', 'adf-ethane-frequency.csv.xz', 'adf-ethane-ts-freq.t21.ascii.xz']
Similarly, one can view all of the resource files that are used for the ZPVC calculations.
>>> print(list_resource(search_string='zpvc')) ['g16-nitromalonamide-zpvc-data.tar.xz', 'nitromalonamide-zpvc-config.conf', 'nitromalonamide-zpvc-dat-files.tar.xz', 'nitromalonamide-zpvc-geometry.csv.xz', 'nitromalonamide-zpvc-grad.dat.xz', 'nitromalonamide-zpvc-prop.dat.xz', 'nitromalonamide-zpvc-results.csv.xz']
Or, one can view all of the resource files that are an ascii Tape21 file.
>>> print(list_resource(search_string='ascii')) ['adf-ch4-freq.t21.ascii.xz', 'adf-ethane-ts-freq.t21.ascii.xz']
Note, these file are in separate directories as shown with the next input parameter
full_path
along with therel_path
parameter for the sake of the example. The command was executed in the path where vibrav was cloned.>>> print(list_resource(full_path=True, search_string='ascii', rel_path=True)) ['vibrav/static/adf/ch4/adf-ch4-freq.t21.ascii.xz', 'vibrav/static/adf/ethane/adf-ethane-ts-freq.t21.ascii.xz']
We can also return both the paths to the resource files along with the filenames of the resource files.
>>> print(list_resource(full_path=True, search_string='ascii', rel_path=True)) [['vibrav/static/adf/ch4/adf-ch4-freq.t21.ascii.xz', 'vibrav/static/adf/ethane/adf-ethane-ts-freq.t21.ascii.xz'], ['adf-ch4-freq.t21.ascii.xz', 'adf-ethane-ts-freq.t21.ascii.xz']]
- vibrav.base.resource(file)[source]¶
Get the requested resource file from the static directory.
- Parameters:
file (
str
) – Name of resource file.- Returns:
resource_path (
str
) – Absolute path to the resource file.- Raises:
ValueError – When there is more than one resource file found with that same name.
FileNotFoundError – When the resource file cannot be found in the static directory.
Examples
The usage of this function is fairly straightforward where the code below can be used to get the filepath of the resource file.
>>> resource('adf-ch4-atom.csv.xz') '/path/to/vibrav/vibrav/static/adf/ch4/adf-ch4-atom.csv.xz'
To view a full list of resource files please see
vibrav.base.list_resource()