Hi Nick,

I think I've found a fix for this issue, see:

https://github.com/yt-project/yt/pull/1799

I'm not 100% sure that fix won't unintentionally break something else, we'll see if there are any test failures.

Thanks for the report!

-Nathan

On Fri, May 25, 2018 at 1:00 PM, Nick Gnedin <gnedin@fnal.gov> wrote:

I am using 3.4.1.

I get the same problem with wrong units with the data set I uploaded:

d = yt.load("rei10_a0.1001/rei10_a0.1001.art")
s = d.sphere([0,0,0],(10,'kpc'))
loc = s.quantities.max_location(('gas', 'density'))
print(loc)

> [7.042448094432284e-28 g/cm**3, 0.3125 cm, 0.0625 cm, 63.8125 cm]



On 05/25/2018 12:49 PM, Nathan Goldbaum wrote:


On Fri, May 25, 2018 at 12:25 PM, Nick Gnedin <gnedin@fnal.gov <mailto:gnedin@fnal.gov>> 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
     ds = yt.load('sizmbhloz-clref04SNth-rs9_a0.9011/sizmbhloz-clref04SNth-rs9_a0.9011.art')

     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
    <mailto:yt-users@python.org>
    To unsubscribe send an email to yt-users-leave@python.org
    <mailto:yt-users-leave@python.org>