Overview
This script performs passive magnetic shimming to improve the homogeneity of a magnetic field. Below is a breakdown of the code:
1. Reading Magnetic Field Data
- The script loads magnetic field data from a
.npyfile. - Converts the field and position data into meters and filters the data within a defined spherical region (DSV - Diameter Spherical Volume).
- The magnetic field data is visualized in 3D scatter plots.
2. Defining Shim Geometry
- Specifies the geometry of the shim array, including magnet dimensions, diameter, and magnetization.
- Creates shim ring templates using the
make_shim_ring_templatefunction. - Saves the initial shim tray arrangement as an STL file for visualization.
3. Field Computation
- Computes the magnetic field generated by the shim tray template.
- Visualizes the computed field and its combination with the measured field.
4. Optimization for Homogeneity
- Defines an optimization problem using the
shimming_problemfunction to minimize field inhomogeneity. - Uses the
MixedVariableGAalgorithm from thepymoolibrary to solve the optimization problem. - Outputs the optimized shim tray configuration.
5. Generating Optimized Shim Tray
- Creates an optimized shim tray based on the optimization results.
- Saves the optimized shim tray as an STL file and visualizes the shimmed magnetic field.
6. Saving and Loading Shim Tray
- Saves the optimized shim tray configuration to a
.pklfile. - Demonstrates how to reload and visualize the saved shim tray.
Key Functions and Libraries
magpylib: Used for magnetic field computations and visualization.pymoo: Provides optimization algorithms for solving the shimming problem.- Custom Functions:
get_field_pos,filter_dsv: Process and filter magnetic field data.make_shim_ring_template: Creates shim tray templates.cost_fn: Evaluates the field homogeneity.write2stl: Exports shim tray configurations to STL files.
Outputs
- Visualizations of the magnetic field before and after shimming.
- STL files for initial and optimized shim tray configurations.
- A
.pklfile containing the optimized shim tray for future use.
This script automates the process of designing and optimizing passive shim trays for magnetic field correction.
Metadata
Release files for passive-shimming 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| passive_shimming-0.0.1.tar.gz | 59.1 kB | Without provenance | Details for passive_shimming-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| passive_shimming-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for passive_shimming-0.0.1-py3-none-any.whl |
Total release size: 120.5 kB
Release files / passive_shimming-0.0.1.tar.gz
| Download URL | passive_shimming-0.0.1.tar.gz |
|---|---|
| Size | 59.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adf8bc9d740c27b516e7791baab3b1c511a3f169a0d946531d0f042cb1e56574
|
|
BLAKE2b-256 checksum How to use checksums |
18ed548c442e71ed2936b98a20c7313b871599dd1f13d90c801703da5528f68b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Release files / passive_shimming-0.0.1-py3-none-any.whl
| Download URL | passive_shimming-0.0.1-py3-none-any.whl |
|---|---|
| Size | 61.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4af77e4e4eea331ec1e8abe2550508163b5af66745dcd4023b2534a02d5b9c49
|
|
BLAKE2b-256 checksum How to use checksums |
b232644dea0aacefa563cb6b61fdc17e9202635c1c023ada903166e72a5d8c45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.9
|
Security for passive-shimming 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.