146def plotSuite(doComponents=False):
147 """Plot all the profiles defined in this module together.
148
149 Plot all the profiles defined in this module together: true exp and dev,
150 the SDSS softened/truncated lux and luv, and the multi-Gaussian approximations
151 to all of these.
152
153 Parameters
154 ----------
155 doComponents : `bool`, optional
156 True, to plot the individual Gaussians that form the multi-Gaussian approximations.
157
158 Returns
159 -------
160 figure : `matplotlib.figure.Figure`
161 Figure that contains the plot.
162 axes : `numpy.ndarray` of `matplotlib.axes.Axes`
163 A 2x4 NumPy array of matplotlib axes objects.
164 """
165 from matplotlib import pyplot
166 fig = pyplot.figure(figsize=(9, 4.7))
167 axes = numpy.zeros((2, 4), dtype=object)
168 r1 = numpy.logspace(-3, 0, 1000, base=10)
169 r2 = numpy.linspace(1, 10, 1000)
170 r = [r1, r2]
171 for i in range(2):
172 for j in range(4):
173 axes[i, j] = fig.add_subplot(2, 4, i*4+j+1)
174 profiles = {name: RadialProfile.get(name) for name in ("exp", "lux", "dev", "luv")}
175 basis = {name: profiles[name].getBasis(8) for name in profiles}
176 z = numpy.zeros((2, 4), dtype=object)
177 colors = ("k", "g", "b", "r")
178 fig.subplots_adjust(wspace=0.025, hspace=0.025, bottom=0.15, left=0.1, right=0.98, top=0.92)
179 centers = [None, None]
180 for i in range(2):
181 for j in range(0, 4, 2):
182 bbox0 = axes[i, j].get_position()
183 bbox1 = axes[i, j+1].get_position()
184 bbox1.x0 = bbox0.x1 - 0.06
185 bbox0.x1 = bbox1.x0
186 centers[j//2] = 0.5*(bbox0.x0 + bbox1.x1)
187 axes[i, j].set_position(bbox0)
188 axes[i, j+1].set_position(bbox1)
189 for j in range(0, 2):
190 z[0, j] = [evaluateRadial(basis[k], r[j], sbNormalize=True, doComponents=doComponents)
191 for k in ("exp", "lux")]
192 z[0, j][0:0] = [profiles[k].evaluate(r[j])[numpy.newaxis, :] for k in ("exp", "lux")]
193 z[0, j+2] = [evaluateRadial(basis[k], r[j], sbNormalize=True, doComponents=doComponents)
194 for k in ("dev", "luv")]
195 z[0, j+2][0:0] = [profiles[k].evaluate(r[j])[numpy.newaxis, :] for k in ("dev", "luv")]
196 methodNames = [["loglog", "semilogy"], ["semilogx", "plot"]]
197 for j in range(0, 4):
198 z[1, j] = [(z[0, j][0][0, :] - z[0, j][i][0, :])/z[0, j][0][0, :] for i in range(0, 4)]
199 handles = []
200 method0 = getattr(axes[0, j], methodNames[0][j%2])
201 method1 = getattr(axes[1, j], methodNames[1][j%2])
202 for k in range(4):
203 y0 = z[0, j][k]
204 handles.append(method0(r[j%2], y0[0, :], color=colors[k])[0])
205 if doComponents:
206 for ll in range(1, y0.shape[0]):
207 method0(r[j%2], y0[ll, :], color=colors[k], alpha=0.25)
208 method1(r[j%2], z[1, j][k], color=colors[k])
209 axes[0, j].set_xticklabels([])
210 axes[0, j].set_ylim(1E-6, 1E3)
211 axes[1, j].set_ylim(-0.2, 1.0)
212 for i, label in enumerate(("profile", "relative error")):
213 axes[i, 0].set_ylabel(label)
214 for t in axes[i, 0].get_yticklabels():
215 t.set_fontsize(11)
216 for j in range(1, 4):
217 axes[0, j].set_yticklabels([])
218 axes[1, j].set_yticklabels([])
219 xticks = [['$\\mathdefault{10^{%d}}$' % i for i in range(-3, 1)],
220 [str(i) for i in range(1, 11)]]
221 xticks[0][-1] = ""
222 xticks[1][-1] = ""
223 for j in range(0, 4):
224 axes[1, j].set_xticklabels(xticks[j%2])
225 for t in axes[1, j].get_xticklabels():
226 t.set_fontsize(11)
227 fig.legend(handles, ["exp/dev", "lux/luv", "approx exp/dev", "approx lux/luv"],
228 loc='lower center', ncol=4)
229 fig.text(centers[0], 0.95, "exponential", ha='center', weight='bold')
230 fig.text(centers[1], 0.95, "de Vaucouleur", ha='center', weight='bold')
231 return fig, axes