solarwindpy.plotting.orbits
Plotting helpers specialized for solar wind orbits.
Classes
|
|
|
|
|
- class OrbitPlot(orbit, *args, **kwargs)[source]
Bases:
ABC- __init__(orbit, *args, **kwargs)[source]
- property orbit
- property grouped
joint.groupby with appropriate axes passes.
- set_path(*args, orbit=None, **kwargs)[source]
Set path information, accounting for orbit info.
- set_orbit(new)[source]
IntervalIndex corresponding to the times we want to subset the orbit.
- make_cut()[source]
- class OrbitHist1D(orbit, x, **kwargs)[source]
-
- __init__(orbit, x, **kwargs)[source]
Create a one-dimensional histogram.
- Parameters:
x (pandas.Series) – Data from which to create bins.
y (pandas.Series or None, optional) – Values to aggregate in bins of
x. IfNone, counts ofxare used.logx (bool, optional) – If
True, compute bins in logarithmic space.axnorm ({"t", "d", None}, optional) – Normalisation applied to the histogram.
"t"uses total counts and"d"yields a density.clip_data (bool, optional) – Remove extreme values at the 0.001 and 0.999 percentiles before binning or aggregation.
nbins (int or array-like, optional) – Binning strategy passed to
numpy.histogram_bin_edges()orpandas.cut()depending on the input type.bin_precision (int, optional) – Precision for decimal bin edges.
- agg(**kwargs)[source]
Perform the aggregation along the agg axes.
If either of the count limits specified in clim are not None, apply them.
fcn allows you to specify a specific function for aggregation. Otherwise, automatically choose “count” or “mean” based on the uniqueness of the aggregated values.
- make_plot(ax=None, fcn=None, **kwargs)[source]
Make a plot on ax.
If ax is None, create a mpl.subplots axis.
**kwargs passed directly to ax.plot.
drawstyle defaults to steps-mid
fcn passed to self.agg. Only one function is allow b/c we don’t yet handle uncertainties.
- property agg_axes
The axis to aggregate into, e.g. the z variable in an (x, y, z) heatmap.
- property alim
- property axnorm
Data normalization in plot.
Not mpl.colors.Normalize instance. That is passed as a kwarg to make_plot.
- calc_bins_intervals(nbins=101, precision=None)
Calculate histogram bins.
- nbins: int, str, array-like
If int, use np.histogram to calculate the bin edges. If str and nbins == “knuth”, use astropy.stats.knuth_bin_width to calculate optimal bin widths. If str and nbins != “knuth”, use np.histogram(data, bins=nbins) to calculate bins. If array-like, treat as bins.
- precision: int or None
Precision at which to store intervals. If None, default to 3.
- property categoricals
- property clim
- property clip
- static clip_data(data, clip)
- construct_cdf(only_plotted=True)
Convert the obsered measuremets.
- Returns:
cdf – “x” column is the value of the measuremnt. “position” column is the normalized position in the cdf. To plot the cdf:
cdf.plot(x=”x”, y=”cdf”)
- Return type:
pd.DataFrame
- property cut
- property data
- property edges
- get_plotted_data_boolean_series()
Return a boolean
pd.Seriesidentifying each plotted measurement.The series shares the same index as the stored data. To align with a different index you may need to adjust the returned series.
- get_subset_above_threshold(threshold, fcn='count')
Get the subset of data above a given threshold using fcn to.
aggregate. If axnorm set, this is used.
- property grouped
joint.groupby with appropriate axes passes.
- property intervals
- property joint
Combines the categorical and continuous data for Groupby.
- property labels
- property log
- property logger
- make_cut()
Calculate the Categorical quantities for the aggregation axes.
- property orbit
- property path
Path for saving figure.
- set_alim(lower=None, upper=None)
Set the minimum (lower) and maximum (upper) allowed value when.
aggregating. This is different from clim because it uses the agg_fcn. So behavior will change based on axnorm, etc.
- set_axnorm(new)
The method by which the gridded data is normalized.
key
description
d
Density normalize
t
Total normalize
- set_clim(lower=None, upper=None)
Set the minimum (lower) and maximum (upper) allowed number of.
counts per bin to return after calling
agg().
- set_data(x, y, clip)
- set_labels(**kwargs)
Set or update x, y, or z labels. Any label not specified in kwargs.
is propagated from self.labels.<x, y, or z>.
- set_log(x=None, y=None)
- set_orbit(new)
IntervalIndex corresponding to the times we want to subset the orbit.
- set_path(*args, orbit=None, **kwargs)
Set path information, accounting for orbit info.
- take_data_in_yrange_across_x(ranges_by_x, get_x_bounds, get_y_bounds)
Take data within y-ranges across x-values.
- Parameters:
ranges_by_x (iterable) – An iterable with keys used to get the left and right bounds for the data and values used to get the top and bottom bounds for the data.
get_x_bounds (function) – First argument is one key of ranges_by_x and returns left, right. Second argument is a kwarg (expected_logx) boolean to transform the returned values according to whether or not the keys are \(log(x)\) or \(x\) in a manner that matches data stored in Hist2D.
get_y_bounds (functions) – Takes on value of ranges_by_x and returns top, bottom. Second argument Second argument is a kwarg (expected_logx) boolean to transform the returned values according to whether or not the keys are \(log(y)\) or \(y\) in a manner that matches data stored in Hist2D.
- Returns:
taken – Array of indices for selecting data in interval.
- Return type:
np.ndarray 1D
- class OrbitHist2D(orbit, x, y, **kwargs)[source]
-
- __init__(orbit, x, y, **kwargs)[source]
- agg(**kwargs)[source]
Wrap Hist1D and Hist2D agg so that we can aggergate orbit legs.
Legs: Inbound, Outbound, and Both.
- project_1d(axis, project_counts=False, **kwargs)[source]
Make a Hist1D from the data stored in this His2D.
- Parameters:
axis (str) – “x” or “y”, specifying the axis to project into 1D.
kwargs – Passed to Hist1D. Primarily to allow specifying bin_precision.
- Returns:
h1
- Return type:
Hist1D
- make_one_plot(kind, ax=None, fcn=None, cbar=True, limit_color_norm=False, cbar_kwargs=None, **kwargs)[source]
Make one of “Inbound”, “Outbound”, or “Both” plots on ax.
If ax is None, create a mpl.subplots axis.
**kwargs passed directly to ax.plot.
drawstyle defaults to steps-mid
fcn passed to self.agg. Only one function is allow b/c we don’t yet handle uncertainties.
- Viable kinds are:
kind
allowable inputs
Inbound
Inbound, I, i
Outbound
Outbound, O, o
Both
Both, B, b
- make_in_out_plot(fcn=None, cbar=True, limit_color_norm=False, cbar_kwargs=None, **kwargs)[source]
Plot “Inbound” and “Outbound” on axes joined at perihelion.
If ax is None, create a mpl.subplots axis.
**kwargs passed directly to ax.plot.
drawstyle defaults to steps-mid
fcn passed to self.agg. Only one function is allow b/c we don’t yet handle uncertainties.
- make_in_out_both_plot(fcn=None, cbar=True, limit_color_norm=False, cbar_kwargs=None, **kwargs)[source]
Plot “Inbound”, “Outbound”, and “Both” on stacked axes.
If ax is None, create a mpl.subplots axis.
**kwargs passed directly to ax.plot.
drawstyle defaults to steps-mid
fcn passed to self.agg. Only one function is allow b/c we don’t yet handle uncertainties.
- property agg_axes
The axis to aggregate into, e.g. the z variable in an (x, y, z) heatmap.
- property alim
- property axnorm
Data normalization in plot.
Not mpl.colors.Normalize instance. That is passed as a kwarg to make_plot.
- calc_bins_intervals(nbins=101, precision=None)
Calculate histogram bins.
- nbins: int, str, array-like
If int, use np.histogram to calculate the bin edges. If str and nbins == “knuth”, use astropy.stats.knuth_bin_width to calculate optimal bin widths. If str and nbins != “knuth”, use np.histogram(data, bins=nbins) to calculate bins. If array-like, treat as bins.
- precision: int or None
Precision at which to store intervals. If None, default to 3.
- property categoricals
- property clim
- property clip
- static clip_data(data, clip)
- property cut
- property data
- property edges
- get_border()
Get the top and bottom edges of the plot.
- Returns:
border – Contains “top” and “bottom” fields, each with a
pd.Series.- Return type:
namedtuple
- get_plotted_data_boolean_series()
Return a boolean
pd.Seriesidentifying each plotted measurement.The series shares the same index as the stored data. To align with a different index you may need to adjust the returned series.
- get_subset_above_threshold(threshold, fcn='count')
Get the subset of data above a given threshold using fcn to.
aggregate. If axnorm set, this is used.
- property grouped
joint.groupby with appropriate axes passes.
- id_data_above_contour(level)
Gets data above the level.
- Parameters:
level (scalar) – The z-value above which to select data. Data is aggregated according to ax_norm.
- Returns:
above_contour – For data in a bin above level, indicates the x-pd.Interval within which the observation falls. NaN are observations that are below level. This object is purposely the same length as the data stored by Hist2D and can be used in groupby operations.
- Return type:
pd.Series
- property intervals
- property joint
Combines the categorical and continuous data for Groupby.
- property labels
- property log
- property logger
- make_cut()
Calculate the Categorical quantities for the aggregation axes.
- make_joint_h2_h1_plot(project_counts=True, kwargs_1d=None, fig_axes=None, **kwargs)
- make_plot(ax=None, cbar=True, limit_color_norm=False, cbar_kwargs=None, fcn=None, alpha_fcn=None, **kwargs)
Make a 2D plot on ax using ax.pcolormesh.
- Parameters:
ax (mpl.axes.Axes, None) – If None, create an Axes instance from plt.subplots.
cbar (bool) – If True, create color bar with labels.z.
limit_color_norm (bool) – If True, limit the color range to 0.001 and 0.999 percentile range of the z-value, count or otherwise.
cbar_kwargs (dict, None) – If not None, kwargs passed to self._make_cbar.
fcn (FunctionType, None) – Aggregation function. If None, automatically select in
agg().alpha_fcn (None, str) – If not None, the function used to aggregate the data for setting alpha value.
kwargs – Passed to ax.pcolormesh. If row or column normalized data, norm defaults to mpl.colors.Normalize(0, 1).
- Returns:
ax (mpl.axes.Axes) – Axes upon which plot was made.
cbar_or_mappable (colorbar.Colorbar, mpl.collections.QuadMesh) – If cbar is True, return the colorbar. Otherwise, return the Quadmesh used to create the colorbar.
- property orbit
- property path
Path for saving figure.
- plot_contours(ax=None, label_levels=True, cbar=True, limit_color_norm=False, cbar_kwargs=None, fcn=None, plot_edges=False, edges_kwargs=None, clabel_kwargs=None, skip_max_clbl=True, use_contourf=False, gaussian_filter_std=0, gaussian_filter_kwargs=None, nan_aware_filter=False, **kwargs)
Make a contour plot on ax using ax.contour.
- Parameters:
ax (mpl.axes.Axes, None) – If None, create an Axes instance from plt.subplots.
label_levels (bool) – If True, add labels to contours with ax.clabel.
cbar (bool) – If True, create color bar with labels.z.
limit_color_norm (bool) – If True, limit the color range to 0.001 and 0.999 percentile range of the z-value, count or otherwise.
cbar_kwargs (dict, None) – If not None, kwargs passed to self._make_cbar.
fcn (FunctionType, None) – Aggregation function. If None, automatically select in
agg().plot_edges (bool) – If True, plot the smoothed, extreme edges of the 2D histogram.
edges_kwargs (None, dict) – Passed to {self.plot_edges!s}.
clabel_kwargs (None, dict) – If not None, dictionary of kwargs passed to ax.clabel.
skip_max_clbl (bool) – If True, don’t label the maximum contour. Primarily used when the maximum contour is, effectively, a point.
maximum_color – The color for the maximum of the PDF.
use_contourf (bool) – If True, use ax.contourf. Else use ax.contour.
gaussian_filter_std (int) – If > 0, apply scipy.ndimage.gaussian_filter to the z-values using the standard deviation specified by gaussian_filter_std.
gaussian_filter_kwargs (None, dict) – If not None and gaussian_filter_std > 0, passed to
scipy.ndimage.gaussian_filter()nan_aware_filter (bool) – If True and gaussian_filter_std > 0, use NaN-aware filtering via normalized convolution. Otherwise use standard scipy.ndimage.gaussian_filter.
kwargs – Passed to
ax.pcolormesh(). If row or column normalized data, norm defaults to mpl.colors.Normalize(0, 1).
- plot_edges(ax, smooth=True, sg_kwargs=None, **kwargs)
Overplot the edges.
- Parameters:
ax – Axis on which to plot.
smooth (bool) – If True, apply a Savitzky-Golay filter (
scipy.signal.savgol_filter()) to the y-values before plotting to smooth the curve.sg_kwargs (dict, None) – If not None, dict of kwargs passed to Savitzky-Golay filter. Also allows for setting of window_length and polyorder as kwargs. They default to 10% of the number of observations (window_length) and 3 (polyorder). Note that because window_length must be odd, if the 10% value is even, we take 1-window_length.
kwargs – Passed to ax.plot
- plot_hist_with_contours(ax=None, cbar=True, limit_color_norm=False, cbar_kwargs=None, fcn=None, levels=None, label_levels=False, use_contourf=True, contour_kwargs=None, clabel_kwargs=None, skip_max_clbl=True, gaussian_filter_std=0, gaussian_filter_kwargs=None, nan_aware_filter=False, **kwargs)
Make a 2D pcolormesh plot with contour overlay.
Combines make_plot (pcolormesh background) with plot_contours (contour/contourf overlay) in a single call.
- Parameters:
ax (mpl.axes.Axes, None) – If None, create an Axes instance from plt.subplots.
cbar (bool) – If True, create color bar with labels.z.
limit_color_norm (bool) – If True, limit the color range to 0.001 and 0.999 percentile range.
cbar_kwargs (dict, None) – If not None, kwargs passed to self._make_cbar.
fcn (FunctionType, None) – Aggregation function. If None, automatically select.
levels (array-like, int, None) – Contour levels. If None, automatically determined.
label_levels (bool) – If True, add labels to contours with ax.clabel.
use_contourf (bool) – If True, use filled contours. Else use line contours.
contour_kwargs (dict, None) – Additional kwargs passed to contour/contourf (e.g., linestyles, colors).
clabel_kwargs (dict, None) – Kwargs passed to ax.clabel.
skip_max_clbl (bool) – If True, don’t label the maximum contour level.
gaussian_filter_std (int) – If > 0, apply Gaussian filter to contour data.
gaussian_filter_kwargs (dict, None) – Kwargs passed to scipy.ndimage.gaussian_filter.
nan_aware_filter (bool) – If True and gaussian_filter_std > 0, use NaN-aware filtering via normalized convolution. Otherwise use standard scipy.ndimage.gaussian_filter.
kwargs – Passed to ax.pcolormesh.
- Returns:
ax (mpl.axes.Axes)
cbar_or_mappable (colorbar.Colorbar or QuadMesh)
qset (QuadContourSet) – The contour set from the overlay.
lbls (list or None) – Contour labels if label_levels is True.
- set_alim(lower=None, upper=None)
Set the minimum (lower) and maximum (upper) allowed value when.
aggregating. This is different from clim because it uses the agg_fcn. So behavior will change based on axnorm, etc.
- set_axnorm(new)
The method by which the gridded data is normalized.
key
description
c
Column normalize
d
Density normalize
r
Row normalize
t
Total normalize
cd
PDFs in each column
rd
PDFs in each row
- set_clim(lower=None, upper=None)
Set the minimum (lower) and maximum (upper) allowed number of.
counts per bin to return after calling
agg().
- set_data(x, y, z, clip)
- set_labels(**kwargs)
Set or update x, y, or z labels. Any label not specified in kwargs.
is propagated from self.labels.<x, y, or z>.
- set_log(x=None, y=None)
- set_orbit(new)
IntervalIndex corresponding to the times we want to subset the orbit.
- set_path(*args, orbit=None, **kwargs)
Set path information, accounting for orbit info.
- take_data_in_yrange_across_x(ranges_by_x, get_x_bounds, get_y_bounds)
Take data within y-ranges across x-values.
- Parameters:
ranges_by_x (iterable) – An iterable with keys used to get the left and right bounds for the data and values used to get the top and bottom bounds for the data.
get_x_bounds (function) – First argument is one key of ranges_by_x and returns left, right. Second argument is a kwarg (expected_logx) boolean to transform the returned values according to whether or not the keys are \(log(x)\) or \(x\) in a manner that matches data stored in Hist2D.
get_y_bounds (functions) – Takes on value of ranges_by_x and returns top, bottom. Second argument Second argument is a kwarg (expected_logx) boolean to transform the returned values according to whether or not the keys are \(log(y)\) or \(y\) in a manner that matches data stored in Hist2D.
- Returns:
taken – Array of indices for selecting data in interval.
- Return type:
np.ndarray 1D