Variable
- class psipy.model.variable.Variable(data, name, unit, runit)
Bases:
object
A single scalar variable.
This class primarily contains methods for plotting data. It can be created with any
xarray.DataArray
that has['theta', 'phi', 'r', 'time']
fields.- Parameters
- dataxarray.Dataset
Variable data.
- namestr
Variable name.
- unitastropy.units.Quantity
Variable unit for the scalar data.
- r_unitastropy.units.Quantity
Unit for the radial coordinates.
Attributes Summary
xarray.DataArray
with the data.Number of timesteps.
Longitude coordinate values.
Radial coordinate values.
Latitude coordinate values.
Timestep coordinate values.
Units of the scalar data.
Methods Summary
contour_equatorial_cut
(levels[, t_idx, ax])Plot contours on an equatorial cut.
contour_phi_cut
(i, levels[, t_idx, ax])Plot contours on a phi cut.
contour_radial_cut
(r_idx, levels[, t_idx, ax])Plot contours on a radial cut.
plot_equatorial_cut
([t_idx, ax])Plot an equatorial cut.
plot_phi_cut
(phi_idx[, t_idx, ax])Plot a phi cut.
plot_radial_cut
(r_idx[, t_idx, ax])Plot a radial cut.
radial_normalized
(radial_exponent)Return a radially normalised copy of this variable.
sample_at_coords
(lon, lat, r[, t])Sample this variable along a 1D trajectory of coordinates.
Attributes Documentation
- data
xarray.DataArray
with the data.
- n_timesteps
Number of timesteps.
- phi_coords
Longitude coordinate values.
- r_coords
Radial coordinate values.
- theta_coords
Latitude coordinate values.
- time_coords
Timestep coordinate values.
- unit
Units of the scalar data.
Methods Documentation
- contour_equatorial_cut(levels, t_idx=0, ax=None, **kwargs)
Plot contours on an equatorial cut.
- Parameters
- levelslist
List of levels to contour.
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- t_idxint, optional
Time index at which to slice the data.
- kwargs
Additional keyword arguments are passed to
xarray.plot.contour
.
- contour_phi_cut(i, levels, t_idx=0, ax=None, **kwargs)
Plot contours on a phi cut.
- Parameters
- iint
Index at which to slice the data.
- levelslist
List of levels to contour.
- t_idxint, optional
Time index at which to slice the data.
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- kwargs
Additional keyword arguments are passed to
xarray.plot.contour
.
- contour_radial_cut(r_idx, levels, t_idx=0, ax=None, **kwargs)
Plot contours on a radial cut.
- Parameters
- r_idxint
Radial index at which to slice the data.
- levelslist
List of levels to contour.
- t_idxint, optional
Time index at which to slice the data.
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- kwargs
Additional keyword arguments are passed to
xarray.plot.contour
.
- plot_equatorial_cut(t_idx=None, ax=None, **kwargs)
Plot an equatorial cut.
- Parameters
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- t_idxint, optional
Time index at which to slice the data. If not given, an anmiation will be created across all time indices.
- kwargs
Additional keyword arguments are passed to
xarray.plot.pcolormesh
.
- Returns
- plot_phi_cut(phi_idx, t_idx=None, ax=None, **kwargs)
Plot a phi cut.
- Parameters
- phi_idxint
Index at which to slice the data.
- t_idxint, optional
Time index at which to slice the data. If not given, an anmiation will be created across all time indices.
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- kwargs
Additional keyword arguments are passed to
xarray.plot.pcolormesh
.
- Returns
- plot_radial_cut(r_idx, t_idx=None, ax=None, **kwargs)
Plot a radial cut.
- Parameters
- r_idxint
Radial index at which to slice the data.
- t_idxint, optional
Time index at which to slice the data. If not given, an anmiation will be created across all time indices.
- axmatplolit.axes.Axes, optional
axes on which to plot. Defaults to current axes if not specified.
- kwargs
Additional keyword arguments are passed to
xarray.plot.pcolormesh
.
- Returns
- radial_normalized(radial_exponent)
Return a radially normalised copy of this variable.
Multiplies the variable by \((r / r_{\odot})^{\gamma}\), where \(\gamma\) =
radial_exponent
is the given exponent.- Parameters
- radial_exponentfloat
- Returns
- Variable
- sample_at_coords(lon: Unit('deg'), lat: Unit('deg'), r: Unit('m'), t: Optional[ndarray] = None) Quantity
Sample this variable along a 1D trajectory of coordinates.
- Parameters
- lonastropy.units.Quantity
Longitudes.
- latastropy.units.Quantity
Latitudes.
- rastropy.units.Quantity
Radial distances.
- tarray-like, optional
Timsteps. If the variable only has a single timstep, this argument is not required.
- Returns
- astropy.units.Quantity
The sampled data.
Notes
Linear interpolation is used to interpoalte between cells. See the docstring of
scipy.interpolate.interpn
for more information.