This looks like it would be a welcome addition to the code if someone wants to put it together, but I agree, that at the minimum, we should remove the bad index value returned to the user.  Good idea!

On Mon, Nov 23, 2015 at 1:08 PM, Matthew Turk wrote:
I have an alternate solution to this problem, which dovetails with the
numpy-like operations.

If we were to make a different DerivedQuantity (which MaxLocation and
MinLocation could subclass with a prescription that they return x,y,z)
that accepted the names of the fields to obtain at the maximum value
of a field, this could probably accomplish what you are looking for.
This would be equivalent to the .argmax() operation, so you would be
able to do:

dd = ds.all_data()
dd.argmax("density", ["temperature", "velocity_magnitude"])

and get back the temperature and velocity_magnitude fields at the
maximum density.

Would that suffice?

On Sun, Nov 22, 2015 at 4:11 PM, Matthew Turk <matthewturk@gmail.com> wrote:
> I'm not sure that, as it stands, it is possible to get the "index",
> unless we made the parallel iteration sequential.  Perhaps a better
> solution would be to not return the index value.
>
> On Sun, Nov 22, 2015 at 4:06 PM, Cameron Hummels
>> New issue 1147: Derived quantities `max_location` and `min_location` not returning correct index values
>> https://bitbucket.org/yt_analysis/yt/issues/1147/derived-quantities-max_location-and
>>
>> Cameron Hummels:
>>
>> Something is going awry in the `max_location` and `min_location` derived quantities such that they return an incorrect index for where the extrema occur.  Here's an example script.  I tried correcting the code, but I got caught up in the chunk processing for derived quantities.
>>
>>
>> ```
>> #!python
>>
>> import yt
>> import numpy as np
>>
>> val, index, x, y, z = ad.quantities.max_location('density')
>> print val == ad['density'][int(index)]  # false
>>
>> print val2 == ad['density'][index2] # true
>>
>> print val == val2 # true
>> print index == index2 # false
>>
>> # Thus, something is going awry in the max_location (and the min_location)
>> # derived quantities where it calculates the index values for the extrema
>> ```
>>
>>
>>
>>
>> _______________________________________________
>> yt-dev mailing list
>> yt-dev@lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
_______________________________________________
yt-dev mailing list
yt-dev@lists.spacepope.org
http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org

--
Cameron Hummels
NSF Postdoctoral Fellow
Department of Astronomy
California Institute of Technology