Skip to main content

CARSpy

https://img.shields.io/badge/License-BSD%203--Clause-blue.svg https://img.shields.io/pypi/v/carspy.svg https://img.shields.io/pypi/pyversions/carspy.svg https://travis-ci.com/chuckedfromspace/carspy.svg Documentation Status

Synthesizing and fitting coherent anti-Stokes Raman spectra in Python.

Background

Having no access to the source codes of any of the existing CARS programs, I started this project simply as a way to learn more about CARS. I ended up spending a lot of time sifting through literatures from the past decades, trying to figure out what were done to analyze experimental CARS spectra and how they were implemented. The latter proved rather challenging as specific implementations weren’t always laid out in sufficient (mathematical) details to facilitate comprehension and replication (e.g., things as trivial as units for different constants weren’t always made clear in some publications).

In an effort to put together a fully-functioning CARS fitting program, I thought it would perhaps benefit other CARS practitioners (especially the newcomers) if I open source my implementations. I hope to also benefit from this transparency and openness to public scrutiny. Although the “draft” code (not available in this public repo) already lives up to my original purpose (least-square fit of experimental broadband CARS spectra), it is most likely not error-free and has a lot of room left for improvement. Therefore, I plan to rewrite the important modules (spectrum synthesis and least-square fit) and slowly bring all features (see below) up to date. I am also looking forward to feedbacks and potential collaborators from the community.

Quick start

$ pip install carspy

See installation guide for alternative methods.

Live demonstration

To try out the basic functions of carspy, head over to the Live demo, which is a webapp built with Plotly/Dash and hosted on Heroku to showcase how CARS spectrum could be synthesized and fitted with carspy. The computation/loading speed is largely limited by the cloud server and Internet speed. For a much better performance, download or fork the carspy app repository and run the app locally.

  • Synthesize CARS spectrum

https://raw.githubusercontent.com/chuckedfromspace/carspy-dash/main/assets/demo1.gif
  • Least-square-fit of a synthesized spectrum

https://raw.githubusercontent.com/chuckedfromspace/carspy-dash/main/assets/demo2.gif

Features

  • CARSpy (stands for Coherent Anti-Stokes Raman Spectroscopy):

carspy structure
  • The CARS model:

cars model

Highlights

  • Readily extendable for species other than N2 and for other CARS setup other than typical broadband CARS.

  • Option to incorporate equilibrium composition using an external chemical equilibrium calculator (such as cantera), such that temperature is the only fitting parameter for thermometry.

  • Vibrational and rotational nonequilibrium: vibrational temperature can be varied independently from rotational temperature.

Comparisons with CARSFT

vs_CARSFT_01

Figure 1 Synthesized CARS spectra in N2 at 1 atm, 2400 K, with a pump linewidth of 0.5 cm-1, using Voigt lineshape and cross-coherence convolution.

vs_CARSFT_02

Figure 2 Synthesized CARS spectra in N2 at 10 atm, 2400 K, with a pump linewidth of 0.5 cm-1, using modified exponential gap law (MEG) and cross-coherence convolution.

Roadmap

The above features currently present in the draft code will be gradually improved and included in the main branch. Here is a tentative plan:

  • (Done) Module for synthesizing CARS spectra (optional with cantera)

  • (Done) Module for least-square fit (optional with lmfit)

  • (Done) Parallel processing example with joblib

  • (Mid-term) EMEG and XMEG for high-pressure combustion environments

  • (Long-term) Enrich documentation

  • (Long-term) Other common diatomic species

  • (Long-term) Dualpump/Wide CARS

Citation

Please consider citing this repository if you use carspy for your publications as:

@misc{Yin2021,
  author = {Yin, Zhiyao},
  title = {CARSpy: Synthesizing and fitting coherent anti-Stokes Raman spectra in Python},
  year = {2021},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/chuckedfromspace/carspy}}
}

Acknowledgement

  • A copy of the NRC report (TR-GD-013_1989) was kindly provided by Dr. Gregory Smallwood and his colleagues at NRC, which has significantly eased the difficulty of understanding some of the key theories in synthesizing CARS spectra.

  • This package was initially created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Change Log

0.6.1 (2021-07-07)

  • Fix the discontinuity problem in the asymmetric Voigt profile

0.6.0 (2021-07-05)

  • Add a peak-finding function for calibrating the spectrometer based on Ar or Hg spectra.

  • Implement a fitting routine for the slit function based either on asymmetric Gaussian or Voigt profiles.

0.5.0 (2021-05-17)

  • Add link to a standalone web application that demonstrates the basic functions for synthesizing CARS spectra

0.4.2 (2021-03-12)

  • Add missing json data files to the package.

0.4.1 (2021-03-10)

  • Implement an asymmetric “super” Voigt function for better fitting slit function.

0.4.0 (2021-03-03)

  • Implement least-square fitting routine with lmfit (optional).

  • Add documentations for the least-square fitting module.

  • Add usage examples for both synthesizing and fitting CARS spectra.

0.3.0 (2021-02-25)

  • Implement optional function for calculating local gas composition at chemical equilibrium using cantera.

  • Add documentations for secondary modules.

  • Add bibtex style references in documentations.

0.2.1 (2021-02-14)

  • Change Sphinx theme.

  • Add existing modules to docs.

  • Fix format errors in docstrings.

0.2.0 (2021-02-13)

  • Implement modules for synthesizing N2 CARS spectra.

0.1.0 (2021-02-13)

  • First release on PyPI.

Metadata

Release files for carspy 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for carspy 0.6.1
File Size Uploaded
carspy-0.6.1.tar.gz 34.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for carspy 0.6.1
File Interpreter ABI Platform
carspy-0.6.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 64.9 kB

Release files / carspy-0.6.1.tar.gz

Download URL carspy-0.6.1.tar.gz
Size 34.6 kB
Tags Source
SHA-256 checksum
How to use checksums
31056dddb028f333900279066f75de3063f3498fb2d9d4f930bf1fffd6f7c6e7
BLAKE2b-256 checksum
How to use checksums
0caba78778033f486e260597c389a222b3a6b49ddf28d46af18b8c8d152102fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.7

Release files / carspy-0.6.1-py2.py3-none-any.whl

Download URL carspy-0.6.1-py2.py3-none-any.whl
Size 30.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
342439b5ecf78d0e803034d8a8a59d33e176a8272863b3f3a03276d0c264026a
BLAKE2b-256 checksum
How to use checksums
744460f804c961d04bfba0604f337f48a77e1af767e8ceae3269fe8cc1757204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.7

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page