Skip to main content

Fast interpolation of panilized detector data. Optimized for static sampling points.

Project description

Lates Release Tests Documentation Documentation License

static-interpolation

Fast interpolation of paneled detector data, optimized for static sampling positions.

Main features

  • Plan first -> execute fast approach.
  • Mask aware interpolation.
  • Native support for paneled data
  • EXtra-geom integration.

Installation

It is available on pipy so you can simply pip install the package

pip install static-interpolation

Usage

AGIPD_1M Detector & polar grid on Ewald's sphere

simple_interpolation

import static_interpolation as si
from extra_geom import AGIPD_1MGeometry
from matplotlib import pyplot as plt

geom = AGIPD_1MGeometry.from_quad_positions(quad_pos=[
    (-525, 625), # in mm
    (-550, -10),
    (520, -160),
    (542.5, 475),
])

# Things that are not in geom but needed
nr,nphi = (512,2048) # polar coord shape
detector_distance = 0.2 # in meters
xray_energy = 7000 # in eV


# Instanciate the interpolator
agipd_interp = si.AGIPD_1MInterpolator.from_polar_ewald(geom,
                                         nr,
                                         nphi,
                                         xray_energy,
                                         detector_distance
										 )

# make test data
data,masks = si.utils._generate_test_data_agipd(geom,n_images=150)

# Interpolate 150 agipd patterns in one go
out,out_masks = agipd_interp(data,masks)


# Plotting
fig = si.utils._plot_agipd_test(data[0],masks[0],out[0],out_masks[0],geom,figsize=(32,12))
plt.show()

General example

simple_interpolation

import numpy as np
import static_interpolation as si
from matplotlib import pyplot as plt

# simple cubic interpolation using 1 panel

# generate test data
rng = np.random.RandomState(12345)
nx,ny = 5,5
n_samples = 100
n_images = 20
data = rng.random((n_images,nx,ny))


# define image layout
layout = si.data_structures.ImageLayout.from_shape((nx,ny))

# define sampling points
sampling_points = np.stack(np.meshgrid(np.arange(n_samples)*(nx-1)/n_samples,np.arange(n_samples)*(ny-1)/n_samples,indexing='ij'),axis=-1)
samples = si.data_structures.SamplingGrid(points = sampling_points[None,...],n_panels=1)

# options
options = si.config.InterpolationPolicy()
options.method = options.Method.linear

# Instanciate interpolatiors
interp_cubic = si.interpolators.StaticInterpolator(layout,samples)
interp_linear = si.interpolators.StaticInterpolator(layout,samples,options)

# Execute interpolations for all 20 images
out = interp_cubic(data)
out_linear = interp_linear(data)

# Plot Result
fig,axs = plt.subplots(1,3,figsize=(10,5))
axs[0].imshow(data[0])
axs[0].set_title("Data")
axs[1].imshow(out[0])
axs[1].set_title("Cubic interpolation")
axs[2].imshow(out_linear[0])
axs[2].set_title("Linear interpolation")
plt.show()

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

static_interpolation-0.5.3.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

static_interpolation-0.5.3-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file static_interpolation-0.5.3.tar.gz.

File metadata

  • Download URL: static_interpolation-0.5.3.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for static_interpolation-0.5.3.tar.gz
Algorithm Hash digest
SHA256 c649a6c2a56608d576cd316f8490d0c5364b9b34cde7cb14f95b3ea5db15bbfa
MD5 db79ca1b9c7a4b213ba8103733e86d45
BLAKE2b-256 c2a4826e74e6f56fbf8816dc50f014ca4528d48ca5addfff77df9d48aa9663bc

See more details on using hashes here.

File details

Details for the file static_interpolation-0.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for static_interpolation-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f0ebfa2d56f3161ae28afb688ac4634aaa3aabe1c1e68fc95c0f669715778d02
MD5 dcc1d0268a2c5d03f677152ebbfb66d5
BLAKE2b-256 6b132c5d7c1a9bb2e3e0e6f663d87d90f334625cc1714c637eb32da89b285d38

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