You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to use the xwrf destaggering routine for a wrfout output variable (10m u-wind component), and received some internal error related to indexing a list. I didn't see this reported in a past or currently open bug report, so I wanted to mention it here.
Minimal Complete Verifiable Example
#Import packagesimportxwrfimportxarrayasxr#Open WRF output file and run post-processing through xwrfnc_file=xr.open_dataset('wrfout_d04_2017-12-07').xwrf.postprocess()
#Destagger the WRF grid for 10m u-wind componentu_wind_destaggered=nc_file['U10'].xwrf.destagger().variable
Relevant log output
---------------------------------------------------------------------------IndexErrorTraceback (mostrecentcalllast)
CellIn[5], line1---->1nc_file_2017_12_07['U10'].xwrf.destagger().variableFile/home/sbarc/students/mariandob/mambaforge/envs/swex/lib/python3.11/site-packages/xwrf/accessors.py:68, inWRFDataArrayAccessor.destagger(self, stagger_dim, unstaggered_dim_name, exclude_staggered_auxiliary_coords)
31defdestagger(
32self,
33stagger_dim: str|None=None,
34unstaggered_dim_name: str|None=None,
35exclude_staggered_auxiliary_coords: bool=False,
36 ) ->xr.DataArray:
37""" 38 Destagger a single WRF xarray.DataArray 39 (...) 66 dimension coordinates or obtained from the original dataset. 67 """--->68new_variable=_destag_variable(
69self.xarray_obj.variable, stagger_dim=stagger_dim, unstag_dim_name=unstaggered_dim_name70 )
72# Need to recalculate staggered coordinates, as they don't already exist independently73# in a DataArray context74new_coords= {}
File/home/sbarc/students/mariandob/mambaforge/envs/swex/lib/python3.11/site-packages/xwrf/destagger.py:55, in_destag_variable(datavar, stagger_dim, unstag_dim_name)
49raiseNotImplementedError(
50'Expected a single destagger dimensions. Found multiple destagger dimensions: '51f'{stagger_dim}'52 )
54# we need a string, not a list containing a string--->55stagger_dim=stagger_dim[0]
56# Otherwise, we have a valid user provided stagger dimension5758# Destagger by mean of offset slices representing each side with respect to the stagger_dim59stagger_dim_size=datavar.sizes[stagger_dim]
IndexError: listindexoutofrange
The destaggering routine works with u-component of wind variable, but not with the u-component at 10m. Why might this be? Is it because the 10m wind components are already destaggered?
The text was updated successfully, but these errors were encountered:
mariandob
changed the title
[Bug]: Destaggering WRF Variables: List Index Out of Range Error
[Bug]: Destaggering WRF 10m Wind: List Index Out of Range Error
Dec 1, 2023
Hi @mariandob,
thanks for raising this issue. This seems to be a non-caught exception which is badly worded but in the end due to the U10 and V10 variables already being destaggered. You can check this by looking at the dimensions and seeing whether any dimension names end in _stag. I'll add some better worded exception to prevent any confusion in the future!
What happened?
I tried to use the xwrf destaggering routine for a wrfout output variable (10m u-wind component), and received some internal error related to indexing a list. I didn't see this reported in a past or currently open bug report, so I wanted to mention it here.
Minimal Complete Verifiable Example
Relevant log output
Environment
Anything else we need to know?
The destaggering routine works with u-component of wind variable, but not with the u-component at 10m. Why might this be? Is it because the 10m wind components are already destaggered?
The text was updated successfully, but these errors were encountered: