Package: jcamp
# jcamp## OverviewA set of Python utilities for reading [JCAMP-DX](http://www.jcamp-dx.org/) files.The following features are supported:JCAMP-DX are parsedxvalues are normalized to wavelength values (in microns)yvalues are interpreted (optional)A few example datasets are provided.## InstallationYou can download and install the latest version of this software from the Python package index ([PyPI](https://pypi.org/)) as follows:`shell pip install--upgradejcamp `## Parsing a fileThejcamp_reader()function takes a filename as input, and returns a dictionary containing the data found in the file.
Specifically, the keys contained in the dictionary are:The field names found in the file’s header, with values being int- or float-type if the corresponding field is a numerical type, or a string-type otherwise.Two arraysxandy, giving the scaled values of the data points (scaled according to thexfactorandyfactorfields in the header, if they exist).The units ofxandyare whatever are indicated in the header fieldsxunitsandyunits, if these exist.If the input is a compound file, then the returned dictionary will contain achildrenfield.
This field is an array of dictionaries that each represent a block.Thejcamp_calc_xsec()function is intended to takes as input the result of thejcamp_reader()function and to convert thexdata to wavelength in microns, and theydata to cross-section in units of m^2 for gas concentration of 1ppm at standard atmospheric pressure and temperature, across a path length of 1 meter.
Thejcamp_calc_xsec()function takes as input the data dictionaryjcamp_dict, and manipulates that dictionary directly without having a separate return value.
Changes to the dictionary may including adding the fields:wavelengths: the array of wavelength values (in microns) for each data pointwavenumbers: the array of wavenumber values (in cm^-1) for each data pointxsec: the array of cross-section values (in units of m^2 at 1ppm.m)and modifying the fields:xunits: micronyunits: m^2 at 1ppm.mThe optional argumentswavemin,wavemaxare used if the user wishes to truncate the data to only a desired spectral range.
For example, settingwavemin=8.0andwavemax=12.0means that the returned data arrays will only contain data corresponding to those wavlengths.
If theskip_nonquantoptional input argument is used, then any input spectrum that does not have the completepath_lengthandpartial_pressurefields in its dictionary will be passed without modification (That is, no conversion to quantitative cross-section will be attempted).
If this option is set to True, then if the code finds missing data, it will attempt to generate a quantitative cross-section by guessing the missing values.
Based upon NIST’s infrared database, typical values for guessing here arepartial_pressure = 150.0 mmHgandpath length = 0.1 m.You can view a notebook demo in the doc folder to see how you can produce a series of plots showing spectra.## jcamp filesThe repository comes with four folders containing JCAMP-format files:infrared_spectra/,mass_spectra/,raman_spectra/, anduvvis_spectra.
These were downloaded from freely-available internet databases, and can be used as example format files.## Using jcamp for web queriesIn order to usejcampfor online queries rather than static text files, we can use the following procedure with therequestspackage:`python response = requests.get(something) content = response.content.splitlines() content =[line.decode("utf-8")for line in content] data_dict = jcamp_read(content) `## ContributingYour contributions and hints are welcome.See [CONTRIBUTING.md](CONTRIBUTING.md) for details.## Licensejcampis licensed under the MIT License - see the [LICENSE.txt](./LICENSE.txt) file for details