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
off-axis slice in spherical coordinates #4750
Comments
Hi, and welcome to yt! Thanks for opening your first issue. We have an issue template that helps us to gather relevant information to help diagnosing and fixing the issue. |
Hi. I think there are two different questions to be answered here:
absolutely ! The way I see it, neither off-axis slices nor support for spherical geometries is complete while this is missing.
That's more difficult to say. Both features have been in the code base for years at this point and as far as I recall no one has even attempted to implement this. It'd require entirely new code so it's not something we can add incrementally from what's already there. It's also possible that it would require substantial refactors of the existing, cartesian-only, off-axis internals. It's hard to say for sure, but that's my intuition of the problem. In short: I would absolutely love to see someone championing this feature, but that's a substantial undertaking. |
Coincidentally, it might be possible to achieve what you're looking for relatively easily™ thanks to #4741, but this PR would need to be fixed in the first place. If we approximate each cell by a parallelepiped, the aforementioned PR provides machinery to compute what each one would look like from an arbitrary position. If we then iterate over all parallelepiped, we have the off-axis projection. This could work in the general case for any dataset that is tiled with parallelepiped. |
I'd also find this hugely helpful.... but don't think I have the time right now to work on it in earnest. And for what it's worth, I've spent some time exploring ways to do this with yt as-is and depending on your needs, there are a couple approaches that can work OK:
|
I spent some time thinking about this and I think we could do it in a reasonably straightforward way with a handful of modifications to the codebase. In essence, a cutting plane through a sphere, given a normal vector, is the same as an equatorial slice through a sphere where the sphere has been rotated such that its pole is the normal vector. So implementing the cutting plane itself would not be terribly difficult in that sense, as we could do almost everything via simply defined offsets, which could be passed in to the routines in I'm more optimistic that this is feasible than I was before reading this thread. For instance, this is what the @cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
cdef int select_cell(self, np.float64_t pos[3], np.float64_t dds[3]) noexcept nogil:
if self.reduced_dimensionality == 1:
return 1
if pos[self.axis] + 0.5*dds[self.axis] > self.coord \
and pos[self.axis] - 0.5*dds[self.axis] - grid_eps <= self.coord:
return 1
return 0 Assuming we've added After writing this out, I think the best solution might be to have a rotation parameter that gets passed into slices that only means anything in the case that the geometry is spherical, and to have the slice selector query that. |
this seems like a promising approach! Would we be limited to the case where the sphere's origin is included in the cutting plane? I'm mostly asking out of curiosity -- I think for most applications the origin be a point in the cutting plane. Also, would anything extra have to be done to get this to work with data selection objects? Having this modified cutting plane work with |
thank you all guys! I am currently using an external interface provided by chrishavlin to temporarily solve this problem. First, I use ds.r[::200j,::200j,::200j] to extract a three-dimensional array in spherical coordinates, and then convert it to Cartesian coordinates for input into 'yt.' Meanwhile, I find it very interesting to implement this project in the codebase. After I obtain my Ph.D. degree, I hope I have time to make contributions in this area. |
I think yt is absolutely awesome and has saved me a lot of time. But I've noticed that when working with data in spherical coordinates, the existing slice functionality only offers slicing directions along 'r', 'theta', and 'phi'. However, these options do not fulfill many requirements in a spherical coordinate system. I am wondering if it's possible to implement a feature where I can define slices like off-axis in Cartesian coordinates even though the data is in spherical coordinates?
The text was updated successfully, but these errors were encountered: