[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[python #KZD-392392]: Metpy: Colormapped Hodograph Doesn't seem to work with CM1 Model Data



Greetings!

So it looks like you ran into a bug in MetPy when passing masked array data to 
Hodograph. I've opened an PR with a fix that will be included in 1.1:

  https://github.com/Unidata/MetPy/pull/1942

In the meanwhile, you can work around this by using the `compressed()` method 
to convert your masked array data to regular numpy arrays with all masked 
points removed (your data didn't actually have any masked points):

    hodo = h.plot_colormapped( 
                              u = uinterp_kt[mask].compressed(),
                              v = vinterp_kt[mask].compressed(),
                              c = agl[mask],
                              intervals = intervals,
                              colors = colormap,
                              alpha = 1
                             )  

Also, I wanted to point out that you can use the units framework to simplify 
formatting the text for you:

    plt.text( p1,  p2[2], f'LCL: {np.around(lcl_pressure):~}', fontsize = 12 )

The '~' in the format string tells is to use the units abbreviation when 
formatting. It should be even simpler but I ran into an issue in Pint, the 
units library (fixed with https://github.com/hgrecco/pint/pull/1341 if you're 
curious).

Hope this helps!

Ryan

> Good Afternoon,
> 
> I’ve been optimizing some research code for visualization and analysis of CM1 
> model data in netCDF format using MetPy 1.0. I’ve got a beautiful, clean 
> layout for sounding visualization including the Skew-T, Hodograph, and 
> sounding derived parameters. I would like to have my hodograph colored by 
> height values and have followed the numerous examples, yet my hodograph only 
> seems to be colored by the first color in my assigned color table (See image 
> below). I’m not sure if this is a data issue as most of the examples I have 
> followed are in regards to upper-air data instead of model output data.
> 
> Attached is my script which contains user-defined functions to open, pull and 
> process the data into a sounding graphic. These functions are called from 
> lines 875 down for testing purposes. The code related to the hodograph can be 
> found between lines 475-528. Lines 880-900 contain variables for setting the 
> path and may need to be adjusted.
> 
> I appreciate any insight that may be available for this issue. I’ve made sure 
> the code is well documented but feel free to contact me if there are any 
> questions.
> 


Ticket Details
===================
Ticket ID: KZD-392392
Department: Support Python
Priority: Low
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.