[yt-users] more gadget visualization
Matthew Turk
matthewturk at gmail.com
Wed Nov 27 11:28:57 PST 2013
Hi Desika,
On Wed, Nov 27, 2013 at 11:56 AM, Desika Narayanan
<dnarayan at haverford.edu> wrote:
> Hey Team YT,
>
> I have a couple of (I think super-easy) questions:
>
> a. How do you paste a script to the yt pastebin? I've done it successfully
> once before, but can't for the life of me figure out how I did it.
>
:) You can use the command "yt pastebin" and then the script name.
There's also "yt pastebin_grab" which takes a number and spits out the
corresponding script to stdout.
> b. Relatedly, there's a (like 10 line) script appended below where I
> projection plot gas densities from a Gadget simulation. I'd like to be
> able to do the following:
>
> b.i - I'd like to be able to project other fields. For example, if I
> look at pf.h.field_list, I get that for particle type 0, the fields:
> ('PartType0', 'Masses'), ('PartType0', 'Metallicity') exist. However, if I
> try to project:
>
>>p = ProjectionPlot(pf,'z',(("deposit", "PartType0_metallicity")))
>
> (instead of the successful density line below), I get the error :
>
>>YTFieldNotFound: Could not find field '('deposit',
>> 'PartType0_metallicity')' in snapshot_006.
>
>
> b.ii. Assuming the parts from b.i are possible, is it then possible to
> multiply two fields together in the projection (say, I wanted metal mass and
> wanted to multiply the particle masses by the particle metallicities).
> Similarly, is it possible to multiply a field by a constant for the particle
> deposition into a projection plot?
>
So! Here's one place we have not really pushed the limits of our
field deposition functionality. As it stands, we only have a very
limited taxonomy of fields that are pre-defined, but it's possible to
define your own. I think ultimately we'll want to actually create
*smoothing* fields for these, rather than the "deposit" functionality
that's in there now, but that's in an open PR at the moment. Once the
actual SPH smoothing is in the code (and it just needs the
normalization stuff you and I talked about a while back, but my supply
of round tuits has been a bit low this week) we'll generate these
automatically for all the fields associated with gas particles and
they'll just be available.
For now, to do what you're describing, you can define your own field like so:
@derived_field(name=("deposit", "PartType0_metallicity"),
validators=[ValidateSpatial()])
def _my_field(field, data):
pos = data["PartType0", "Coordinates"]
d = data.deposit(pos, [data["PartType0", "Metallicity"]],
method = "sum")
d /= data["gas","CellVolume"]
return d
There are other options you can supply, but here's what it will do: it
will sum the values of Metallicity in each cell, then divide by the
volume of the cell, giving an average. You can apply multiplications
of mass and whatnot, divisions of total deposited mass, and on and on,
all based on the prescription just there.
Let me know if that helps,
Matt
>
> Thanks,
> Desika
>
>
> -------------------------
> from yt.mods import *
>
>
> snap = "/Users/desika/powderday/grid_data/snapshot_006.hdf5"
> bbox = [[-220.0, 220.0],
> [-220.0, 220.0],
> [-220.0, 220.0]]
>
>
> unit_base = {'UnitLength_in_cm' : 3.08568e+21,
> 'UnitMass_in_g' : 1.989e+43,
> 'UnitVelocity_in_cm_per_s' : 100000}
>
> pf = load(snap,unit_base = unit_base,bounding_box=bbox)
> pf.h
>
> p = ProjectionPlot(pf,'z',(("deposit", "PartType0_density")))
> p.set_width(200,'kpc')
> p.save()
>
>
> _______________________________________________
> 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