[yt-users] Mismatched array dimensions when trying to construct surface.triangles
David Ketcheson
dketch at gmail.com
Tue Nov 11 05:37:56 PST 2014
I'm trying to plot isosurfaces from AMRClaw data. I've been able to
successfully plot slices and projections. Here is the script I'm using for
isosurfaces:
https://gist.github.com/ketch/30d8bdf41422dc20bb95
(based on
http://yt-project.org/doc/cookbook/complex_plots.html#plotting-isocontours)
I get the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/Users/ketch/Downloads/plot_yt_amrclaw.py in <module>()
35 ad = ds.all_data()
36 surface = ds.h.surface(ad,"q",0.2)
---> 37 p3dc = Poly3DCollection(surface.triangles, linewidth=0)#,
linewidth=0.1,alpha=0.9)
38 colors = yt.apply_colormap((surface["q"]), cmap_name="hot")
39 p3dc.set_facecolors(colors[0,:,:]/255.)
/Users/ketch/anaconda/lib/python2.7/site-packages/yt/data_objects/construction_data_containers.pyc
in triangles(self)
1021 def triangles(self):
1022 if self.vertices is None:
-> 1023 self.get_data()
1024 vv = np.empty((self.vertices.shape[1]/3, 3, 3),
dtype="float64")
1025 for i in range(3):
/Users/ketch/anaconda/lib/python2.7/site-packages/yt/data_objects/construction_data_containers.pyc
in get_data(self, fields, sample_type)
913 my_verts = self._extract_isocontours_from_grid(
914 block, self.surface_field,
self.field_value,
--> 915 mask, fields, sample_type)
916 if fields is not None:
917 my_verts, svals = my_verts
/Users/ketch/anaconda/lib/python2.7/site-packages/yt/data_objects/construction_data_containers.pyc
in _extract_isocontours_from_grid(self, grid, field, value, mask,
sample_values, sample_type)
933 mask, sample_values = None,
934 sample_type = "face"):
--> 935 vals = grid.get_vertex_centered_data(field, no_ghost =
False)
936 if sample_values is not None:
937 svals = grid.get_vertex_centered_data(sample_values)
/Users/ketch/anaconda/lib/python2.7/site-packages/yt/data_objects/grid_patch.py
in get_vertex_centered_data(self, field, smoothed, no_ghost)
289 else:
290 cg = self.retrieve_ghost_zones(1, field,
smoothed=smoothed)
--> 291 np.add(new_field, cg[field][1: ,1: ,1: ], new_field)
292 np.add(new_field, cg[field][:-1,1: ,1: ], new_field)
293 np.add(new_field, cg[field][1: ,:-1,1: ], new_field)
ValueError: operands could not be broadcast together with shapes (47,47,47)
(48,48,48) (47,47,47)
I get the same error if I just ask for surface.triangles.
After a bit of hunting, I found that the whole thing works fine if I set
smoothed=False in line 290. Any ideas as to why the array size comes out
wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141111/fa3ed417/attachment.htm>
More information about the yt-users
mailing list