Fit lmfit models to xarray objects.
Project description
xarray-lmfit
xarray-lmfit is a Python package that bridges the power of xarray for handling multi-dimensional labeled arrays with the flexible fitting capabilities of lmfit.
With xarray-lmfit, lmfit models can be fit to xarray Datasets and DataArrays, automatically propagating across multiple dimensions. The fit results are stored as xarray Datasets, retaining the original coordinates and dimensions of the input data.
Disclaimer: Please note that this package is independent and not affiliated with the xarray or lmfit projects. If you encounter any issues, please report them on the xarray-lmfit issue tracker.
Installation
Install via pip:
pip install xarray-lmfit
Install via conda:
conda install -c conda-forge xarray-lmfit
Usage
Below is a basic example to demonstrate how to use xarray-lmfit:
import xarray as xr
import numpy as np
from lmfit.models import GaussianModel
import xarray_lmfit as xlm
# Create an example dataset
x = np.linspace(0, 10, 100)
y = 3.0 * np.exp(-((x - 5) ** 2) / (2 * 1.0**2)) + np.random.normal(0, 0.1, x.size)
data = xr.DataArray(y, dims="x", coords={"x": x})
# Define the model to be used
model = GaussianModel()
# Perform the fit
result = data.xlm.modelfit("x", model=model)
Documentation
For more detailed documentation and examples, please visit the documentation.
License
This project is licensed under the GPL-3.0 License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xarray_lmfit-0.5.3.tar.gz.
File metadata
- Download URL: xarray_lmfit-0.5.3.tar.gz
- Upload date:
- Size: 38.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34d947ddbd40e91804e9e049e4d62bfe2e07052c1333f5547ec929fc4a4481d4
|
|
| MD5 |
742f8d34d90c5b0bee40c3b36e8372d4
|
|
| BLAKE2b-256 |
b37ce7d4db9c03d17406012b325bf5456909f6301336a963618504c6ce951f78
|
File details
Details for the file xarray_lmfit-0.5.3-py3-none-any.whl.
File metadata
- Download URL: xarray_lmfit-0.5.3-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b7194f6a5037369b3f7e20ace765cdf115787285050cf7e8f0e90902a003dae
|
|
| MD5 |
a052c5ae8509a96c736fd7078d63fc0e
|
|
| BLAKE2b-256 |
4a23e913998b69fd223cc5162b5e67c7d3ef4535055c02487376a926ed233842
|