Skip to main content

Fit lmfit models to xarray objects.

Project description

xarray-lmfit

Supported Python Versions PyPi Conda Version Workflow Status Documentation Status pre-commit.ci status codecov Ruff

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xarray_lmfit-0.3.0.tar.gz (203.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xarray_lmfit-0.3.0-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file xarray_lmfit-0.3.0.tar.gz.

File metadata

  • Download URL: xarray_lmfit-0.3.0.tar.gz
  • Upload date:
  • Size: 203.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.8.15

File hashes

Hashes for xarray_lmfit-0.3.0.tar.gz
Algorithm Hash digest
SHA256 33ff7b8d83f42ffcc2a32c5854e6e1197f4f1e24c0fbcbbf51fadec2bb905637
MD5 0377d4868600295de64a92493c12e372
BLAKE2b-256 6fe7a28524ab718965ad793cc1ac3a3237de665609390ef402dfd70f55159a3a

See more details on using hashes here.

File details

Details for the file xarray_lmfit-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xarray_lmfit-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b492ede74dcd1635f6ce02414d0dab29a8c31f84a9d4dcb94f5e3d648c34e9f6
MD5 39971f7cd005a0f4e742d9b6db5a1c66
BLAKE2b-256 c01599b571ea8390af5f7ddedb7cfbede7fff7b5e25e20a6d00cac63f10a18ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page