Saturation curve plotter
Plot some good-looking saturation curves from measurements.
Import as:
saturation_curve(xdata, ydata, xunit=None, yunit=None, xlabel=None, ylabel='Signal', fit=True, darkmode=False, title=None)
Plot a saturation curve from data.
If fitting is desired, a Letokhov saturation curve is fitted to the data and plotted.
The fit parameters are printed on the plot.
The fit is done with the scipy.optimize.curve_fit function and only considers
uncertainties in the y-axis data, if given.
The fit function is n = ni + nmax * (1 - exp(-x / isat)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xdata
|
ndarray
|
x-axis data. Can contain two columns for error bars. |
required |
ydata
|
ndarray
|
y-axis data. Can contain two columns for error bars. |
required |
xunit
|
Union[Quantity, str]
|
Unit for x-axis data. If |
None
|
yunit
|
Union[Quantity, str]
|
Unit for y-axis data. If |
None
|
xlabel
|
str
|
Label for x-axis. If None, try to infer from xunit. Infers "Power" if xunit is in W or "Irradiance" if xunit is in W/cm^2. |
None
|
fit
|
bool
|
If True, fit a Letokhov saturation curve to the data, plot it, and mark up with fit parameters. |
True
|
darkmode
|
bool
|
If True, use darkmode for the plot. |
False
|
title
|
str
|
Title for the plot |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Matplotlib axis |
Source code in src/rttools/rims/saturation_curve.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |