{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Spectra : stemplot\n\nOnce you have a table, one way to visualise how the ion peaks are distributed is to use\n:func:`~interferences.plot.spectra.stemplot`, which you can also access from your\ndataframe using the :class:`~interferences.mz` accessor:\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nfrom interferences import build_table\nfrom pyrolite.geochem.ind import REE"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Let's build a table to play with first, focusing on potential interferences for\nthulium (Tm), which has only one stable isotope ($\\mathrm{^{169}Tm}$),\nand is susceptible to interferences, especially for quadrupole ICP-MS:\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "window = (\"Tm[169]\", 0.1)\ndf = build_table(REE() + [\"O\", \"N\", \"H\"], window=window, max_atoms=2)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "From this table, we can create our plot, here limiting the labelling to the\nfive peaks with highest estimated intensity:\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "ax = df.mz.stemplot(window=window, max_labels=5, figsize=(8, 4))\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "While the production of the doubly-charged double-REE ions is likely less significant\nthan shown here (no penalisation for higher charges/larger molecules is included\nin generating these spectra), we can see that $\\mathrm{^{153}Eu^{16}O}$ could\nbe a potential interference issue if the conditions are relatively oxidised,\nand if there's sufficient hydrogen, $\\mathrm{^{168}Er^{1}H}$ may similarly\ncontribute to problems.\n\nNotably, there's a number of other potential ions in vicinity of\n$\\mathrm{^{169}Tm}$. However, most of these are doubly-charged double-REE ions.\nGiven the highly-correlated nature of the REE, these may not pose as significant\nissues for standardisation as the hydride and oxide ions.\n\n\n"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}