Skip to content

Commit

Permalink
[#159] Restructuring binning
Browse files Browse the repository at this point in the history
  • Loading branch information
dvezinet committed Nov 14, 2024
1 parent 473a9b0 commit d3a9ac8
Show file tree
Hide file tree
Showing 5 changed files with 1,413 additions and 1,474 deletions.
94 changes: 0 additions & 94 deletions datastock/_class01.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from . import _class01_show as _show
from . import _class01_compute as _compute
from . import _class01_domain as _domain
from . import _class01_binning as _binning
from . import _class01_interpolate as _interpolate
from . import _class01_uniformize as _uniformize
from . import _export_dataframe
Expand Down Expand Up @@ -778,99 +777,6 @@ def get_domain_ref(

return _domain.domain_ref(coll=self, domain=domain)

# ---------------------
# Binning
# ---------------------

def binning(
self,
data=None,
data_units=None,
axis=None,
# binning
bins0=None,
bins1=None,
bin_data0=None,
bin_data1=None,
bin_units0=None,
# kind of binning
integrate=None,
statistic=None,
# options
safety_ratio=None,
dref_vector=None,
verb=None,
returnas=None,
# storing
store=None,
store_keys=None,
):
""" Return the binned data
data: the data on which to apply binning, can be
- a list of np.ndarray to be binned
(any dimension as long as they all have the same)
- a list of keys to ddata items sharing the same refs
data_units: str only necessary if data is a list of arrays
axis: int or array of int indices
the axis of data along which to bin
data will be flattened along all those axis priori to binning
If None, assumes bin_data is not variable and uses all its axis
bins0: the bins (centers), can be
- a 1d vector of monotonous bins
- a int, used to compute a bins vector from max(data), min(data)
bin_data0: the data used to compute binning indices, can be:
- a str, key to a ddata item
- a np.ndarray
- a list of any of the above if each data has diff. size along axis
bin_units: str
only used if integrate = True and bin_data is a np.ndarray
integrate: bool
flag indicating whether binning is used for integration
Implies that:
Only usable for 1d binning (axis has to be a single index)
data is multiplied by bin_data0 step prior to binning
statistic: str
the statistic kwd feed to scipy.stats.binned_statistic()
automatically set to 'sum' if integrate = True
store: bool
If True, will sotre the result in ddata
Only possible if all (data, bin_data and bin) are provided as keys
"""

return _binning.binning(
coll=self,
data=data,
data_units=data_units,
axis=axis,
# binning
bins0=bins0,
bins1=bins1,
bin_data0=bin_data0,
bin_data1=bin_data1,
bin_units0=bin_units0,
# kind of binning
integrate=integrate,
statistic=statistic,
# options
safety_ratio=safety_ratio,
dref_vector=dref_vector,
verb=verb,
returnas=returnas,
# storing
store=store,
store_keys=store_keys,
)

# ---------------------
# Interpolation
# ---------------------
Expand Down
Loading

0 comments on commit d3a9ac8

Please sign in to comment.