Code Monkey home page Code Monkey logo

Comments (5)

lukelbd avatar lukelbd commented on May 22, 2024

Fixing this one was crazy. It turns out that this artifact is related to this particular dataset and occurs in matplotlib normally, but cartopy patches that error in some complex and mysterious way, but I was doing something that ruined cartopy's patch. Try these examples after updating (the s is just to make the dataset smaller):

import matplotlib.pyplot as plt
import proplot as plot
import climpred as cp
s = 2
# Load data
data = cp.tutorial.load_dataset('MPI-control-3D')
data = data.isel(time=0).tos
# Does not generate artifact
f, ax = plot.subplots(width=5, proj='pcarree', axcolorbar='r')
ax.pcolormesh(data.lon[::s,::s], data.lat[::s,::s], data[::s,::s], levels=20, colorbar='r')
# Basemap, generates artifact
# f, ax = plot.subplots(width=5, basemap=True, proj='pcarree', axcolorbar='r')
# ax.pcolormesh(data.lon[::s,::s], data.lat[::s,::s], data[::s,::s], levels=20, colorbar='r')
# On Cartesian axes/without projection, generates artifact
# f, ax = plot.subplots(width=5, axcolorbar='r')
# ax.pcolor(data.lon[::s,::s], data.lat[::s,::s], data[::s,::s], levels=20, colorbar='r')
# With pyplot, generates artifact
# f, ax = plt.subplots()
# ax.pcolor(data.lon[::s,::s], data.lat[::s,::s], data[::s,::s])

The cartopy patch evidently works by masking content in your data array. My BinNorm normalizer that I apply to all colormap objects was deleting/ignoring this mask (see the ma.getmaskarray lines in commit 222392e).

Also the latest ProPlot versions fix the weird font bug we came across the other day. It had to do with me adding a font .ttf file with a style unrecognized by matplotlib/that matplotlib interpreted as 'normal'.

I also added your polar projection zoom-ins to getting started, fixed a tight-layout bug that appeard with zoomed-in projections, fixed a bug related to the circular bounding box limits, fixed a bug where the facecolor attribute for map axes would get reset, added the 'nplaea', 'splaea', 'npaeqd', and 'spaeqd' projections to cartopy like in basemap, and various other bugfixes/cleanup tasks. It's all a blur.

Still just pushing to master at will.... will get into your workflow once I set up CI with some smaller tests.

from proplot.

lukelbd avatar lukelbd commented on May 22, 2024

Also thanks for posting this issue. It definitely needed to be fixed and would probably have appeared mysteriously for various other users with various other datasets. I was exhausted when I posted this.

from proplot.

bradyrx avatar bradyrx commented on May 22, 2024

@lukelbd
Awesome, thanks for all the updates here. So in summary, only use the cartopy projection format for these 2D maps? Looks like all the other options (including Basemap) generate those artifacts.

from proplot.

lukelbd avatar lukelbd commented on May 22, 2024

Yep that's right. My guess is it has to do with your data graticule crossing the edge of the map; cartopy takes pains to fix issues associated with stuff running over the map edge.

from proplot.

bradyrx avatar bradyrx commented on May 22, 2024

Having the Greenland-pole grid on the ocean always causes issues. With 2D lat/lon you can't really contour properly. I'm used to these problems, but they shouldn't occur on pcolormesh. Glad you were able to fix it!

from proplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.