Skip to main content

Library for handling x-y pattern data.

Project description

codecov CI Documentation Status

xypattern

Description

A simple small library to handle x-y patterns, such as are collected with x-ray diffraction or Raman spectroscopy.

Installation

pip install xypattern

Features

  • Load and save patterns from/to various file formats (.xy, .chi, .fxye)
  • Apply scaling, offset, and smoothing to patterns
  • Background subtraction (manual or automatic)
  • Pattern manipulation (limiting, extending, deleting ranges)
  • Mathematical operations (addition, subtraction, multiplication)
  • Pattern transformation (x-axis transformation)
  • Pattern rebinning
  • Pattern serialization to/from dictionaries

Usage Examples

Reading a file

from xypattern import Pattern
import matplotlib.pyplot as plt

p1 = Pattern.from_file('path/to/file')
p1.scaling = 0.5
p1.offset = 0.1

plt.plot(p1.x, p1.y)
plt.show()

Use a background pattern

p2 = Pattern.from_file('path/to/file')
p2.scaling = 0.9
p1.background_pattern = p2

Automatic background subtraction

from xypattern.auto_background import SmoothBrucknerBackground

p1 = Pattern.from_file('path/to/file')
p1.auto_bkg = SmoothBrucknerBackground(smooth_width=0.2, iterations=30, cheb_order=20)
p1.auto_bkg_roi = [10.0, 60.0]  # Optional region of interest for background calculation

Pattern manipulation

# Limit pattern to a specific x-range
limited_pattern = p1.limit(10.0, 60.0)

# Extend pattern to a specific x-value
extended_pattern = p1.extend_to(5.0, 0.0)

# Delete specific x-ranges
cleaned_pattern = p1.delete_ranges([[10.0, 15.0], [40.0, 45.0]])

# Transform x-axis (e.g., convert from 2theta to q-space)
from math import pi, sin
wavelength = 0.3344  # Å
transformed_pattern = p1.transform_x(lambda x: 4 * pi * sin(x * pi / 360) / wavelength)

Scale and stitch multiple patterns

p1 = Pattern.from_file('path/to/file1')
p2 = Pattern.from_file('path/to/file2')
p3 = Pattern.from_file('path/to/file3')

from xypattern.combine import scale_patterns, stitch_patterns

patterns = [p1, p2, p3]
scale_patterns(patterns)
stitched_pattern = stitch_patterns(patterns)

Pattern serialization

# Save pattern to dictionary (useful for JSON serialization)
pattern_dict = p1.to_dict()

# Create pattern from dictionary
p2 = Pattern.from_dict(pattern_dict)

# Create a deep copy of a pattern
p2 = p1.copy()

API Documentation

For detailed API documentation, please visit https://xypattern.readthedocs.io/ or https://cprescher.github.io/xypattern/.

Building Documentation

The project documentation is built using Sphinx. To build the documentation locally:

# Install development dependencies
poetry install --with dev

# Navigate to the docs directory
cd docs

# Build the documentation
make html

The built documentation will be available in the docs/_build/html directory. Open index.html in your web browser to view it.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

xypattern-1.2.3.tar.gz (21.5 kB view details)

Uploaded Source

Built Distributions

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

xypattern-1.2.3-cp313-cp313-win_amd64.whl (87.9 kB view details)

Uploaded CPython 3.13Windows x86-64

xypattern-1.2.3-cp313-cp313-manylinux_2_39_x86_64.whl (484.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp313-cp313-macosx_15_0_arm64.whl (171.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

xypattern-1.2.3-cp312-cp312-win_amd64.whl (88.2 kB view details)

Uploaded CPython 3.12Windows x86-64

xypattern-1.2.3-cp312-cp312-manylinux_2_39_x86_64.whl (490.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp312-cp312-macosx_15_0_arm64.whl (173.1 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

xypattern-1.2.3-cp311-cp311-win_amd64.whl (87.0 kB view details)

Uploaded CPython 3.11Windows x86-64

xypattern-1.2.3-cp311-cp311-manylinux_2_39_x86_64.whl (489.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp311-cp311-macosx_15_0_arm64.whl (171.3 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

xypattern-1.2.3-cp310-cp310-win_amd64.whl (87.1 kB view details)

Uploaded CPython 3.10Windows x86-64

xypattern-1.2.3-cp310-cp310-manylinux_2_39_x86_64.whl (462.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp310-cp310-macosx_15_0_arm64.whl (171.3 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

xypattern-1.2.3-cp39-cp39-win_amd64.whl (87.3 kB view details)

Uploaded CPython 3.9Windows x86-64

xypattern-1.2.3-cp39-cp39-manylinux_2_39_x86_64.whl (462.0 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp39-cp39-macosx_15_0_arm64.whl (171.9 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

xypattern-1.2.3-cp38-cp38-win_amd64.whl (88.2 kB view details)

Uploaded CPython 3.8Windows x86-64

xypattern-1.2.3-cp38-cp38-manylinux_2_39_x86_64.whl (476.6 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.39+ x86-64

xypattern-1.2.3-cp38-cp38-macosx_15_0_arm64.whl (175.3 kB view details)

Uploaded CPython 3.8macOS 15.0+ ARM64

File details

Details for the file xypattern-1.2.3.tar.gz.

File metadata

  • Download URL: xypattern-1.2.3.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3.tar.gz
Algorithm Hash digest
SHA256 33d623be7ec0b4b86d1cd9f4cabfdc6f99f2b16e6e3ef28690aaf3d929c93493
MD5 678aa6800c7f7101acf80ac768bd309b
BLAKE2b-256 337f2a7b0bef9479ebbe157e1419a3ab0545b98c68e5b880d2787d5117d9fdc4

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3.tar.gz:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 87.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e22c7501a27a2884fed104a88178152ab659f0da1a2ba8633c362e0600a61125
MD5 0394c6d3859bd327e0d8e7c384a8f17c
BLAKE2b-256 348387ad2fb5b72337fd1e64d83f66dd6240e7680f2cf8aef991e647c4629c59

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp313-cp313-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e370326ea2a77b94a8d89e563c4388c0a0a4ee6391fda9fe3505de2daae749e0
MD5 1379750c274738e8b686c62e14186f7a
BLAKE2b-256 6edd5dccef672464c38b1a3ce5e3404a1608064567ffe56b42b804403bcfc0ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp313-cp313-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6bc06921d9816746d154b8f1179f0ab8490b1fbc3e3d3b3a1b28bdfded9a0ed6
MD5 080a9caac2e134526997556ef3b16993
BLAKE2b-256 a67872122c6d1990649de908006c3dd167285d6b0c96e6055f6d08055e6f43c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 88.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7266b5b15bac6b019ef1cf7f0c6e05bba275404929660c3738625a44e863be78
MD5 2bcd895cd0cdba85acfaabfbf4d3ac89
BLAKE2b-256 3c2ced2eda7284ffd35976780e826edf4c009f0df68e5085bfe8846bdf2907e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp312-cp312-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 7a91d0cb56ab221b578b6bf0f17919d42904cbb05c1bf3604175a7b9d2a32ba7
MD5 2cc5353dec3db80d366746249331faec
BLAKE2b-256 59d107b51ea6176e0be0dc60d249e9d61ff001d5d47715c63c90851a577f2e48

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp312-cp312-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b66018e8c1f4e2e134f6b1c9760ebf0eed6812a8741587180c8a0cccbfa948ae
MD5 8edbf8de17364cd187e6e3d9e6c20fef
BLAKE2b-256 89df6afb304bfa5d8ab23ac883ae527154361a704c583d32ee9f44a4667a36ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 87.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9d9ddebe7e0b6c5462f4c458dce90025b1e57741ec1e117c48939ad03e996a6a
MD5 00a8a7beda75f9eb898ed84847998563
BLAKE2b-256 61ff433821b20ec05e5b1f9aa29c1ffbaff55fd5e2233612b826c30c1bfa5609

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp311-cp311-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 a1afb22fec564604457be955362357fc9adf83823969006da2b7c8acc6fff3e5
MD5 b31b12f418787297d85a6749a15ccb3d
BLAKE2b-256 8efc359dbb77828122cb8503ed304e4bc358aa7632cf3b08570ab872b2e7ed62

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp311-cp311-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0006c218031ad28bd8fac9255b3d5c24ec9ee44203e0aa98f0d9b3968b015a8e
MD5 697f0c5b5cd47fe63a45dd1f0e4b0616
BLAKE2b-256 ca8cd625919b5da96efdf67606131f89a1487a51fa0e805c622ca97f39781a24

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 87.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 171c6d85d851b74e2417e0904e9701970c0b4278b96a69a7f423e01f9e4b71b8
MD5 9064e29e19f7c7ef8ea76bd412954396
BLAKE2b-256 0a536969ed1d513cbdd7d3b5b0272cfef0908f745744ead5ac447c47cb54130d

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp310-cp310-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 ce5ff7b9dde2dc34b2c36a7162b9515ccd92026de0218686060175d8f08f8cf1
MD5 a033898e707a0efac65fdb287bb5adc0
BLAKE2b-256 1b5faa6e5c4f9a3ad89ec459191e2ff796e3f3298219da8e6c47bb5f54053518

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp310-cp310-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 eb92c64a6c1635244da1fb9b7a6783fdc6222c37a8fc96b3a09c94b1b1d89334
MD5 9cdbb8804055ac26e2fd25551aa09a45
BLAKE2b-256 8ca7cb5687b75694b4688216f843f2567397d4d988a11213a2885b39cdfc81e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 87.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 1763d6c528ce93eead4889aad645b2049ae95c2992c8109c1164877f6f76fe2d
MD5 85735d2a8bbef34756b77e723f85f776
BLAKE2b-256 f18cedaa65b96fab6a070cecf4ccd457fa223f0464d21f7046a4cbef449b324f

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp39-cp39-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 3210dd9fb1e1d0a36cb2b1d254f8f4800024c61b4ff912545def9b41cb8b1f1b
MD5 8d3582be44f0fd7788b4474f58c5fc86
BLAKE2b-256 b03abd010bc753cd4acae17f79c50a563c92a5177de363303a9ff0d914029d61

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp39-cp39-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2b99ac5e1e596bdb22f0f23393000b18b7769e44a93868121c68eb52f18fe05b
MD5 d780cb5a115e87631cfd6fdb7c947fb1
BLAKE2b-256 a345ac8b7ea1972572a7b90d8a48775c46c49264d6ec132762169e806634eeb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp39-cp39-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: xypattern-1.2.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 88.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xypattern-1.2.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ac9cb230d6950b7e6345f3efe743d347cb79ce7b5284510c57314123bbb07b4b
MD5 9c04be386189e1be516c01a395445ce2
BLAKE2b-256 fdc8228553c30086b3501dd75625aa2ce531804835feaf663b81d81626666332

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp38-cp38-win_amd64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp38-cp38-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp38-cp38-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 5155dcaab986244b0bfa3adb38d29992c9b94e31ef152ae9622d8557cddb9e85
MD5 1f976876270288ebf726fedb7a2635ef
BLAKE2b-256 02c3f8f00b7536c32c0291daa28ff07ab547f7d96fe635da7c3e5f24dd696952

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp38-cp38-manylinux_2_39_x86_64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xypattern-1.2.3-cp38-cp38-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.3-cp38-cp38-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 20642fa28e71aaf71d82651ff257b2e36003d49fd4cf108ec5e7d1f932c29c85
MD5 dcf4194323188d5a0e945e3ec2d2e24b
BLAKE2b-256 73b34311d6d02b09fc1e1c18bf9d8e6c43e4f9ca2d4c485da69dce697706e681

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.3-cp38-cp38-macosx_15_0_arm64.whl:

Publisher: CD.yml on CPrescher/xypattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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