Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

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