{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Reading IXAS spectra\n", "\n", "*Last update: June 2021*\n", "\n", "The International X-ray Absorption Society ([IXAS](https://xrayabsorption.org)) maintains a [data library of XAFS spectra](https://xaslib.xrayabsorption.org/elem/) for several compounds and absorption edges. In this tutorial we will be accesing the library to retrieve, process and visualize spectra in `araucaria`.\n", "\n", "This notebook explains the the following steps:\n", "\n", "1. Read spectra from a uniform resource locator (URL).\n", "2. Create a collection with the spectra.\n", "3. Plot processed spectra." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Python version : 3.9.4\n", "Numpy version : 1.20.3\n", "Scipy version : 1.6.3\n", "Lmfit version : 1.0.2\n", "H5py version : 3.2.1\n", "Matplotlib version : 3.4.2\n", "Araucaria version : 0.1.10\n" ] } ], "source": [ "from araucaria.utils import get_version\n", "print(get_version(dependencies=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reading spectra directly from a URL\n", "\n", "The IXAS data library offers a [website frontend](https://xaslib.xrayabsorption.org/elem/) to download data. However, we will be reading it directly with assistance of the [urllib](https://docs.python.org/3/library/urllib.html) module of Python.\n", "\n", "We will be retrieving the following spectra acquired at the Se K-edge in the Advanced Photon Source synchrotron:\n", "\n", "| Name | ID |\n", "| :- | --- |\n", "| Se_CoSe_rt_01 | 185 |\n", "| Se_Cu2Se_rt_01 | 187 |\n", "| Se_CuSe_rt_01 | 189 |\n", "\n", "\n", "For convenience we will first create a dictionary with the names and ID of spectra. This dictionary will then be used to construct a list with the URLs:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://xaslib.xrayabsorption.org/rawfile/185/Se_CoSe_rt_01.xdi\n", "https://xaslib.xrayabsorption.org/rawfile/187/Se_Cu2Se_rt_01.xdi\n", "https://xaslib.xrayabsorption.org/rawfile/189/Se_CuSe_rt_01.xdi\n" ] } ], "source": [ "from os.path import join\n", "\n", "# dictionary with names and IDs\n", "dvals = {'names': ['Se_'+name+'_rt_01.xdi' for name in ['CoSe', 'Cu2Se', 'CuSe'] ],\n", " 'id' : ['185' , '187', '189']}\n", "\n", "# constructing urls\n", "urls = []\n", "static = 'https://xaslib.xrayabsorption.org/rawfile/'\n", "for i, name in enumerate(dvals['names']):\n", " urls.append(static + dvals['id'][i] + '/' + name)\n", "\n", "# printing urls\n", "for val in urls:\n", " print(val)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "