[yt-users] Making a Multiplot using Ramses data
k.grisdale at surrey.ac.uk
k.grisdale at surrey.ac.uk
Wed Nov 13 06:13:22 PST 2013
Hi Matt,
In addition to my last message I have just found that yt will no longer except python scripts and produce projection plots. If I have a script what and type python script_name.py I get the “Running with the wrong number of fields error” displayed in the email below. However if I just copy and paste the same commands directly into yt I get out all the plots perfectly.
Any idea why this might be.
Here is the script incase that helps:
from yt.mods import *
p1 = load("output_00001/info_00001.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
p2 = load("output_00002/info_00002.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
p3 = load("output_00003/info_00003.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
p4 = load("output_00004/info_00004.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
p5 = load("output_00005/info_00005.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
p6 = load("output_00006/info_00006.txt", fields = ["Density","x-velocity", "y-velocity", "z-velocity", "Pressure"])
cen = [0,0,0]
pr1 = ProjectionPlot(p1,'z','Density',center=cen)
pr1.set_cmap('Density','YlOrRd')
pr1.set_log("Density", False)
pr1.set_zlim('Density', 0.01,0.35)
pr1.save("p1")
pr2 = ProjectionPlot(p2,'z','Density',center=cen)
pr2.set_cmap('Density','YlOrRd')
pr2.set_log("Density", False)
pr2.set_zlim('Density', 0.01,0.35)
pr2.save("p2")
pr3 = ProjectionPlot(p3,'z','Density',center=cen)
pr3.set_cmap('Density','YlOrRd')
pr3.set_log("Density", False)
pr3.set_zlim('Density', 0.01,0.35)
pr3.save("p3")
pr4 = ProjectionPlot(p4,'z','Density',center=cen)
pr4.set_cmap('Density','YlOrRd')
pr4.set_log("Density", False)
pr4.set_zlim('Density', 0.01,0.35)
pr4.save("p4")
pr5 = ProjectionPlot(p5,'z','Density',center=cen)
pr5.set_cmap('Density','YlOrRd')
pr5.set_log("Density", False)
pr5.set_zlim('Density', 0.01,0.35)
pr5.save("p5")
pr6 = ProjectionPlot(p6,'z','Density',center=cen)
pr6.set_cmap('Density','YlOrRd')
pr6.set_log("Density", False)
pr6.set_zlim('Density', 0.01,0.35)
pr6.save("p6")
Thanks
Kearn
On 13 Nov 2013, at 13:26, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
Huh, weird. So in 3 we switched the order of projection arguments. Try swapping 0 and "Density".
Sorry this has been such a pain!!
Matt
On Nov 13, 2013 8:23 AM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Hi Matt,
Thanks for that yt now loads in Ramses data but I get new errors.
If I use:
p1 = load("output_00001/info_00001.txt")
pr1 = ProjectionPlot(p1,'z','Density',center=cen)
I get:
You are running with the wrong number of fields.
Please specify these in the load command.
We are looking for 6 fields.
The last set of field sizes was: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 16, 16, 16, 16, 16, 16]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/visualization/plot_window.py", line 1441, in __init__
field_parameters = field_parameters)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.py", line 234, in __init__
self.get_data(field)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.py", line 278, in get_data
chunk_fields, "io")):
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/utilities/parallel_tools/parallel_analysis_interface.py", line 434, in parallel_objects
for obj_id, obj in oiter:
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 453, in chunks
self.get_data(fields)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 531, in get_data
fluids, self, self._current_chunk)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/geometry/geometry_handler.py", line 520, in _read_fluid_fields
chunk_size)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/frontends/ramses/io.py", line 41, in _read_fluid_selection
rv = subset.fill(content, fields, selector)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/frontends/ramses/data_structures.py", line 304, in fill
for level, offset in enumerate(self.domain.hydro_offset):
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/frontends/ramses/data_structures.py", line 102, in hydro_offset
hvals = fpu.read_attrs(f, header, "=")
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/utilities/fortran_utils.py", line 74, in read_attrs
assert(s1 == s2)
AssertionError
If I use the multi plot script that we have been discussing I get this error:
Traceback (most recent call last):
File "plotterm3.py", line 20, in <module>
proj1 = p1.h.proj(0, "Density", center=cen)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.py", line 234, in __init__
self.get_data(field)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/construction_data_containers.py", line 266, in get_data
fields = self._determine_fields(ensure_list(fields))
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/data_containers.py", line 396, in _determine_fields
finfo = self.pf._get_field_info("unknown", fname)
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/data_objects/static_output.py", line 331, in _get_field_info
raise YTFieldNotFound((ftype, fname), self)
yt.utilities.exceptions.YTFieldNotFound: Could not find field '('gas', 0)' in info_00001.
Ideas what I’ve done?
Thanks
Kearn
PS: As far as I know I am running yt 3. is there a way to check which version I have?
On 13 Nov 2013, at 13:08, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
Looks like you got back onto the yt-2.X branch. I of course screwed
up and should have realized that you were on 3.0! :) (You were,
right?) My fault completely. Give a shot at this:
hg pull http://bitbucket.org/yt_analysis/yt-3.0
hg up -C tip
python2.7 setup.py build_ext -i -f
That should get you back running.
-Matt
On Wed, Nov 13, 2013 at 5:23 AM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Hi Matt,
I have just applied the pull request using the command:
cd $YT_DEST/src/yt-hg
hg pull && hg update yt
But now when i tried to load RAMSES data into the YT I get the following
error:
yt : [ERROR ] 2013-11-13 10:22:49,486 Couldn't figure out output type for
output_00001/info_00001.txt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/convenience.py", line
90, in load
raise YTOutputNotIdentified(args, kwargs)
yt.utilities.exceptions.YTOutputNotIdentified: Supplied
('output_00001/info_00001.txt',) {}, but could not load!
Any idea what has happened?
Thanks
Kearn
Traceback (most recent call last):
File "plotterm3.py", line 7, in <module>
p1 = load("output_00001/info_00001.txt")
File "/Applications/Code/yt/yt-x86_64/src/yt-hg/yt/convenience.py", line
90, in load
raise YTOutputNotIdentified(args, kwargs)
yt.utilities.exceptions.YTOutputNotIdentified: Supplied
('output_00001/info_00001.txt',) {}, but could not load!
On 12 Nov 2013, at 14:57, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
On Tue, Nov 12, 2013 at 9:47 AM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Dear Matt,
Thanks again. The normalize command was just what I needed.
Does the projection plot used in the multi-plot work differently to the
normal ProjectionPlot?
I ask because with the code below I get the image below, while using the
same centre and width with the multi plot I get the image I sent in my last
email. I have tried playing around with different centres, and projection
radii but this only moves the image around or makes the square that it does
plot different sizes(this is still the case even after changing to a linear
scale). Both plots are using the same data set so i am explicating the same
plot.
They sort of work the same. What you're doing with the FRBs is much
lower-level, though, even though it's what the ProjectionPlot uses. I think
the issue you're running into is that the FixedResolutionBuffer is *not*
periodic by default, and to_frb() doesn't turn it on. I've issued a pull
request that adds this functionality to the to_frb() command, as I think it
is a problem not to have it!
https://bitbucket.org/yt_analysis/yt/pull-request/639/adding-periodic-default-false-to-to_frb
-Matt
Thanks Kearn
from yt.mods import *
p6 = load("output_00006/info_00006.txt")
cen = [0,0,0]
pr6 = ProjectionPlot(p6,'z','Density',center=cen)
pr6.set_cmap('Density','YlOrRd')
pr6.set_zlim('Density', 0.0,0.35)
pr6.save("p6")
<p6_Projection_z_Density.png>
On 12 Nov 2013, at 11:33, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
On Tue, Nov 12, 2013 at 3:46 AM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Hi Matt.
The Script you sent me has been of great help! I have now managed to get
yt to plot projections for my data.
However I am still having small trouble. Firstly script only plots the 1
quarter of each projection(I can change which quarter), [Graph below] and
secondly I would like to set the colorbar to be linear for my data. How can
I go about that?
If you change LogNorm to Normalize (and change the import) it should
change to linear. You can probably then just remove the LogLocator ticker.
To change the FOV, the 0.25 "unitary" is what I set, and you should be able
to change it to whatever you like. Just be sure to also change the center
value to be the center of the domain! :)
-Matt
Thanks
Kearn
<Screen Shot 2013-11-12 at 08.46.03.png>
On 11 Nov 2013, at 22:39, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
Oops, I guess my reply was less than helpful! Sorry about that --
been one of those days.
On Mon, Nov 11, 2013 at 3:30 PM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Hi Matt,
Thanks for the reply. The code that I used below is my attempt at
adapting
the script on the yt pages explaining how to use Multi-Plot Slice and
Projections. As I couldn’t figure out how make multi-plots of yt
Projections
I thought I’d try the adapting route. Which means there bits there I
don’t
get but have included as I thought they where needed for the multi plot.
I've spent a bit of time looking at this and I've been able to make a
multi plot that I think matches what you're looking for. I've put the
script here, and I've also tried to note where there might be issues
with it that could be important when you adapt it to your data.
http://paste.yt-project.org/show/4047/
Let me know if that helps out, or if I can help in any other way.
-Matt
Thanks again
Kearn
On 11 Nov 2013, at 20:13, Matthew Turk <matthewturk at gmail.com<mailto:matthewturk at gmail.com>> wrote:
Hi Kearn,
On Mon, Nov 11, 2013 at 10:18 AM, <k.grisdale at surrey.ac.uk<mailto:k.grisdale at surrey.ac.uk>> wrote:
Hi everyone
I am trying to make a multi plot using data from Ramses. I have outputs
from Ramses at 6 different times and I want to make projections at each
time
and place than in a multi plot to show evolution of the system. However
when
the code that I have written gives the results below.
<Screen Shot 2013-11-11 at 15.12.13.png>
Can anyone offer any suggestions as to wear my code is going wrong?
Thanks
Kearn
The code I’m using ( the for dax lines have been commented out because
every time they are included I get the error at the bottom)
from yt.mods import * # set up our namespace
import matplotlib.colorbar as cb
from matplotlib.colors import LogNorm
p1 = load("output_00001/info_00001.txt")
p2 = load("output_00002/info_00002.txt")
p3 = load("output_00003/info_00003.txt")
p4 = load("output_00004/info_00004.txt")
p5 = load("output_00005/info_00005.txt")
p6 = load("output_00006/info_00006.txt")
cen = [0,0,0]
orient = 'vertical'
fig, axes, colorbars = get_multi_plot(3, 2, colorbar=orient, bw = 4)
proj1 = p1.h.proj(2, "Density", center=cen)
proj2 = p2.h.proj(2, "Density", center=cen)
proj3 = p3.h.proj(2, "Density", center=cen)
proj4 = p4.h.proj(2, "Density", center=cen)
proj5 = p5.h.proj(2, "Density", center=cen)
proj6 = p6.h.proj(2, "Density", center=cen)
proj1_frb = proj1.to_frb((0.7,"cm"),512)
proj2_frb = proj2.to_frb((0.7,"cm"),512)
proj3_frb = proj3.to_frb((0.7,"cm"),512)
proj4_frb = proj4.to_frb((0.7,"cm"),512)
proj5_frb = proj5.to_frb((0.7,"cm"),512)
proj6_frb = proj6.to_frb((0.7,"cm"),512)
dens_axes = [axes[0][0], axes[1][0]]
#for dax in zip(dens_axes) :
I'm not sure what you're doing here -- this will yield:
[(axes[0][0],), (axes[1][0],)]
So you'll be getting back a tuple of length one inside the loop. You
should
be able to do dax[0]? But I'm not sure you need to zip in the first
place,
either.
-Matt
# dax.xaxis.set_visible(False)
# dax.yaxis.set_visible(False)
plots = [dens_axes[0].imshow(proj1_frb["Density"],origin ='lower'),
dens_axes[0].imshow(proj2_frb["Density"],origin ='lower'),
dens_axes[0].imshow(proj3_frb["Density"],origin ='lower'),
dens_axes[0].imshow(proj4_frb["Density"],origin ='lower'),
dens_axes[0].imshow(proj5_frb["Density"],origin ='lower'),
dens_axes[0].imshow(proj6_frb["Density"],origin ='lower')]
plots[0].set_clim((0.0,0.34))
plots[0].set_cmap("YlOrRd")
plots[1].set_clim((0.0,0.345))
plots[1].set_cmap("YlOrRd")
plots[2].set_clim((0.0,0.34))
plots[2].set_cmap("YlOrRd")
plots[3].set_clim((0.0,0.34))
plots[3].set_cmap("YlOrRd")
plots[4].set_clim((0.0,0.34))
plots[4].set_cmap("YlOrRd")
plots[5].set_clim((0.0,0.34))
plots[5].set_cmap("YlOrRd")
fig.savefig("test”)
error:
Traceback (most recent call last):
File "plotterm2.py", line 34, in <module>
dax.xaxis.set_visible(False)
AttributeError: 'tuple' object has no attribute 'xaxis'
_______________________________________________
yt-users mailing list
yt-users at lists.spacepope.org<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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<mailto: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/20131113/77de9cdb/attachment.html>
More information about the yt-users
mailing list