solarwindpy.Hist1Dο
- class Hist1D(x, y=None, logx=False, axnorm=None, clip_data=False, nbins=101, bin_precision=None)[source]ο
Bases:
AggPlotCreate 1D plot of x, optionally aggregating y in bins of x.
- _gb_axes, path
- set_path, set_data, agg, _format_axis, make_plot
- __init__(x, y=None, logx=False, axnorm=None, clip_data=False, nbins=101, bin_precision=None)[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.
- set_axnorm(new)[source]ο
The method by which the gridded data is normalized.
key
description
d
Density normalize
t
Total normalize
- construct_cdf(only_plotted=True)[source]ο
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
- 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.
- set_labels(**kwargs)[source]ο
Set or update x, y, or z labels. Any label not specified in kwargs.
is propagated from self.labels.<x, y, or z>.
- make_plot(ax=None, fcn=None, transpose_axes=False, gaussian_filter_std=0, plot_window=False, plot_window_edges=False, gaussian_filter_kwargs=None, **kwargs)[source]ο
Make a plot.
- Parameters:
ax (None, mpl.axis.Axis) β If None, create a subplot axis.
fcn (None, str, aggregative function, or 2-tuple) β Passed directly to {self.__class__.__name__}.agg. If None, use the default aggregation function. If str or a single aggregative function, use it. If a 2-tuple is passed, then the first element aggregates and the second element calculates an uncertainty.
transpose_axes (bool) β If True, plot independent values on y-axis and dependent values on x-axis. Primary use case is plotting 1D projection of 2D plot adjascent to 2D axis.
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()plot_window (bool) β Requires two functions passed to fcn. Instead of error bars, plots the uncertainty window as a semi-transparent band.
plot_window_edges (bool) β If True, plot solid lines at the window boundaries.
kwargs β Passed directly to ax.plot.
- take_data_in_yrange_across_x(ranges_by_x, get_x_bounds, get_y_bounds)[source]ο
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
- 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_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 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_clim(lower=None, upper=None)ο
Set the minimum (lower) and maximum (upper) allowed number of.
counts per bin to return after calling
agg().
- set_log(x=None, y=None)ο