Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting data in spherical coordinates #52

Closed
dennissergeev opened this issue Aug 17, 2019 · 6 comments
Closed

Plotting data in spherical coordinates #52

dennissergeev opened this issue Aug 17, 2019 · 6 comments

Comments

@dennissergeev
Copy link

Description

Hi!

I am only starting to use this awesome library, but I was wondering if it is possible to plot isosurfaces (as well as other basic types of plots) on a sphere where (X, Y, Z) directions are not relative to the scene, but rather to the surface of the sphere (as in longitude, latitude, height).

Thanks in advance.

Example Data

My input data could be in this form:

import numpy as np

# coordinate arrays
lons = np.arange(-180, 181, 2.5)
lats = np.arange(-90, 91, 2)
pressure_levels = np.array([1000, 950, 900, 850, 800, 700, 600, 500])

# the data array
arr = np.random.rand(*(pressure_levels.shape + lats.shape + lons.shape))

# selected isosurfaces
iso_to_plot = [0.2, 0.5]
@banesullivan
Copy link
Member

Hi @dennissergeev - apologies for the slow response!

Unfortunately, VTK/PyVista does not support spherical coordinates in the rendering scene. You'd have to convert the spherical coordinates you have to cartesian using a transform of some sort.

I have a feeling you could make a structured grid of this sphere and still have a 3D volume. I'll try to see what I can do with your example above when I have a chance

@dennissergeev
Copy link
Author

dennissergeev commented Aug 22, 2019

Thanks!

AFAIK it is possible in Paraview (though API is a bit convoluted), so I guess it is technically possible in pyvista too, since they both use VTK...

@banesullivan
Copy link
Member

That is actually news to me! I didn't think it was possible to use spherical coordinates in ParaView (never tried, really).

Could you share some more details on this? Maybe screenshots? Or weblinks/tutorals? If I can figure out how they do it in ParaView, then we should be able to do it in PyVista.

They dont have a spherical axes grid, do they?!

@dennissergeev
Copy link
Author

I only tried to use it in the Paraview's GUI and to be honest didn't get far, but the option is available (see the "Spherical coordinates" tick box in the screenshot below)

Screenshot from 2019-08-22 17:50:23

Perhaps this package that uses Paraview python could be helpful: https://github.com/mjucker/pv_atmos/blob/master/grids.py#L367

as well as a tutorial from the same guy: https://youtu.be/ya-xXY5uzeo?t=332

@banesullivan
Copy link
Member

Ah I think all of those things are just applying a spherical transform to the data and not actually using a spherical coordinate system

Sent with GitHawk

@banesullivan
Copy link
Member

With the comments in #67, I think this is resolved. Spherical coordinate systems aren’t supported but you can apply a spherical transform to any mesh in the methods described to achieve the same effect which is what ParaView does (to my knowledge)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants