Skip to content

Commit 1390c80

Browse files
committed
fix: replace q-grid by q-bin-edges
1 parent 1f3d215 commit 1390c80

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/ess/reflectometry/tools.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,24 +238,27 @@ def cost(scaling_factors):
238238

239239
def combine_curves(
240240
curves: Sequence[sc.DataArray],
241-
qgrid: sc.Variable | None = None,
241+
q_bin_edges: sc.Variable | None = None,
242242
) -> sc.DataArray:
243243
'''Combines the given curves by interpolating them
244-
on a grid and merging them by the requested method.
245-
The default method is a weighted mean where the weights
244+
on a 1d grid defined by :code:`q_bin_edges` and averaging
245+
over the provided reflectivity curves.
246+
247+
The averaging is done using a weighted mean where the weights
246248
are proportional to the variances.
247249
248250
Unless the curves are already scaled correctly they might
249-
need to be scaled using :func:`scale_reflectivity_curves_to_overlap`.
251+
need to be scaled using :func:`scale_reflectivity_curves_to_overlap`
252+
before calling this function.
250253
251254
All curves must be have the same unit for data and the Q-coordinate.
252255
253256
Parameters
254257
----------
255258
curves:
256259
the reflectivity curves that should be combined
257-
qgrid:
258-
the Q-grid of the resulting combined reflectivity curve
260+
q_bin_edges:
261+
the Q bin edges of the resulting combined reflectivity curve
259262
260263
Returns
261264
---------
@@ -267,8 +270,8 @@ def combine_curves(
267270
if len({c.coords['Q'].unit for c in curves}) != 1:
268271
raise ValueError('The Q-coordinates must have the same unit for each curve')
269272

270-
r = _interpolate_on_qgrid(map(sc.values, curves), qgrid).values
271-
v = _interpolate_on_qgrid(map(sc.variances, curves), qgrid).values
273+
r = _interpolate_on_qgrid(map(sc.values, curves), q_bin_edges).values
274+
v = _interpolate_on_qgrid(map(sc.variances, curves), q_bin_edges).values
272275

273276
v[v == 0] = np.nan
274277
inv_v = 1.0 / v
@@ -281,5 +284,5 @@ def combine_curves(
281284
variances=v_avg,
282285
unit=next(iter(curves)).data.unit,
283286
),
284-
coords={'Q': qgrid},
287+
coords={'Q': q_bin_edges},
285288
)

0 commit comments

Comments
 (0)