|
@@ 350-401 (lines=52) @@
|
| 347 |
|
|
| 348 |
|
Adds dry adiabats (lines of constant potential temperature) to the |
| 349 |
|
plot. The default style of these lines is dashed red lines with an alpha |
| 350 |
|
value of 0.5. These can be overridden using keyword arguments. |
| 351 |
|
|
| 352 |
|
Parameters |
| 353 |
|
---------- |
| 354 |
|
t0 : array_like, optional |
| 355 |
|
Starting temperature values in Kelvin. If none are given, they will be |
| 356 |
|
generated using the current temperature range at the bottom of |
| 357 |
|
the plot. |
| 358 |
|
p : array_like, optional |
| 359 |
|
Pressure values to be included in the dry adiabats. If not |
| 360 |
|
specified, they will be linearly distributed across the current |
| 361 |
|
plotted pressure range. |
| 362 |
|
kwargs |
| 363 |
|
Other keyword arguments to pass to :class:`matplotlib.collections.LineCollection` |
| 364 |
|
|
| 365 |
|
Returns |
| 366 |
|
------- |
| 367 |
|
matplotlib.collections.LineCollection |
| 368 |
|
instance created |
| 369 |
|
|
| 370 |
|
See Also |
| 371 |
|
-------- |
| 372 |
|
:func:`~metpy.calc.thermo.dry_lapse` |
| 373 |
|
:meth:`plot_moist_adiabats` |
| 374 |
|
:class:`matplotlib.collections.LineCollection` |
| 375 |
|
''' |
| 376 |
|
|
| 377 |
|
# Determine set of starting temps if necessary |
| 378 |
|
if t0 is None: |
| 379 |
|
xmin, xmax = self.ax.get_xlim() |
| 380 |
|
t0 = np.arange(xmin, xmax + 1, 10) * units.degC |
| 381 |
|
|
| 382 |
|
# Get pressure levels based on ylims if necessary |
| 383 |
|
if p is None: |
| 384 |
|
p = np.linspace(*self.ax.get_ylim()) * units.mbar |
| 385 |
|
|
| 386 |
|
# Assemble into data for plotting |
| 387 |
|
t = dry_lapse(p, t0[:, np.newaxis]).to(units.degC) |
| 388 |
|
linedata = [np.vstack((ti, p)).T for ti in t] |
| 389 |
|
|
| 390 |
|
# Add to plot |
| 391 |
|
kwargs.setdefault('colors', 'r') |
| 392 |
|
kwargs.setdefault('linestyles', 'dashed') |
| 393 |
|
kwargs.setdefault('alpha', 0.5) |
| 394 |
|
return self.ax.add_collection(LineCollection(linedata, **kwargs)) |
| 395 |
|
|
| 396 |
|
def plot_moist_adiabats(self, t0=None, p=None, **kwargs): |
| 397 |
|
r'''Plot moist adiabats. |
| 398 |
|
|
| 399 |
|
Adds saturated pseudo-adiabats (lines of constant equivalent potential |
| 400 |
|
temperature) to the plot. The default style of these lines is dashed |
| 401 |
|
blue lines with an alpha value of 0.5. These can be overridden using |
| 402 |
|
keyword arguments. |
| 403 |
|
|
| 404 |
|
Parameters |
|
@@ 299-348 (lines=50) @@
|
| 296 |
|
`barbs` command that adds to appropriate transform to place the |
| 297 |
|
barbs in a vertical line, located as a function of pressure. |
| 298 |
|
|
| 299 |
|
Parameters |
| 300 |
|
---------- |
| 301 |
|
p : array_like |
| 302 |
|
pressure values |
| 303 |
|
u : array_like |
| 304 |
|
U (East-West) component of wind |
| 305 |
|
v : array_like |
| 306 |
|
V (North-South) component of wind |
| 307 |
|
xloc : float, optional |
| 308 |
|
Position for the barbs, in normalized axes coordinates, where 0.0 |
| 309 |
|
denotes far left and 1.0 denotes far right. Defaults to far right. |
| 310 |
|
x_clip_radius : float, optional |
| 311 |
|
Space, in normalized axes coordinates, to leave before clipping |
| 312 |
|
wind barbs in the x-direction. Defaults to 0.08. |
| 313 |
|
y_clip_radius : float, optional |
| 314 |
|
Space, in normalized axes coordinates, to leave above/below plot |
| 315 |
|
before clipping wind barbs in the y-direction. Defaults to 0.08. |
| 316 |
|
kwargs |
| 317 |
|
Other keyword arguments to pass to :func:`~matplotlib.pyplot.barbs` |
| 318 |
|
|
| 319 |
|
Returns |
| 320 |
|
------- |
| 321 |
|
matplotlib.quiver.Barbs |
| 322 |
|
instance created |
| 323 |
|
|
| 324 |
|
See Also |
| 325 |
|
-------- |
| 326 |
|
:func:`matplotlib.pyplot.barbs` |
| 327 |
|
''' |
| 328 |
|
|
| 329 |
|
# Assemble array of x-locations in axes space |
| 330 |
|
x = np.empty_like(p) |
| 331 |
|
x.fill(xloc) |
| 332 |
|
|
| 333 |
|
# Do barbs plot at this location |
| 334 |
|
b = self.ax.barbs(x, p, u, v, |
| 335 |
|
transform=self.ax.get_yaxis_transform(which='tick2'), |
| 336 |
|
clip_on=True, **kwargs) |
| 337 |
|
|
| 338 |
|
# Override the default clip box, which is the axes rectangle, so we can have |
| 339 |
|
# barbs that extend outside. |
| 340 |
|
ax_bbox = transforms.Bbox([[xloc - x_clip_radius, -y_clip_radius], |
| 341 |
|
[xloc + x_clip_radius, 1.0 + y_clip_radius]]) |
| 342 |
|
b.set_clip_box(transforms.TransformedBbox(ax_bbox, self.ax.transAxes)) |
| 343 |
|
return b |
| 344 |
|
|
| 345 |
|
def plot_dry_adiabats(self, t0=None, p=None, **kwargs): |
| 346 |
|
r'''Plot dry adiabats. |
| 347 |
|
|
| 348 |
|
Adds dry adiabats (lines of constant potential temperature) to the |
| 349 |
|
plot. The default style of these lines is dashed red lines with an alpha |
| 350 |
|
value of 0.5. These can be overridden using keyword arguments. |
| 351 |
|
|