[yt-users] Define a derived field of disk surface density

Matthew Turk matthewturk at gmail.com
Wed Mar 19 04:15:18 PDT 2014


Hi Suoqing,

Okay, I think I have an idea.  I believe other people have done this
before.  What you can do is compute the surface density, then supply
this as a "field_parameter" to your data.  For instance, you can
compute a 2D grid of the surface density using the projection tool you
already are, and convert this to a "fixed resolution buffer".
Something like:

proj = pf.h.proj(...
frb = proj.to_frb(...

Then the frb["Density"] value will be a 2D buffer, possibly transposed
(i.e., you may need to do .transpose() on it), that corresponds to the
surface density resulting from the projection.  You can then set this
as a field parameter:

data_source = pf.h.all_data()
data_source.set_field_parameter("surface_density", frb["Density"])

Now, in a derived  field, you can access this:

def my_field(field, data):
    surface_density = data.get_field_parameter("surface_density")
    ...

And you should be able to project with this:

pf.h.proj(..., source=data_source)

Note that in 3.0, "source" becomes "data_source", but otherwise it
should mostly be the same.

I'd strongly encourage you to try this out, but also to test that your
x,y values in the surface_density variable are correctly set up -- as
in, that the origin is in the correct place for where you are, rather
than with the x,y axes flipped or with the origin in upper left or
something.

Good luck, and let us know if it works,

-Matt

On Tue, Mar 18, 2014 at 5:27 PM, Suoqing JI <suoqing at physics.ucsb.edu> wrote:
> Hi Matt,
>
> Thanks for your response!
>
> I want to integrate the density from -zmin to +zmin for every cells located
> on (x, y), or in your words, on (r ,theta). So the cells with the same (x,
> y) location will have the same value of surface density, as the figures
> show. The surface density is a function of only (x, y).
>
> Best wishes,
> --
> Suoqing JI
> Ph.D Student
> Department of Physics
> University of California, Santa Barbara
> CA 93106, USA
>
> On Mar 18, 2014, at 7:38 AM, Matthew Turk <matthewturk at gmail.com> wrote:
>
> Hi Suoqing,
>
> If I understand correctly, you want to compute the *local* surface
> density (i.e., the integrated density up to that height) for each
> cell?  As in, re you defining it such that it's a function of r,
> theta, z, or are you computing the surface density *once* for a disk
> object and using that (i.e., function of r, theta)?
>
> -Matt
>
> On Tue, Mar 18, 2014 at 2:24 AM, Suoqing JI <suoqing at physics.ucsb.edu>
> wrote:
>
> Hi,
>
> I'm working on FLASH 3D Cartesian AMR data, and would like to define a
> derived field of surface density, so I can use surface density field to
> calculate other derived fields.
>
> My current script does give desired results (slice_y:
> http://i.imgur.com/XigIYJc.png   slice_z: http://i.imgur.com/kA2Fmlt.png,
> and the disk is cut from original data). However, it's extremely
> inefficient, because I cast a ray through disk height for every cells
> located on x-y plane surface of each AMR block.
>
> So is there any clever way to define surface density as a derived field in
> YT, as what the figures attached show? Or some way without defining surface
> density as a derived field, but I can get access to surface density values
> when computing other derived fields?
>
> Thanks a lot!
>
> Best wishes,
> --
> Suoqing JI
> Ph.D Student
> Department of Physics
> University of California, Santa Barbara
> CA 93106, USA
>
> _______________________________________________
> 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