Hi Guido, That means there are five cells in that contour -- which may not be enough for your purposes, so do be careful that you consider that to be a resolved clump, as you may want to bump back a level or two. The first axis of the fcoords array is the cell, and the second is the xyz axis. You should be able to call .center_of_mass() on the contour object to see the center of mass of the object. On Thu, Aug 11, 2022 at 5:35 PM Guido Granda Muñoz <guidogranda@gmail.com> wrote:
Hello, I'm trying to obtain the coordinates of the highest density contour level in a region of a simulation. The code I'm using is the following:
import yt from yt.units import *
loc='/fs/san11/enro/guido/cflows_gg/fixed_mesh_l9_supersonic/' basename='cflows_gg_hdf5_plt_cnt_' out_name='reg1_cg_lines_start_points'
n_s=10 n_e=10 d_n=1
nlines=7 # number of lines per plane dimension ## region ## # region 1 # xc=0.0 yc=1.0 zc=4.3 lx=3.0 ly=2.0 lz=2.0
center_r=[xc,yc,zc]*pc left_r =[xc-lx,yc-ly,zc-lz]*pc right_r =[xc+lx,yc+ly,zc+lz]*pc #### connected sets ### levels=3 for i in range(n_s,n_e+1,d_n): print('i: {}'.format(i)) ds=yt.load(loc+basename+str(i).zfill(4)) reg=ds.region(center_r,left_r,right_r) reg_max_rho=reg[('gas','density')].max() reg_min_rho=reg[('gas','density')].min() print("Density : [{0:.4e},{1:.4e}]".format(reg_max_rho,reg_min_rho)) contour_values, connected_sets=reg.extract_connected_sets(('gas','density'),levels,reg_min_rho*100,reg_max_rho,) #print("contour_values: {}".format(contour_values))
So, I wonder if the way to obtain the coordinates that I need is with: connected_sets[levels-1][1].fcoords This is what I obtained: unyt_array([[ 4.82137180e+16, -2.45889962e+18, 7.37669886e+18], [ 4.82137180e+16, -2.45889962e+18, 7.47312629e+18], [ 1.44641154e+17, -2.55532706e+18, 7.18384399e+18], [ 1.44641154e+17, -2.55532706e+18, 7.37669886e+18], [ 1.44641154e+17, -2.45889962e+18, 7.28027142e+18]], 'code_length') This is a (5,3) array, why it has that shape ?? Thanks, _______________________________________________ yt-users mailing list -- yt-users@python.org To unsubscribe send an email to yt-users-leave@python.org https://mail.python.org/mailman3/lists/yt-users.python.org/ Member address: matthewturk@gmail.com