Skip to content

.where() returning Xarray objects  #985

@philipc2

Description

@philipc2

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 #861 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions