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

[python #OFO-708651]: convert a dimensioned quantity to undimensioned quantity -- FYI ONLY

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: [python #OFO-708651]: convert a dimensioned quantity to undimensioned quantity -- FYI ONLY
  • Date: Wed, 02 Mar 2022 16:52:18 -0700

Greetings!

Ah. Yeah, matplotlib's contour code doesn't appreciate getting things with 
units.

Glad you got it working!

Ryan

> uhm,
> 
> in my code I had the following lines:
> 
> 
> max_value = np.max(wind_kts)
> print(f"Maximum wind speed {max_value}")
> min_value = np.min(wind_kts)
> print(f"Minimum wind speed {min_value}")
> max = int(max_value.magnitude)
> min = int(min_value.magnitude)
> step = int((max - min)/10)
> 
> 
> I wanted to guess at what my step levels should be for a contour plot, when I 
> used
> max_value (see above) and min_value as (max_value - min_value)/10
> 
> I got an error, but when I used say max_value.magnitude I could do the math .
> 

Ticket Details
===================
Ticket ID: OFO-708651
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.