Metadata-Version: 2.1
Name: ntfit
Version: 2.2.2
Summary: nonuniform-temperature fitting
Home-page: https://gitlab.com/nam5312/ntfit
Author: Nathan Malarich
Author-email: nathan.malarich@colorado.edu
License: UNKNOWN
Platform: UNKNOWN
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
Classifier: Programming Language :: Python :: 3.6
Description-Content-Type: text/markdown
License-File: LICENSE.md

# Non-uniform Temperature Fitting (NTfit)

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7109070.svg)](https://doi.org/10.5281/zenodo.7109070)
[![License](https://img.shields.io/badge/License-BSD%203-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![PyPI](https://badge.fury.io/py/ntfit.svg)](https://badge.fury.io/py/ntfit)

Nonuniform-temperature fitting code, to extract spatial temperature variations along a laser path. For high-temperature gas diagnostics.

In support of the 2-part paper series N.A. Malarich and G.B. Rieker, "Resolving nonuniform temperature distributions with single-beam absorption spectroscopy"

Nonuniform-temperature fitting is a two-step process. 
The Python package ntfit has sub-packages for each step.
1) `ntfit.spectrafit`: Extract linestrengths from broadband spectrum with E"-binning.
2) `ntfit.tdist`: Fit temperature distribution from linestrength fit in (1) with Tikhonov regularization.

For help running the fits, check out `examples/Example_td.py`, or the associated .ipynb (Jupyter Notebook) file.

## Should I use this code?
 
If you are fitting temperature from an absorption spectrum with more than two visible absorption features, then try it.

You might not have great success if
1) You don't have an accurate lineshape model for many of your absorption features
2) You have multiple absorbing species in your spectral fitting window. (This was designed for a pure H2O spectrum. However, if you are, say, fitting CO2, you can subtract out the nominal background absorption of your weaker H2O lines first and then try this code for CO2)
3) Check the lower-state energies of your strongest absorption features. If they are clumped together around 1 or 2 values, all the E" within 10% of each other, then your spectrum might not have enough information. However, if you have weaker absorption features above your noise floor but buried underneath stronger absorption features, then this might be exactly the code you want (see Figs 2, 8 of [my paper](https://arxiv.org/abs/2011.06638) ).


## Package requirements
Your computer must already have the following Python packages:
This package developed on WinPython64-3680, using
```
python3.6.8
numpy=1.16.2
matplotlib=3.3.4
scipy=1.2.1
```
NTfit also includes [HAPI](https://github.com/hitranonline/hapi), available under MIT license. 
NTfit changed HAPI version 1.1.0.9.6 lineshape equations (power-law temperature dependence) from original HAPI to improve high-temperature acuracy.
See `ntfit/hapi/hapi_combustion.py` docstring for details.
Partition functions are calculated using TIPS2017.



## References
If you use this package, please cite the following articles.
for E"-bin fitting with `HAPI`:

* R.V. Kochanov, I.E. Gordon, L.S. Rothman, P. Wcislo, C. Hill, J.S. Wilzewski, 
   HITRAN Application Programming Interface (HAPI): A comprehensive approach to working 
   with spectroscopic data, J. Quant. Spectrosc. Radiat. Transfer 177, 15-30 (2016) 
   DOI: [10.1016/j.jqsrt.2016.03.005](https://www.doi.org/10.1016/j.jqsrt.2016.03.005).

* N.A. Malarich and G.B. Rieker, "Resolving nonuniform temperature distributions with single-beam absorption spectroscopy. Part II: Implementation from broadband spectra" JQSRT (2021) 
DOI: [10.1016/j.jqsrt.2021.107805](https://www.doi.org/10.1016/j.jqsrt.2021.107805)

* (time-domain fitting) R.K. Cole, A.S. Makowiecki, Z. Hoghooghi, G.B. Rieker, "Baseline-free Quantitative Absorption Spectroscopy Based on Cepstral Analysis" Optics Express 27 (2019) 
DOI: [10.1364/OE.27.037920](https://www.doi.org/10.1364/OE.27.037920).

for `ntfit.tdist`:

* N.A. Malarich and G.B. Rieker, "Resolving nonuniform temperature distributions with single-beam absorption spectroscopy. Part I: Theoretical capabilities and limitations" JQSRT (2021) 
DOI: [10.1016/j.jqsrt.2020.107455](https://www.doi.org/10.1016/j.jqsrt.2020.107455)


##  Author

[Nathan Malarich](https://nam5312.gitlab.io/personal_website/) (<nathan.malarich@colorado.edu>)

# Change Log

## [2.2.2] - 2024-08-16
- less buggy handling of full spectrum bandwidth vs subrange for time-domain fit

## [2.2.1] -2024-08-15
- Added molefraction-column result to temperature inversion

## [2.2] - 2024-08-10
### Changed
- `fit_snorm_width_shift()` scales Lorentz-width and shift of original model, rather than recalculating Voigt lineshapes each iteration. Huge speed and stability improvements at a small cost of accuracy for E"-bins having lines with varied air-lineshape coefficients. 
- `p_rat` a Lorentz-scaling, not a pressure-ratio. Values << 1, detect magnitude or saved fits for backwards compatibility.
- changed several variable names to be (hopefully) more intuitive and following Python style guide
- Absorption models calculated further into wings
### Added
- r-squared fit statistics to ntfit.spectrafit


## [2.1] - 2022-09-23
### Changed
- ntfit now a separate sub-package, compatible with pip install
- `hapi` sub-package has separate file for Q(T) tables
- Removed uniform_fit example, as lookup table is much more efficient way to fit temperature
- Tikhonov regularization module now `ntfit.tdist`
- E"-bin spectral-fitting now `ntfit.spectrafit`

## [2.0] - 2021-03-01
### Added
- E"-bin spectral fitting package with hapi

