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

[python #VUC-241122]: Some of examples not work

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 #VUC-241122]: Some of examples not work
  • Date: Mon, 27 Mar 2023 15:24:05 -0600

Greetings!

Apologies for the delayed response. It looks like this notebook needs some 
updates due to changes in our THREDDS data server.

The cell causing you problems should really look like:

from metpy.units import units
import numpy as np

# get netCDF variables
pressure = point_data.variables["altitude"]
temp = point_data.variables["Temperature_isobaric"]
u_cmp = point_data.variables["u-component_of_wind_isobaric"]
v_cmp = point_data.variables["v-component_of_wind_isobaric"]
relh = point_data.variables["Relative_humidity_isobaric"]

# download data and assign the units based on the variables metadata
# Need to put units on the left to assure things work properly with masked 
arrays
p = units(pressure.units) * pressure[:].squeeze()
T = units(temp.units) * temp[:].squeeze()
u = units(u_cmp.units) * u_cmp[:].squeeze()
v = units(v_cmp.units) * v_cmp[:].squeeze()
relh = units('percent') * relh[:].squeeze()

Once I make that change, the cell runs without error. I've opened an issue to 
remind us to update that example: 
https://github.com/Unidata/python-training/issues/135

Thanks for reporting!

Cheers!

Ryan

> Package Version: 1.4
> Operating System: Windows 7 64bit Pro
> Hardware: i7
> Description of problem: I try to find how but 
> https://unidata.github.io/python-training/workshop/Model_Output/downloading-model-fields-with-ncss/#pointrequest
> 
> NOT WORK.
> 
> Any advice please.
> Problem is in line:
> pressure = point_data.variables["isobaric"]
> 
> 


Ticket Details
===================
Ticket ID: VUC-241122
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.