Skip to content

Commit

Permalink
Ensure the field value of an isocontour are in the field's units. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Goldbaum committed May 19, 2017
1 parent 2d3c68c commit acca719
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions yt/data_objects/construction_data_containers.py
Expand Up @@ -1092,7 +1092,7 @@ class YTSurface(YTSelectionContainer3D):
surface_field : string
Any field that can be obtained in a data object. This is the field
which will be isocontoured.
field_value : float
field_value : float, YTQuantity, or unit tuple
The value at which the isocontour should be calculated.
Examples
Expand Down Expand Up @@ -1120,11 +1120,19 @@ class YTSurface(YTSelectionContainer3D):
vertices = None
def __init__(self, data_source, surface_field, field_value, ds=None):
self.data_source = data_source
self.surface_field = surface_field
self.field_value = field_value
self.surface_field = data_source._determine_fields(surface_field)[0]
finfo = data_source.ds.field_info[self.surface_field]
try:
self.field_value = field_value.to(finfo.units)
except AttributeError:
if isinstance(field_value, tuple):
self.field_value = data_source.ds.quan(*field_value)
self.field_value = self.field_value.to(finfo.units)
else:
self.field_value = data_source.ds.quan(field_value, finfo.units)
self.vertex_samples = YTFieldData()
center = data_source.get_field_parameter("center")
super(YTSurface, self).__init__(center = center, ds=ds)
super(YTSurface, self).__init__(center=center, ds=ds)

def _generate_container_field(self, field):
self.get_data(field)
Expand Down

0 comments on commit acca719

Please sign in to comment.