[yt-users] coordinate question

Elizabeth Tasker taskere at mcmaster.ca
Mon Aug 22 16:09:14 PDT 2011


Hi,

I feel I have a co-ordinate problem.

I have a yt script that uses extract_connected_sets to find a bunch of 
contoured objects, for which I calculate the centre of mass (core_com 
below).

I then cut out a covering_grid centred on each object that is 2 kpc in 
width.

I image the slice of the covering_grid through its and over-plot the 
positions of the centre of mass of the contoured objects on it.

The problem is, they don't line up!

cloud50.png shows the process centred on object 50. Object 50 itself is 
nicely over a blob but the others are randomly scattered. Although this 
is only a slice, the z-direction of the objects differs only slightly: 
it shouldn't be possible to have an object sitting over nothing 
(especially when the slice effectively shows potential, which varies 
smoothly).

cloud51.png shows the same process now centred on object 51. 51 is now 
over a clear blob, but you can see that the image has moved differently 
to the numbers. (The image has shifted down and the numbers way up).

It looks to me that this should be flipped somehow (although 
experimental inverting the x-y axes have failed!), but I cannot see 
where the mistake is.

The (abbreviated) code looks like:

contours = dd.extract_connected_sets("NegEscapeVelocity", 1, 30.0, maxv, 
log_space=False)
allcloudcores = contours[1][0] #cores defined by contour 0
thiscore = allcloudcores[c]

core_com = []
for c in range(ncores):
    core_com.append(thiscore.quantities["CenterOfMass"]())


extractLE = []
extractRE = []
extractDims = []

min_x, max_x = thiscore.quantities["Extrema"]("x")[0]
min_y, max_y = thiscore.quantities["Extrema"]("y")[0]
min_z, max_z = thiscore.quantities["Extrema"]("z")[0]

extractLE.append(max(min_x-1.0, 0.0))
extractLE.append(max(min_y-1.0, 0.0))
extractLE.append(max(min_z-1.0, 0.0))

extractRE.append(min(max_x+1.0, thiscore.pf.domain_right_edge[0]))
extractRE.append(min(max_y+1.0, thiscore.pf.domain_right_edge[1]))
extractRE.append(min(max_z+1.0, thiscore.pf.domain_right_edge[2]))

for dim in range(3):
            
extractDims.append(round((extractRE[dim]-extractLE[dim])/cellsize))

extractCube = pf.h.covering_grid(extract_level,
                                         left_edge=extractLE,
                                         right_edge=extractRE,
                                         dims=extractDims,
                                         num_ghost_zones = 3)

plotfig = pylab.figure()
pylab.imshow(extractCube["NegEscapeVelocity"][:,:,int(extractDims[2]/2)], 
extent=[extractLE[0], extractRE[0], extractLE[1], extractRE[1]])
colorbar = pylab.colorbar()
colorbar.set_label("Negative escape velocity [km/s]")
pylab.xlabel('x [kpc]')
pylab.ylabel('y [kpc]')

for m in range(ncores):
      pylab.annotate('%s' % (m), xy=(core_com[m][0], core_com[m][1]), 
xycoords='data')

pylab.savefig('clouds_novel%s' % (c))




Is this a problem of where the "zero" point is in yt / enzo / python? I 
was assuming (0,0,0) is the bottom left?

Elizabeth
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloud50.png
Type: image/png
Size: 172601 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20110822/9aa6c0d2/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloud51.png
Type: image/png
Size: 177627 bytes
Desc: not available
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20110822/9aa6c0d2/attachment-0001.png>


More information about the yt-users mailing list