Ultra-sound attenuation and phase-shift computation during high magnetic field.
Project description
pyuson
Description
pyuson provides a Python API to read and analyse ultra-sound echoes experiments on samples exposed to a high magnetic field. It is bundled with a graphical user interface written with PyQt.
Installation
Method 1 : As an app
If you plan to just use the graphical user interface, consider installing pyuson as a tool managed by uv, a modern Python package manager.
To do so, install uv (see the official installation instructions : https://docs.astral.sh/uv/getting-started/installation/) :
- On Windows, enter the following command in PowerShell :
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
- On Linux and MacOS, enter the following in a terminal :
curl -LsSf https://astral.sh/uv/install.sh | sh
Once uv is installed, from the command line (PowerShell in Windows), install pyuson with uv :
uv tool install pyuson
pyuson will be installed along its dependencies in an isolated environment with no risks to mess up with your current tools and Python versions.
Then, launch the GUI by running pyuson from the command line.
To update, run : uv tool upgrade pyuson.
Method 2 : As a library
Installing pyuson as a library will allow you to use it from scripts and Jupyter notebooks (e.g. you will be able to import it with import pyuson).
-
. Create a Python environment :
With
conda:conda create -n pyuson-env -c conda-forge python=3.12You may replace the environment name
pyuson-envwith whatever you want.Activate the environment with :
conda activate pyuson-env -
Install the
pyusonpackage :With
pip, with thepyuson-envactivated :pip install pyuson
Updates
To upgrade pyuson to the latest version, simply run from the activated environment :
pip install pyuson --upgrade
Manual download
- Download the repository, extract it on your computer.
- Create and activate a conda environment as shown above.
- Install the extracted repository with
pip:
pip install "/path/to/pyuson-main"
Alternatively, if you wish to make modification to the source code so that your change is reflected immediately, use the editable mode :
pip install -e /path/to/pyuson-main
Notebook support
To use Jupyter notebooks with pyuson, some more dependencies should be installed. From a terminal with the virtual environment activated (conda activate pyuson-env), install them with the following command :
pip install notebook ipympl ipywidgets
Usage
You can use this package through the graphical user interface, or directly from Python prompt, script or Jupyter notebook using the Processor classes. All this methods rely on a TOML configuration file that specifies the experiment parameters and analysis settings.
Template configuration files are provided in the configs folder. Copy-paste and edit it according to your need. Each entry of the file is commented so it should be somewhat straightforward to configure. Then :
-
Run the graphical interface with
python -m pyusonfrom a terminal with thepyuson-envenvironment activated. Drag & drop the configuration file in the window, load the data, and interactively choose the time-window in which the amplitude and phase will be computed. -
Check the example scripts and notebooks in the
examplesfolder. Copy them elsewhere locally (to make sure you retain your changes and have a working rollback if anything goes wrong) edit them and use them as you see fit. Note that they are not interactive, e.g. you'll need to specify the time window directly (withd.cfg.settings["range_analysis"] = 1.035, 1.055- expressed in µs).
Contribute
This project is managed with uv. Best way to get started is to install uv on your platform : https://docs.astral.sh/uv/getting-started/installation/.
Fork the repository in your own GitLab account, then clone the repository on your computer :
git clone git@gitlab.in2p3.fr:your-name/pyuson.git
Enter the folder from the command line :
cd pyuson
And use uv to create a functional virtual environment :
uv sync --all-groups --all-extras
This will create a .venv folder with Python and the dependencies, that should be recognized when openning the project in any IDE (PyCharm or VSCode). Note that the .venv folder is ignored by git.
If you need to add a dependency, just use uv add {dependency-name} (eg. uv add pandas). It will find the latest compatible version, add it to the lockfile and to the pyproject.toml file.
Alternatively, install miniforge for your platform, create a virtual environment with Python 3.12 (conda create -n pyuson-env python=3.12), activate it (conda activate pyuson-env) and install the package in editable mode : pip install -e ..
You can start coding ! When your changes are finished and tested, you can commit and push your changes to your fork and open a Merge Request (MR) from the GitLab web interface.
Tests
Tests should be put in the tests folder and run with pytest.
Recommended
Install the ruff extension for your IDE and format the code with ruff.
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
Built Distribution
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 pyuson-0.7.4.tar.gz.
File metadata
- Download URL: pyuson-0.7.4.tar.gz
- Upload date:
- Size: 99.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b27de37f84c99da23ef5171dbde4953dc9b4f2268c43a98ca8e1f7689c3d8e65
|
|
| MD5 |
95bcf7b4d90d6e1bb42f29b8413144c5
|
|
| BLAKE2b-256 |
1c69837242a4e381951957af62bb7c3643ba62ff4cde25d41dbcdbe2f441e09e
|
File details
Details for the file pyuson-0.7.4-py3-none-any.whl.
File metadata
- Download URL: pyuson-0.7.4-py3-none-any.whl
- Upload date:
- Size: 113.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40ae9b59b942d94f54a59a4cbcbfdbf3bf7f19cf27f1201fb1c69c2741e03f72
|
|
| MD5 |
f06f7f9fec404d8e604afdd03b7b7056
|
|
| BLAKE2b-256 |
a2aa1fad42df10a74c4b24f7ad5f8fe4123d354986993f185bf3669b887e7ee9
|