From d413c8bbed938196a5e9cb0fefafb1827d3ce96c Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Mon, 16 Apr 2018 18:54:00 -0400 Subject: [PATCH] Refs #49 Untested loading of DAVE data --- notebooks/strexp_fitting.ipynb | 45 +++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/notebooks/strexp_fitting.ipynb b/notebooks/strexp_fitting.ipynb index 4226e4c..459c2cf 100644 --- a/notebooks/strexp_fitting.ipynb +++ b/notebooks/strexp_fitting.ipynb @@ -148,14 +148,23 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/tmp/qef_data/data/notebooks/strexp\n" + ] + } + ], "source": [ "qef_data_dir = '/tmp/qef_data'\n", "data_dir = os.path.join(qef_data_dir, 'data', 'notebooks', 'strexp')\n", "if not os.path.isdir(data_dir):\n", - " raise RuntimeError('data dir', data_dir, 'does not exists')" + " raise IOError('data dir ' + data_dir + 'does not exists')\n", + "print(data_dir)" ] }, { @@ -165,13 +174,41 @@ "(Top)

Load data and visualize data

" ] }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "filenames = dict(dat='data.grp', bkg='background.grp', res='resolution.grp')\n", + "# Check files exists\n", + "for filename in filenames.values():\n", + " full_filename = pjn(data_dir, filename)\n", + " if not os.path.exists(full_filename):\n", + " raise IOError('File ' + filename + ' not found in ' + data_dir)\n", + " \n", + "res = load_dave(pjn(data_dir, 'resolution.grp'))\n", + "dat = load_dave(pjn(data_dir, 'data.grp'))\n", + "bkg = load_dave(pjn(data_dir, 'resolution.grp'))\n", + "\n", + "f, (ax1, ax2, ax3) = plt.subplots(1, 3)\n", + "[ax1.semilogy(res['x'], spectrum) for spectrum in res['y']]; ax1.set_title('resolution')\n", + "[ax2.semilogy(dat['x'], spectrum) for spectrum in dat['y']]; ax2.set_title('sample')\n", + "[ax3.semilogy(bkg['x'], spectrum) for spectrum in bkg['y']]; ax3.set_title('empty can')" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "files = dict(dat='data.grp', bkg='background.grp', 'res'=resolution.grp)\n", + "filenames = dict(dat='data.grp', bkg='background.grp', 'res'=resolution.grp)\n", + "# Check files exists\n", + "for filename in filenames.values():\n", + " if not os.path.isdir(os.path.join(data_dir, filename)):\n", + " raise IOError('File', filename, 'not found in', data_dir)\n", + " \n", "res = load_nexus(pjn(data_dir,'irs26173_graphite_res.nxs'))\n", "emin, emax = np.min(res['x']), np.max(res['x'])\n", "dat = load_nexus(pjn(data_dir,'irs26176_graphite002_red.nxs')) # data has 10 histograms\n",