Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions docs/user-guide/loki/loki-detector-test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%matplotlib widget\n",
"\n",
"import scipp as sc\n",
"import plopp\n",
"from ess import loki\n",
"from ess.sans.types import *\n",
"import scippneutron as scn"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1",
"metadata": {},
"outputs": [],
"source": [
"workflow = loki.LokiWorkflow()\n",
"\n",
"# Set detector bank name: in this case there is only one bank\n",
"workflow[NeXusDetectorName] = \"loki_detector_0\"\n",
"\n",
"# Wavelength and Q binning parameters\n",
"workflow[WavelengthBins] = sc.linspace(\"wavelength\", 1.0, 13.0, 201, unit=\"angstrom\")\n",
"workflow[QBins] = sc.linspace(dim=\"Q\", start=0.01, stop=0.3, num=101, unit=\"1/angstrom\")\n",
"\n",
"# Other parameters\n",
"workflow[CorrectForGravity] = True\n",
"workflow[UncertaintyBroadcastMode] = UncertaintyBroadcastMode.upper_bound\n",
"workflow[ReturnEvents] = False\n",
"workflow[BeamCenter] = sc.vector([0.0, 0.0, 0.0], unit=\"m\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"# Adjust filename as needed\n",
"workflow[Filename[SampleRun]] = '977695_00057856.hdf'\n",
"detector_events = workflow.compute(DetectorData[SampleRun])\n",
"counts = detector_events.hist()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"metadata": {},
"outputs": [],
"source": [
"plopp.slicer(counts)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4",
"metadata": {},
"outputs": [],
"source": [
"scn.instrument_view(counts, pixel_size=0.001)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "dev311",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
3 changes: 2 additions & 1 deletion src/ess/loki/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import importlib.metadata

from . import workflow
from .workflow import LokiAtLarmorWorkflow, default_parameters
from .workflow import LokiAtLarmorWorkflow, LokiWorkflow, default_parameters

try:
__version__ = importlib.metadata.version(__package__ or __name__)
Expand All @@ -15,6 +15,7 @@

__all__ = [
'LokiAtLarmorWorkflow',
'LokiWorkflow',
'default_parameters',
'workflow',
]
23 changes: 22 additions & 1 deletion src/ess/loki/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
TransmissionRun,
)

bank_size = {'layer': 4, 'tube': -1, 'straw': 7, 'pixel': 512}
DETECTOR_BANK_SIZES = {
'larmor_detector': {'layer': 4, 'tube': 32, 'straw': 7, 'pixel': 512}
'larmor_detector': bank_size,
**{f'loki_detector_{i}': bank_size for i in range(9)},
}


Expand Down Expand Up @@ -134,3 +136,22 @@ def LokiAtLarmorTutorialWorkflow() -> sciline.Pipeline:
workflow[Filename[EmptyBeamRun]] = data.loki_tutorial_run_60392()
workflow[BeamCenter] = sc.vector(value=[-0.02914868, -0.01816138, 0.0], unit='m')
return workflow


@register_workflow
def LokiWorkflow() -> sciline.Pipeline:
"""
Workflow with default parameters for Loki.

Returns
-------
:
Loki workflow as a sciline.Pipeline
"""
workflow = sans.SansWorkflow()
for provider in loki_providers:
workflow.insert(provider)
for key, param in default_parameters().items():
workflow[key] = param
workflow.typical_outputs = typical_outputs
return workflow
Loading