Skip to content
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

Add helper functionality to plot quantities against temperature with axes labeled in both K and eV #2639

Open
namurphy opened this issue Apr 16, 2024 · 2 comments
Labels
effort: medium Requiring perhaps ∼1–3 days feature request Issues requesting a new feature or enhancement Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python visualization

Comments

@namurphy
Copy link
Member

namurphy commented Apr 16, 2024

Feature description

It would be helpful to have a plotting helper function that would let us have one x-axis or y-axis show temperature in kelvin and another showing $k_BT$ in eV on the opposite axis.

Motivation

Different fields in and adjacent to plasma science have different conventions for representing temperature. Fields like solar physics and astronomy often use K or MK, while laboratory plasma scientists tend to represent temperature (times an invisible Boltzmann constant) in eV or keV. In a cross-disciplinary meeting, it can take mental bandwidth (brainwidth? 🧠) for some folks to convert temperatures in K to eV, or from eV to K. Having an easy way to plot quantities against temperature with labels in both eV and K would help make plots that can be better understood across communities.

Implementation strategy

  • I'm not sure where this would be best implemented. It could possibly go in plasmapy.utils, or we might want to include
  • We'd need to make sure that this would handle linear, linear-log, and log-log plots.
  • We'd probably want to use the astropy.visualization.quantity_support context manager, as well as the astropy.units.temperature_energy equivalency.
  • It'd help to have an optional particle keyword argument so that the symbol of the particle can be included in the labels (i.e., $T_e$). To do this we'd probably need to add an extra attribute on Particle.
  • We'd need to make sure that this would work in multi-part plots.
  • We might want to add an admonition to the docs to say that we should not have the Boltzmann constant be silent, i.e. that we should say $k_B T$ instead of just $T$ for temperatures in eV.
  • We probably want to include a way to specify the specific units (i.e., K vs. eV or MK vs. keV).
  • How to test matplotlib plots is discussed in matplotlib's testing guide.
  • It'll also be helpful to include an example Jupyter notebook to demonstrate this, or to modify an existing notebook. It may be better to include this as a separate, follow-up pull request.
@namurphy namurphy added feature request Issues requesting a new feature or enhancement effort: medium Requiring perhaps ∼1–3 days visualization Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics labels Apr 16, 2024
@kuchtact
Copy link

I think that having a more general function where any two variables can be passed and the conversion is taken care of could also be useful. As an example doing meters and ion skin depth.

@pheuer
Copy link
Member

pheuer commented May 18, 2024

I think that having a more general function where any two variables can be passed and the conversion is taken care of could also be useful. As an example doing meters and ion skin depth.

Really it would be nice if matplotlib just had a better way of adding a second axis with a fixed relationship to the coordinates on the other axis

Current way to do this in matplotlib? https://stackoverflow.com/questions/55907892/matplotlib-secondary-axis-with-values-mapped-from-primary-axis/55909132#55909132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: medium Requiring perhaps ∼1–3 days feature request Issues requesting a new feature or enhancement Plasma Lv1 | Beginner Issues appropriate for someone who has some knowledge of physics Python Lv2 | Intermediate Issues that require a medium amount of knowledge of Python visualization
Projects
None yet
Development

No branches or pull requests

3 participants