boutproject / xBOUT

Collects BOUT++ data from parallelized simulations into xarray.
https://xbout.readthedocs.io/en/latest/
Apache License 2.0
21 stars 10 forks source link

BOUT-specific plotting methods #11

Closed TomNicholas closed 4 years ago

TomNicholas commented 5 years ago

Once real-space coordinates are included, we can implement tokamak/BOUT-specific plotting methods.

For example we could make a method da.bout.plot_poloidal_slice().

Not sure whether xarray's built-in handling of plotting with non-uniform coordinates would be sufficient, or whether it would be harder than that.

Someone has almost certainly done this already, it might be in BOUT's pylib (boutdata.pol_slice() and boututils.plotpolslice() would certainly be useful) or maybe even in OMFIT? Could again have crossover with PlasmaPy?

If we end up reimplementing this then might want to look at the internals of cartopy.

TomNicholas commented 5 years ago

So I've been doing some reading, and I think we should strive to emulate something like this example from the xarray documentation, which uses cartopy to project data onto a globe, then plots it with matplotlib:

import cartopy.crs as ccrs

air = xr.tutorial.open_dataset('air_temperature').air

ax = plt.axes(projection=ccrs.Orthographic(-80, 35))

air.isel(time=0).plot.contourf(ax=ax, transform=ccrs.PlateCarree());

ax.set_global(); ax.coastlines();

example xarray + cartopy plot

There are several advantages of this approach:

So basically I think that eventually xBOUT should have a module (or maybe it could be standalone project...) which is basically cartopy for tokamaks (cartomak??)

@ZedThree @d7919 @bendudson @JosephThomasParker @johnomotani thoughts?

TomNicholas commented 4 years ago

While my general grand vision above is another matter, I think that the aim of plotting bout-specific geometries has been fulfilled by #34 and #50 , so I'm going to close this.