Exemplo n.º 1
0
def test_neutron_instrument_view_with_cmap_args():
    d = make_dataset_with_beamline()
    scn.instrument_view(d["a"],
                        vmin=0.001 * sc.units.one,
                        vmax=5.0 * sc.units.one,
                        cmap="magma",
                        norm="log")
Exemplo n.º 2
0
def test_neutron_instrument_view_with_size_scalar():
    d = make_dataset_with_beamline()
    scn.instrument_view(d["a"],
                        components={
                            'sample':
                            _make_component_settings(data=d,
                                                     component_size=2.0)
                        })
Exemplo n.º 3
0
def test_neutron_instrument_view_components_with_non_beamline_component():
    d = make_dataset_with_beamline()
    widget_center = sc.vector(value=[1, 1, 1], unit=sc.units.m)
    scn.instrument_view(d["a"],
                        components={
                            'widget':
                            _make_component_settings(data=d,
                                                     center=widget_center)
                        })
Exemplo n.º 4
0
def test_neutron_instrument_view_components_multiple_valid():
    d = make_dataset_with_beamline()
    scn.instrument_view(d["a"],
                        components={
                            'sample':
                            _make_component_settings(data=d,
                                                     center='sample_position'),
                            'source':
                            _make_component_settings(data=d,
                                                     center='source_position')
                        })
Exemplo n.º 5
0
def test_neutron_instrument_view_components_with_wireframe():
    d = make_dataset_with_beamline()
    scn.instrument_view(d["a"],
                        components={
                            'sample':
                            _make_component_settings(data=d, wireframe=False)
                        })
    scn.instrument_view(d["a"],
                        components={
                            'sample':
                            _make_component_settings(data=d, wireframe=True)
                        })
Exemplo n.º 6
0
def test_neutron_instrument_view_components_with_invalid_size_unit():
    d = make_dataset_with_beamline()
    # mm is fine, source_position is set in meters. Just a scaling factor.
    scn.instrument_view(d["a"],
                        components={
                            'sample':
                            _make_component_settings(data=d,
                                                     size_unit=sc.units.mm)
                        })
    # cannot scale us to meters. This should throw
    with pytest.raises(sc.core.UnitError):
        scn.instrument_view(d["a"],
                            components={
                                'sample':
                                _make_component_settings(data=d,
                                                         size_unit=sc.units.us)
                            })
Exemplo n.º 7
0
def test_neutron_instrument_view_components_with_invalid_type():
    d = make_dataset_with_beamline()
    # Check that all our valid shape types work
    for shape_type in ['box', 'cylinder', 'disk']:
        scn.instrument_view(d["a"],
                            components={
                                'sample':
                                _make_component_settings(data=d,
                                                         type=shape_type)
                            })
    with pytest.raises(ValueError):
        scn.instrument_view(d["a"],
                            components={
                                'sample':
                                _make_component_settings(data=d,
                                                         type='trefoil_knot')
                            })
Exemplo n.º 8
0
def instrument_view(da: sc.DataArray,
                    components: dict = None,
                    pixel_size: float = 0.0035,
                    **kwargs) -> sc.plotting.objects.Plot:
    """
    Instrument view for the Amor instrument, which automatically populates a list of
    additional beamline components, and sets the pixel size.

    :param da: The input data for which to display the instrument view.
    :param components: A dict of additional components to display. By default, a
        set of components defined in `beamline.instrument_view_components()` are added.
    :param pixel_size: The detector pixel size. Default is 0.0035.
    """
    default_components = instrument_view_components(da)
    if components is not None:
        default_components = {**default_components, **components}

    return scn.instrument_view(da,
                               components=default_components,
                               pixel_size=pixel_size,
                               **kwargs)
Exemplo n.º 9
0
def test_neutron_instrument_view_components_valid():
    d = make_dataset_with_beamline()
    scn.instrument_view(
        d["a"], components={'sample': _make_component_settings(data=d)})
Exemplo n.º 10
0
def test_neutron_instrument_view_with_masks():
    d = make_dataset_with_beamline()
    x = np.transpose(d.coords['position'].values)[0, :]
    d['a'].masks['amask'] = sc.Variable(dims=['position'],
                                        values=np.less(np.abs(x), 0.5))
    scn.instrument_view(d["a"])
Exemplo n.º 11
0
def test_neutron_instrument_view_with_dataset():
    d = make_dataset_with_beamline()
    d['b'] = sc.Variable(dims=['position', 'tof'],
                         values=np.arange(36.).reshape(4, 9))
    scn.instrument_view(d)
Exemplo n.º 12
0
def test_neutron_instrument_view_3d():
    d = make_dataset_with_beamline()
    scn.instrument_view(d["a"])