-
Notifications
You must be signed in to change notification settings - Fork 406
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
Improve Reading/Using Colortable Files #3243
Comments
The magic of Python and file-like objects can make this a little cleaner: from io import StringIO
from matplotlib.colors import ListedColormap
from metpy.plots.ctables import convert_gempak_table, read_colortable
with open("ir_upc2.tbl","r") as infile:
converted = StringIO()
convert_gempak_table(infile, converted)
# Reset StringIO to have pointer at beginning
converted.seek(0)
colortable = read_colortable(converted)
cmap = ListedColormap(colortable) |
Why would opening/closing the file within with open('ir_upc2.tbl', r') as infile:
camp = ListedColormap(read_colorable(convert_gempak_table(infile))) We also made the intentional decision to start that we provided a path for people to convert the tables as needed, but we weren't going to make those a standard format for us in the name of moving away from the legacy tools, which is why the GEMPAK table format isn't "just" supported by the registry. Is that something we need to revisit? |
Yeah, there may not need to be improvements to what the code is doing, but we have under documented this to make it accessible for at least a segment of our users (including myself). I think your suggestion of removing the So, no probably don't need to revisit wholesale. |
What should we add?
A question came in on how to read and use a GEMPAK colortable file (basically a plain text file with a list of colors in RGB format) within MetPy. There was not a straightforward path to making this accessible...here is the code needed to go from reading the initial file, to a useful Matplotlib colormap:
Potential Improvements:
convert_gempak_table()
functionOther thoughts/comments?
Reference
No response
The text was updated successfully, but these errors were encountered: