[yt-users] Clearing a derived field from all grids

Elizabeth Tasker tasker at astro1.sci.hokudai.ac.jp
Mon Dec 12 17:58:58 PST 2011


Hi Matt,

Unfortunately, that doesn't work.

I can do:

del ng[n][fieldname]

But then I'd have to recreate the field afresh for each grid (very
slow), as opposed to just when I rerun the whole loop again:

for c in (nclouds):
  grids, cis = kd.locate_neighbors_from_position(position)
  for  n in range(26):
    phi = grids[n]["EffectivePotential"][cis[n]]
     del grids[n]["EffectivePotential"]

I really want to delete every c-loop, not every n loop.

Possibly the best way is to loop over the n loop again and delete the
grids afterwards:

for n in range(26):
del grids[n]["EffectivePotential"]

Which is fine, I was just checking if there was a neater way!

Elizabeth


On 12 December 2011 20:18, Matthew Turk <matthewturk at gmail.com> wrote:
> Hi Elizabeth,
>
> You can do:
>
> del ng[fieldname]
>
> -Matt
>
> On Dec 12, 2011 5:45 AM, "Elizabeth Tasker"
> <tasker at astro1.sci.hokudai.ac.jp> wrote:
>>
>> Hi,
>>
>> Is there a way of deleting a single derived field from all grids?
>>
>> I seem to be having a problem with my derived field not being
>> re-calculated for every element in a loop (it needs to be). Therefore,
>> if I run the complete loop, I get an incorrect result for some of the
>> elements which are totally fine if I tell the code to just calculate
>> that element in a single sweep.
>>
>> I've tried deleting the individual elements that use that variable,
>> but it doesn't seem to be enough, e.g.
>>
>> ng, nc = kd.locate_neighbors_from_position(nposn)
>> .
>> .
>> .
>> del ng
>>
>>
>> Elizabeth
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
> _______________________________________________
> 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