Skip to content

Issue with new plot_util.plot_polar_contour() #653

@jpolton

Description

@jpolton

Hi Jeff,
I've just had a look at what's been merged into develop. It looks like there have bene some changes to plot_util.plot_polar_contour() which mean it now doesn't work with the gc31_arctic_example_plot.py script. This is what I had working once I'd taken the pyproj dependency out.

def plot_polar_contour(lon, lat, var, ax_in, **kwargs):

    crs_ps = ccrs.CRS("epsg:3413")  # North pole projection
    crs_wgs84 = ccrs.CRS("epsg:4326")
    # NSIDC grid
    x_grid, y_grid = np.meshgrid(np.linspace(-3850, 3750, 304) * 1000, np.linspace(-5350, 5850, 448) * 1000)
    grid = crs_wgs84.transform_points(crs_ps, x_grid, y_grid)
    lon_grid = grid[:, :, 0]
    lat_grid = grid[:, :, 1]
    points = np.vstack((lon.flatten(), lat.flatten())).T
    grid_var = si.griddata(points, var.flatten(), (lon_grid, lat_grid), method="linear")
    cs_out = ax_in.contour(x_grid, y_grid, grid_var, transform=ccrs.epsg(3413), **kwargs)
    return cs_out

Or, to get it working in the current format with pyproj you'll need to change two lines to:

transformer = pyproj.Transformer.from_crs("epsg:3413", "epsg:4326", always_xy=True)
cs_out = ax_in.contour(x_grid, y_grid, grid_var, transform=ccrs.epsg(3413), **kwargs)

Thanks,
Ben

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

MSM - in progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions