[yt-users] writing to a file
Nathan Goldbaum
nathan12343 at gmail.com
Thu Jul 6 21:56:01 PDT 2017
On Thu, Jul 6, 2017 at 11:44 PM, Stephanie Tonnesen <stonnes at gmail.com>
wrote:
> Hi all,
>
> I am trying to write a bunch of information from a gas-only single enzo
> output to a file for colleagues to read. I don't think they are familiar
> with HDF5, so I am hoping to write to a fits file. What I want to put in
> the file is the x,y,z coordinates, the x,y,z velocity, and the total energy
> of the gas--which is a user-defined function in my case. Ideally I also
> only want to include gas that has a tracer fraction of some value.
>
> so basically I have something like:
>
> ds = yt.load("file")
> galgas = ds.cut_region(["obj['Metal_Density']/obj['density'] > 0.1"])
>
To get the x, y, z position:
x = galgas['x']
y = galgas['y']
z = galgas['z']
And the velocity:
vx = galgas['velocity_x']
vy = galgas['velocity_y']
vz = galgas['velocity_z']
And your tnermal energy derived field:
te = galgas['your_te_field']
These will all be YTArrays. You can convert these to astropy quantities by
doing:
vx = vx.to_astropy()
Or you could convert them to ndarrays:
vx = np.array(vx)
And then you could use astropy.io.fits to make a fits file from these
arrays.
-Nathan
>
> can I just create an array of the fields I want from galgas?
>
> Thanks,
> Stephanie
>
> --
> Dr. Stephanie Tonnesen
> Alvin E. Nashman Postdoctoral Fellow
> Carnegie Observatories, Pasadena, CA
> stonnes at gmail.com
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20170706/e6a8da4f/attachment.html>
More information about the yt-users
mailing list