From 2be9543f3e819091d05070cb299253df2f24ce4f Mon Sep 17 00:00:00 2001
From: opd16 on bm16ctrl <mauro.rovezzi@esrf.fr>
Date: Fri, 15 Nov 2024 14:23:27 +0100
Subject: [PATCH] add sandbox notebook for testing

---
 notebooks/devel_sandbox.ipynb | 190 ++++++++++++++++++++++++++++++++++
 1 file changed, 190 insertions(+)
 create mode 100644 notebooks/devel_sandbox.ipynb

diff --git a/notebooks/devel_sandbox.ipynb b/notebooks/devel_sandbox.ipynb
new file mode 100644
index 0000000..19406c0
--- /dev/null
+++ b/notebooks/devel_sandbox.ipynb
@@ -0,0 +1,190 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Development sandbox notebook\n",
+    "\n",
+    "This notebook is for development and testing of new features and bug fixes only."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "%load_ext autoreload\n",
+    "%autoreload 2\n",
+    "\n",
+    "# Uncomment the following two lines if the plots do not show in the notebook\n",
+    "# import plotly.io as pio\n",
+    "# pio.renderers.default = \"iframe\"\n",
+    "\n",
+    "import os\n",
+    "from dataclasses import asdict\n",
+    "from IPython.display import display\n",
+    "from famewoks import __version__ as wkflver\n",
+    "from famewoks.datamodel import (\n",
+    "    ExpSession,\n",
+    "    ExpCounters,\n",
+    "    CNTS_FLUO_XMAP,\n",
+    "    CNTS_FLUO,\n",
+    "    CNTS_CAS,\n",
+    ")\n",
+    "from famewoks.tests.datainfos import DATAINFOS, get_exp_session\n",
+    "from famewoks.plots import plot_data, plot_eshift\n",
+    "from famewoks.bliss2larch import (\n",
+    "    search_samples,\n",
+    "    show_samples_info,\n",
+    "    search_datasets,\n",
+    "    load_data,\n",
+    "    get_scans,\n",
+    "    get_group,\n",
+    "    set_enealign,\n",
+    "    apply_eshift,\n",
+    "    set_bad_fluo_channels,\n",
+    "    set_bad_scans,\n",
+    "    set_bad_samples,\n",
+    "    merge_data,\n",
+    "    save_data,\n",
+    ")\n",
+    "from famewoks.bliss2larch import _logger\n",
+    "\n",
+    "# adjust the logger level:\n",
+    "# \"DEBUG\" -> show all messages\n",
+    "# \"INFO\" -> useful messages\n",
+    "# \"WARNING\" -> warnings only\n",
+    "# \"ERROR\" -> only errors\n",
+    "_logger.setLevel(\"INFO\")\n",
+    "\n",
+    "# show workflow version (and famewoks branch information)\n",
+    "branch = os.popen(\"cd ~/devel/famewoks; git branch --show-current\").read()[:-1]\n",
+    "_logger.info(f\"--> Using famewoks version: {wkflver} (branch: {branch})\")\n",
+    "\n",
+    "# define the counters names or use those already defined for BM16: CNTS_FLUO_XMAP, CNTS_FLUO, CNTS_CAS\n",
+    "CNTS_CAS_XPAD = ExpCounters(\n",
+    "    ene=\"energy_enc\",\n",
+    "    ix=[\"p201_1_bkg_sub\", \"p201_3_bkg_sub\", \"p201_5_bkg_sub\"],  #: I0, I1, I2\n",
+    "    fluo_roi=[\"xpad_roi1\"],  # all detector names for ROI1\n",
+    "    fluo_corr=[\"xpad_roi1\"],  # all detector names (DT corrected)\n",
+    "    fluo_time=[\"sec\"],  # elapsed time, which is different for the spikes\n",
+    "    time=\"sec\",  # \"musst_timer\"\n",
+    ")\n",
+    "# define the experimental session metadata manually\n",
+    "session = ExpSession(\n",
+    "    flag=1,\n",
+    "    datadir=\"/data/visitor/a161838/bm16/20241113\",\n",
+    "    proposal=\"a161838\",\n",
+    "    session=\"20241113\",\n",
+    "    proposer=\"Quantin\",\n",
+    "    lc=\"AA, IK\",\n",
+    "    elem=\"V\",\n",
+    "    edge=\"K\",\n",
+    "    comment=\"\",\n",
+    "    counters=CNTS_CAS,  # *NOTE* give here the correct counters names!\n",
+    "    samples=[],\n",
+    "    bad_samples=[],\n",
+    "    bad_fluo_channels=None,\n",
+    "    enealign=None,\n",
+    ")\n",
+    "\n",
+    "# (testing) otherwise it is possible to get the session from a collection of previous experiments\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Isaure\",session=\"20241003\")\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Rimondi\",session=\"20241001\")\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Biswas\",session=\"20240924\")\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Sanchez\",session=\"20240716\")\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Stellato\",session=\"20240625\")\n",
+    "# session = get_exp_session(DATAINFOS, proposer=\"Bertrand\",session=\"20240910\")\n",
+    "\n",
+    "# display the session metadata\n",
+    "#display(asdict(session))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "samples = search_samples(session, ignore_names=[\"rack\", \"mount\", \"align\", \"bl_\", \"sample\"])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "sel_sample = 10\n",
+    "datasets = search_datasets(session, sample=sel_sample)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "sel_dataset = 0\n",
+    "dataset = datasets[sel_dataset]\n",
+    "load_data(\n",
+    "    session,\n",
+    "    dataset,\n",
+    "    use_fluo_corr=False,\n",
+    "    iskip=1, #: ignore the first point\n",
+    "    istrip=1, #: ignore the last point\n",
+    "    calc_eshift=True,\n",
+    "    merge=True,\n",
+    "    skip_scans=[],\n",
+    ")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "fig = plot_data(\n",
+    "    dataset,\n",
+    "    data=\"fluo\",\n",
+    "    ynorm=\"area\",\n",
+    "    show_slide=True,\n",
+    "    show_i0=False,\n",
+    "    show_e0=True,\n",
+    "    show_merge=\"rebin\",\n",
+    ")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "sloth2411",
+   "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.12.7"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
-- 
GitLab