diff --git a/src/tof/chopper.py b/src/tof/chopper.py index 2c22c35..6bba09b 100644 --- a/src/tof/chopper.py +++ b/src/tof/chopper.py @@ -41,16 +41,16 @@ class Chopper: The opening angles of the chopper cutouts. close: The closing angles of the chopper cutouts. - center: - The center of the chopper cutouts. - width: - The width of the chopper cutouts. + centers: + The centers of the chopper cutouts. + widths: + The widths of the chopper cutouts. name: The name of the chopper. Notes ----- - Either `open` and `close` or `center` and `width` must be provided, but not both. + Either `open` and `close` or `centers` and `widths` must be provided, but not both. """ def __init__( @@ -61,8 +61,8 @@ def __init__( phase: sc.Variable, open: sc.Variable | None = None, close: sc.Variable | None = None, - center: sc.Variable | None = None, - width: sc.Variable | None = None, + centers: sc.Variable | None = None, + widths: sc.Variable | None = None, direction: Direction = Clockwise, name: str = "", ): @@ -76,18 +76,18 @@ def __init__( ) self.direction = direction # Check that either open/close or center/width are provided, but not both - if tuple(x for x in (open, close, center, width) if x is not None) not in ( + if tuple(x for x in (open, close, centers, widths) if x is not None) not in ( (open, close), - (center, width), + (centers, widths), ): raise ValueError( - "Either open/close or center/width must be provided, got" - f" open={open}, close={close}, center={center}, width={width}." + "Either open/close or centers/widths must be provided, got" + f" open={open}, close={close}, center={centers}, width={widths}." ) if open is None: - half_width = width * 0.5 - open = center - half_width - close = center + half_width + half_width = widths * 0.5 + open = centers - half_width + close = centers + half_width self.open = (open if open.dims else open.flatten(to='cutout')).to( dtype=float, copy=False diff --git a/tests/chopper_test.py b/tests/chopper_test.py index c81a970..2da9ad0 100644 --- a/tests/chopper_test.py +++ b/tests/chopper_test.py @@ -295,17 +295,17 @@ def test_bad_direction_raises(): def test_chopper_create_from_centers_and_widths(): f = 10.0 * Hz - center = sc.array(dims=['cutout'], values=[15.0, 46.0], unit='deg') - width = sc.array(dims=['cutout'], values=[10.0, 16.0], unit='deg') + centers = sc.array(dims=['cutout'], values=[15.0, 46.0], unit='deg') + widths = sc.array(dims=['cutout'], values=[10.0, 16.0], unit='deg') chopper = tof.Chopper( frequency=f, - center=center, - width=width, + centers=centers, + widths=widths, phase=0.0 * deg, distance=5.0 * meter, ) - assert sc.allclose(chopper.open, center - width / 2) - assert sc.allclose(chopper.close, center + width / 2) + assert sc.allclose(chopper.open, centers - widths / 2) + assert sc.allclose(chopper.close, centers + widths / 2) expected = tof.Chopper( frequency=f, @@ -320,14 +320,14 @@ def test_chopper_create_from_centers_and_widths(): def test_chopper_create_raises_when_both_edges_and_centers_are_supplied(): with pytest.raises( - ValueError, match="Either open/close or center/width must be provided" + ValueError, match="Either open/close or centers/widths must be provided" ): tof.Chopper( frequency=10.0 * Hz, open=10.0 * deg, close=20.0 * deg, - center=15.0 * deg, - width=10.0 * deg, + centers=15.0 * deg, + widths=10.0 * deg, phase=0.0 * deg, distance=5.0 * meter, )