Coder Social home page Coder Social logo

Comments (7)

w142236 avatar w142236 commented on May 19, 2024 1

I know this was posted a long time ago, but
ctable.get_colortable()
is no longer a function of ctable for the latest version. I got it to work by instead using:
cmap = ctable.registry.get_with_steps('NWSReflectivity',5,5)
I found this from here:

from metpy.

dopplershift avatar dopplershift commented on May 19, 2024 1

@w142236 Yes, the correct call for get_colortable should be:

from metpy.plots import ctables
ctables.registry.get_colortable('NWSReflectivity')

If you find this doesn't work for you, please open a new issue and we'll try to get you sorted out.

from metpy.

shoyer avatar shoyer commented on May 19, 2024

@rankinstudio matplotlib has the gist_ncar colormap built in:

from metpy.

dopplershift avatar dopplershift commented on May 19, 2024

The metpy colormap for NWS Reflectivity was "painstakingly" :) hand-pulled from the colors on the NWS website long ago, they're not the problem. What you need is what matplotlib calls a "norm", or an instance of the Normalize class.

Matplotlib's colormaps handle mapping numbers in the range [0, 1] to colors. The norm handles mapping your actual range of colors to the range [0, 1]. If you don't explicitly pass a norm to something like pcolor, using the norm keyword argument, matplotlib creates one based on the range of data you're plotting; this is great for maximizing the dynamic range, bad for matching familiar plots. You probably want something like:

from matplotlib.colors import Normalize
import matplotlib.pyplot as plt
from metpy.plots import ctables
# READ AND PARSE HERE
cmap = ctables.get_colortable('NWSReflectivity')
plt.pcolor(x, y, data, cmap=cmap, norm=Normalize(-25, 75))

I'm not sure if I got the range exactly right, but I think that should get you started.

from metpy.

rankinstudio avatar rankinstudio commented on May 19, 2024

Thanks!

Looks like -1, 80 put me in the right ballpark. Figured it was a usability thing. Appreciate the support.

Cheers,

radar

from metpy.

dopplershift avatar dopplershift commented on May 19, 2024

No problem. Glad you're finding this useful.

from metpy.

w142236 avatar w142236 commented on May 19, 2024

@w142236 Yes, the correct call for get_colortable should be:

from metpy.plots import ctables
ctables.registry.get_colortable('NWSReflectivity')

If you find this doesn't work for you, please open a new issue and we'll try to get you sorted out.

Nah it's fine. I think the creator of metpy might have moved things around and changed some of the function names. That isn't too difficult for people with a good IDE like Spyder, but I have to run my code from a command line so I have to look a lot of this stuff up.

from metpy.

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.