Fix plotting CartesianPoint with correct units#551
Conversation
|
Looks good to me. Why wasn't this a problem in the past? |
We used to multiply the internal units to the coordinates of the points, but it was removed in PR #489 in commit 71f1435#diff-95b64031ac6b998495f3633cff57e7303b8128e459b3e9bfcc24214ad67cf409L14. This is also related to #183 (comment) |
| @series begin | ||
| seriestype --> :scatter | ||
| [pt.x], [pt.y], [pt.z] | ||
| [to_internal_units(pt.x) * internal_length_unit], |
There was a problem hiding this comment.
Quick explanation: to_internal_units will convert the value to internal_length_unit (in our case meters) and then strip the unit (or do nothing if the value does not have any units), and then add the unit again afterwards.
Therefore, we can handle both numbers with and without units.
There was a problem hiding this comment.
Yes, that seems very safe! I like it.
|
The updated documentation should be found here: https://juliaphysics.github.io/SolidStateDetectors.jl/previews/PR551 (once completed) |
Oh, oops. :-) Yes, then let's do it like this. |
|
Maybe we can have a central function |
|
I would refer this to a dedicated PR, that then also tackles everything else in #183 |
|
Sure. |
|
https://juliaphysics.github.io/SolidStateDetectors.jl/previews/PR551/tutorials/complete_simulation_chain_IVC/#Simulation-of-charge-drifts Looks like the plotting works now, I'm gonna merge this PR now. |

Quick attempt to fix #550:
CartesianPointscan now have units or be unitless.However, when plotting, it would be nice to always have them have units.
Right now, if a CartesianPoint does not have units, there is no way that the plot recipe knows what units the coordinates should have. According to our docstrings, we expect x, y and z to be in units of meters though, so this should also be reflected in the plots or be updated.
SolidStateDetectors.jl/src/ConstructiveSolidGeometry/PointsAndVectors/Points.jl
Lines 46 to 60 in 610bcce