grid_deltas_from_dataarray() returns all nans
See original GitHub issueWhat went wrong?
When attempting to use absolute_vorticity()
, I encountered some trouble getting any values at all.
Causes dx/dy values to be all NaN because lat_lon_grid_deltas()
does not appear to properly handle Xarray DataArray’s.
I’m not sure whether the fix is to modify xarray.py
call to lat_lon_grid_deltas()
to be something like latitude.data
and longitude.data
, or change how lat_lon_grid_deltas()
works so that if given a DataArray it can get the underlying data out.
Happy to make a contribution with a little guidance. Thanks.
P.S.- still having trouble getting appropriate-looking absolute vorticity values but still working on that.
Operating System
Linux
Version
1.3.1
Python Version
3.9.15
Code to Reproduce
# If I use some sample ERA5 latitude/longitude grid data with this code:
dx, dy = mpcalc.lat_lon_grid_deltas(ds['longitude'],ds['latitude'])
print(dx)
print(dy)
# [[nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan] ... [nan nan nan ... nan nan nan] # [nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan]] meter
# [[nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan] ... [nan nan nan ... nan nan nan] # [nan nan nan ... nan nan nan] [nan nan nan ... nan nan nan]] meter
dx, dy = mpcalc.lat_lon_grid_deltas(ds['longitude'].data,ds['latitude'].data)
print(dx)
print(dy)
# [[13899.351016076906 13899.351016076906 13899.351016076906 ... 13899.351016076906 13899.351016076906 # 13899.351016076906] [14004.262721525833 14004.262721525833 14004.262721525833 ... 14004.262721525833 # 14004.262721525833 14004.262721525833] [14108.90780683885 14108.90780683885 14108.90780683885 ... # 14108.90780683885 14108.90780683885 14108.90780683885] ... [26787.690257756163 26787.690257756163 # 26787.690257756163 ... 26787.690257756163 26787.690257756163 26787.690257756163] [26819.849824192395 # 26819.849824192395 26819.849824192395 ... 26819.849824192395 26819.849824192395 26819.849824192395]# [26851.498778762038 26851.498778762038 26851.498778762038 ... 26851.498778762038 26851.498778762038 # 26851.498778762038]] meter
# [[-27798.718571171168 -27798.718571171168 -27798.718571171168 ... -27798.718571171168 -27798.718571171168 # -27798.718571171168] [-27798.7185711694 -27798.7185711694 -27798.7185711694 ... -27798.7185711694 # -27798.7185711694 -27798.7185711694] [-27798.71857117152 -27798.71857117152 -27798.71857117152 ... # -27798.71857117152 -27798.71857117152 -27798.71857117152] ... [-27798.718571170106 -27798.718571170106 # -27798.718571170106 ... -27798.718571170106 -27798.718571170106 -27798.718571170106] [-27798.71857117046 # -27798.71857117046 -27798.71857117046 ... -27798.71857117046 -27798.71857117046 -27798.71857117046] # [-27798.71857117046 -27798.71857117046 -27798.71857117046 ... -27798.71857117046 -27798.71857117046 # -27798.71857117046]] meter
# The first dx/dy are all NaN but the second dx/dy seem reasonable.
Errors, Traceback, and Logs
None
Issue Analytics
- State:
- Created 9 months ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Select all Rows with NaN Values in Pandas DataFrame
Here are 4 ways to select all rows with NaN values in Pandas DataFrame: (1) Using isna() to select all rows with NaN...
Read more >pandas map returning all NaNs - Stack Overflow
But the resulting dataframe returns NaN for all IDs . I was able to successfully create the desired dataframe using Excel Vlookup though....
Read more >Pandas Drop Rows with NaN Values in DataFrame
Use dropna() function to drop rows with NaN / None values in pandas DataFrame. ... Below are a quick example # Drop all...
Read more >Determine which array elements are NaN - MATLAB isnan
This MATLAB function returns a logical array containing 1 (true) where the elements of A are NaN, and 0 (false) where they are...
Read more >Working with missing data — pandas 1.5.2 documentation
The sum of an empty or all-NA Series or column of a DataFrame is 0. >>> In [36]: pd.Series([np.nan]).sum() Out[36]: 0.0 In [37]:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Update:
I am stripping
attrs
myself I think:ds = xr.combine_by_coords(singlesets,combine_attrs="drop")
So, no fault of the RDA here.
sigh What’s the source for this data?
Can you see if it works if you add units of ‘degrees’ to those
DataArray
s? (ds[‘latitude’].attrs[‘units’] = ‘degrees’)