Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with new plot_util.plot_polar_contour() #653

Open
jpolton opened this issue Nov 23, 2023 · 5 comments
Open

Issue with new plot_util.plot_polar_contour() #653

jpolton opened this issue Nov 23, 2023 · 5 comments
Assignees

Comments

@jpolton
Copy link
Collaborator

jpolton commented Nov 23, 2023

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

@jpolton jpolton converted this from a draft issue Nov 23, 2023
@jpolton
Copy link
Collaborator Author

jpolton commented Nov 23, 2023

Thanks @b-barton. I've made this an Issue so we get it sorted.
I haven't got head space to think about this at the moment but our plan is to merge develop into Master 2 weeks today (Dec7), so we will get it sorted by then.
Odd that this got into develop without being spotted. Hmmm

@b-barton
Copy link
Collaborator

b-barton commented Nov 23, 2023 via email

@b-barton b-barton moved this from BODC - In Progress to MSM - in progress in COAsT_dev Nov 24, 2023
@b-barton
Copy link
Collaborator

b-barton commented Nov 24, 2023

I've made a new branch with the version of the code without pyproj: 0653/merge_plot_polar_contour

@b-barton
Copy link
Collaborator

b-barton commented Nov 24, 2023

I've taken the develop branch and changed the code in plot_util.plot_polar_contour() to use cartopy. This function definitely needs cartopy. It can be tested with example_scripts\configuration_gallery\gc31_arctic_example_plot.py. I'm guessing there has been some problems with git actions and cartopy so I've put the same as other functions that use cartopy with the:

try:
    import cartopy.crs as ccrs  # mapping plots
except ImportError:
    warn("No cartopy found - please run\nconda install -c conda-forge cartopy")
    sys.exit(-1)

@b-barton
Copy link
Collaborator

There is a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: MSM - in progress
Development

No branches or pull requests

3 participants