Issue #587: OffAxisSlicePlot annote_velocity (yt_analysis/yt)
New issue 587: OffAxisSlicePlot annote_velocity https://bitbucket.org/yt_analysis/yt/issue/587/offaxissliceplot-annote_veloc... Kyle Stewart: When I try to use annotate_velocity on the SlicePlot command it works fine, as before, but I get an error when I try to use it with the OffAxisSlicePlot command: The code I'm using is: ``` #!python gal=pf.h.sphere(center, 10.0/pf['kpc']) Lgal = gal.quantities["AngularMomentumVector"]() p=SlicePlot(pf, 2, ["Density", "HI_Density", "Temperature"], center=center, width=(140,'kpc')) p.annotate_velocity(factor=32) p.save("test") p=OffAxisSlicePlot(pf, Lgal, ["Density", "HI_Density", "Temperature"], center=center, width=(140,'kpc')) p.annotate_velocity(factor=32) p.save("test") ``` The SlicePlot part works fine. The error I get for the OffAxisSlicePlot is: ``` #!python In [347]: p.annotate_velocity(factor=32) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/scripts/iyt in <module>() ----> 1 p.annotate_velocity(factor=32) /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/visualization/plot_window.py in newfunc(*args, **kwargs) 97 rv = f(*args, **kwargs) 98 args[0]._plot_valid = False ---> 99 args[0]._setup_plots() 100 return rv 101 return newfunc /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/visualization/plot_window.py in _setup_plots(self) 956 label.set_fontproperties(fp) 957 --> 958 self.run_callbacks(f) 959 960 self._plot_valid = True /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/visualization/plot_window.py in run_callbacks(self, f) 966 CallbackMaker = callback_registry[name] 967 callback = CallbackMaker(*args[1:], **kwargs) --> 968 callback(cbw) 969 for key in self._frb.keys(): 970 if key not in keys: /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/visualization/plot_modifications.py in __call__(self, plot) 132 yv = "%s-velocity" % (y_names[plot.data.axis]) 133 qcb = QuiverCallback(xv, yv, self.factor, scale=self.scale, scale_units=self.scale_units, normalize=self.normalize) --> 134 return qcb(plot) 135 136 class MagFieldCallback(PlotCallback): /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/visualization/plot_modifications.py in __call__(self, plot) 629 plot.data['pdx'], plot.data['pdy'], plot.data['pdz'], 630 plot.data.center, plot.data._inv_mat, indices, --> 631 plot.data[self.field_x], 632 int(nx), int(ny), 633 (x0, x1, y0, y1),).transpose() /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/data_containers.py in __getitem__(self, key) 198 return self.field_data[f] 199 else: --> 200 self.get_data(f) 201 return self.field_data[f] 202 /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/data_containers.py in get_data(self, fields) 505 self.field_data.update(read_particles) 506 fields_to_generate = gen_fluids + gen_particles --> 507 self._generate_fields(fields_to_generate) 508 509 def _generate_fields(self, fields_to_generate): /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/data_containers.py in _generate_fields(self, fields_to_generate) 515 if field in self.field_data: continue 516 try: --> 517 self.field_data[field] = self._generate_field(field) 518 except GenerationInProgress as gip: 519 for f in gip.fields: /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/data_containers.py in _generate_field(self, field) 224 return self._generate_particle_field(field) 225 else: --> 226 return self._generate_fluid_field(field) 227 228 def _generate_fluid_field(self, field): /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/data_containers.py in _generate_fluid_field(self, field) 240 rv = self._generate_spatial_fluid(field, ngt_exception.ghost_zones) 241 else: --> 242 rv = finfo(gen_obj) 243 return rv 244 /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/field_info_container.py in __call__(self, data) 478 ii = self.check_available(data) 479 original_fields = data.keys() # Copy --> 480 dd = self._function(self, data) 481 if dd is not None: 482 dd *= self._convert_function(data) /Users/kstewart/code/yt-3.0/yt-x86_64/src/yt-3.0-hg/yt/data_objects/universal_fields.py in _CuttingPlaneVelocityX(field, data) 886 bulk_velocity = np.zeros(3) 887 v_vec = np.array([data["%s-velocity" % ax] for ax in 'xyz']) \ --> 888 - bulk_velocity[...,np.newaxis] 889 return np.dot(x_vec, v_vec) 890 add_field("CuttingPlaneVelocityX", TypeError: unsupported operand type(s) for -: 'NoneType' and 'float' ```
participants (1)
-
Kyle Stewart