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