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.2.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.2-cp313-cp313-win_amd64.whl (92.2 kB view details)

Uploaded CPython 3.13Windows x86-64

xypattern-1.2.2-cp313-cp313-manylinux_2_39_x86_64.whl (490.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp313-cp313-macosx_14_0_arm64.whl (169.8 kB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

xypattern-1.2.2-cp312-cp312-win_amd64.whl (92.4 kB view details)

Uploaded CPython 3.12Windows x86-64

xypattern-1.2.2-cp312-cp312-manylinux_2_39_x86_64.whl (492.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp312-cp312-macosx_14_0_arm64.whl (171.7 kB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

xypattern-1.2.2-cp311-cp311-win_amd64.whl (91.6 kB view details)

Uploaded CPython 3.11Windows x86-64

xypattern-1.2.2-cp311-cp311-manylinux_2_39_x86_64.whl (503.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp311-cp311-macosx_14_0_arm64.whl (169.3 kB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

xypattern-1.2.2-cp310-cp310-win_amd64.whl (91.5 kB view details)

Uploaded CPython 3.10Windows x86-64

xypattern-1.2.2-cp310-cp310-manylinux_2_39_x86_64.whl (464.8 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp310-cp310-macosx_14_0_arm64.whl (169.3 kB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

xypattern-1.2.2-cp39-cp39-win_amd64.whl (92.0 kB view details)

Uploaded CPython 3.9Windows x86-64

xypattern-1.2.2-cp39-cp39-manylinux_2_39_x86_64.whl (467.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp39-cp39-macosx_14_0_arm64.whl (170.5 kB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

xypattern-1.2.2-cp38-cp38-win_amd64.whl (92.2 kB view details)

Uploaded CPython 3.8Windows x86-64

xypattern-1.2.2-cp38-cp38-manylinux_2_39_x86_64.whl (477.4 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.39+ x86-64

xypattern-1.2.2-cp38-cp38-macosx_14_0_arm64.whl (170.4 kB view details)

Uploaded CPython 3.8macOS 14.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for xypattern-1.2.2.tar.gz
Algorithm Hash digest
SHA256 84d8077796ab169b8b7c971b0ec7536068021e357585657d1d15511d2973ebb1
MD5 ac4192aae5ae645451caa41fb8200a8c
BLAKE2b-256 200789b6290ce5cf1d150f5864d70bfd25b8c5936011d93f33273c6fad93d1f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2.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.2-cp313-cp313-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 63b6466dd042e3e3275f86c4c12f51ed431c2f4262485986c6d1d127cdb95c5f
MD5 cb859000dcd75658b2e01adb58cfc7de
BLAKE2b-256 c787585067049036dff222ba71a4c074176c4bcdab821c643c7f392ae1e5aefc

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 222c1c1e878e1772e9a78d562ffb47737e3289e331542ed3271abfd80071d0d7
MD5 cd5d8da653ed49aec9f58b879cd81daf
BLAKE2b-256 fec1e74af24aab7bab61740cd6783c39bdff5ec96ec43869ee4fc6607735e335

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 48d3c92172b01a90f6ca4eabce463f755a410d07aa47f42c254f2d36878b4f05
MD5 2b838dbbaf58a22cadf04071fa8777ad
BLAKE2b-256 d711665c7198c6ce549862e64eec150625ee5609b120bd7d0a856e6e383cf54b

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp313-cp313-macosx_14_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.2-cp312-cp312-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b316a83f2f59a0094e5fbe8e9513f7b6ce509707eb85e59259a7d6dcae3eb633
MD5 a1fa9ce6eb71e95d7e933866fe1c7101
BLAKE2b-256 8700c01c48b4facdcf6f0f934c46c0ad8c535b798df4bd583f6c0134e0eb4a4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 968e2a999d9ea11f7dcb274fead4dfac7c51fdd24ad2f30d6645dc73b32396f4
MD5 6d26562ac462e62c98754fdee159164c
BLAKE2b-256 8c9027cb0acb5769aae44ec5972de5ee49f14980bb0bcc3dbe621f09a720e52b

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 dbeff40f804cdb1916d73147b8ba69caabb1ead2f13af6de9e129125dcb00681
MD5 21aebf9da7a428592d6b255583889f05
BLAKE2b-256 9475a95565a4b1c09b7550b0d23ca417ba07681659c6ee952ccd48787e79d806

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp312-cp312-macosx_14_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.2-cp311-cp311-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 899ee687a14e375bea2d083e43c47daba21afaee46bfc74bee2dc30cada25f12
MD5 ed5e6b77696cc9b660354eadea894a26
BLAKE2b-256 11ec4eaeee952e76dd3b36ae40729734e83712644c06013b83aed7bff6959d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 703fb36f21833eaf58d9b06d57e5f6b4e202616a46337881ba93c463bc4402ee
MD5 163ba3650f5a0b826f99c2bc9f2adcd3
BLAKE2b-256 06c1a81138a5b7c92ce946c39fb5ecffe3f645cada36ad8ea64ed6eb8cbc5805

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 031a7f224b582fd16e168833dd12c17ac40909b917971bf42204a7cf98fe8087
MD5 a85f197ed4ad625df719e2fccadd9932
BLAKE2b-256 dbe25a3363e1cb4a907e0ed22a2abad86403b5a814d4ca9f73570189f524c8e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp311-cp311-macosx_14_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.2-cp310-cp310-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 459a172a0b65aaeccb234b1ba59ec82c5b0153fe34c024c496360853a7dc499d
MD5 dcf661bf325ae731559a3d7b2a741d3b
BLAKE2b-256 bd150c68ea3d17269333fafbb85ac6e932ecada4456d71ef248f038d61511f11

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 679617452f54c6f822fc6b18e3fba8828579feece6dd5db5204fc644d921c796
MD5 62f497bf352f8666c3753afb23687acf
BLAKE2b-256 8f4eeb31aba4d6e89ea14fe73727c371b37d733c30c22ef6e1317b621ecac98a

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8d848e4f71acd1b50d0f9aab07f86efd74082f4ca9e3c6dc4e5907dda2cb91fb
MD5 8f8669f20e6407d161266ece28061c9c
BLAKE2b-256 c93c68ccb050dc4d85ff4061156c7496d7ec3c062e3bf6609823ba0d7e0d4456

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp310-cp310-macosx_14_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.2-cp39-cp39-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c23e62a7b6977f6e1a55aed4b26448245dba06106e3bd85d4e6171a87b8093db
MD5 e62b4ba3cd4516e08b525cb0d5e02c2d
BLAKE2b-256 e704c7f52b4b54c74d953ea451db2fa2dff99c7d5a0717904f381cd9cc8c9a71

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e08adfca386985a2f626101292f26326fb4f2707e13acdab4c13d5abfdf39b59
MD5 c282bcbe27a89cdc723b00c6f5a3c538
BLAKE2b-256 098054c44f0f758d18f033cb48831e66c308062041248600022a2d8633815878

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 abce4f8b16c7f79042373e42976b5d4f1329cfe46933b7bd577c7286ef385fca
MD5 66396927159bb8bd6c60bd27f692773b
BLAKE2b-256 b15e8d1ec4b081b01cbde0cf1e81557a3b060d00944a254c3a25efe24e18e670

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp39-cp39-macosx_14_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.2-cp38-cp38-win_amd64.whl.

File metadata

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

File hashes

Hashes for xypattern-1.2.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 26b3659f2fb582be704ec87859ceac5f9604c31e132b88ce5053c794ece6a4ec
MD5 6cf42d1abf522f88ff4f41ce3bd2cad5
BLAKE2b-256 e435209b29b13b1143a1c00acba1234430535cfd319eb6fb7cffa147dca07907

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp38-cp38-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp38-cp38-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d6688e8e41945532a40293fbfdd92d3ead852aa3ca7f17472cd7002548bccaa6
MD5 b3d13c88d12909f52d3a053a03b46fe0
BLAKE2b-256 638e44a74f51645a22757d0231be529440af859c03e6c8a9028ae8611af4291a

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-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.2-cp38-cp38-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for xypattern-1.2.2-cp38-cp38-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e052befd420e0e5b1d6e090554fed1e92e125f7bc0d8dbc74b7c6c58193555f2
MD5 241fd51d314877596c065406c6e5cb01
BLAKE2b-256 769c65559a935c5707566c428da508b54f53258d3a0d774c5c58c07e07e355fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for xypattern-1.2.2-cp38-cp38-macosx_14_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