Code Duplication    Length = 50-52 lines in 2 locations

metpy/plots/skewt.py 2 locations

@@ 350-401 (lines=52) @@
347
        x_clip_radius : float, optional
348
            Space, in normalized axes coordinates, to leave before clipping
349
            wind barbs in the x-direction. Defaults to 0.08.
350
        y_clip_radius : float, optional
351
            Space, in normalized axes coordinates, to leave above/below plot
352
            before clipping wind barbs in the y-direction. Defaults to 0.08.
353
        kwargs
354
            Other keyword arguments to pass to :func:`~matplotlib.pyplot.barbs`
355
356
        Returns
357
        -------
358
        matplotlib.quiver.Barbs
359
            instance created
360
361
        See Also
362
        --------
363
        :func:`matplotlib.pyplot.barbs`
364
        """
365
        # Assemble array of x-locations in axes space
366
        x = np.empty_like(p)
367
        x.fill(xloc)
368
369
        # Do barbs plot at this location
370
        b = self.ax.barbs(x, p, u, v,
371
                          transform=self.ax.get_yaxis_transform(which='tick2'),
372
                          clip_on=True, **kwargs)
373
374
        # Override the default clip box, which is the axes rectangle, so we can have
375
        # barbs that extend outside.
376
        ax_bbox = transforms.Bbox([[xloc - x_clip_radius, -y_clip_radius],
377
                                   [xloc + x_clip_radius, 1.0 + y_clip_radius]])
378
        b.set_clip_box(transforms.TransformedBbox(ax_bbox, self.ax.transAxes))
379
        return b
380
381
    def plot_dry_adiabats(self, t0=None, p=None, **kwargs):
382
        r"""Plot dry adiabats.
383
384
        Adds dry adiabats (lines of constant potential temperature) to the
385
        plot. The default style of these lines is dashed red lines with an alpha
386
        value of 0.5. These can be overridden using keyword arguments.
387
388
        Parameters
389
        ----------
390
        t0 : array_like, optional
391
            Starting temperature values in Kelvin. If none are given, they will be
392
            generated using the current temperature range at the bottom of
393
            the plot.
394
        p : array_like, optional
395
            Pressure values to be included in the dry adiabats. If not
396
            specified, they will be linearly distributed across the current
397
            plotted pressure range.
398
        kwargs
399
            Other keyword arguments to pass to :class:`matplotlib.collections.LineCollection`
400
401
        Returns
402
        -------
403
        matplotlib.collections.LineCollection
404
            instance created
@@ 299-348 (lines=50) @@
296
        t : array_like
297
            temperature values, can also be used for things like dew point
298
        args
299
            Other positional arguments to pass to :func:`~matplotlib.pyplot.semilogy`
300
        kwargs
301
            Other keyword arguments to pass to :func:`~matplotlib.pyplot.semilogy`
302
303
        Returns
304
        -------
305
        list[matplotlib.lines.Line2D]
306
            lines plotted
307
308
        See Also
309
        --------
310
        :func:`matplotlib.pyplot.semilogy`
311
        """
312
        # Skew-T logP plotting
313
        t, p = delete_masked_points(t, p)
314
        l = self.ax.semilogy(t, p, *args, **kwargs)
315
316
        # Disables the log-formatting that comes with semilogy
317
        self.ax.yaxis.set_major_formatter(ScalarFormatter())
318
        self.ax.yaxis.set_major_locator(MultipleLocator(100))
319
        self.ax.yaxis.set_minor_formatter(NullFormatter())
320
        if not self.ax.yaxis_inverted():
321
            self.ax.invert_yaxis()
322
323
        # Try to make sane default temperature plotting
324
        self.ax.xaxis.set_major_locator(MultipleLocator(10))
325
        self.ax.set_xlim(-50, 50)
326
327
        return l
328
329
    def plot_barbs(self, p, u, v, xloc=1.0, x_clip_radius=0.08, y_clip_radius=0.08, **kwargs):
330
        r"""Plot wind barbs.
331
332
        Adds wind barbs to the skew-T plot. This is a wrapper around the
333
        `barbs` command that adds to appropriate transform to place the
334
        barbs in a vertical line, located as a function of pressure.
335
336
        Parameters
337
        ----------
338
        p : array_like
339
            pressure values
340
        u : array_like
341
            U (East-West) component of wind
342
        v : array_like
343
            V (North-South) component of wind
344
        xloc : float, optional
345
            Position for the barbs, in normalized axes coordinates, where 0.0
346
            denotes far left and 1.0 denotes far right. Defaults to far right.
347
        x_clip_radius : float, optional
348
            Space, in normalized axes coordinates, to leave before clipping
349
            wind barbs in the x-direction. Defaults to 0.08.
350
        y_clip_radius : float, optional
351
            Space, in normalized axes coordinates, to leave above/below plot