Axis
- class histpy.Axis(edges, label=None, scale=None)[source]
Bases:
objectBin edges. Optionally labeled
You can select specific edges using the slice operator (
[]). The result is also another Axis object.- Parameters:
edges (array-like) – Bin edges. Can be a Quantity array, if you need units
label (str) – Label for axis. If edges is an Axis object, this will override its label
scale (str) – Bin center mode e.g. “linear” or “log”. See axis_scale property. If edges is an Axis object, this will override its mode
- property unit
Return the astropy units of the axis. Or
Noneis units where not declare.
- property axis_scale
Control what is considered the center of the bin. This affects centers() and interpolations.
- Modes:
linear (default): The center is the midpoint between the bin edges
symmetric: same as linear, except for the first center, which will correspond to the lower edge. This is, for example, useful when the histogram is filled with the absolute value of a variable.
log: The center is the logarithmic (or geometrical) midpoint between the bin edges.
- find_bin(value)[source]
Return the bin value corresponds to.
- Returns:
Bin number. -1 for underflow, nbins for overflow
- Return type:
int
- interp_weights(value)[source]
Get the two closest bins to value, together with the weights to linearly interpolate between them. The bin contents are assigned to the center of the bin.
Values beyond the center of the first/last bin will result in the contents of the first/last bint, accordingly.
- Returns:
Bins. Shaped (2,N) [float, float]: Weights. Shaped (2,N)
- Return type:
[int, int]
- property lower_bounds
Lower bound of each bin
- property upper_bounds
Upper bound of each bin
- property bounds
Start of [lower_bound, upper_bound] values for each bin.
- property lo_lim
Overall lower bound
- property hi_lim
Overall upper bound of histogram
- property edges
Edges of each bin
- property label
Axis label
- property label_with_unit
Axis ‘label [units]’
- property centers
Center of each bin.
- property widths
Width each bin.
- property nbins
Number of elements along each axis. Either an int (1D histogram) or an array