[yt-users] load structured mesh

Andrea Negri negri.andre at gmail.com
Tue May 10 15:01:27 PDT 2016


Hi Matthew,
I trid with this simple script,  but I have got some errors in just
doing a simple slice over phi.

import yt
import numpy as np
import sys


#new grid
low_r = 1.
high_r = 1000.
r=np.logspace(low_r, high_r, 100)
theta = np.linspace(0., np.pi, 10)
phi = np.linspace(0., 2.*np.pi, 2)

coordinates,connectivity = yt.hexahedral_connectivity(r,theta,phi)

d=np.random.random((len(r)-1, len(theta)-1, len(phi)-1))


data = dict(density = (d, "g/cm**3"))


### r, theta, phi
bbox = np.array([[r[0], r[-1]], [theta[0], theta[-1]], [phi[0], phi[-1]]])

ds = yt.load_hexahedral_mesh(data,connectivity,coordinates,bbox=bbox,geometry=('spherical'))


slc = yt.SlicePlot(ds, "r", ["density"]).save()
slc = yt.SlicePlot(ds, "theta", ["density"]).save()
slc = yt.SlicePlot(ds, "phi", ["density"]).save()

On 3 May 2016 at 15:52, Matthew Turk <matthewturk at gmail.com> wrote:
> Whoops!  I meant load_hexahedral_mesh, but that link still works.  :)
>
> On Tue, May 3, 2016 at 8:43 AM, Matthew Turk <matthewturk at gmail.com> wrote:
>>
>> Hi Andrea,
>>
>> I *think* you could use load_semistructured_mesh for this; it can accept
>> different coordinate systems, too.  There's an example here:
>>
>>
>> http://yt-project.org/docs/dev/examining/loading_data.html#semi-structured-grid-data
>>
>> -Matt
>>
>> On Tue, May 3, 2016 at 3:01 AM, Andrea Negri <negri.andre at gmail.com>
>> wrote:
>>>
>>> Hi John,
>>>
>>> unfortunately I have a cell spacing varying inside a grid. A viable
>>> way would be to interpolate my data on a regular grid, and then load
>>> it.
>>> The interpolation part is not so computationally demanding (I have
>>> already tested it), it is just the plotting which is slow process (I'm
>>> talking of plotting a slice).
>>> Maybe this can be improved by building a set of grid with lower and
>>> lower resolution. Is there any documentation on how t he grid in the
>>> grid data format should be?
>>>
>>>
>>> Andrea
>>>
>>> On 3 May 2016 at 01:37, John ZuHone <jzuhone at gmail.com> wrote:
>>> > If by "non-uniform" you mean that you have grids of differing
>>> > resolutions
>>> > then yt and grid data format support that, but if you have cell spacing
>>> > varying _inside_ a grid then yt does not yet support this. We're
>>> > working on
>>> > it, but it will probably take some time before it is operational.
>>> >
>>> >
>>> > =================================
>>> > John ZuHone, Chandra/ACIS operations
>>> > Harvard-Smithsonian Center for Astrophysics
>>> >
>>> > 60 Garden St., MS-67       (w) 617-496-1816
>>> > Cambridge, MA 02138.     (m) 781-708-5004
>>> >
>>> > john.zuhone at cfa.harvard.edu
>>> > http://hea-www.cfa.harvard.edu/~jzuhone
>>> > =================================
>>> >
>>> > On May 2, 2016, at 7:18 PM, Andrea Negri <negri.andre at gmail.com> wrote:
>>> >
>>> > Dear John,
>>> >
>>> > thanks for the suggestions. Do you know if the grid data format is
>>> > compatible with a non uniform mesh? I was thinking of porting my
>>> > outputs in this format.
>>> >
>>> >
>>> > Cheers,
>>> > Andrea
>>> >
>>> > On 2 May 2016 at 18:52, John Zuhone <jzuhone at gmail.com> wrote:
>>> >
>>> > Hi Andrea,
>>> >
>>> >
>>> > yt has some support for axisymmetric grids in 2D, so you won’t need to
>>> > convert to a 3D array.
>>> >
>>> >
>>> > The bigger issue is the logarithmic grid spacing. This is currently
>>> > being
>>> > worked on, but is in a very early state. Currently what it does is use
>>> > “logr” as the coordinate instead of r, which may not be very ideal for
>>> > every
>>> > situation. A lot of yt functionality is probably not compatible with
>>> > this
>>> > way of doing things.
>>> >
>>> >
>>> > Nevertheless, if you would like to explore it further, let us know.
>>> >
>>> >
>>> > Best,
>>> >
>>> >
>>> > John Z
>>> >
>>> >
>>> > On May 2, 2016, at 10:53 AM, Andrea Negri <negri.andre at gmail.com>
>>> > wrote:
>>> >
>>> >
>>> > Of course. I have a 2.5D simulation in spherical coordinates. It is
>>> >
>>> > axial symmetric, so the actual grid is 2D, r and theta. The grid is
>>> >
>>> > structured, the grid spacing in theta is constant, while the spacing
>>> >
>>> > in r follows a geometrical progression, i.e. dr[i+1] = dr[i] * factor,
>>> >
>>> > where factor is a constant.
>>> >
>>> >
>>> > I don't know if yt supports axisymmetric grids, but I can bypass this
>>> >
>>> > issue by duplicating the 2D array into a 3D one. Sure, it is not
>>> >
>>> > efficient...
>>> >
>>> >
>>> > My ultimate goal is to produce projections, off axis projections and
>>> >
>>> > mock X-ray observations.
>>> >
>>> >
>>> >
>>> > Thanks,
>>> >
>>> > Andrea
>>> >
>>> >
>>> > On 2 May 2016 at 16:43, Nathan Goldbaum <nathan12343 at gmail.com> wrote:
>>> >
>>> > Can you share a little bit more detail about your grid structure? I
>>> > know
>>> >
>>> > that support for log-radial bins is being worked on right now, for
>>> > example.
>>> >
>>> >
>>> > On Mon, May 2, 2016 at 3:18 AM, Andrea Negri <negri.andre at gmail.com>
>>> > wrote:
>>> >
>>> >
>>> > Hi all,
>>> >
>>> >
>>> > I'm trying to read ZEUS-MP 2 data, and I'm building my programs step
>>> >
>>> > by step. I was able to load data regularly spaced in spherical
>>> >
>>> > coordinates. However, I actually have a non-uniform radial grid.
>>> >
>>> >
>>> > I tried with the script in attachment, but I have got odd errors...
>>> >
>>> >
>>> > Also, I have found this page, is it relevant for my case (just because
>>> >
>>> > my code is mentioned, the answer would be yes :) )?
>>> >
>>> > https://bitbucket.org/yt_analysis/grid_data_format
>>> >
>>> >
>>> >
>>> > Thanks,
>>> >
>>> > Andrea
>>> >
>>> >
>>> > _______________________________________________
>>> >
>>> > yt-users mailing list
>>> >
>>> > yt-users at lists.spacepope.org
>>> >
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> >
>>> > yt-users mailing list
>>> >
>>> > yt-users at lists.spacepope.org
>>> >
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> >
>>> > _______________________________________________
>>> >
>>> > yt-users mailing list
>>> >
>>> > yt-users at lists.spacepope.org
>>> >
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> >
>>> > _______________________________________________
>>> >
>>> > yt-users mailing list
>>> >
>>> > yt-users at lists.spacepope.org
>>> >
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> > _______________________________________________
>>> > yt-users mailing list
>>> > yt-users at lists.spacepope.org
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> >
>>> > _______________________________________________
>>> > yt-users mailing list
>>> > yt-users at lists.spacepope.org
>>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>> >
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>



More information about the yt-users mailing list