Variable
- class psipy.model.variable.Variable(data, name, unit)
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']
fields.- Parameters
- dataxarray.DataArray
Variable data.
- namestr
Variable name.
- unitastropy.units.Quantity
Variable unit.
Attributes Summary
xarray.DataArray
with the data.Longitude coordinate values.
Radial coordinate values.
Latitude coordinate values.
Units of the scalar data.
Methods Summary
contour_equatorial_cut
(levels[, ax])Plot contours on an equatorial cut.
contour_phi_cut
(i, levels[, ax])Plot contours on a phi cut.
contour_radial_cut
(i, levels[, ax])Plot contours on a radial cut.
plot_equatorial_cut
([ax])Plot an equatorial cut.
plot_phi_cut
(i[, ax])Plot a phi cut.
plot_radial_cut
(i[, ax])Plot a radial cut.
radial_normalized
(radial_exponent)Return a radially normalised copy of this variable.
sample_at_coords
(lon, lat, r)Sample this variable along a 1D trajectory of coordinates.
Attributes Documentation
- data
xarray.DataArray
with the data.
- phi_coords
Longitude coordinate values.
- r_coords
Radial coordinate values.
- theta_coords
Latitude coordinate values.
- unit
Units of the scalar data.
Methods Documentation
- contour_equatorial_cut(levels, 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.
- kwargs :
Additional keyword arguments are passed to
xarray.plot.contour
.
- contour_phi_cut(i, levels, ax=None, **kwargs)
Plot contours on a phi cut.
- Parameters
- iint
Index at which to slice the data.
- levelslist
List of levels to contour.
- 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(i, levels, ax=None, **kwargs)
Plot contours on a radial cut.
- Parameters
- iint
Index at which to slice the data.
- levelslist
List of levels to contour.
- 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(ax=None, **kwargs)
Plot an equatorial cut.
- Parameters
- 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
.
- plot_phi_cut(i, ax=None, **kwargs)
Plot a phi cut.
- Parameters
- iint
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.pcolormesh
.
- plot_radial_cut(i, ax=None, **kwargs)
Plot a radial cut.
- Parameters
- iint
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.pcolormesh
.
- 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, lat, r)
Sample this variable along a 1D trajectory of coordinates.
- Parameters
- lonastropy.units.Quantity
Longitudes.
- latastropy.units.Quantity
Latitudes.
- rastropy.units.Quantity
Radial distances.
- 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.