jcamp


Namejcamp JSON
Version 1.2.2 PyPI version JSON
download
home_pagehttps://github.com/nzhagen/jcamp
SummaryJCAMP-DX file reader
upload_time2022-12-25 05:36:19
maintainer
docs_urlNone
authorNathan Hagen
requires_python
license
keywords jcamp jcamp-dx spectra
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # jcamp

## Overview

A set of Python utilities for reading [JCAMP-DX](http://www.jcamp-dx.org/) files.

The following features are supported:

* JCAMP-DX are parsed
* `x` values are normalized to wavelength values (in microns)
* `y` values are interpreted (optional)

A few example datasets are provided.


## Installation

You can download and install the latest version of this software from the Python package index ([PyPI](https://pypi.org/)) as follows:

```shell
pip install --upgrade jcamp
```


## Parsing a file

The `jcamp_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:

1. 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.
2. Two arrays `x` and `y`, giving the scaled values of the data points (scaled according to the `xfactor` and `yfactor` fields in the header, if they exist).

The units of `x` and `y` are whatever are indicated in the header fields `xunits` and `yunits`, if these exist.

If the input is a compound file, then the returned dictionary will contain a `children` field.
This field is an array of dictionaries that each represent a block.

The `jcamp_calc_xsec()` function is intended to takes as input the result of the `jcamp_reader()` function and to convert the `x` data to wavelength in microns, and the `y` data 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.
The `jcamp_calc_xsec()` function takes as input the data dictionary `jcamp_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 point
* wavenumbers: the array of wavenumber values (in cm^-1) for each data point
* xsec: the array of cross-section values (in units of m^2 at 1ppm.m)

and modifying the fields:

* xunits: micron
* yunits: m^2 at 1ppm.m

The optional arguments `wavemin`, `wavemax` are used if the user wishes to truncate the data to only a desired spectral range.
For example, setting `wavemin=8.0` and `wavemax=12.0` means that the returned data arrays will only contain data corresponding to those wavlengths.
If the `skip_nonquant` optional input argument is used, then any input spectrum that does not have the complete `path_length` and `partial_pressure` fields 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 are `partial_pressure = 150.0 mmHg` and `path 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 files

The repository comes with four folders containing JCAMP-format files: `infrared_spectra/`, `mass_spectra/`, `raman_spectra/`, and `uvvis_spectra`.
These were downloaded from freely-available internet databases, and can be used as example format files.


## Using jcamp for web queries

In order to use `jcamp` for online queries rather than static text files, we can use the following procedure with the `requests` package:

```python
response = requests.get(something)
content = response.content.splitlines()
content = [line.decode("utf-8") for line in content]
data_dict = jcamp_read(content)
```


## Contributing

Your contributions and hints are welcome.

See [CONTRIBUTING.md](CONTRIBUTING.md) for details.


## License

`jcamp` is licensed under the MIT License - see the [LICENSE.txt](./LICENSE.txt) file for details
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nzhagen/jcamp",
    "name": "jcamp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "jcamp,jcamp-dx,spectra",
    "author": "Nathan Hagen",
    "author_email": "and.the.light.shattered@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/75/9e/d01a2f6bbacd90c5a3a7f53fb496b7968613cdcefda7d307bfb023eebcf5/jcamp-1.2.2.tar.gz",
    "platform": null,
    "description": "# jcamp\n\n## Overview\n\nA set of Python utilities for reading [JCAMP-DX](http://www.jcamp-dx.org/) files.\n\nThe following features are supported:\n\n* JCAMP-DX are parsed\n* `x` values are normalized to wavelength values (in microns)\n* `y` values are interpreted (optional)\n\nA few example datasets are provided.\n\n\n## Installation\n\nYou can download and install the latest version of this software from the Python package index ([PyPI](https://pypi.org/)) as follows:\n\n```shell\npip install --upgrade jcamp\n```\n\n\n## Parsing a file\n\nThe `jcamp_reader()` function takes a filename as input, and returns a dictionary containing the data found in the file.\nSpecifically, the keys contained in the dictionary are:\n\n1. 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.\n2. Two arrays `x` and `y`, giving the scaled values of the data points (scaled according to the `xfactor` and `yfactor` fields in the header, if they exist).\n\nThe units of `x` and `y` are whatever are indicated in the header fields `xunits` and `yunits`, if these exist.\n\nIf the input is a compound file, then the returned dictionary will contain a `children` field.\nThis field is an array of dictionaries that each represent a block.\n\nThe `jcamp_calc_xsec()` function is intended to takes as input the result of the `jcamp_reader()` function and to convert the `x` data to wavelength in microns, and the `y` data 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.\nThe `jcamp_calc_xsec()` function takes as input the data dictionary `jcamp_dict`, and manipulates that dictionary directly without having a separate return value.\nChanges to the dictionary may including adding the fields:\n\n* wavelengths: the array of wavelength values (in microns) for each data point\n* wavenumbers: the array of wavenumber values (in cm^-1) for each data point\n* xsec: the array of cross-section values (in units of m^2 at 1ppm.m)\n\nand modifying the fields:\n\n* xunits: micron\n* yunits: m^2 at 1ppm.m\n\nThe optional arguments `wavemin`, `wavemax` are used if the user wishes to truncate the data to only a desired spectral range.\nFor example, setting `wavemin=8.0` and `wavemax=12.0` means that the returned data arrays will only contain data corresponding to those wavlengths.\nIf the `skip_nonquant` optional input argument is used, then any input spectrum that does not have the complete `path_length` and `partial_pressure` fields in its dictionary will be passed without modification (That is, no conversion to quantitative cross-section will be attempted).\nIf 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.\nBased upon NIST's infrared database, typical values for guessing here are `partial_pressure = 150.0 mmHg` and `path length = 0.1 m`.\n\nYou can view a notebook demo in the doc folder to see how you can produce a series of plots showing spectra.\n\n\n## jcamp files\n\nThe repository comes with four folders containing JCAMP-format files: `infrared_spectra/`, `mass_spectra/`, `raman_spectra/`, and `uvvis_spectra`.\nThese were downloaded from freely-available internet databases, and can be used as example format files.\n\n\n## Using jcamp for web queries\n\nIn order to use `jcamp` for online queries rather than static text files, we can use the following procedure with the `requests` package:\n\n```python\nresponse = requests.get(something)\ncontent = response.content.splitlines()\ncontent = [line.decode(\"utf-8\") for line in content]\ndata_dict = jcamp_read(content)\n```\n\n\n## Contributing\n\nYour contributions and hints are welcome.\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n\n## License\n\n`jcamp` is licensed under the MIT License - see the [LICENSE.txt](./LICENSE.txt) file for details",
    "bugtrack_url": null,
    "license": "",
    "summary": "JCAMP-DX file reader",
    "version": "1.2.2",
    "split_keywords": [
        "jcamp",
        "jcamp-dx",
        "spectra"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "48e2ed889006d545e25ac1231fd37e1c",
                "sha256": "c207da4544080d9d285692fb1ed9f57e4580fd76c6589c8b347a1303f26a8775"
            },
            "downloads": -1,
            "filename": "jcamp-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "48e2ed889006d545e25ac1231fd37e1c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10972,
            "upload_time": "2022-12-25T05:36:19",
            "upload_time_iso_8601": "2022-12-25T05:36:19.278197Z",
            "url": "https://files.pythonhosted.org/packages/75/9e/d01a2f6bbacd90c5a3a7f53fb496b7968613cdcefda7d307bfb023eebcf5/jcamp-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-25 05:36:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "nzhagen",
    "github_project": "jcamp",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "jcamp"
}
        
Elapsed time: 0.07970s