PyMolFit
A Python framework for model-based telluric absorption correction. PyMolFit builds an atmospheric transmission model, fits it to selected observed pixels, and corrects the spectrum on its original wavelength grid. It does not execute Molecfit or LBLRTM.
Install
Requires Python 3.10 or later:
python -m pip install "pymolfit[plot]"
To use the unpublished development version, run this inside your checkout:
python -m pip install -e ".[plot]"
The first correction may download the AER molecular catalogue and atmospheric data. Later runs reuse downloaded data. A HITRAN account is not required.
Correct a spectrum
from pymolfit import correct
result = correct(
input_path="spectrum.fits",
output_path="corrected.ecsv",
show_plot=True,
)
The returned result and saved ECSV contain the observed and corrected spectra, transmission, fitted model, masks and diagnostics. Reopen the product without fitting again:
from pymolfit import load_fit_product, plot_fit
result = load_fit_product("corrected.ecsv")
plot_fit(result, show=True)
Input files need reliable wavelength units, air/vacuum convention and observing metadata. Ambiguous FITS extensions or wavelength conventions require an explicit choice. Array users attach their observing conditions to a Spectrum object. A supplied stellar template defines fitting exclusions; it is not subtracted from the observation. Additive sky emission is not corrected by this absorption model.
Documentation
Start with the documentation index.
- Four short notebooks: FITS, FITS with a stellar template, wavelength/flux arrays, and interactive region selection.
- Parameter descriptions: basic
correct()arguments, followed byAdvancedOptions. - Spectrum, Observation and TheoreticalSpectrum.
- Interactive region selection.
- Full-spectrum speed and residual comparison.
- Before/after and transmission figure scripts.
- Mathematical implementation.
Upgrading to 0.8
This release removes deprecated calling conventions. Pass a path or a
Spectrum as correct(input_path=...); put wavelength/flux arrays and an
Observation on that Spectrum. Put fitting overrides in
advanced=AdvancedOptions(...) and cache settings in cache=CacheConfig(...).
Use show_interactive_window=True to open the region editor.
The old spectrum= alias, flat correction keywords and synthetic demo options
are no longer accepted. Low-level correct_file() and correct_arrays()
remain available for custom atmospheric and spectroscopic inputs.
Development
python -m pip install -e ".[dev,plot]"
python -m pytest -q
python -m ruff check src tests tools docs/figure_examples docs/troubleshooting paper_validation
See CONTRIBUTING.md. Report problems through the issue tracker.
Scientific basis
PyMolFit uses established telluric-modelling methods. Publications should acknowledge the relevant upstream resources:
- Molecfit: Smette et al. 2015 and Kausch et al. 2015.
- AER LBLRTM, MT_CKD and HITRAN.
- MIPAS and NOAA GDAS.
- NumPy, SciPy and Astropy.
License
Original Python code uses the BSD 3-Clause License. Scientific datasets and derived coefficient tables retain their upstream terms and attribution requirements; see THIRD_PARTY_NOTICES.md and the example-data provenance.
Metadata
Release files for pymolfit 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymolfit-0.8.0.tar.gz | 3.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymolfit-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.6 MB
Release files / pymolfit-0.8.0.tar.gz
| Download URL | pymolfit-0.8.0.tar.gz |
|---|---|
| Size | 3.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62cdff4ad9eba3ef05533b5825409b19a679308ba5eb07b3071b62089fd0008c
|
|
BLAKE2b-256 checksum How to use checksums |
2aa4bea707e7fb02a2b5e7344a3698e28827139b0b6abef13e6cb78eb23b08e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / pymolfit-0.8.0-py3-none-any.whl
| Download URL | pymolfit-0.8.0-py3-none-any.whl |
|---|---|
| Size | 650.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b21e7c167dbc0b1e5e6f1c40a2d79523b83502d44b71cf65974dfa9d35f46ce
|
|
BLAKE2b-256 checksum How to use checksums |
6dcfa80780e4fc108f6ce7845dd8b397bc1fdc96ca1eddeda7e24d857339278a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|