Skip to main content

SWAXSanalysis


This package is used to convert edf files that contain one header and one dataset into an HDF5 file that contains information selected by the user.

Versioning Y.X1.X2.X3 :

  • Y : year of release
  • X1 : Big update (refactoring, new GUI, new way to use...)
  • X2 : Update including new functionality.
  • X3 : If 0, stable release, if not, it's a work in progress

How it works


To convert the EDF file, the program uses a configuration file created by the user. To help create said file, a GUI is provided. This same GUI can be used to do basic processes to an HDF5 file that follows the NXcanSAS definition, as described by the NeXus Foundation : https://manual.nexusformat.org/classes/applications/NXcanSAS.html#nxcansas

Once the configuration file has been created it should be saved in the "configs" folder inside the Data Treatment Center. You need to move the config file inside the Data Treatment Center directly for it to be detected and used in the conversion of file. By default, the Data Treatment Center is created on your desktop.

Once the config file is moved, you can put the EDF files you want to convert to hdf5 in the Treatment Queue folder.

You can also use the package directly in a python script by importing the main class and some utility functions :

from SWAXSanalysis.class_nexus_file import NexusFile
from SWAXSanalysis.utils import save_data, extract_from_h5, delete_data

In any case, an example notebook along with a jupyter notebook launcher is present in SWAXSanalysis/machine_configs/XEUSS. Otherwise, a copy of this jupyter launcher / notebook is also present in the Data Treatment center once the app has been launched.

How to install


You have to activate a python virtual environment (more info on how to activate a Venv here) and type the following command :

pip install SWAXSanalysis

After SWAXSanalysis is installed you need to install this branch of smi_analysis via the following command

pip install git+https://github.com/gfreychet/smi-analysis.git@master

This wraps up the installation of the package in the activated virtual environment. If you want to use the GUI, you only need to type

SWAXSanalysis

in the same activated virtual environment

The conversion process can be automated if the launcher.py has been launched with the argument --no-gui "true" like so :

python3 -m SWAXSanalysis.launcher --nogui true 

Changing the location of the Data Treatment Center


By default, the Data Treatment Center and Treatment Queue folder will be created on your desktop. To change the location of the Data Treatment Center, go to :

path\to\your\venv\Lib\site-packages\SWAXSanalysis

and open the __init__.py file. In this file, find this line (should be line N°28) :

ENV_PATH: Path = DESKTOP_PATH

And change it to

ENV_PATH: Path = Path(r"path\where\Data Treatment Center\should\be")

Implementing new code


New process

To add a new process to the code, simply go to the class_nexus_file.py and in the class NexusFile, you can define a new method. There are some things you should know :

  1. If you want your process to be used only in script, there is no special condition. However if you want it to be picked up by the GUI, the method's name must start with process_....
  2. If you want the process to be available in the GUI. You have to follow this signature standard :
def process_example(
            self,
            param1: type1 = default1,
            param2: type2 = default2,
            param3: type3 = default3
    ) -> None:
    pass

You need to type your variables and give it a default value. You can put any default value but None or "" are the most generic ones. Don't hesitate to look at the other processes to guide you.

To learn more about typing :
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html 3. A process must include a for loop to apply the process to all files :

for index, smi_data in enumerate(self.list_smi_data):
    pass

Usually, we iterate over self.list_smi_data since it's the pre-processed data and it was corrected via pyFAI. But should you want to iterate over the HDF5 files directly you can use self.nx_files.
This loop should encompass al the code that actually treats and manipulate the smi_data.

  1. If you want to add a way to save data you need to use the save_data function, present in the same file.
  2. If you want to add a way to display data you need to use the _display_data method. This method is quite complex so don't hesitate to look at other processes to see how to use it properly.

Testing new implementation


When implementing new code in the package, you should always test if you broke something. To do so, you have a few test that you can conduct. Those test are present in the tests folder of the github project. In this folder you have :

  • test_conversion : which is a test that should always be run
  • test_new_nexus_def : this test should be run in case you have implemented a new NeXus definition

Known issues


  • Changing the ENV_PATH by changing the __init__.py script is impractical.
  • While creating the configuration file, there is no way to choose the NeXus definition, meaning that you have to change the loaded definition in the python script directly.
  • The program can't handle anything other than EDF file with one header and one dataset
  • Azimuthal angle range is behaving weirdly when 0 is not in the range
  • 2 param intensity is still a bit of a work in progress but should work as long as you do not use it with the batch option enabled
  • While processing something in the data processing tab, the windows stops responding but everything is still processing.

Prospects


  • Manage uncertainty

Metadata

Release files for SWAXSanalysis 2025.5.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SWAXSanalysis 2025.5.1.0
File Size Uploaded
swaxsanalysis-2025.5.1.0.tar.gz 20.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for SWAXSanalysis 2025.5.1.0
File Interpreter ABI Platform
swaxsanalysis-2025.5.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 39.9 MB

Release files / swaxsanalysis-2025.5.1.0.tar.gz

Download URL swaxsanalysis-2025.5.1.0.tar.gz
Size 20.0 MB
Tags Source
SHA-256 checksum
How to use checksums
3938dfa1785e6b8dfdb058bfbffb6df18f7a6fe64d8592765e6ecc993885beba
BLAKE2b-256 checksum
How to use checksums
a25287f1604366f8c7af0b8000b08b76041a003982f610dfa53d8d04c5446bfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / swaxsanalysis-2025.5.1.0-py3-none-any.whl

Download URL swaxsanalysis-2025.5.1.0-py3-none-any.whl
Size 20.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
15dbb6f6ab78c2a0cb246a848d4693420a7c6c7f237a2c7b54898d0d6af0e751
BLAKE2b-256 checksum
How to use checksums
76a66b3f6883426de47d1a4a92a3ed33b6dc376438d5af5ea1f25948c5b791e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release history Release notifications | RSS feed

This release

2025.5.1.0 This release

2 release files

2025.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page