oilftir 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oilftir-0.1.1/LICENSE +21 -0
- oilftir-0.1.1/PKG-INFO +293 -0
- oilftir-0.1.1/README.md +259 -0
- oilftir-0.1.1/data/fresh_oil.txt +524 -0
- oilftir-0.1.1/data/ftir_example.sp +0 -0
- oilftir-0.1.1/data/library/oil_1.sp +0 -0
- oilftir-0.1.1/data/library/oil_2.sp +0 -0
- oilftir-0.1.1/data/library/oil_3.sp +0 -0
- oilftir-0.1.1/data/library/zddp_ftir.txt +664 -0
- oilftir-0.1.1/data/unknown_oil.sp +0 -0
- oilftir-0.1.1/docs/_build/html/.buildinfo +4 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/autoapi/index.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/autoapi/oilftir/astm_utils/index.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/autoapi/oilftir/index.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/environment.pickle +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/index.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/installation.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/.doctrees/quickstart.doctree +0 -0
- oilftir-0.1.1/docs/_build/html/_modules/index.html +296 -0
- oilftir-0.1.1/docs/_build/html/_modules/oilftir/astm_utils.html +1193 -0
- oilftir-0.1.1/docs/_build/html/_modules/oilftir.html +324 -0
- oilftir-0.1.1/docs/_build/html/_sources/autoapi/index.rst.txt +11 -0
- oilftir-0.1.1/docs/_build/html/_sources/autoapi/oilftir/astm_utils/index.rst.txt +381 -0
- oilftir-0.1.1/docs/_build/html/_sources/autoapi/oilftir/index.rst.txt +373 -0
- oilftir-0.1.1/docs/_build/html/_sources/index.rst.txt +57 -0
- oilftir-0.1.1/docs/_build/html/_sources/installation.rst.txt +38 -0
- oilftir-0.1.1/docs/_build/html/_sources/quickstart.rst.txt +140 -0
- oilftir-0.1.1/docs/_build/html/_static/basic.css +906 -0
- oilftir-0.1.1/docs/_build/html/_static/debug.css +69 -0
- oilftir-0.1.1/docs/_build/html/_static/doctools.js +149 -0
- oilftir-0.1.1/docs/_build/html/_static/documentation_options.js +13 -0
- oilftir-0.1.1/docs/_build/html/_static/file.png +0 -0
- oilftir-0.1.1/docs/_build/html/_static/graphviz.css +12 -0
- oilftir-0.1.1/docs/_build/html/_static/language_data.js +192 -0
- oilftir-0.1.1/docs/_build/html/_static/minus.png +0 -0
- oilftir-0.1.1/docs/_build/html/_static/plus.png +0 -0
- oilftir-0.1.1/docs/_build/html/_static/pygments.css +250 -0
- oilftir-0.1.1/docs/_build/html/_static/scripts/furo-extensions.js +0 -0
- oilftir-0.1.1/docs/_build/html/_static/scripts/furo.js +3 -0
- oilftir-0.1.1/docs/_build/html/_static/scripts/furo.js.LICENSE.txt +7 -0
- oilftir-0.1.1/docs/_build/html/_static/scripts/furo.js.map +1 -0
- oilftir-0.1.1/docs/_build/html/_static/searchtools.js +635 -0
- oilftir-0.1.1/docs/_build/html/_static/skeleton.css +296 -0
- oilftir-0.1.1/docs/_build/html/_static/sphinx_highlight.js +154 -0
- oilftir-0.1.1/docs/_build/html/_static/styles/furo-extensions.css +2 -0
- oilftir-0.1.1/docs/_build/html/_static/styles/furo-extensions.css.map +1 -0
- oilftir-0.1.1/docs/_build/html/_static/styles/furo.css +2 -0
- oilftir-0.1.1/docs/_build/html/_static/styles/furo.css.map +1 -0
- oilftir-0.1.1/docs/_build/html/autoapi/index.html +336 -0
- oilftir-0.1.1/docs/_build/html/autoapi/oilftir/astm_utils/index.html +870 -0
- oilftir-0.1.1/docs/_build/html/autoapi/oilftir/index.html +879 -0
- oilftir-0.1.1/docs/_build/html/genindex.html +514 -0
- oilftir-0.1.1/docs/_build/html/index.html +398 -0
- oilftir-0.1.1/docs/_build/html/installation.html +375 -0
- oilftir-0.1.1/docs/_build/html/objects.inv +7 -0
- oilftir-0.1.1/docs/_build/html/py-modindex.html +318 -0
- oilftir-0.1.1/docs/_build/html/quickstart.html +470 -0
- oilftir-0.1.1/docs/_build/html/search.html +308 -0
- oilftir-0.1.1/docs/_build/html/searchindex.js +1 -0
- oilftir-0.1.1/docs/conf.py +96 -0
- oilftir-0.1.1/docs/index.rst +57 -0
- oilftir-0.1.1/docs/installation.rst +38 -0
- oilftir-0.1.1/docs/quickstart.rst +140 -0
- oilftir-0.1.1/docs/requirements.txt +3 -0
- oilftir-0.1.1/example.py +127 -0
- oilftir-0.1.1/oilftir/.readthedocs.yaml +22 -0
- oilftir-0.1.1/oilftir/__init__.py +24 -0
- oilftir-0.1.1/oilftir/__pycache__/astm_utils.cpython-311.pyc +0 -0
- oilftir-0.1.1/oilftir/__pycache__/astm_utils.cpython-312.pyc +0 -0
- oilftir-0.1.1/oilftir/astm_utils.py +845 -0
- oilftir-0.1.1/oilftir.egg-info/PKG-INFO +293 -0
- oilftir-0.1.1/oilftir.egg-info/SOURCES.txt +77 -0
- oilftir-0.1.1/oilftir.egg-info/dependency_links.txt +1 -0
- oilftir-0.1.1/oilftir.egg-info/requires.txt +8 -0
- oilftir-0.1.1/oilftir.egg-info/top_level.txt +1 -0
- oilftir-0.1.1/output/comparison.png +0 -0
- oilftir-0.1.1/pyproject.toml +45 -0
- oilftir-0.1.1/setup.cfg +4 -0
- oilftir-0.1.1/setup.py +24 -0
oilftir-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NahueMendez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
oilftir-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oilftir
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: FTIR-based condition monitoring of lubricating oils — ASTM E2412 toolkit
|
|
5
|
+
Author: Nahuel Mendez
|
|
6
|
+
Author-email: Nahuel Mendez <nahueldanielmendez@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/NahueMendez/oilftir
|
|
9
|
+
Project-URL: LinkedIn, https://www.linkedin.com/in/ingnahuelmendez/
|
|
10
|
+
Keywords: ftir,astm-e2412,lubricating-oil,condition-monitoring,spectroscopy,tribology
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Intended Audience :: Manufacturing
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: numpy
|
|
25
|
+
Requires-Dist: pandas
|
|
26
|
+
Requires-Dist: scipy
|
|
27
|
+
Requires-Dist: matplotlib
|
|
28
|
+
Requires-Dist: pybaselines
|
|
29
|
+
Provides-Extra: specio
|
|
30
|
+
Requires-Dist: specio; extra == "specio"
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: requires-python
|
|
34
|
+
|
|
35
|
+
# oilftir
|
|
36
|
+
|
|
37
|
+
**FTIR-based condition monitoring of lubricating oils — ASTM E2412**
|
|
38
|
+
|
|
39
|
+
`oilftir` is a Python library for processing and analysing FTIR spectra of
|
|
40
|
+
used lubricating oils following the
|
|
41
|
+
[ASTM E2412](https://www.astm.org/e2412-23.html) standard.
|
|
42
|
+
It provides spectrum loading, baseline correction, net area integration for
|
|
43
|
+
all standard degradation and contamination bands, concentration estimation
|
|
44
|
+
from calibration curves, spectral library search (HQI), and publication-ready
|
|
45
|
+
plots.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
| Feature | Description |
|
|
52
|
+
|---|---|
|
|
53
|
+
| **Spectrum loading** | CSV / TXT and PerkinElmer `.sp` (optional) |
|
|
54
|
+
| **Baseline correction** | Modified polynomial (ModPoly) via `pybaselines` |
|
|
55
|
+
| **ASTM E2412 areas** | Oxidation, nitration, sulfation, water, glycol, petrol, diesel, ZDDP, soot |
|
|
56
|
+
| **Calibration** | Generic polynomial curve — bring your own standards |
|
|
57
|
+
| **Reference subtraction** | Least-squares scaling + difference spectrum |
|
|
58
|
+
| **Library search** | Hit Quality Index (HQI), parallel brute-force |
|
|
59
|
+
| **Plotting** | Dual-panel (absorbance + transmittance), multi-spectrum overlay |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install oilftir
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To read PerkinElmer `.sp` files, install the optional dependency:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
pip install oilftir[specio]
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### From source
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
git clone https://github.com/your-username/oilftir.git
|
|
79
|
+
cd oilftir
|
|
80
|
+
pip install -e .
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Quick start
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from oilftir.astm_utils import load_spectrum, remove_baseline, astm_areas
|
|
89
|
+
|
|
90
|
+
# Load and correct a spectrum
|
|
91
|
+
df, meta = load_spectrum("used_oil.csv", magnitude="A")
|
|
92
|
+
df = remove_baseline(df)
|
|
93
|
+
|
|
94
|
+
# Compute all ASTM E2412 band areas
|
|
95
|
+
areas = astm_areas(df)
|
|
96
|
+
print(areas)
|
|
97
|
+
# {
|
|
98
|
+
# 'oxidation': 0.2341,
|
|
99
|
+
# 'nitration': 0.0812,
|
|
100
|
+
# 'sulfation': 0.1503,
|
|
101
|
+
# 'water': 4.7620,
|
|
102
|
+
# 'glycol': 0.0000,
|
|
103
|
+
# 'fuel_petrol': 0.0034,
|
|
104
|
+
# 'fuel_diesel': 0.0198,
|
|
105
|
+
# 'antiwear_zddp': 8.3410,
|
|
106
|
+
# 'soot': 12.5000,
|
|
107
|
+
# }
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
See [`example.py`](example.py) for a full walkthrough including concentration
|
|
111
|
+
estimation, reference subtraction, plotting, and library search.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Input file format
|
|
116
|
+
|
|
117
|
+
Plain-text files must be two-column (wavenumber, amplitude), comma- or
|
|
118
|
+
space-delimited, with `#` for comment lines:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
# wavenumber (cm-1), absorbance
|
|
122
|
+
4000.0 0.0031
|
|
123
|
+
3999.0 0.0028
|
|
124
|
+
...
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## API reference
|
|
130
|
+
|
|
131
|
+
### Loading
|
|
132
|
+
|
|
133
|
+
```python
|
|
134
|
+
load_spectrum(path, magnitude='A') → (DataFrame, dict)
|
|
135
|
+
```
|
|
136
|
+
`magnitude`: `'A'` (absorbance) or `'T'` (transmittance, 0–1 or 0–100).
|
|
137
|
+
|
|
138
|
+
### Pre-processing
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
remove_baseline(df, units='A', poly_order=5) → DataFrame
|
|
142
|
+
scale_reference(df_sample, df_ref, units='A') → DataFrame
|
|
143
|
+
subtract_reference(df_sample, df_ref, wavenumber_range, units='A')
|
|
144
|
+
→ (y_diff, k, y_ref_scaled)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### ASTM E2412 band areas
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
astm_areas(df) → dict # all bands at once
|
|
151
|
+
area_oxidation(df) → float # 1670–1800 cm⁻¹
|
|
152
|
+
area_nitration(df) → float # 1600–1650 cm⁻¹
|
|
153
|
+
area_sulfation(df) → float # 1120–1180 cm⁻¹
|
|
154
|
+
area_water(df) → float # 3150–3500 cm⁻¹
|
|
155
|
+
area_glycol(df) → float # 1030–1100 cm⁻¹
|
|
156
|
+
area_fuel_petrol(df) → float # 745–755 cm⁻¹
|
|
157
|
+
area_fuel_diesel(df) → float # 805–815 cm⁻¹
|
|
158
|
+
area_antiwear_zddp(df) → float # 960–1025 cm⁻¹
|
|
159
|
+
soot_load(df) → float # absorbance at 2000 cm⁻¹ × 100
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
All area functions return a net integrated area in absorbance·cm⁻¹ (≥ 0).
|
|
163
|
+
|
|
164
|
+
### Calibration
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
area_to_concentration(area, calibration_areas, calibration_concentrations,
|
|
168
|
+
poly_order=3) → float
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Provide your own (area, concentration) calibration pairs — the function fits
|
|
172
|
+
a polynomial and evaluates it at `area`.
|
|
173
|
+
|
|
174
|
+
### Library search
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
library_search(query_path, library_dir, top_n=5, extension='*.sp')
|
|
178
|
+
→ list[dict] # sorted by HQI descending
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
hqi(x_query, y_query, x_ref, y_ref) → float # 0–100 %
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Plotting
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
plot_spectra(data_dict, title, xlim, ylim_A, ylim_T, save_path)
|
|
189
|
+
→ (fig, axes)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
`data_dict` format:
|
|
193
|
+
```python
|
|
194
|
+
{
|
|
195
|
+
"Label": {
|
|
196
|
+
"df": <DataFrame>, # required
|
|
197
|
+
"color": "steelblue", # optional
|
|
198
|
+
"alpha": 1.0, # optional
|
|
199
|
+
"linewidth": 1.5, # optional
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Dependencies
|
|
207
|
+
|
|
208
|
+
| Package | Purpose |
|
|
209
|
+
|---|---|
|
|
210
|
+
| `numpy` | Numerical operations |
|
|
211
|
+
| `pandas` | Spectrum data frames |
|
|
212
|
+
| `scipy` | Spearman correlation (HQI fallback) |
|
|
213
|
+
| `matplotlib` | Plotting |
|
|
214
|
+
| `pybaselines` | Baseline correction |
|
|
215
|
+
| `specio` *(optional)* | PerkinElmer `.sp` file reading |
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## Contributing
|
|
220
|
+
|
|
221
|
+
Contributions are welcome. Please open an issue or pull request on GitHub.
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
## Authors
|
|
225
|
+
`oilftir` was developed at the Chemistry Laboratory of CENADIF ([Centro Nacional de Desarrollo e Innovación Ferroviaria](https://www.argentina.gob.ar/transporte/fase/cenadif)), Argentina, in the context of used-oil condition monitoring for the local railway industry.
|
|
226
|
+
|
|
227
|
+
### Lead developer
|
|
228
|
+
|
|
229
|
+
**Nahuel Mendez** — R&D Engineer/Physical Data Scientist, CENADIF |
|
|
230
|
+
|
|
231
|
+
[](https://github.com/NahueMendez)
|
|
232
|
+
[](https://www.linkedin.com/in/ingnahuelmendez/)
|
|
233
|
+
[](mailto:nahueldanielmendez@gmail.com)
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
### Collaborators
|
|
237
|
+
|
|
238
|
+
| Name | Role |
|
|
239
|
+
| :--- | :--- |
|
|
240
|
+
| **Hernán Gomez Molino**, Eng. | Head of Laboratories, CENADIF |
|
|
241
|
+
| **Leandro Asens**, Eng. | Head of the Chemistry Laboratory, CENADIF |
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Citing
|
|
245
|
+
|
|
246
|
+
If you use `oilftir` in your research or academic work, please cite both the ASTM standard and this software library:
|
|
247
|
+
|
|
248
|
+
### 1. The Software Library
|
|
249
|
+
> Mendez, N., Gomez Molino, H., & Asens, L. (2026). *oilftir: A Python library for FTIR-based condition monitoring of lubricating oils following ASTM E2412*. https://doi.org/10.5281/zenodo.20137147
|
|
250
|
+
|
|
251
|
+
### 2. The Implemented Standard
|
|
252
|
+
> ASTM E2412-23, *Standard Practice for Condition Monitoring of Used Lubricants by Trend Analysis Using Fourier Transform Infrared (FT-IR) Spectrometry*, ASTM International, West Conshohocken, PA.
|
|
253
|
+
|
|
254
|
+
You can also use the following BibTeX entry for your reference manager:
|
|
255
|
+
|
|
256
|
+
```bibtex
|
|
257
|
+
@software{mendez_oilftir_2026,
|
|
258
|
+
author = {Mendez, Nahuel and Gomez Molino, Hern{\'a}n and Asens, Leandro},
|
|
259
|
+
title = {oilftir: A Python library for FTIR-based condition monitoring of lubricating oils following ASTM E2412},
|
|
260
|
+
month = may,
|
|
261
|
+
year = 2026,
|
|
262
|
+
publisher = {Zenodo},
|
|
263
|
+
doi = {10.5281/zenodo.20137147},
|
|
264
|
+
url = {doi.org}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
```
|
|
272
|
+
MIT License
|
|
273
|
+
|
|
274
|
+
Copyright (c) 2026 oilftir contributors
|
|
275
|
+
|
|
276
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
277
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
278
|
+
in the Software without restriction, including without limitation the rights
|
|
279
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
280
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
281
|
+
furnished to do so, subject to the following conditions:
|
|
282
|
+
|
|
283
|
+
The above copyright notice and this permission notice shall be included in all
|
|
284
|
+
copies or substantial portions of the Software.
|
|
285
|
+
|
|
286
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
287
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
288
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
289
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
290
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
291
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
292
|
+
SOFTWARE.
|
|
293
|
+
```
|
oilftir-0.1.1/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# oilftir
|
|
2
|
+
|
|
3
|
+
**FTIR-based condition monitoring of lubricating oils — ASTM E2412**
|
|
4
|
+
|
|
5
|
+
`oilftir` is a Python library for processing and analysing FTIR spectra of
|
|
6
|
+
used lubricating oils following the
|
|
7
|
+
[ASTM E2412](https://www.astm.org/e2412-23.html) standard.
|
|
8
|
+
It provides spectrum loading, baseline correction, net area integration for
|
|
9
|
+
all standard degradation and contamination bands, concentration estimation
|
|
10
|
+
from calibration curves, spectral library search (HQI), and publication-ready
|
|
11
|
+
plots.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
| Feature | Description |
|
|
18
|
+
|---|---|
|
|
19
|
+
| **Spectrum loading** | CSV / TXT and PerkinElmer `.sp` (optional) |
|
|
20
|
+
| **Baseline correction** | Modified polynomial (ModPoly) via `pybaselines` |
|
|
21
|
+
| **ASTM E2412 areas** | Oxidation, nitration, sulfation, water, glycol, petrol, diesel, ZDDP, soot |
|
|
22
|
+
| **Calibration** | Generic polynomial curve — bring your own standards |
|
|
23
|
+
| **Reference subtraction** | Least-squares scaling + difference spectrum |
|
|
24
|
+
| **Library search** | Hit Quality Index (HQI), parallel brute-force |
|
|
25
|
+
| **Plotting** | Dual-panel (absorbance + transmittance), multi-spectrum overlay |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install oilftir
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
To read PerkinElmer `.sp` files, install the optional dependency:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install oilftir[specio]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### From source
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/your-username/oilftir.git
|
|
45
|
+
cd oilftir
|
|
46
|
+
pip install -e .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from oilftir.astm_utils import load_spectrum, remove_baseline, astm_areas
|
|
55
|
+
|
|
56
|
+
# Load and correct a spectrum
|
|
57
|
+
df, meta = load_spectrum("used_oil.csv", magnitude="A")
|
|
58
|
+
df = remove_baseline(df)
|
|
59
|
+
|
|
60
|
+
# Compute all ASTM E2412 band areas
|
|
61
|
+
areas = astm_areas(df)
|
|
62
|
+
print(areas)
|
|
63
|
+
# {
|
|
64
|
+
# 'oxidation': 0.2341,
|
|
65
|
+
# 'nitration': 0.0812,
|
|
66
|
+
# 'sulfation': 0.1503,
|
|
67
|
+
# 'water': 4.7620,
|
|
68
|
+
# 'glycol': 0.0000,
|
|
69
|
+
# 'fuel_petrol': 0.0034,
|
|
70
|
+
# 'fuel_diesel': 0.0198,
|
|
71
|
+
# 'antiwear_zddp': 8.3410,
|
|
72
|
+
# 'soot': 12.5000,
|
|
73
|
+
# }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [`example.py`](example.py) for a full walkthrough including concentration
|
|
77
|
+
estimation, reference subtraction, plotting, and library search.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Input file format
|
|
82
|
+
|
|
83
|
+
Plain-text files must be two-column (wavenumber, amplitude), comma- or
|
|
84
|
+
space-delimited, with `#` for comment lines:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
# wavenumber (cm-1), absorbance
|
|
88
|
+
4000.0 0.0031
|
|
89
|
+
3999.0 0.0028
|
|
90
|
+
...
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## API reference
|
|
96
|
+
|
|
97
|
+
### Loading
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
load_spectrum(path, magnitude='A') → (DataFrame, dict)
|
|
101
|
+
```
|
|
102
|
+
`magnitude`: `'A'` (absorbance) or `'T'` (transmittance, 0–1 or 0–100).
|
|
103
|
+
|
|
104
|
+
### Pre-processing
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
remove_baseline(df, units='A', poly_order=5) → DataFrame
|
|
108
|
+
scale_reference(df_sample, df_ref, units='A') → DataFrame
|
|
109
|
+
subtract_reference(df_sample, df_ref, wavenumber_range, units='A')
|
|
110
|
+
→ (y_diff, k, y_ref_scaled)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### ASTM E2412 band areas
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
astm_areas(df) → dict # all bands at once
|
|
117
|
+
area_oxidation(df) → float # 1670–1800 cm⁻¹
|
|
118
|
+
area_nitration(df) → float # 1600–1650 cm⁻¹
|
|
119
|
+
area_sulfation(df) → float # 1120–1180 cm⁻¹
|
|
120
|
+
area_water(df) → float # 3150–3500 cm⁻¹
|
|
121
|
+
area_glycol(df) → float # 1030–1100 cm⁻¹
|
|
122
|
+
area_fuel_petrol(df) → float # 745–755 cm⁻¹
|
|
123
|
+
area_fuel_diesel(df) → float # 805–815 cm⁻¹
|
|
124
|
+
area_antiwear_zddp(df) → float # 960–1025 cm⁻¹
|
|
125
|
+
soot_load(df) → float # absorbance at 2000 cm⁻¹ × 100
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
All area functions return a net integrated area in absorbance·cm⁻¹ (≥ 0).
|
|
129
|
+
|
|
130
|
+
### Calibration
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
area_to_concentration(area, calibration_areas, calibration_concentrations,
|
|
134
|
+
poly_order=3) → float
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Provide your own (area, concentration) calibration pairs — the function fits
|
|
138
|
+
a polynomial and evaluates it at `area`.
|
|
139
|
+
|
|
140
|
+
### Library search
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
library_search(query_path, library_dir, top_n=5, extension='*.sp')
|
|
144
|
+
→ list[dict] # sorted by HQI descending
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
hqi(x_query, y_query, x_ref, y_ref) → float # 0–100 %
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Plotting
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
plot_spectra(data_dict, title, xlim, ylim_A, ylim_T, save_path)
|
|
155
|
+
→ (fig, axes)
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`data_dict` format:
|
|
159
|
+
```python
|
|
160
|
+
{
|
|
161
|
+
"Label": {
|
|
162
|
+
"df": <DataFrame>, # required
|
|
163
|
+
"color": "steelblue", # optional
|
|
164
|
+
"alpha": 1.0, # optional
|
|
165
|
+
"linewidth": 1.5, # optional
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Dependencies
|
|
173
|
+
|
|
174
|
+
| Package | Purpose |
|
|
175
|
+
|---|---|
|
|
176
|
+
| `numpy` | Numerical operations |
|
|
177
|
+
| `pandas` | Spectrum data frames |
|
|
178
|
+
| `scipy` | Spearman correlation (HQI fallback) |
|
|
179
|
+
| `matplotlib` | Plotting |
|
|
180
|
+
| `pybaselines` | Baseline correction |
|
|
181
|
+
| `specio` *(optional)* | PerkinElmer `.sp` file reading |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome. Please open an issue or pull request on GitHub.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
## Authors
|
|
191
|
+
`oilftir` was developed at the Chemistry Laboratory of CENADIF ([Centro Nacional de Desarrollo e Innovación Ferroviaria](https://www.argentina.gob.ar/transporte/fase/cenadif)), Argentina, in the context of used-oil condition monitoring for the local railway industry.
|
|
192
|
+
|
|
193
|
+
### Lead developer
|
|
194
|
+
|
|
195
|
+
**Nahuel Mendez** — R&D Engineer/Physical Data Scientist, CENADIF |
|
|
196
|
+
|
|
197
|
+
[](https://github.com/NahueMendez)
|
|
198
|
+
[](https://www.linkedin.com/in/ingnahuelmendez/)
|
|
199
|
+
[](mailto:nahueldanielmendez@gmail.com)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
### Collaborators
|
|
203
|
+
|
|
204
|
+
| Name | Role |
|
|
205
|
+
| :--- | :--- |
|
|
206
|
+
| **Hernán Gomez Molino**, Eng. | Head of Laboratories, CENADIF |
|
|
207
|
+
| **Leandro Asens**, Eng. | Head of the Chemistry Laboratory, CENADIF |
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Citing
|
|
211
|
+
|
|
212
|
+
If you use `oilftir` in your research or academic work, please cite both the ASTM standard and this software library:
|
|
213
|
+
|
|
214
|
+
### 1. The Software Library
|
|
215
|
+
> Mendez, N., Gomez Molino, H., & Asens, L. (2026). *oilftir: A Python library for FTIR-based condition monitoring of lubricating oils following ASTM E2412*. https://doi.org/10.5281/zenodo.20137147
|
|
216
|
+
|
|
217
|
+
### 2. The Implemented Standard
|
|
218
|
+
> ASTM E2412-23, *Standard Practice for Condition Monitoring of Used Lubricants by Trend Analysis Using Fourier Transform Infrared (FT-IR) Spectrometry*, ASTM International, West Conshohocken, PA.
|
|
219
|
+
|
|
220
|
+
You can also use the following BibTeX entry for your reference manager:
|
|
221
|
+
|
|
222
|
+
```bibtex
|
|
223
|
+
@software{mendez_oilftir_2026,
|
|
224
|
+
author = {Mendez, Nahuel and Gomez Molino, Hern{\'a}n and Asens, Leandro},
|
|
225
|
+
title = {oilftir: A Python library for FTIR-based condition monitoring of lubricating oils following ASTM E2412},
|
|
226
|
+
month = may,
|
|
227
|
+
year = 2026,
|
|
228
|
+
publisher = {Zenodo},
|
|
229
|
+
doi = {10.5281/zenodo.20137147},
|
|
230
|
+
url = {doi.org}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## License
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
MIT License
|
|
239
|
+
|
|
240
|
+
Copyright (c) 2026 oilftir contributors
|
|
241
|
+
|
|
242
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
243
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
244
|
+
in the Software without restriction, including without limitation the rights
|
|
245
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
246
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
247
|
+
furnished to do so, subject to the following conditions:
|
|
248
|
+
|
|
249
|
+
The above copyright notice and this permission notice shall be included in all
|
|
250
|
+
copies or substantial portions of the Software.
|
|
251
|
+
|
|
252
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
253
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
254
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
255
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
256
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
257
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
258
|
+
SOFTWARE.
|
|
259
|
+
```
|