Skip to main content

spyral-utils

CI PyPI version shields.io PyPI license

spyral-utils is a utility library that contains some of the core functionality of Spyral. These utilities were found to be useful not just within Spyral but also continuing analysis after using Spyral. Some key utilities include:

  • Nuclear masses from the AMDC AME 2020 masses
  • Some histogramming and gating/cuting tools that are plotting backend agnostic
  • Energy loss analysis for gas and solid targets using pycatima
  • 4-vector analysis through the vector package
  • Point triplet clustering algorithm (also called tripclust or Dalitz clustering)

See the documentation for more details.

Installation

spyral-utils can be installed using pip install spyral-utils

System requirements

spyral-utils requires Python >= 3.10 and < 3.13

spyral-utils is cross-platform and tested for MacOS 14, Windows 11, and Ubuntu 22.04.

Formats

Several parts of the utilities allow for saving and creating objects from JSON. Below is an outline of the expected formats for each of these

Targets

For a gas target:

{
    "compound": [
        [1, 1, 2]
    ],
    "pressure(Torr)": 300.0
}

For a solid target:

{
    "compound": [
        [6, 12, 1]
    ],
    "thickness(ug/cm^2)": 50.0
}

For a gas mixture:

{
    "components": [
        [
            [6, 12, 1],
            [1, 1, 4],
        ],
        [
            [18, 40, 1]
        ]
    ],
    "volume_fractions": [0.1, 0.9],
    "pressure(Torr)": 50.0
}

Compound specifications are lists of elements where each element is an array of [Z, A, S]. S is the stoichiometry of that particular element in the compound. spyral-utils does not support target layers at this time (but layered targets can be built from the building blocks provided by spyral-utils). In the above examples the gas target is for 1H2 gas at 300 Torr pressure and the solid target is for 12C1 foil with a thickness of 50 μg/cm2. The gas mixutre example is for P10 gas (10% methane in argon) at 50 Torr.

2D-Cuts

The JSON description of a 2D-Cut (or 2D-gate) on data is as follows:

{
    "name": "test_cut",
    "vertices": [
        [0.0, 0.0],
        [1.0, 0.0],
        [1.0, 1.0],
        [0.0, 1.0],
        [0.0, 0.0]
    ]
}

name is a identifier given for that particular cut. verticies is a list of [x,y] coordinates which define the polygon. Note that the polygon must be closed (the final vertex must be the same as the first vertex). You can also add the xaxis and yaxis keywords to specify the names of the axes of the cut (i.e. the column names of a dataframe).

{
    "name": "test_cut",
    "xaxis": "my_x",
    "yaxis": "my_y",
    "vertices": [
        [0.0, 0.0],
        [1.0, 0.0],
        [1.0, 1.0],
        [0.0, 1.0],
        [0.0, 0.0]
    ]
}

Particle ID

The JSON description of a particle ID gate is as follows:

{
    "name": "test_cut",
    "vertices": [
        [0.0, 0.0],
        [1.0, 0.0],
        [1.0, 1.0],
        [0.0, 1.0],
        [0.0, 0.0]
    ],
    "Z": 6,
    "A": 12
}

The name and vertices fields are the same as those used by a Cut2D. The particle ID has the additional data Z and A which are the element and mass number of the associated nucleus. Like in a Cut2D you can also specify the axis names of the cut

{
    "name": "test_cut",
    "xaxis": "my_x",
    "yaxis": "my_y",
    "vertices": [
        [0.0, 0.0],
        [1.0, 0.0],
        [1.0, 1.0],
        [0.0, 1.0],
        [0.0, 0.0]
    ],
    "Z": 6,
    "A": 12
}

References

For documentation we use

For testing we use

Authors

  • Gordon McCann
  • Nathan Turi
  • Daniel Bazin

Metadata

Release files for spyral-utils 2.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 spyral-utils 2.1.0
File Size Uploaded
spyral_utils-2.1.0.tar.gz 133.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spyral-utils 2.1.0
File Interpreter ABI Platform
spyral_utils-2.1.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details

Total release size: 397.7 kB

Release files / spyral_utils-2.1.0.tar.gz

Download URL spyral_utils-2.1.0.tar.gz
Size 133.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4a9b604f940ddaa7c58c4adde93dc9d712c601a32135d986a4cf53a63158c259
BLAKE2b-256 checksum
How to use checksums
05601dac73f2dd13c66f62ed404f0ad90a4f84eda405eeb77a82986006f6324a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / spyral_utils-2.1.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL spyral_utils-2.1.0-cp312-cp312-macosx_26_0_arm64.whl
Size 263.9 kB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
0ac462655f62ae33689ffedaf633e201e5510f6f939d1632957addfca4377c51
BLAKE2b-256 checksum
How to use checksums
f746d0f8ea26846396a411a400df149724cd88fb190e9e9c5d800cb02f80fb51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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