{ "cells": [ { "metadata": {}, "cell_type": "markdown", "source": [ "# Tutorial 7: Angular scans\n", "\n", "As a package dedicated to GID data, `pygid` supports measurements with a varying angle of incidence (`ai`).\n", "\n", "The angle of incidence `ai` can be provided in several ways:\n", "\n", "- **Single value**\n", " ```python\n", " ai = 0.01\n", " ```\n", "- **List of values**\n", " ```python\n", " ai = [0.0, 0.01, 0.02]\n", " ```\n", "- **Automatically parsed from a scan command** (start, stop, number-1).\n", "```python\n", "scan = \"ascan om 0.0400 0.1000 12\"\n", "```\n", "or\n", "```python\n", "scan = \"0.0400 0.1000 12\"\n", "```\n", "\n", "NOTE: For angular scans, the number of angles (ai) in ExpParams should match the number of loaded images." ], "id": "617f6418251cf81" }, { "metadata": { "ExecuteTime": { "end_time": "2026-02-09T17:53:59.946930Z", "start_time": "2026-02-09T17:53:59.942287Z" } }, "cell_type": "code", "source": [ "from pygid.datasets import get_dataset\n", "\n", "# Download example dataset from Zenodo\n", "try:\n", " files = get_dataset(\"tutorial_07\")\n", " poni_path = files[\"poni\"]\n", " mask_path = files[\"mask\"]\n", " # several files for batch processing\n", " data_path = files[\"data\"]\n", "except:\n", " print(\"Dataset download skipped on Read the Docs.\")" ], "id": "25b1340933d39802", "outputs": [], "execution_count": 2 }, { "metadata": {}, "cell_type": "markdown", "source": "#### Single image for a single angle of incidence", "id": "8e5c87abc0054bed" }, { "metadata": { "ExecuteTime": { "end_time": "2026-02-09T17:57:49.852862Z", "start_time": "2026-02-09T17:57:49.761101Z" } }, "cell_type": "code", "source": [ "import pygid\n", "\n", "params = pygid.ExpParams(\n", " poni_path=poni_path,\n", " mask_path=mask_path,\n", " ai=0.004, # angle of incidence (degrees)\n", " fliplr=True,\n", " flipud=True\n", ")\n", "\n", "matrix = pygid.CoordMaps(\n", " params, # pygid.ExpParams\n", " vert_positive=True,\n", " hor_positive=True,\n", ")\n", "\n", "analysis = pygid.Conversion(\n", " matrix=matrix,\n", " path=data_path,\n", " dataset='/entry_0000/ESRF-ID10/eiger4m/data',\n", " frame_num = 0, # corresponding image\n", ")\n", "print(f\"ai: {params.ai}, number of images: {len(analysis.img_raw)}\")" ], "id": "82ab191f9e6a5d19", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ai: 0.004, number of images: 1\n" ] } ], "execution_count": 9 }, { "metadata": {}, "cell_type": "markdown", "source": "#### List of images, list of angles", "id": "a71456aeb9961d6a" }, { "metadata": { "ExecuteTime": { "end_time": "2026-02-09T17:57:43.165100Z", "start_time": "2026-02-09T17:57:42.949957Z" } }, "cell_type": "code", "source": [ "import pygid\n", "\n", "params = pygid.ExpParams(\n", " poni_path=poni_path,\n", " mask_path=mask_path,\n", " ai=[0.065, 0.07, 0.075], # angles of incidence (degrees)\n", " fliplr=True,\n", " flipud=True\n", ")\n", "\n", "matrix = pygid.CoordMaps(\n", " params, # pygid.ExpParams\n", " vert_positive=True,\n", " hor_positive=True,\n", ")\n", "\n", "analysis = pygid.Conversion(\n", " matrix=matrix,\n", " path=data_path,\n", " dataset='/entry_0000/ESRF-ID10/eiger4m/data',\n", " frame_num = [6,7,8], # corresponding images\n", ")\n", "\n", "print(f\"ai: {params.ai}, number of images: {len(analysis.img_raw)}\")" ], "id": "3aa8df31b1362eaa", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "ai: [0.065, 0.07, 0.075], number of images: 3\n" ] } ], "execution_count": 8 }, { "metadata": {}, "cell_type": "markdown", "source": "#### List of images, scan command", "id": "d2aa4465d0c6099a" }, { "metadata": { "ExecuteTime": { "end_time": "2026-02-09T17:58:13.619747Z", "start_time": "2026-02-09T17:58:13.144072Z" } }, "cell_type": "code", "source": [ "params = pygid.ExpParams(\n", " poni_path=poni_path, # path to the PONI file\n", " mask_path=mask_path,\n", " scan = \"ascan om 0.0400 0.1000 12\", # angle of incidence (degrees)\n", " fliplr=True,\n", " flipud=True\n", ")\n", "\n", "matrix = pygid.CoordMaps(\n", " params, # pygid.ExpParams\n", " vert_positive=True,\n", " hor_positive=True,\n", ")\n", "\n", "analysis = pygid.Conversion(\n", " matrix=matrix,\n", " path=data_path,\n", " dataset='/entry_0000/ESRF-ID10/eiger4m/data',\n", " frame_num = None, # all images\n", ")\n", "\n", "\n", "print(f\"ai: {params.ai}, number of images: {len(analysis.img_raw)}\")" ], "id": "264a1da28b48ba2a", "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO - ai list calculated: [0.04, 0.045, 0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.1]\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "ai: [0.04, 0.045, 0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.1], number of images: 13\n" ] } ], "execution_count": 11 }, { "metadata": {}, "cell_type": "code", "outputs": [], "execution_count": null, "source": "", "id": "11a7b36ca13e2b1e" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 5 }