On Fri, May 25, 2018 at 12:25 PM, Nick Gnedin wrote:

Guys,

Sorry for multiple question, here is another simple one.

I have a dataset d for which I create a sphere:

s = d.sphere([x0,y0,z0],r0)
vcen = s.quantities.bulk_velocity()
s.set_field_parameter("bulk_velocity",vcen)

It is located somewhere in the box:

print(x0,y0,z0)
> 0.04789762673404803 Mpc 4.396788395087413 Mpc 0.9398923037682868 Mpc

Now I would like to find the location of the max density for some field. When I try this:

print(s.quantities.max_location(('deposit', 'STAR_density')))
print(s.quantities.max_location(('gas', 'density')))
print(s.quantities.max_location(('deposit', 'N-BODY_density')))

I get non-nonsensical values:

[1.1195988056992701e-21 g/cm**3, 1.3408203125 cm, 117.7998046875 cm, 25.3603515625 cm]
[1.3058663046178781e-20 g/cm**3, 1.3408203125 cm, 117.8017578125 cm, 25.3603515625 cm]
[1.73680472946578e-20 g/cm**3, 1.3896484375 cm, 117.7919921875 cm, 25.3271484375 cm]

Density values are ok, but positions surely cannot be measured in a small number of cm. Given that in code units the box size is 128, it seems like locations are returned in code units but interpreted as cm.

Hmm, I agree that's probably what's happening. That said, I can't seem to reproduce the issue on yt 3.4.1, with the following script:

import yt

c = [0.04789762673404803*Mpc, 4.396788395087413*Mpc, 0.9398923037682868*Mpc]
s = ds.sphere(c, 50*Mpc)
print(s.quantities.max_location(('gas', 'density')))

I get:

[3.4612530065401464e-22 g/cm**3, 63.9970703125 code_length, 63.9990234375 code_length, 63.9970703125 code_length]

If you're not already using yt 3.4.1, can you try updating? You can see your current yt version with:

\$ python -c "import yt; print(yt.__version__)"

If you're on yt 3.4.1 and are still seeing the issue, I guess it has something to do with the dataset you're using or the precise details of the code you're running. Is this the same dataset you sent me in the other thread?

-Nathan

n
_______________________________________________
yt-users mailing list -- yt-users@python.org
To unsubscribe send an email to yt-users-leave@python.org