Commit d7d89663 authored by Magnus Nord's avatar Magnus Nord

Merge branch 'adf_quantification'

parents ecf83abc a2101090
Pipeline #36992373 failed with stage
in 14 minutes
......@@ -12,6 +12,8 @@ test_non_release_branches:
- xvfb-run -a python3 -m pytest --nbval-lax introduction_to_atomap.ipynb
- cd nanoparticle_example_notebook
- xvfb-run -a python3 -m pytest --nbval-lax --current-env
- cd ../adf_quantification_notebook
- xvfb-run -a python3 -m pytest --nbval-lax --current-env
- cd ../scripts
- xvfb-run -a python3 minimal_example_perovskite_100.py
- xvfb-run -a python3 minimal_example_perovskite_100_manual.py
......@@ -33,6 +35,8 @@ test_release_branch:
- xvfb-run -a python3 -m pytest --nbval-lax introduction_to_atomap.ipynb
- cd nanoparticle_example_notebook
- xvfb-run -a python3 -m pytest --nbval-lax --current-env
- cd ../adf_quantification_notebook
- xvfb-run -a python3 -m pytest --nbval-lax --current-env
- cd ../scripts
- xvfb-run -a python3 minimal_example_perovskite_100.py
- xvfb-run -a python3 minimal_example_perovskite_100_manual.py
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Analysing and Quantifying the Intensity of ADF STEM Images"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- 2018/3: First written by Katherine E. MacArthur \n",
"- 2018/8: Minor improvements by Magnus Nord"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 1 : Import hyperspy and atomap."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"nbval-skip"
]
},
"outputs": [],
"source": [
"%matplotlib qt5"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import hyperspy.api as hs\n",
"import atomap.api as am"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 2: Import and analyse electron flux."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = hs.load('PACBED.tif')\n",
"s.plot()\n",
"flux_pattern = s.data"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The following step creates an interactive plot to select the region which to fit a power law to the flux patter. Until anything is selected 'profiler' will be empty intially."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"profiler = am.quant.find_flux_limits(flux_pattern, 25)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Select the left limit with the left mouse button, the right limit with the right mouse button and then confirm with the centre button. Good values here could be 103 for the left limit, and 406 for the right limit.\n",
"\n",
"Once coordinates have been seleted a message will be printed above confirming.\n",
"\n",
"The limits can also be given directly to the function:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"profiler = am.quant.find_flux_limits(flux_pattern, 25, limits=(103, 406))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Running `analyse_flux` fits a power law to the flux profile in the selected region."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"expo = am.quant.analyse_flux(profiler[0].coords, profiler[1], 25)\n",
"expo"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 3: Import the an experimental image and a detector map."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s = hs.load('Pt0.7Ni0.3_ADF.tif')\n",
"s.plot()\n",
"det_image = am.example_data.get_detector_image_signal()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 4: Normalised images to an absolute scale."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For detector quantification with flux weighting use:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s_normalised = am.quant.detector_normalisation(s, det_image, inner_angle=60, outer_angle=None, flux_expo=expo[0])\n",
"s_normalised.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"For detector quantification without flux weighting simply remove the flux exponent."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s_normalised2 = am.quant.detector_normalisation(s, det_image, inner_angle=60, outer_angle=None)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"## Step 5: Carry out peak finding on normalised image."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"s_peaks = am.get_feature_separation(s, separation_range=(5,30), threshold_rel=0.1)\n",
"s_peaks.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"atom_positions = am.get_atom_positions(s, 8, threshold_rel=0.1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sublattice = am.Sublattice(atom_positions, s.data)\n",
"sublattice.plot()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sublattice.construct_zone_axes()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sublattice.refine_atom_positions_using_2d_gaussian(sublattice.image)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Step 6: Carry out integration of intensity over each atomic column."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(integrated_s, intensityRecord, pointRecord) = am.integrate(\n",
" s, sublattice.x_position, sublattice.y_position, method='Voronoi', max_radius=13)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"intensityRecord.plot(cmap='viridis')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Please note no multiplication is added au"
]
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "development_env",
"language": "python",
"name": "development_env"
},
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment