jcamp

A set of Python utilities for reading JCAMP-DX files.

https://github.com/nzhagen/jcamp

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.1%) to scientific vocabulary
Last synced: 7 months ago · JSON representation ·

Repository

A set of Python utilities for reading JCAMP-DX files.

Basic Info
  • Host: GitHub
  • Owner: nzhagen
  • License: mit
  • Language: Python
  • Default Branch: master
  • Size: 7.87 MB
Statistics
  • Stars: 54
  • Watchers: 10
  • Forks: 33
  • Open Issues: 2
  • Releases: 0
Created over 12 years ago · Last pushed 7 months ago
Metadata Files
Readme Contributing License Citation

README.md

jcamp

Overview

A set of Python utilities for reading JCAMP-DX 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) 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)

Writing JCAMP-DX format files

The jcamp_writefile() function is used to write out a file given an input data dictionary. Note that the dictionary must have two required entries: x and y, giving the primary data to write. The remainder of the dictionary is written into the file header.

The core of the jcamp_writefile() function is the jcamp_write() function, which converts the input data dictionary to a long string, while the jcamp_writefile() function simply takes that string an writes it to a file. The reason for separating the two here is that it allows one to use the writing functions independent of files, or of directly exporting JCAMP-DX formats to software tools that take such strings as input.

Contributing

Your contributions and hints are welcome.

See CONTRIBUTING.md for details.

License

jcamp is licensed under the MIT License - see the LICENSE.txt file for details

Owner

  • Name: nh
  • Login: nzhagen
  • Kind: user

Citation (citation.bib)

 @misc{nzhagen_2013,
 	title={jcamp: A set of python utilities for reading JCAMP-DX files},
	url={https://github.com/nzhagen/jcamp},
	publisher={GitHub},
	journal={Github repository},
	author={N. Hagen},
	year={2013},
	month={Jul}
}

GitHub Events

Total
  • Issues event: 5
  • Watch event: 2
  • Issue comment event: 7
  • Push event: 4
  • Pull request event: 1
  • Fork event: 1
Last Year
  • Issues event: 5
  • Watch event: 2
  • Issue comment event: 7
  • Push event: 4
  • Pull request event: 1
  • Fork event: 1

Committers

Last synced: about 2 years ago

All Time
  • Total Commits: 132
  • Total Committers: 17
  • Avg Commits per committer: 7.765
  • Development Distribution Score (DDS): 0.606
Past Year
  • Commits: 18
  • Committers: 2
  • Avg Commits per committer: 9.0
  • Development Distribution Score (DDS): 0.444
Top Committers
Name Email Commits
Nathan Hagen n****n@g****m 52
nzhagen a****d@g****m 18
Benjamin ABEL b****6@g****m 11
Lars Kruse k****e@s****m 9
Simon Dollinger s****r@m****m 8
Nicolas Patry n****s@k****r 7
Thomas Alexander t****8@g****m 6
Your Name y****u@e****m 5
nh nh@d****n 4
Kyle Niemeyer k****r@g****m 3
Raphael Proux r****x@e****m 3
Alessandro Ferrari a****4@g****m 1
Bronson Philippa b****a@g****m 1
Jamie Cho j****e@g****m 1
Jamie Cho j****o@g****m 1
MartinTa M****r@g****t 1
Nathan Hagen n****n@r****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 16
  • Total pull requests: 29
  • Average time to close issues: over 1 year
  • Average time to close pull requests: about 2 months
  • Total issue authors: 13
  • Total pull request authors: 13
  • Average comments per issue: 3.44
  • Average comments per pull request: 1.66
  • Merged pull requests: 24
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 1.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sumpfralle (3)
  • raphaelproux (2)
  • RussBowers (1)
  • borondics (1)
  • datmdoan (1)
  • bastigw (1)
  • nmnori (1)
  • myw (1)
  • ocefpaf (1)
  • mbtns (1)
  • muammar (1)
  • di0nys0s (1)
  • hadas-equinom (1)
Pull Request Authors
  • sumpfralle (6)
  • sdollinger (6)
  • raphaelproux (3)
  • taalexander (3)
  • frenchytheasian (2)
  • jamieleecho (2)
  • kyleniemeyer (1)
  • BavYeti (1)
  • MartinTa (1)
  • Narsil (1)
  • bronsonp (1)
  • ghost (1)
  • Ferryistaken (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 2,216 last-month
  • Total docker downloads: 11
  • Total dependent packages: 0
  • Total dependent repositories: 4
  • Total versions: 6
  • Total maintainers: 1
pypi.org: jcamp

A set of Python utilities for reading JCAMP-DX files.

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 4
  • Downloads: 2,216 Last month
  • Docker Downloads: 11
Rankings
Docker downloads count: 3.5%
Dependent packages count: 7.3%
Forks count: 7.5%
Dependent repos count: 7.6%
Average: 8.2%
Stargazers count: 9.6%
Downloads: 13.9%
Maintainers (1)
Last synced: 7 months ago