Skip to main content

Rust with Python bindings. Contains sliding (filtering) operations (padding, convolution, mean, median, standard deviation, sigma clipping) for float64 numpy data with NaN values and a kernel with weights.

Project description

rsliding package

This python package contains utilities to compute a sliding sigma clipping, where the kernel can contain weights and the data can contain NaN values (has to be float64).

The actual core code is in Rust. This package was created to have a less memory hungry sigma clipping code compared to the similar sliding python package (cf. https://github.com/avoyeux/sliding.git). It is also a few times faster than the sliding package equivalent (except in some cases when using the Convolution or SlidingMean class). Check the Functions markdown section to know about the different available classes.

IMPORTANT: the code only works if the kernel dimensions are odd and has the same dimensionality than the input data.

Install package

Given that pre-compiled binaries are needed if the user doesn't have the Rust compiler installed, the user should install the package through PyPi.

(OPTIONAL) Create and activate a python virtual environnement:

python3 -m venv .venv
source .venv/bin/activate

or on Windows OS:

python -m venv .venv

# Command Prompt
.venv\Scripts\activate

# PowerShell
.venv\Scripts\Activate.ps1

# Git Bash or WSL
source .venv/Scripts/activate

Install package in virtual environnement (or on bare-metal - wouldn't recommend):

pip install rsliding

Functions

The rsliding package has 6 different classes:

  • Padding which returns the padded data. Not really useful given np.pad is way more efficient. A Python binding exist just so that the user can check the results if wanted be.
  • Convolution which lets you perform a convolution (NaN handling done).
  • SlidingMean which performs a sliding mean (NaN handling done).
  • SlidingMedian which performs a sliding median (NaN handling done).
  • SlidingStandardDeviation which performs a sliding standard deviation (NaN handling done).
  • SlidingSigmaClipping which performs a sliding sigma clipping (NaN handling done).

Example

# IMPORTs
import numpy as np
from rsliding import SlidingSigmaClipping

# CREATE fake data
fake_data = np.random.rand(36, 1024, 128).astype(np.float64)
fake_data[10:15, 100:200, 50:75] = 1.3
fake_data[7:, 40:60, 70:] = 1.7

# KERNEL
kernel = np.ones((5, 3, 7), dtype=np.float64)
kernel[2, 1, 3] = 0.

# NaN ~5%
is_nan = np.random.rand(*fake_data.shape) < 0.05
fake_data[is_nan] = np.nan

# CLIPPING no lower value
clipped = SlidingSigmaClipping(
    data=fake_data,
    kernel=kernel,
    center_choice='median',
    sigma=3.,
    sigma_lower=None,
    max_iters=3,
    borders='reflect',
    threads=1,
    masked_array=False,
    neumaier=True,
).clipped

IMPORTANT

Before using this package some information is needed:

  • float64 values for the data: the data needs to be of float64 type. Given the default class argument values, the data will be cast to float64 before calling Rust.
  • threads: there is a threads argument for most of the classes. It is not used during the padding operations but used for in all other intensive operations. Done like so as using threads for the padding would most likely slow down the computation speed in most cases.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

rsliding-1.0.0-cp310-abi3-win_amd64.whl (328.4 kB view details)

Uploaded CPython 3.10+Windows x86-64

rsliding-1.0.0-cp310-abi3-manylinux_2_34_x86_64.whl (427.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

rsliding-1.0.0-cp310-abi3-macosx_11_0_arm64.whl (374.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file rsliding-1.0.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rsliding-1.0.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 328.4 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rsliding-1.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 df02142fa2fe59a90d0a3303323ac6861a81a602207d8ef9ebc4e934469f78e2
MD5 70919e22323d454ca41b42955d4cd3d0
BLAKE2b-256 aa6d7e529016815c17004d9db8b52e1ab64668134cf7218d8d02c9402d94b91a

See more details on using hashes here.

File details

Details for the file rsliding-1.0.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for rsliding-1.0.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 eea146c1bda0508be7a42ea82a354e156c490f883c1184255b6faa40c180e057
MD5 b34251b659d4de951abcd51ca096b6f9
BLAKE2b-256 8b8fa7224da649295b7b62e74dab28b25d11ad9f1ed0ac957f765a04a47d9000

See more details on using hashes here.

File details

Details for the file rsliding-1.0.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rsliding-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 770cd2767ef028981c6d761b0f8aaadb80e03c873928ee6bf85b6d2d2a01396d
MD5 59020a92177e7c9d3dc13ed7fcd06c17
BLAKE2b-256 eee8572d91f8fd370dea2e6ee895d9f92abae6e006368b663ad65b2e46d0e73b

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