Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 04 00:46
    Coverage (main) +0.00%
  • Dec 04 00:46
    Coverage (main) +0.00%
  • Dec 04 00:46
    Coverage (main) +0.00%
  • Dec 04 00:45
    Coverage (main) +0.00%
  • Dec 04 00:44
    Coverage (main) +0.00%
  • Dec 04 00:41

    dcamron on gh-pages

    Deploy dev to GitHub Pages (compare)

  • Dec 04 00:25
    Coverage (#2241) +0.00%
  • Dec 04 00:25

    dopplershift on main

    MNT: Reduce warning to a debug … Merge pull request #2241 from d… (compare)

  • Dec 04 00:25
    dopplershift closed #2241
  • Dec 04 00:25
    dopplershift closed #2238
  • Dec 03 23:55
    Coverage (#2241) +0.00%
  • Dec 03 23:54
    Coverage (#2241) +0.00%
  • Dec 03 23:54
    Coverage (#2241) +0.00%
  • Dec 03 23:53
    Coverage (#2241) +0.00%
  • Dec 03 23:52
    Coverage (#2241) +0.00%
  • Dec 03 23:49
    Coverage (#2241) +0.00%
  • Dec 03 23:32
    dopplershift review_requested #2241
  • Dec 03 23:32
    dopplershift review_requested #2241
  • Dec 03 23:32
    dopplershift review_request_removed #2241
  • Dec 03 23:32
    dopplershift review_requested #2241
Gerrit Holl
@gerritholl
Hi. I'm researching if metpy can save me time interacting with NOAA/NCEI/NWS databases such as the Integrated Surface Dataset (ISD) or the Storm Events Database, compared to directly using pandas. It seems metpy's strength and scope lies more with meteorological calculations than with I/O, though. I would write a function for myself with functionality such as "search storm with those characteristics" in the storm events database, interpret the dates and times (which are in local time), associate units to numbers, and return it as perhaps a pint-pandas object. Would someone know if such functionality exists publicly, either in metpy or elsewhere? Would it be something that might fit in metpy?
Ryan May
@dopplershift
Hi @gerritholl ! I'm not aware of any tools out there to do what you're looking for. If you could create such a function that had general, well-defined functionality (and tests), then we'd be interested in considering it for inclusion.
1 reply
Kyle Y. Parsotan
@Kyl67899
@dopplershift I received your email. The following link has the coding and the error messages attached. Please visit: https://github.com/Kyl67899/wx367
Ryan May
@dopplershift

@Kyl67899 Your problem is this code:

    p,t,td,prof_t = mpcalc.parcel_profile_with_lcl(p,T,Td)

You overwrite the original p variable, which doesn't contain the LCL level, with a new array p that contains the LCL. You then use this p with the extra level together with your original T and Td arrays, rather than the new ones that contain the interpolated values for the LCL, which you put in t and td. Thus they contain different amounts of data and lead to the error message:

ValueError: x and y must have same first dimension, but have shapes (95,) and (96,)

2 replies
Kyle Y. Parsotan
@Kyl67899
@MethaneRain I kind of understan what you are saying about the p and overwriting that same variable ratger than using a different one. However i tried to put the P and changed it in the beginning to be different from the way i read it in. But i will try to fix that and repost if there are additional problems. I did do line by line on the comments to find the error but I didnt think it would be that. Fir the second part I don't understand what you are saying...
4 replies
Sorry about the misspelled words. My phone like to autocorrect.
jmedinah09
@jmedinah09

Hi, I'm getting a strange behavior of the parcel_profile method when using in a skew-t plot. The thing is that it seems to be drawing a bigger area between the parcel path and the observed air temperature. I'm also getting different values of some indexes related of this profile (CAPE, CIN, LIFT, EQLV, and so on)compared with the Wyoming sounding calculation.

I'm calculating this path as follow:
parcel_path = mpcalc.parcel_profile(d['pressure'], d['temperature'][0], d['dewpoint'][0]).

3 replies
jmedinah09
@jmedinah09
índices.png
41 replies
2021071912.78486.skewt.parc.gif
Those plots are based on the same observation of today at 12z.
Ryan May
@dopplershift
@jmedinah09 The difference looks entirely due to the use of different parcels to calculate the vertical parcel profile. You control this with the temperature and dewpoint values you pass to parcel_profile. In the code above, you are passing d['temperature'][0] and d['dewpoint'][0], so you are telling it to use a surface profile. If you want a mixed parcel like Wyoming uses, look at the mixed_layer function.
1 reply
WxmanJ
@WxmanJ
@dopplershift, does MetPy offer the ability to contour a RAOB upper air analysis? I am looking to plot the 700mb Temperature from a global UA netcdf file from ruc.noaa.gov/raobs.
2 replies
Steven Briscoe
@nevets963
Hi folks! I'm processing the L2 Chunks (from AWS) using MetPy. Does anyone know how I get the speed/velocity (or 'rpm') of the radar rotation? I.e. I want to know how long it took for it complete 60 deg. I checked out l2File.rda["AZ_LAT"] but that seems to be the latency for something else I'm yet to understand. Thanks!
3 replies
kimutaijoy
@kimutaijoy
Hi. I want to do a cross_section analysis of NetCDF data with a time dimension longer than one. metpy.parse_cf().squeeze() does not work for that. How should handle the data?
6 replies
jmedinah09
@jmedinah09
Hi everyone! How can I calculate the freezing level in a sounding?
4 replies
Gerrit Holl
@gerritholl
I think the workflows on Unidata/MetPy#1962 will not run until a maintainer approves them. Could a maintainer please do so? Unit tests pass locally but should be tested on GitHub too.
Ryan May
@dopplershift
@gerritholl Looks like it's been run. We'll get to a review on that after we get over the hump getting 1.1 out the door.
Claude Dicaire
@eliteuser26
I've been trying to put a comment on one issue in the Metpy repository but I am unable to send it. It comes back with an error code where I can't comment at this moment. Anyone encountered this issue?
Tried the Android app and the web.
Claude Dicaire
@eliteuser26
Well it resolved itself now about commenting on an issue.
Kyle Y. Parsotan
@Kyl67899
Hello, How do I get the High and low-pressure symbols to show up like on tropicaltidbits website? Code: https://github.com/Kyl67899/Hurricane-Irma-/blob/master/Hurricane_Irma_life_cycle_KYP_project_WX272_halperin_032720.py
54 replies
Kyle Y. Parsotan
@Kyl67899
Is there a mp.calc function for calculating the precipitable water?
2 replies
Kyle Y. Parsotan
@Kyl67899

Can anyone help me as to why when I calculate the mix layer I am getting an error on the height?

p = data['pressure']

T = data['temperature']

Td = data['dewpoint']

hei = data['height']

#https://stackoverflow.com/questions/65985185/cape-cin-returning-incorrect-values

# Calculate the mixed parcel--need to pass pressure as an additional variable to "mix" so that we get
# an appropriate "average pressure" to use as the mixed parcel
    parcel_temp, parcel_dewp, mixed_press = mpcalc.mixed_layer(data['pressure'], data['temperature'],
                                                           data['dewpoint'], data['pressure'],
                                                           height=data['height'], depth=500 * units.m)

#also calculates the same thing
   parcel_temp, parcel_dewp, mixed_press = mpcalc.mixed_layer(p, T, Td, p, hei, depth=500 * units.m)

Error Message:

Traceback (most recent call last):

  File "/home/students/parsotak/wx367/Advanced_Sounding.py", line 168, in <module>
    height=data['height'], depth=500 * units.m)

  File "/wx/python/anaconda3/envs/metpy/lib/python3.7/site-packages/metpy/xarray.py", line 677, in wrapper
    return func(*args, **kwargs)

  File "/wx/python/anaconda3/envs/metpy/lib/python3.7/site-packages/metpy/units.py", line 305, in wrapper
    bound_args = sig.bind(*args, **kwargs)

  File "/wx/python/anaconda3/envs/metpy/lib/python3.7/inspect.py", line 3015, in bind
    return args[0]._bind(args[1:], kwargs)

  File "/wx/python/anaconda3/envs/metpy/lib/python3.7/inspect.py", line 3006, in _bind
    arg=next(iter(kwargs))))

TypeError: got an unexpected keyword argument 'height'

Use this website: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.mixed_layer.html

8 replies
Kyle Y. Parsotan
@Kyl67899
Hello, Is there a way to calculate the lift of the parcel without the use of metpy? Since the university and system admin at the school refuses to update the metpy to be able to use the function to easily calculate the value?
Ryan May
@dopplershift
If you can't get MetPy updated, then you could always try to follow the docs for that version: https://unidata.github.io/MetPy/v0.12/
35 replies
kimutaijoy
@kimutaijoy
Hi. I'm doing cross-section analysis and I'm calculating Relative Humidity from Specific humidity. In my dataset, the name for temperature variable is ta. From the error, it seems the variable name must read temperature.
ValueError: This function changed in 1.0--double check that the function is being called properly.
relative_humidity_from_specific_humidity given arguments with incorrect units: temperature requires "[temperature]" but given "dimensionless"
26 replies
kimutaijoy
@kimutaijoy
image.png
Ryan May
@dopplershift
@kimutaijoy Can you open an issue or discussion over on GitHub ? That would help get the attention of some other people who are more experienced using cross_section. I'm not quite sure if this is a bug in MetPy or a metadata issue.
Jon Thielen
@jthielen
@dopplershift @kimutaijoy cross_section issue? I can take a look if you point me to the source files and code. From what I can gather in the replies above, my guess is something weird with xarray's keep_attrs behavior (which MetPy's internals may or may not be correctly handling), but won't be able to tell for sure without digging into the actual data and code.
Ryan May
@dopplershift
@jthielen Since I have your attention, I'll kick it over to Discussions real quick since I have the data and repro code snippet
Jon Thielen
@jthielen
:thumbsup:
Ryan May
@dopplershift
@jthielen One quick clarifying question: we should be able to make a cross-section directly on a lat/lon (1D each) grid, right?
Jon Thielen
@jthielen
Yes; the key is having horizontal dimension coordinates and a corresponding metpy_crs added.
Kyle Y. Parsotan
@Kyl67899
Where would I be able to retrieve data archives for GLM and are their examples of python plots with GLM plotted?
1 reply
Kyle Y. Parsotan
@Kyl67899
This message was deleted
1 reply
Kyle Y. Parsotan
@Kyl67899
This message was deleted
Kyle Y. Parsotan
@Kyl67899
This message was deleted
Cath Lagare
@cathrenelag

Hello. I'm trying to calculate the horizontal distribution of the depth of a MAUL (∂θe/∂z < 0). Thanks for the suggestion in stackexhange to try asking here.
I'm processing a WRFout file. First, I tried this

import numpy as np
import xarray as xr
from wrf import (getvar)

eth = np.array(getvar(ncfile, "eth", timeidx=time))
z = np.array(getvar(ncfile, "z", timeidx=time, units="km"))

deth = np.gradient(eth, axis=0)
dz = np.gradient(z, axis=0)
deth_dz = deth/dz

dthdz = xr.DataArray(data=deth_dz, dims=['Height', 'Latitude', 'Longitude'])

But when I do dthdz.sum(dim='Height'), I get very low depth values.
So I tried the suggestion of using thickness_hydrostatic by

eth = getvar(ncfile, "eth", timeidx=time)
pres = getvar(ncfile, "pressure", timeidx=time)
dthdz = mpcalc.thickness_hydrostatic(pres, eth)

However, the results are in 1D so I'm not sure how to do the horizontal plot of the depth.
I would just like to know where I'm doing it wrong. Thank you!

5 replies
Sid Gupta
@sidguptaCS
Hi everyone! My name is Sid and I am new to the MetPy development project. I look forward to contributing and creating an impact! :)
Are there any "major" issues ongoing for this package?
Ryan May
@dopplershift
Hi @sidguptaCS ! If you don't have any issues from your own use of MetPy, I'd take a look at the issue tracker and see what seems clear. I'd recommend starting with something simple since you're just starting out.
Sid Gupta
@sidguptaCS
Sounds good!
jmedinah09
@jmedinah09
Hi folks, where can I find suitable svg tropical cyclone icons as used in this tutorial:https://www.youtube.com/watch?v=Hggn5r3IKJA?
Not sure why it has been so difficult to me to find them although it seems to be kind of simple.
Ryan May
@dopplershift
@jmedinah09 I'm not sure. We have Unidata/MetPy#226 open about trying to add the ability to plot such a symbol to MetPy.
1 reply
Gerrit Holl
@gerritholl
Why did https://github.com/Unidata/MetPy/runs/3235203696 "fail to import metpy.io"?
2 replies
Cath Lagare
@cathrenelag

Hi. Thanks for last time! I have another question. Is it possible to calculate advection on multiple levels? I tried this with NCL before using advect_variable function and it worked fine. I tried this but got an error,

from wrf import (getvar)
import metpy.calc as mpcalc

time = 16
p = getvar(ncfile, "pressure")
qvv = getvar(ncfile, "QVAPOR", timeidx=time) 
qvv = qvv.metpy.assign_crs(grid_mapping_name='latitude_longitude', earth_radius=6371229.0)

uwind = getvar(ncfile, "ua", timeidx=time)
uwind = uwind.metpy.assign_crs(grid_mapping_name='latitude_longitude', earth_radius=6371229.0)

vwind = getvar(ncfile, "va", timeidx=time)
vwind = vwind.metpy.assign_crs(grid_mapping_name='latitude_longitude', earth_radius=6371229.0)

lat = getvar(ncfile, "XLAT")
lon = getvar(ncfile, "XLONG")
lat = lat[:,0]
lon = lon[0,:]

dx, dy = mpcalc.lat_lon_grid_deltas(lon, lat)
dx = dx[None, :]
dy = dy[None, :]

adv = mpcalc.advection(qvv, [uwind, vwind], dx=dx, dy=dy, x_dim=-1, y_dim=-2)

Error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-6316e58ce54b> in <module>
     23 dy = dy[None, :]
     24 
---> 25 adv = mpcalc.advection(qvv, [uwind, vwind], dx=dx, dy=dy, x_dim=-1, y_dim=-2)

~/.conda/envs/env/lib/python3.8/site-packages/metpy/xarray.py in wrapper(*args, **kwargs)
   1491                                  'latitude/longitude coordinates.')
   1492 
-> 1493         return func(*bound_args.args, **bound_args.kwargs)
   1494     return wrapper
   1495 

~/.conda/envs/env/lib/python3.8/site-packages/metpy/xarray.py in wrapper(*args, **kwargs)
   1218                     return tuple(wrapping(*args) for args in zip(result, match))
   1219                 else:
-> 1220                     return wrapping(result, match)
   1221         return wrapper
   1222     return decorator

~/.conda/envs/env/lib/python3.8/site-packages/metpy/xarray.py in _wrap_output_like_not_matching_units(result, match)
   1274             result = units.Quantity(result)
   1275         return (
-> 1276             xr.DataArray(result, coords=match.coords, dims=match.dims) if output_xarray
   1277             else result
   1278         )

~/.conda/envs/env/lib/python3.8/site-packages/xarray/core/dataarray.py in __init__(self, data, coords, dims, name, attrs, indexes, fastpath)
    407             data = _check_data_shape(data, coords, dims)
    408             data = as_compatible_data(data)
--> 409             coords, dims = _infer_coords_and_dims(data.shape, coords, dims)
    410             variable = Variable(dims, data, attrs, fastpath=True)
    411             indexes = dict(

~/.conda/envs/env/lib/python3.8/site-packages/xarray/core/dataarray.py in _infer_coords_and_dims(shape, coords, dims)
    124         dims = tuple(dims)
    125     elif len(dims) != len(shape):
--> 126         raise ValueError(
    127             "different number of dimensions on data "
    128             "and dims: %s vs %s" % (len(shape), len(dims))

ValueError: different number of dimensions on data and dims: 4 vs 3

Checking shapes...
qvv.shape, uwind.shape, vwind.shape, dx.shape, dy.shape
((59, 750, 606), (59, 750, 606), (59, 750, 606), (1, 750, 605), (1, 749, 606))

Not sure if this is valid, but any input will help. Thanks!

1 reply
justin-richling
@justin-richling

Hey all, I have a quick question about calculating the geostrophic wind. I'm getting an attribute error: 'Variable' object has no attribute 'coords'

I'm using a GFS grib file converted via CDO tools to get a netcdf file. I haven't had any other issues trying to calculate variables from metpy.calc with this data. I can get frontogenesis, pv, and others but not geostrophic wind.

Here is what I've tried:

datafile = "gfs_4_20200415_1800_015.nc"
ds = xr.open_dataset(datafile).metpy.parse_cf()
# gh is the geopotential height variable from the netcdf converted grib file
hgt_full = ds.variables['gh']
lat = ds.variables["lat"][:]
lon = ds.variables["lon"][:]
dx, dy = mpcalc.lat_lon_grid_deltas(lon, lat)

u_geo, v_geo = mpcalc.geostrophic_wind(hgt_full[0,:,:,:],latitude=lat,dx=dx,dy=dy, x_dim=-1, y_dim=-2)

Is it something to do with slicing of the lat, dx/dy at all? Thanks.

4 replies
winash12
@winash12
Vertical cross sections - Using the code in MetPy how does one represent omega - vertical velocity ? I want a downward arrow for negative omega and an upward arrow for positive omega. How does one do that ?
15 replies
Warren Pettee
@WEP11
Is the Standardized Precipitation Index in MetPy? If not, we can work on adding our functions for SPI. The NDMC likes to use our gamma distribution version of SPI, I imagine if there was suddenly interest, others would want to implement different distribution methods. Anyway, and thoughts? Thanks!
2 replies
Justin Richling
@MethaneRain
When using Xarray and parse_cf is there an easy way to ignore the Found valid latitude/longitude coordinates, ...warnings? I've tried using the warnings package, but these don't get caught.
import warnings
warnings.filterwarnings("ignore")
11 replies