[yt-users] accessing single elements of data when defining a new field

Matthew Turk matthewturk at gmail.com
Tue Jul 11 05:16:20 PDT 2017


Hi Salvatore,

This is odd -- I believe that it should work as you have written it.
Can you describe how it fails?  And, what happens if instead of doing

for ii in range(0, len(t)):

you did something like:

for val in t:

and then operated on val?

On Tue, Jul 11, 2017 at 4:59 AM, sacielo <sacielo at gmail.com> wrote:
> Hello
>
> I am trying to define a new field for a grid simulation (using ramses, if it
> matters), basically an estimate of radiative cooling in a simulation that
> does not include that.
>
> I find myself to perform a 2D interpolation in a table (cooling rate given
> temperature and metal content), then I wish to save this as a new field. I
> am using a scipy 2D interpolator in order to do so. The problem is that for
> the interpolation I need to access the single elements in the temperature
> and metal fields, within the function I use to define a new dataset
> (unfortunately, I am forced to loop on the fields).
>
> Now, I can't understand how to do that from the "data" and "field" arguments
> of the functions.
>
> Something like
> t = data['temperature']
> for ii in range(0, len(t)):
>     print t[ii]
>
> fails (t[ii] is a complex array itself)
>
> t.base() and t.item() or t[ii].item()
>
> fail as well....
>
>
> Any idea?
>
> Thank you!
>
>
> --
> Salvatore
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>


More information about the yt-users mailing list