Hello! I did reproduce your advection code error, and I was able to execute the code and produce maps from your provided NARR_20080105_1800.nc. In this provided netCDF file there are dimensions of time provided for Jan 05 2018 at both 18Z and 21Z. The 21Z entry is is only full of NaN-data, but it still exists in the file. I am adapting the Differential Temperature Advection notebook available here (https://unidata.github.io/python-training/gallery/differential_temperature_advection/), and will provide my full adaptation below and attach an image of the produced maps. (imports are unedited) ds = xr.open_dataset('NARR_20080105_1800.nc') # With our dataset open, select only the first entry in the time dimension ds = ds.isel(time=0) # Get lat/lon data from file - edit for variable name lats = ds.latitude.data lons = ds.longitude.data # Calculate variable dx, dy values for use in calculations - no edit dx, dy = mpcalc.lat_lon_grid_deltas(lons, lats) # Get 700-hPa data and smooth - edit to make selectable level = 700 hght_700 = mpcalc.smooth_n_point(ds['HGT'].sel(plevel=level).squeeze(), 9) tmpk_700 = mpcalc.smooth_n_point(ds['TMP'].sel(plevel=level).squeeze(), 9) uwnd_700 = mpcalc.smooth_n_point(ds['UGRD'].sel(plevel=level).squeeze(), 9) vwnd_700 = mpcalc.smooth_n_point(ds['VGRD'].sel(plevel=level).squeeze(), 9) # Get 300-hPa data and smooth - edit to make selectable level = 300 hght_300 = mpcalc.smooth_n_point(ds['HGT'].sel(plevel=level).squeeze(), 9) tmpk_300 = mpcalc.smooth_n_point(ds['TMP'].sel(plevel=level).squeeze(), 9) uwnd_300 = mpcalc.smooth_n_point(ds['UGRD'].sel(plevel=level).squeeze(), 9) vwnd_300 = mpcalc.smooth_n_point(ds['VGRD'].sel(plevel=level).squeeze(), 9) # Convert Temperatures to degC - no edit tmpc_700 = tmpk_700.to('degC') tmpc_300 = tmpk_300.to('degC') # Get time in a nice datetime object format - edit to remove datetime object conversion vtime = ds.time.values # Use MetPy advection function to calculate temperature advection at two levels - no edit tadv_700 = mpcalc.advection(tmpk_700, (uwnd_700, vwnd_700), (dx, dy), dim_order='yx').to_base_units() tadv_300 = mpcalc.advection(tmpk_300, (uwnd_300, vwnd_300), (dx, dy), dim_order='yx').to_base_units() # Centered finite difference to calculate differential temperature advection - no edit diff_tadv = ((tadv_700 - tadv_300)/(400 * units.hPa)).to_base_units() # Set up plot crs (mapcrs) and the data crs, will need to transform all variables - no edit ... (the plotting code continues unedited) I hope this helps, and if this doesn't work for you please follow up and let me know! There's no rush here, and I'll be available whenever you get time to dedicate to it. Thanks. All the best, Drew Camron > A few quick questions/comments here: > - Did you reproduce my error? > - Did the code run after you added suggested edit? > - Where did you add that edit? > - I added this and still get same error as before, but probably I need to > edit correctly: > > > *# select one 2D field, advice from Unidatads.isel(time=0)* > > - (BTW - "dataset" is not defined so dataset.isel means nothing) > > - We just have one time step in the file, so I don't really understand your > instruction > > I should be able to focus some on this, this afternoon. Ticket Details =================== Ticket ID: AQS-174406 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.
Description: PNG image