Good morning YT-users, I'm trying to take derivatives on a 2d dataset, below is what I do and the error I get: # - - - - - - A SIMPLE TEST TO TRY GETTING A 2D DERIVATIVE - - - - - - - - - - ... ds_list = [yt.load('%s/DD%04d/data%04d'%(base_directory,n1,n1)) for n1 in frame_list] ds = ds_list[0] g = ds.index.grids[0] ds.periodicity = (True, True, True) ad = ds.all_data() # this is to access the grad operator and the added derived field which are found further below: map(xyz_derived_fields, ds_list) # the following line breaks down print(ad['deriv_vx']) # - - - - - - - - - - - - ANOTHER .PY FILE - - - - - - - - - - ... def grad(data,fieldname,direction): iM2 = slice(None,-2) iP2 = slice(2,None) all = slice(1,-1) all_all=[all]*3 dxi=1./(2*data.dds) out = np.zeros_like(data[fieldname]) Right = [all]*3 Left = [all]*3 print(data.shape) if data.shape[2] == 1: all_all[2]=slice(None) Right[2]=slice(None) Left[2]=slice(None) Right[direction] = iP2 Left[direction] = iM2 out[all_all] = (data[fieldname][Right] - data[fieldname][Left]) * dxi[direction] return out def xyz_derived_fields(target): def deriv_vx(field,data): return grad(data,'velocity_x',0) MyValidators = [yt.ValidateSpatial(1,['velocity_x', 'velocity_y','velocity_z'])] target.add_field('deriv_vx', function=deriv_vx, units='cm/s', validators=MyValidators) # this is the error: - - - - - - - - - - - /home/luzlourdes/yt-conda/lib/python2.7/site-packages/yt/units/yt_array.py:1161: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 2; dimension is 4 but corresponding boolean dimension is 1 ret = super(YTArray, self).__getitem__(item) [ 0. 0. 0. ..., 0. 0. 0.] cm/s # - - - - - - - - - - - - - - - - - - - - - May I use your knowledge and help on knowing what is happening and/or how we could go about solving this? Please let me know if I could provide you with anything further. Thank you, Luz Jimenez Vela Graduate Student at FSU
participants (3)
-
llj16b@my.fsu.edu
-
Luz Jimenez Vela
-
Nathan Goldbaum