From 46f0976c9c4d041dbb1450c9c17b0b4335b58f66 Mon Sep 17 00:00:00 2001 From: Johannes Schumann <johannes.schumann@fau.de> Date: Tue, 4 May 2021 12:19:12 +0200 Subject: [PATCH] Add minimal run example in jupyter notebook --- notebooks/RunExample.ipynb | 130 +++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 notebooks/RunExample.ipynb diff --git a/notebooks/RunExample.ipynb b/notebooks/RunExample.ipynb new file mode 100644 index 0000000..396e2ee --- /dev/null +++ b/notebooks/RunExample.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [], + "source": [ + "from tempfile import TemporaryDirectory\n", + "\n", + "from km3buu.jobcard import generate_neutrino_jobcard\n", + "from km3buu.jobcard import XSECTIONMODE_LOOKUP, PROCESS_LOOKUP, FLAVOR_LOOKUP\n", + "from km3buu.ctrl import run_jobcard\n", + "from km3buu.geometry import CanVolume, SphericalVolume\n", + "\n", + "from km3buu.output import GiBUUOutput, write_detector_file" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Jobcard" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [], + "source": [ + "events = 1000\n", + "energy_min = 0.1\n", + "energy_max = 50\n", + "interaction = \"cc\"\n", + "flavor = \"electron\"\n", + "target_z = 8\n", + "target_a = 16\n", + "fluxfile = None\n", + "jc = generate_neutrino_jobcard(events, interaction, flavor, (energy_min,energy_max), (target_z,target_a),fluxfile=fluxfile)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Run" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2021-05-04 12:16:12 \u001b[31mERROR \u001b[0m ++ ctrl.py\u001b[31m: GiBUU stacktrace:\n", + "/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)\n", + "\u001b[0m\n" + ] + }, + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "outdir = TemporaryDirectory()\n", + "run_jobcard(jc, outdir.name)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Output" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "fobj = GiBUUOutput(outdir.name)\n", + "\n", + "volume = CanVolume()\n", + "# volume = SphericalVolume(100)\n", + "\n", + "write_detector_file(fobj, geometry=volume)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "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.9.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} -- GitLab