from yt.mods import *
from yt.analysis_modules.star_analysis.api import *
from yt.analysis_modules.halo_finding.api import *

pf = load("output_0108")

#loading halos
haloes = LoadHaloes(pf, "DD0108")

i=0
for halo in haloes:
  # Get the pertinent arrays.
  r = halo.maximum_radius()
  c = halo.center_of_mass()
  pc = PlotCollection(pf, center=c)
  region = pf.h.region(c,c-r,c+r)
  if i >= 1: break
  pc.add_projection("Density",0,data_source=region)
  pc.add_projection("Density",1,data_source=region)
  pc.add_projection("Density",2,data_source=region)
  pc.add_projection("Temperature",0,weight_field= 'Density',data_source=region)
  pc.add_projection("Temperature",1,weight_field= 'Density',data_source=region)
  pc.add_projection("Temperature",2,weight_field= 'Density',data_source=region)  
  pc.set_width(2*r,'1')
  pc.save("Halo%04i"%i)
  i=i+1


