solarwindpy.core.ions.Ionο
- class Ion(data: DataFrame, species: str)[source]ο
Bases:
BaseContainer for a single ion species.
- Parameters:
data (
pandas.DataFrame) β Data for the ion in the form("M", "C")whereMis the measurement type (n,v,w) andCis the component.species (str) β Species identifier, e.g.
"p"for protons or"a"for alpha particles.
- __init__(data: DataFrame, species: str)[source]ο
Initialize an Ion instance with plasma measurement data.
- Parameters:
data (pandas.DataFrame) β Ion measurement data with MultiIndex columns formatted as (βMβ, βCβ) where M is measurement type (n, v, w, T) and C is component (x, y, z, par, per, etc.).
species (str) β Ion species identifier following standard conventions: - βp1β or βpβ for protons - βaβ for alpha particles (He2+) - βo6β for O6+ ions - Other species as needed
Notes
The Ion class provides access to fundamental plasma measurements:
n: Number density [cm^-3]
v: Velocity vector [km/s]
w: Thermal speed [km/s] (assumes mwΒ² = 2kT)
T: Temperature [K] (derived from thermal speed)
Physical constants and mass values are automatically assigned based on the species identifier using standard atomic masses.
Examples
Create a proton ion from measurement data:
>>> import pandas as pd >>> import numpy as np >>> columns = pd.MultiIndex.from_tuples([ ... ('n', '', 'p1'), ... ('v', 'x', 'p1'), ('v', 'y', 'p1'), ('v', 'z', 'p1'), ... ('w', 'par', 'p1'), ('w', 'per', 'p1') ... ], names=['M', 'C', 'S']) >>> df = pd.DataFrame(np.random.rand(2, 6), columns=columns) >>> proton_data = df.xs('p1', level='S', axis=1) >>> proton = Ion(proton_data, 'p1') >>> proton.species 'p1'
- set_species(species: str) None[source]ο
Set the species of the ion.
- Parameters:
species (str) β The species of the ion.
- Raises:
ValueError β If the species contains a β+β character.
- set_data(data: DataFrame) None[source]ο
Set the data for the ion.
- Parameters:
data (pd.DataFrame) β The data to set for the ion.
- Raises:
ValueError β If the data column names are unrecognized.
- property number_density: Seriesο
Get the number density of the ion.
- property n: Seriesο
Alias for number_density property.
- property mass_density: Seriesο
Calculate the ionβs mass density.
- property rho: Seriesο
Alias for mass_density property.
- property anisotropy: Seriesο
Calculate temperature anisotropy R_T = p_β/p_β₯.
- Returns:
Temperature anisotropy.
- Return type:
pd.Series
- property temperature: DataFrameο
Calculate temperature T = (m / (2 * k_B)) * w^2.
- Returns:
Temperature of the ion.
- Return type:
pd.DataFrame
- property pth: DataFrameο
Calculate thermal pressure p_th = 0.5 * Ο * w^2.
- Returns:
Thermal pressure.
- Return type:
pd.DataFrame
- property cs: DataFrameο
Calculate the speciesβ sound speed.
- Returns:
Sound speed of the ion species.
- Return type:
pd.DataFrame
- property specific_entropy: Seriesο
Calculate the specific entropy S = p_th * Ο^(-Ξ³).
- Returns:
Specific entropy of the ion.
- Return type:
pd.Series
References
Siscoe, G. L. (1983). Solar System Magnetohydrodynamics (pp. 11-100). https://doi.org/10.1007/978-94-009-7194-3_2
- property S: Seriesο
Alias for specific_entropy property.
- property kinetic_energy_fluxο
Calculate the kinetic energy flux.
The kinetic energy flux is calculated as:
\[W_k = \frac{1}{2} \rho v^3\]- Returns:
Kinetic energy flux.
- Return type:
pd.Series
- property Wkο
Shortcut to
kinetic_energy_flux.
- property constants: Constantsο
Physical constants.
- Returns:
Physical constants instance.
- Return type:
uc.Constants
- property data: DataFrameο
Underlying DataFrame containing the data.
- Returns:
Data with MultiIndex columns.
- Return type:
pd.DataFrame
- head()ο
Return the first few rows of the data.
- Returns:
First few rows of the data.
- Return type:
pd.DataFrame
- static mi_tuples(x: Tuple[Tuple[str, ...], ...]) MultiIndexο
Create a MultiIndex from tuples with appropriate names.
- Parameters:
x (Tuple[Tuple[str, ...], ...]) β Tuples to create MultiIndex from.
- Returns:
MultiIndex created from tuples.
- Return type:
MI
- tail()ο
Return the last few rows of the data.
- Returns:
Last few rows of the data.
- Return type:
pd.DataFrame