uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

`.where()` returning Xarray objects

Open philipc2 opened this issue 4 months ago • 0 comments

Hi @philipc2, I have another small question about something that doesn't seem to be working. I would like to use the .where() functionality with a uxds array, something like

variable = variable.where(variable<0,0)

and this doesn't give any complaints by itself, but when I try to plot the result of something like this, it gives a weird complaint about not recognizing the "title" I've put into the .plot() command. Here is the code I'm trying to use:

upwp_ug = uxds['UPWP_UG_CLUBB']
upwp_ug = upwp_ug.where(upwp_ug<0,0)
#upwp_ug = abs(upwp_ug)
upwp_ug_sum=upwp_ug.sum(dim='ilev')
print(upwp_ug_sum.shape)
upwp_ug_sum.mean(dim='time').plot(title="3a1 minus dflt, sum(abs(UPWP_UG_CLUBB)) (m2/s2)", projection=ccrs.PlateCarree()) * gf.coastline(projection=projection)

If I comment out the line with .where() and uncomment the abs() value line, it plots fine. But as is, it complains about the title:

AttributeError: Line2D.set() got an unexpected keyword argument 'title'

Any ideas? Does .where() not work yet with UXARRAY? Thanks!

Originally posted by @bstephens82 in https://github.com/UXARRAY/uxarray/discussions/861#discussioncomment-10810792

philipc2 avatar Oct 01 '24 17:10 philipc2