-
Notifications
You must be signed in to change notification settings - Fork 60
Add support for integrated sensor pixel field visualization #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…te-github-actions
After a long discussion with CoPilot Its mostly telling me what it thinks I want to hear, and not offering so much objective perspective - but it helped me go through the use cases. I suggest the following interface:
|
…-sensor-pixel-field
… and color scales
…or improved clarity in Pixel Field documentation
…ield and related functions
…scaling and colorscaling
…t symbol handling in PixelField
…/magpylib into show-sensor-pixel-field
@OrtnerMichael Ready for final review! As discussed in our latest meeting, we are still going to keep the nested structure with the following parameters:
|
Notes
This PR aims to add a new field visualization method that easily integrates with Magpylib. The
Sensor
object with itspixel
is the perfect object to use for this purpose!With this new capability one can display the vector field for
"B", "H", "M", or "J"
and overlay a magnitude (e.g. "Bxy", "Hz", etc.. )Below some example on how it may be used (more in the PR docs):
Animated B-field
Code to reproduce
Tasks
Updated Task List
Align
style.pixel.field
parameters naming and behaviorsource
(default=None
): defines the field source for vector direction and color mapping:None
: No field representation is shown"B"
,"Hxy"
,"Jxyz"
, etc.: Colors are mapped to the magnitude of the specified fieldsymbol
(default="cone"
): specifies the rendering symbol for field values"none"
:pixel.symbol
representation takes precedence overpixel.field.symbol
"cone"
: 3D cone representation"arrow3d"
: 3D arrow representation"arrow"
: 2D line-based arrowshownull
(default=True
): toggles visibility of pixels with zero and invalid field vectorsTrue
: Null vectors are displayedFalse
: Null vectors are hiddensizescaling
(default="uniform"
): determines how arrow size relates to thesource
magnitude"uniform"
: Uniform arrow size"linear"
: Size proportional to magnitude"log"
: Size proportional to normalized logarithm of magnitude"log^n"
: Size proportional to normalized nth (2 to 9) logarithm of magnitudesizemin
(default=0.1
): minimum relative size of field symbols (float between 0 and 1)colorscaling
(default="uniform"
): determines how arrow color relates to thesource
magnitude"uniform"
: Uniform color for all arrows"linear"
: Color scaling proportional to magnitude"log"
: Color scaling proportional to normalized logarithm of magnitude"log^n"
: Color scaling proportional to normalized nth (2 to 9) logarithm of magnitudecolormap
(default="Viridis"
): specifies the colormap used for color mapping"Viridis"
,"Inferno"
,"Magma"
, etc.) compatible with both Plotly and MatplotlibMagnitude normalization is performed individually for each sensor along its path
style.pixel.symbol
behavior when field representation is disabled:pixel.field.source=None
orpixel.field.symbol="none"
, falls back topixel.symbol
representationpoint
/box
or according topixel.symbol
)Show hull over pixels only when no field values are provided (when
pixel.field.source=None
)Make sure it works with all backends
Docs: add or modify an example to reflect the changes
Changelog: document new feature
Testing: add unit tests to cover the common and edge cases