Hi, I've hit a problem with the latest version of yt and covering grid that is linked with the number of ghostzones. My code looked like: for dim in range(3): left.append(cloud_position[c][dim] - 0.5*width[dim]) right.append(cloud_position[c][dim] + 0.5*width[dim]) dims.append(int(round((right[dim]-left[dim])/cellsize))) cgrid = pf.h.covering_grid(level, left_edge = left, dims=dims, num_ghost_zones=2) but gives me: TypeError Traceback (most recent call last) /home/tasker/yt-new2/src/yt-hg/scripts/iyt in <module>() ----> 1 execfile("export_hdf5_cube.py") /home/tasker/yt-new2/src/yt-hg/scripts/iyt in <module>() 51 left_edge = left, 52 dims=dims, ---> 53 num_ghost_zones=2) 54 55 /home/tasker/yt-new2/src/yt-hg/yt/data_objects/data_containers.pyc in __init__(self, level, left_edge, dims, fields, pf, num_ghost_zones, use_pbar, **kwargs) 3689 self.level = level 3690 rdx = self.pf.domain_dimensions*self.pf.refine_by**level -> 3691 rdx[np.where(dims - 2 * num_ghost_zones <= 1)] = 1 # issue 602 3692 self.dds = self.pf.domain_width / rdx.astype("float64") 3693 self.ActiveDimensions = np.array(dims, dtype='int32') TypeError: unsupported operand type(s) for -: 'list' and 'int' This happens regardless of whether I use num_ghost_zones or not. If I don't have ghost_zones set, the error occurs at line 52, but still points to line 3691. Dims and left look fine: In [9]: dims Out[9]: [64, 64, 64] In [10]: left Out[10]: [20.424700000000001, 11.512700000000001, 15.7158] In [11]: level Out[11]: 5 In [14]: rdx = pf.domain_dimensions*pf.refine_by**level In [15]: rdx Out[15]: array([4096, 4096, 4096]) If I set num_ghost_zones = na.array([0,0,0]) then it runs. However, if I then try cgrid["x"] I hit more problems circulating around the same area: ValueError Traceback (most recent call last) /home/tasker/yt-new2/src/yt-hg/scripts/iyt in <module>() ----> 1 cgrid["y"] /home/tasker/yt-new2/src/yt-hg/yt/data_objects/data_containers.pyc in __getitem__(self, key) 316 if key not in self.fields: 317 self.fields.append(key) --> 318 self.get_data(key) 319 return self.field_data[key] 320 /home/tasker/yt-new2/src/yt-hg/yt/data_objects/data_containers.pyc in get_data(self, fields) 3733 try: 3734 #print "Generating", field -> 3735 self._generate_field(field) 3736 continue 3737 except NeedsOriginalGrid, ngt_exception: /home/tasker/yt-new2/src/yt-hg/yt/data_objects/data_containers.pyc in _generate_field(self, field) 3764 if self.pf.field_info.has_key(field): 3765 # First we check the validator; this might even raise! -> 3766 self.pf.field_info[field].check_available(self) 3767 self[field] = self.pf.field_info[field](self) 3768 else: # Can't find the field, try as it might /home/tasker/yt-new2/src/yt-hg/yt/data_objects/field_info_container.pyc in check_available(self, data) 354 """ 355 for validator in self.validators: --> 356 validator(data) 357 # If we don't get an exception, we're good to go 358 return True /home/tasker/yt-new2/src/yt-hg/yt/data_objects/field_info_container.pyc in __call__(self, data) 482 if not data._spatial: 483 raise NeedsGridType(self.ghost_zones,self.fields) --> 484 if self.ghost_zones <= data._num_ghost_zones: 485 return True 486 raise NeedsGridType(self.ghost_zones,self.fields) ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() cgrid["Density"] and the velocities are fine. I'm suspecting this is because the position calculation in the code is not expecting an array for the ghost zone number? Oddly, I see from the mailing list is this reminiscent of a problem nyx was having. Elizabeth
participants (2)
-
Elizabeth Tasker
-
Matthew Turk