Debian Codegraph @

doc/source/gap_analysis.rst

raw
1 Gap Analysis
2 ============
3
4 This example explains the procedure that is necessary to analyse a gap (e.g.
5 a superconducting gap) from an ARPES spectrum with ``arpys``.
6
7 Throughout the example we will assume that we have a file 'spectrum.p'
8 containing the ARPES spectrum and 'gold.p' with the corresponding gold
9 reference data, and that they have been loaded with
10 :func:`~arpys.dataloaders.load_data` and saved as ``D`` and ``G``
11 respectively.
12 Also, the ``dataloading`` and ``postprocessing`` modules have been loaded::
13
14 from arpys import dl,pp
15
16 1. Adjust Fermi level
17 ---------------------
18
19 First off, we need to precisely determine the Fermi level (which can vary
20 across angular channels).
21 This is done by fitting a Fermi-Dirac distribution convoluted by a Gaussian
22 to simulate the instrument resolution to each EDC.
23 Often it helps to add some additional linear components to the fit function,
24 as is done in :func:`~arpys.postprocessing.fermi_fit_func`.
25
26 1.1 Fermi fit
27 ^^^^^^^^^^^^^
28
29 This process is automated in :func:`~arpys.postprocessing.fig_gold_array`
30 (the more convenient method of using :func:`~arpys.postprocessing.fit_gold`
31 relies on a specific organization of the data within ``G`` and is therefore
32 less recommended).
33 If we know that the energies lie along ``G.xscale`` and the shape of
34 ``G.data`` is ``(1, n_angles, n_energies)`` we would do::
35
36 levels, sigmas, slopes, offsets, functions = pp.fit_gold_array(G.data[0],
37 G.xscale, ef, T)
38
39 where ``ef`` is a starting guess for the Fermi level and ``T`` is the
40 temperature at which the spectrum was taken.
41
42 .. note::
43 If the shape of ``G.data`` differs from the above, we would need to
44 reorganize it first. Ultimately,
45 :func:`~arpys.postprocessing.fit_gold_array` expects a 2d array of shape
46 ``(n_angles, n_energies)``.
47
48 Confer the documentation of :func:`~arpys.postprocessing.fit_gold_array` for
49 explanation of its output.
50 You will mostly need the ``levels`` only, but all the other output is useful
51 for checking whether the fit worked reasonably.
52
53 .. note::
54 You may notice that the execution of the above command may take some
55 time.
56 This is because there are ``n_angles`` fitting procedures that need
57 to be carried out.
58 If you have confirmed that the fitting worked reasonably well, it is
59 therefore a good idea to store the result in some form, and just load it
60 in again, whenever needed, instead of always carrying out the fit.
61 One way of achieving this is by using ``pickle``::
62
63 import pickle
64 with open('my_file_to_store_gold_fit_results.p', 'wb') as f :
65 pickle.dump(levels, f)
66
67 The ``levels`` can then be loaded by::
68
69 with open('my_file_to_store_gold_fit_results.p', 'rb') as f :
70 levels = pickle.load(f)
71
72 Of course you can store more than just the levels.
73 This is a nice way of storing arbitrary python objects (however, some
74 objects cannot be *pickled*, like for example the ``functions``).
75
76 ``arpys`` provides two convenience functions to save you some typing:
77 :func:`~arpys.dataloaders.dump` and :func:`~arpys.dataloaders.load_pickle`.
78
79 .. _sec_smoothing:
80
81 1.2 Smoothing
82 ^^^^^^^^^^^^^
83
84 Since the ``levels`` are usually quite noisy, it is recommended to apply some
85 operation to get a *nicer* curve. One way is to smoothen it (e.g. using
86 :func:`arpys.postprocessing.smooth`) or to fit a polynomial to the ``levels``.
87 The following figure shows what this could look like.
88
89 .. figure:: ../img/gold.png
90 :alt: Image not found.
91
92 Fermi level fitting. To the left we see a false color plot of the gold
93 spectrum. Clearly the Fermi level is closely above 50.4 eV, which is what
94 was given as the starting guess for
95 :func:`~arpys.postprocessing.fig_gold_array`.
96 To the right, the resulting ``levels`` are plotted against the angles
97 (``G.xscale`` in this example) in blue. Clearly, this result is rather noisy.
98 The red line shows a smoothed version of the blue curve.
99
100 1.3 Applying to data
101 ^^^^^^^^^^^^^^^^^^^^
102
103 Once we have our levels, we can use them to *straighten* our Fermi level in
104 the spectrum.
105 If we just want to plot the data, we can apply the ``levels`` continuously,
106 with the helper function :func:`~arpys.postprocessing.adjust_fermi_level`,
107 which returns an energy mesh of shape ``(n_energies, n_angles)`` that can be
108 given to the :meth:`~matplotlib.axes.Axes.pcolormesh` function.
109
110 However, if we are interested in further analysis (which we are in this
111 example), we need to apply the energy shifts discretely, in pixel units (the
112 follwoing assumes the same structure of ``D`` as we had for ``G`` before and
113 ``levels`` is the smoothened result of section :ref:`sec_smoothing`)::
114
115 pixel_shifts = pp.get_pixel_shifts(G.xscale, levels)
116 data, cutoff = pp.apply_pixel_shifts(D.data[0], pixel_shifts)
117
118 .. _fig_fermi_shifts:
119
120 .. figure:: ../img/fermi_level_shift.png
121 :alt: Image not found.
122
123 Application of the Fermi level correction.
124 Left (*raw*) we see a part of our spectrum plotted in pixel coordinates
125 with the curvy Fermi level indicated by the white dashed line.
126 Right (*shifted*) the Fermi level has been adjusted and the white dashed
127 line is straight.
128 The red lines indicate the integration regime we will use for MDC
129 extraction, the magenta lines show where we extract our background EDC
130 from and the blue and white horizontal lines show where the actual EDCs at
131 :math:`k_\mathrm{F}` are taken from.
132
133 2. Finding :math:`k_\mathrm{F}`
134 -------------------------------
135
136 As a next step, in order to extract the EDCs at :math:`k_\mathrm{F}`, we need
137 to find it (them, actually, as there is one to the left and one to the right
138 in this example) by fitting Lorentzians to the MDC at :math:`E_\mathrm{F}`.
139 Useful functions in that context are
140 :func:`~arpys.utilities.functions.indexof` to get the index of the Fermi energy,
141 :func:`~arpys.utilities.functions.lorentzian` and of course scipy's
142 :func:`scipy.optimize.curve_fit`.
143
144 .. note::
145 At this point you can of course work in pixel, angular or k coordinates,
146 your choice.
147 Be reminded of :func:`arpys.postprocessing.angle_to_k` for the conversion
148 to k space.
149
150 The details of the fit can be left up to you.
151 It can be helpful to try fitting only the relevant region along k, as can be
152 seen in the figure, where the fit only considered the region where the black
153 lines are drawn.
154
155 .. figure:: ../img/mdc_fitting.png
156 :alt: Image not found.
157
158 Extracted MDC and fitted Lorentzian curves.
159
160 3. EDC extraction and processing
161 --------------------------------
162
163 Now that we know :math:`k_\mathrm{F}`, we can extract the EDCs from the data
164 (as indicated in the :ref:`figure above <fig_fermi_shifts>`), subtract
165 background and symmetrize.
166
167 3.1 Background subtraction
168 ^^^^^^^^^^^^^^^^^^^^^^^^^^
169
170 Of course, different situations may require different treatments of the
171 background.
172 Here are two common possibilities:
173
174 * Extract an EDC in a band-free region of the data, possibly smoothen it
175 and use that as the background.
176 * :func:`~arpys.postprocessing.subtract_bg_matt`. A simple and intuitive
177 method that has proven useful.
178
179 .. figure:: ../img/bg_subtraction.png
180 :alt: Image not found.
181
182 Background subtraction. Here the simple EDC subtraction method is used.
183
184 3.2 Symmetrization
185 ^^^^^^^^^^^^^^^^^^
186
187 Finally, you can use :func:`arpys.postprocessing.symmetrize_linear` to
188 symmetrize the EDC around :math:`E_\mathrm{F}`::
189
190 sym_edc, sym_energy = pp.symmetrize_linear(edc, ef_index, energies)
191
192 .. figure:: ../img/symmetrized.png
193 :alt: Image not found.
194
195 Original (blue) and symmetrized (orange) EDCs.
196