[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[python #LLO-424423]: problem with metpy importing modules
- Subject: [python #LLO-424423]: problem with metpy importing modules
- Date: Mon, 27 Jun 2022 12:30:57 -0600
Greetings!
Apologies for the delayed response.
Since you're working with a DataArray, you don't even need to manually
calculate the deltas, but instead you can do this with a single call to
gradient:
dlon, dlat = mpcalc.gradient(temps, axes=['longitude', 'latitude'])
The fact that the coordinates are attached to temps lets the function handle
all the coordinate manipulation for you.
Hope this helps!
Ryan
> I have another issue. I am trying to use the gradient function on a 3D xarray
> DataSet (lat,lon,time)
>
> <xarray.Dataset>
> Dimensions: (latitude: 141, longitude: 401, time: 16)
> Coordinates:
> * latitude (latitude) float32 20.0 20.25 20.5 20.75 ... 54.5 54.75 55.0
> * longitude (longitude) float32 140.0 140.2 140.5 140.8 ... 239.5 239.8 240.0
> * time (time) datetime64[ns] 2013-01-13 ... 2013-01-16T18:00:00
> Data variables:
> t (time, latitude, longitude) float32 289.4 289.5 ... 275.1 275.5
> Attributes:
> Conventions: CF-1.6
> history: 2022-06-06 12:05:32 GMT by grib_to_netcdf-2.24.3: /opt/ecmw…
>
>
> I have calculated the delays for longitude and latitude:
>
> deltas=mpcalc.lat_lon_grid_deltas(DS.longitude,DS.latitude)
>
> I now wish to calculate the gradients along latitude and longitude for each
> tilmestep.
>
> I can do this for a single tilmestep using:
>
> temps=DS.t[9,:,:]
> gradients=mpcalc.gradient(temps,deltas=(deltas[1],deltas[0]))
>
> however I cannot get it to work on the dataset with multiple time steps. I
> could use a loop but assume it is something to do with using axes in the
> gradient function. I have tried both on the original dataset and on the
> extracted DataArray but cannot achieve any success. What should I add to the
> gradient command to match the deltas with the longitude and latitude axes
> only?
>
Ticket Details
===================
Ticket ID: LLO-424423
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.