Comments (7)
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.
@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.
@rankinstudio matplotlib has the gist_ncar
colormap built in:
from metpy.
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.
Thanks!
Looks like -1, 80 put me in the right ballpark. Figured it was a usability thing. Appreciate the support.
Cheers,
from metpy.
No problem. Glad you're finding this useful.
from metpy.
@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)
- numpy.arctan2 returns an angle in radian HOT 1
- GEMPAK Comparison Guide gets cut off with wide browser HOT 2
- AttributeError: module 'numpy' has no attribute 'alen' HOT 6
- Integration with Python performance tools like JAX HOT 10
- Feature request: wind_direction_categorical HOT 2
- Create GHA for doctests HOT 3
- cast angle_to_direction to input array type HOT 5
- METAR Site ID data for KGVW (Galveston 209B) is incorrect HOT 7
- parse_metar_file with file object not working HOT 3
- Add CAP Strength Calculation to MetPy HOT 5
- Unittest failure on debian sid HOT 2
- Nightly build is failing HOT 1
- Laplacian based on finite difference vs spectral technique HOT 1
- Duff moisture code
- Drought code HOT 1
- Nightly build is failing HOT 1
- All `plot_` functions in `StationPlot` should return the collection HOT 3
- Nightly build is failing HOT 1
- Parse metar from pandas dataframe into another dataframe HOT 3
- Divergence equation in different coordinates? And derivative documentation is limited access, could someone add the finite differentiation scheme formulation or provide a different document? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from metpy.