[yt-users] running out of memory in a loop

Matthew Turk matthewturk at gmail.com
Wed Oct 23 12:36:01 PDT 2013


Hi Stephanie,

Can you try adding this at the top of your script:

import gc

and just after i + i + 1 putting:

gc.collect()

If this fixes the problem, then there may just be extra references sitting
around.  If not, then I suspect there may be an issue with the Athena
frontend hanging onto data.

-Matt


On Wed, Oct 23, 2013 at 3:20 PM, Stephanie Tonnesen <stonnes at gmail.com>wrote:

> Hi everyone,
>
> Okay, so I am trying to make a SlicePlot, a ProjectionPlot, and a
> phase_object for a bunch of different outputs.  My code keeps using up all
> my memory and dying after the first loop.  I am not using variables, I
> think, so how do I free up my memory at the end of each loop?
>
> See code below.
>
> Thanks,
>
> Stephanie
>
>
> import matplotlib.pylab as pl
> from mpl_toolkits.mplot3d import Axes3D
> from yt.mods import *
>
> def _xkpc(field,data):
>     return(data["x"]*26.)
>
> def _ykpc(field,data):
>     return(data["y"]*26.)
>
> def _zkpc(field,data):
>     return(data["z"]*26.)
>
> def _CellMassSolar(field,data):
>     return(data["CellMass"]/1.99e33)
>
> add_field("xkpc",function=_xkpc,units="kpc")
> add_field("ykpc",function=_ykpc,units="kpc")
> add_field("zkpc",function=_zkpc,units="kpc")
> add_field("CellMassSolar",function=_CellMassSolar,units=r'M$_{\odot}$')
>
> outstring =
> ['0020','0030','0040','0050','0060','0070','0080','0090','0100','0110','0120','0130']
> i = 0
> while i < len(outstring):
>     pf =
> load("id0/rps."+outstring[i]+".vtk",parameters={"TimeUnits":3.086e14,"LengthUnits":8.0236e22,"DensityUnits":9.999e-30,"VelocityUnits":2.6e8})
>
>
>     p = SlicePlot(pf,"x","Density")
>     p.set_log("Density", True)
>     p.save()
>
>
>     p2 = ProjectionPlot(pf,"x","Density")
>     p2.set_log("Density", True)
>     p2.save()
>
>
>     alld = pf.h.all_data()
>
>     pc = PlotCollection(pf)
>     tracerp25 = alld.cut_region(["grid['specific_scalar[0]'] > 0.25",
> "grid['z'] > 0.04"])
>     tp25extrema = tracerp25.quantities["Extrema"]("Density")
>
> pc.add_phase_object(tracerp25,["zkpc","z-velocity","CellMassSolar"],weight=None,x_bins=50,y_bins=50,y_bounds
> = [-1e8,1.5e8],x_log=False,y_log=False)
>     pc.set_zlim(10000,1e10)
>     pc.save()
>
>     i = i+1
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20131023/ac3c41f3/attachment.html>


More information about the yt-users mailing list