Skip to content

Commit

Permalink
pass config parameters to histogram calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jan 27, 2025
1 parent cae52ed commit 9962e78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/sed/binning/binning.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ def normalization_histogram_from_timed_dataframe(
axis: str,
bin_centers: np.ndarray,
time_unit: float,
**kwds,
) -> xr.DataArray:
"""Get a normalization histogram from a timed dataframe.
Expand All @@ -475,11 +476,12 @@ def normalization_histogram_from_timed_dataframe(
histogram.
bin_centers (np.ndarray): Bin centers used for binning of the axis.
time_unit (float): Time unit the data frame entries are based on.
**kwds: Additional keyword arguments passed to the bin_dataframe function.
Returns:
xr.DataArray: Calculated normalization histogram.
"""
histogram = bin_dataframe(df, axes=[axis], bins=[bin_centers]) * time_unit
histogram = bin_dataframe(df, axes=[axis], bins=[bin_centers], **kwds) * time_unit

data_array = xr.DataArray(
data=histogram,
Expand Down
12 changes: 12 additions & 0 deletions src/sed/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2377,13 +2377,25 @@ def get_normalization_histogram(
axis,
self._binned.coords[axis].values,
self._config["dataframe"]["timed_dataframe_unit_time"],
hist_mode=self.config["binning"]["hist_mode"],
mode=self.config["binning"]["mode"],
pbar=self.config["binning"]["pbar"],
n_cores=self.config["core"]["num_cores"],
threads_per_worker=self.config["binning"]["threads_per_worker"],
threadpool_api=self.config["binning"]["threadpool_API"],
)
else:
self._normalization_histogram = normalization_histogram_from_timed_dataframe(
self._timed_dataframe,
axis,
self._binned.coords[axis].values,
self._config["dataframe"]["timed_dataframe_unit_time"],
hist_mode=self.config["binning"]["hist_mode"],
mode=self.config["binning"]["mode"],
pbar=self.config["binning"]["pbar"],
n_cores=self.config["core"]["num_cores"],
threads_per_worker=self.config["binning"]["threads_per_worker"],
threadpool_api=self.config["binning"]["threadpool_API"],
)

return self._normalization_histogram
Expand Down

0 comments on commit 9962e78

Please sign in to comment.