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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gixpy-2.3.tar.gz.
File metadata
- Download URL: gixpy-2.3.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ba7864cf7f3f7e31e11924c0634a707d66f8b2d19d2e7921e49b62808b20231
|
|
| MD5 |
c2a5578ee08d04758c738860d575e7a9
|
|
| BLAKE2b-256 |
954a86754c0f27534f44d3920b90ac344539aa24bab46b1b8cd96428786ca5df
|
File details
Details for the file gixpy-2.3-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: gixpy-2.3-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
514734c8f4b2d54c09b079ffc8ab9db263e4f54f093b459ac22540d3a271f6a6
|
|
| MD5 |
73745aa439062032fedc750b09108768
|
|
| BLAKE2b-256 |
fdf4d86bc8e98de79743e3df219a96bd62aede2defb7108b3a6423d4d0a72d51
|
File details
Details for the file gixpy-2.3-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: gixpy-2.3-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 40.9 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b76a99cdfeb10f9989045f7e3f25c39075b20f2bcdb4c16663d60da084b7bdab
|
|
| MD5 |
1d05276e7c5b754d08160b9e430bd76b
|
|
| BLAKE2b-256 |
9b00cad4a891bcde99a2276148852abeeb2462de5ae90c35279d1fa952e5cf64
|
File details
Details for the file gixpy-2.3-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: gixpy-2.3-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 40.9 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56e03b782e23c7bf60b2ae1c0e983a3a4145738fb6901fbc431c1dd6af3648c9
|
|
| MD5 |
bb0a37e8cde0a18a8e4832bf1499ed54
|
|
| BLAKE2b-256 |
2040d215c4ab2ff8cafccded131fefbbbe880573e968aa5340d993307985d6d6
|
File details
Details for the file gixpy-2.3-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: gixpy-2.3-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 40.9 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ca08251e502f981d4c790603474f4e49df1ef10c8e047c9c62009692358d97d
|
|
| MD5 |
a24577e6c1c51e576f851764e242eddc
|
|
| BLAKE2b-256 |
f31efa0157033e5d6ae4ab23078ab555e111ba2f9c173f8ab38b0929f2d05219
|
File details
Details for the file gixpy-2.3-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: gixpy-2.3-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 40.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba1876197474206699e3ef908733972280281955449f5a8158ed4f0b829d52ee
|
|
| MD5 |
b1d038716bb290a7b31256f91f46cc84
|
|
| BLAKE2b-256 |
3b9c5798245dc39e6542d2443bdfebd54fc05e71b1dcba2a584c0e9c853c595b
|