[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #XNB-470459]: A question about wind barbs in the dateline of the Pacific (180 degrees) using Cartopy?



Greetings!

> First, I keep missing your python classes, our you have any online classes 
> soon?

We haven't offered an online one in a bit, we've been working behind the scenes 
on reworking how we offer that training. I'll keep a note of your interest as 
we look towards our next workshop schedule.

> Second, I would like to show 100mb winds across the Pacific (see attachment). 
> I can do this with contouring packages using the following code segments:

I was able to make a quiver work with some synthetic data as:

    import cartopy.crs as ccrs
    import cartopy.feature as cfeature
    import matplotlib.pyplot as plt
    import numpy as np
    
    center_lon = 180
    
    fig = plt.figure(figsize=[9, 9], facecolor='lightgrey')
    ax = fig.add_subplot(1, 1, 1, 
projection=ccrs.PlateCarree(central_longitude=center_lon))
    
    ax.set_extent([100, 265, -25, 50], crs=ccrs.PlateCarree())
    
    ax.add_feature(cfeature.STATES, edgecolor='white', linewidth=1.5)
    ax.add_feature(cfeature.COASTLINE, edgecolor='white', linewidth=2.0)
    ax.add_feature(cfeature.LAND)
    
    lon = np.linspace(-120, 120, 10)
    lat = np.linspace(-10, 40, 5)
    lon2D_sub, lat2D_sub = np.meshgrid(lon, lat)
    u_sub = np.full_like(lon2D_sub, 5)
    v_sub = np.full_like(lon2D_sub, 5)
    
    Q = plt.quiver(lon2D_sub, lat2D_sub, u_sub, v_sub, angles="xy", 
color='black',
        units='width',transform=ccrs.PlateCarree(central_longitude=center_lon))

This worked fine for me here with Cartopy 0.21.1.

I suspect that this is heavily dependent on:

1. Having the data in the right "kind" of longitude; I used the -180 -> 180 
system
2. Having the data for the eastern hemisphere before the data for the western

Maybe the synthetic data I created above can shed some light on where yours 
differs?

Hope this helps,

Ryan

Ticket Details
===================
Ticket ID: XNB-470459
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.