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

Color map that more closely matches the NWS mapping #52

Closed
rankinstudio opened this issue Jun 9, 2015 · 7 comments
Closed

Color map that more closely matches the NWS mapping #52

rankinstudio opened this issue Jun 9, 2015 · 7 comments

Comments

@rankinstudio
Copy link

Hey Ryan,

There doesn't seem to be a color map available that closely matches the level II image outputs from the NWS. Is this something that is easily modified?

Thanks!

colormaps

@shoyer
Copy link

shoyer commented Jun 16, 2015

@rankinstudio matplotlib has the gist_ncar colormap built in:

@dopplershift
Copy link
Member

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.

@rankinstudio
Copy link
Author

Thanks!

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

Cheers,

radar

@dopplershift
Copy link
Member

No problem. Glad you're finding this useful.

@w142236
Copy link

w142236 commented Sep 22, 2020

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:

@dopplershift
Copy link
Member

@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.

@w142236
Copy link

w142236 commented Sep 22, 2020

@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.

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

No branches or pull requests

4 participants