Skip to main content

Python package to quickly transform images from grazing incidence X-ray experiments using C

Project description

Installation

GixPy is distributed on PyPI and can be installed using pip:

pip install gixpy

It can be built from source by cloning https://github.com/ttortorici/gixpy.git and using Python's build tool (don't forget to cd into the repository):

pip install -U setuptools build
python -m build --wheel
pip install dist/*.whl

where * should be replaced with the actual wheel's filename, and \ should be used instead of / on Windows.

How to use

Here's an example of N files from a directory and tranforming them all at once. WARNING Currently there is a bug when you feed in a list or tuple of arrays. Every transformation gets saved over the first image of the return arrays. Instead just run the function on each array separately. The function is fast, so this shouldn't be a big problem for now (I'm moving on to more important things at the moment, and may come back and fix this bug).

import gixpy as gp
from pathlib import Path
import numpy as np
import fabio
import pyFAI

dir = Path("path/to/data")

poni = pyFAI.load(dir / "name-of-poni-file.poni")

rows, columns = poni.get_shape()

# inspect data
im_num = 0
for file in dir.glob("*.tif"):
    im_num += 1

# instantiate list to put data in
data = [None] * (im_num + 1)  # adding an extra space to put "weights"
transformed_data = [None] * (im_num + 1)

# make weights based on exposure time to track how many pixels get moved to each new location
exposure_time = 1800  # in seconds
data[-1] = np.ones((rows, columns)) * expsoure_time

# set geometric parameters not saved in poni file
incident_angle = 0.3  # in degrees
tilt_angle = 0  # in degrees

for ii, file in enumerate(dir.glob("*.tif")):
    data[ii] = fabio.open(file).data
    transformed_data[ii], new_beam_center = gp.transform(
    data,
    incident_angle,
    poni.get_pixel1(),
    poni.get_poni1(),
    poni.get_poni2(),
    poni.get_dist(),
    tilt_angle
)

transfromed_weights = transformed_data[-1]
adjusted_data = np.array(transformed_data[:-1]) * (exposure_time / transformed_weights)

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

gixpy-2.1.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

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

gixpy-2.1-cp313-cp313-win_amd64.whl (40.9 kB view details)

Uploaded CPython 3.13Windows x86-64

File details

Details for the file gixpy-2.1.tar.gz.

File metadata

  • Download URL: gixpy-2.1.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for gixpy-2.1.tar.gz
Algorithm Hash digest
SHA256 594e56096b0907bc90253f2477cd9239a13d86055eba3ff4df534877266a04cd
MD5 b36f124ebd9c9e1377a344c2271e96a0
BLAKE2b-256 1adffb370e1a244b8c174df8707769dd9ae0874ccda89718d9f10628dd20be6e

See more details on using hashes here.

File details

Details for the file gixpy-2.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: gixpy-2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for gixpy-2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 52fa96f9e490246aa216e3022e69d0c2cb53a066eb4fa14c8e2fcfdf4225f2c2
MD5 b07c4d67a12db9101321952905fe7a4e
BLAKE2b-256 7fdc2db0a75fb0fa0796068fbe33451a3756712dd93e01a689dfd2cf807864c6

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