<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hear hear.  I am working on something right now, which is doing a similar thing.  no matter what I set the limits to, it is giving me only a factor of 10 of the data in the color scale.  My example is very similar, just using set_zlim...<div><br><div><br></div><div><br><div><div>On Sep 15, 2009, at 1:34 PM, Fen Zhao wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi all,<br><br>I've recently been having problems setting the colorbar max and min in<br>yt, and would appreciate some help figuring out what the problem might<br>be.  Full python code attached at the end, but the important parts<br>are:<br><br>        pf=lagos.EnzoStaticOutput(thefile)<br><span class="Apple-tab-span" style="white-space:pre">     </span>pc = PlotCollection(pf, center=[c1, c2, c3])<br><br><br><span class="Apple-tab-span" style="white-space:pre">  </span>plot1=pc.add_slice("B", 0)<br><span class="Apple-tab-span" style="white-space:pre">      </span>plot2=pc.add_slice("Density", 0)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3=pc.add_slice("Velocity_Vorticity1", 0)<br><span class="Apple-tab-span" style="white-space:pre">    </span>plot3.set_log_field(False)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3.set_zlim(-200, 500)<br><span class="Apple-tab-span" style="white-space:pre"> </span>thefile2=(output % ind) +"large"<br><span class="Apple-tab-span" style="white-space:pre">        </span>pc.save(thefile2)<br><br><span class="Apple-tab-span" style="white-space:pre">       </span>plot1.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot2.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot3.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot3.set_log_field(False)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3.set_zlim(-200, 500)<br><span class="Apple-tab-span" style="white-space:pre"> </span>thefile2=(output  % ind) + "halo"<br><span class="Apple-tab-span" style="white-space:pre">  </span>pc.save(thefile2)<br><br><br>Neither the "large" or "halo" have the colorbar set correctly.<br><br>Cheers,<br>Fen<br><br><br><br>Context of code:<br><br><br>import sys<br>sys.path = ["/usr/work/mturk/local-testing/lib/python2.5/site-packages/"] + \<br>           sys.path<br><br>from yt.config import ytcfg; ytcfg["lagos","serialize"] = "False"<br>from yt.mods import *<br><br>#import yt.lagos as lagos<br>#import yt.raven as raven<br>#import os.path<br><br>def write_out_binned_vals(plot, fn):<br><span class="Apple-tab-span" style="white-space:pre">      </span>vals = plot.vals<br><span class="Apple-tab-span" style="white-space:pre">  </span>x = plot.x_bins<br><span class="Apple-tab-span" style="white-space:pre">   </span>y = plot.y_bins<br><span class="Apple-tab-span" style="white-space:pre">   </span>print "Opening",fn, vals.shape, x.shape, y.shape<br><span class="Apple-tab-span" style="white-space:pre">        </span>f=open(fn,"w")<br><span class="Apple-tab-span" style="white-space:pre">  </span>for i in range(x.shape[0]):<br><span class="Apple-tab-span" style="white-space:pre">       </span><span class="Apple-tab-span" style="white-space:pre">    </span>for j in range(y.shape[0]):<br><span class="Apple-tab-span" style="white-space:pre">       </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>print i,j<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre">    </span><span class="Apple-tab-span" style="white-space:pre">    </span>f.write("%0.5e\t%0.5e\t%0.5e\n" % (x[i],y[j],vals[i,j]))<br><span class="Apple-tab-span" style="white-space:pre">        </span>f.close()<br><br>#ind=71<br>#inputDir="/a/wain027/g.ki.ki01/fenzhao/data/nobackup/vorticity/correct"<br>inputDir="/lustre/ki/orange/fenzhao/vorticity/try2"<br>outputDir="/a/wain027/g.ki.ki01/fenzhao/data/nobackup/vorticity/analysis/slices/data/images/other"<br>outputName="lustreversion"<br><br>start=40<br>end=40<br><br>ind=start<br><br>while ind<=end:<br><span class="Apple-tab-span" style="white-space:pre">        </span>thefile= inputDir + "/star_%04i.dir/star_%04i" % (ind,ind)<br><span class="Apple-tab-span" style="white-space:pre">      </span>output= outputDir + "/" + outputName+ "%04i"<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>pf=lagos.EnzoStaticOutput(thefile)<br><br><span class="Apple-tab-span" style="white-space:pre">      </span>timeUnits=pf["years"]<br><span class="Apple-tab-span" style="white-space:pre">   </span>DensityUnits=pf["Density"]<br><span class="Apple-tab-span" style="white-space:pre">      </span>LengthUnits=pf["cm"]<br><span class="Apple-tab-span" style="white-space:pre">    </span>VelocityUnits=pf["x-velocity"]<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>newred=pf["CosmologyCurrentRedshift"]<br><span class="Apple-tab-span" style="white-space:pre">   </span>a=1/(1+newred)<br><br><span class="Apple-tab-span" style="white-space:pre">  </span>k=1.3806503e-16<br><span class="Apple-tab-span" style="white-space:pre">   </span>c=2.99792e10<br><span class="Apple-tab-span" style="white-space:pre">      </span>e=4.8032068e-10<br><span class="Apple-tab-span" style="white-space:pre">   </span>me=9.1093897e-28<br><span class="Apple-tab-span" style="white-space:pre">  </span>mh=1.66053886e-24<br><br><span class="Apple-tab-span" style="white-space:pre">       </span>pressure=k*(DensityUnits/mh)<br><span class="Apple-tab-span" style="white-space:pre">      </span>density=DensityUnits/mh<br><span class="Apple-tab-span" style="white-space:pre">   </span>graddensity=density/LengthUnits<br><span class="Apple-tab-span" style="white-space:pre">   </span>gradpressure=pressure/LengthUnits<br><span class="Apple-tab-span" style="white-space:pre"> </span>bbunits=(c/e)*graddensity*gradpressure/(density**2)<br><br><span class="Apple-tab-span" style="white-space:pre">     </span>vorticityUnits=VelocityUnits/LengthUnits<br><span class="Apple-tab-span" style="white-space:pre">  </span>alpha=mh*c/e/(1+1e-4)<br><br><span class="Apple-tab-span" style="white-space:pre">   </span>def Vorticity(field,data):<br><span class="Apple-tab-span" style="white-space:pre">        </span><span class="Apple-tab-span" style="white-space:pre">    </span>return (((data["Velocity_Vorticity1"]**2)+(data["Velocity_Vorticity2"]**2)+(data["<br>Velocity_Vorticity3"]**2))**0.5)*vorticityUnits<br><span class="Apple-tab-span" style="white-space:pre"> </span>lagos.add_field("Vorticity", units=r"\rm{s}^{-1}",function=Vorticity)<br><br><br><span class="Apple-tab-span" style="white-space:pre">     </span>import numpy as na<br><span class="Apple-tab-span" style="white-space:pre">        </span>def B(field, data):<br><span class="Apple-tab-span" style="white-space:pre">       </span><span class="Apple-tab-span" style="white-space:pre">    </span>return na.clip(alpha*(data["Vorticity"]),1e-30,1e30)<br><span class="Apple-tab-span" style="white-space:pre">    </span>lagos.add_field("B", units=r"\rm{Gauss}", function=B)<br><br><br><span class="Apple-tab-span" style="white-space:pre">     </span>haloradius=0.013<br><br><span class="Apple-tab-span" style="white-space:pre">        </span>halo = pf.h.sphere([0.5, 0.5, 0.5], haloradius*2.0)<br><span class="Apple-tab-span" style="white-space:pre">       </span>v, i, c1, c2, c3, gi = halo.quantities["MaxLocation"]("Density",<br>lazy_reader=True)<br><br><br><span class="Apple-tab-span" style="white-space:pre">       </span><br><span class="Apple-tab-span" style="white-space:pre">  </span>pc = PlotCollection(pf, center=[c1, c2, c3])<br><br><br><span class="Apple-tab-span" style="white-space:pre">  </span>plot1=pc.add_slice("B", 0)<br><span class="Apple-tab-span" style="white-space:pre">      </span>plot2=pc.add_slice("Density", 0)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3=pc.add_slice("Velocity_Vorticity1", 0)<br><span class="Apple-tab-span" style="white-space:pre">    </span>plot3.set_log_field(False)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3.set_zlim(-200, 500)<br><span class="Apple-tab-span" style="white-space:pre"> </span>thefile2=(output % ind) +"large"<br><span class="Apple-tab-span" style="white-space:pre">        </span>pc.save(thefile2)<br><br><span class="Apple-tab-span" style="white-space:pre">       </span>plot1.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot2.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot3.set_width(haloradius*2,1)<br><span class="Apple-tab-span" style="white-space:pre">   </span>plot3.set_log_field(False)<br><span class="Apple-tab-span" style="white-space:pre">        </span>plot3.set_zlim(-200, 500)<br><span class="Apple-tab-span" style="white-space:pre"> </span>thefile2=(output  % ind) + "halo"<br><span class="Apple-tab-span" style="white-space:pre">  </span>pc.save(thefile2)<br><br><span class="Apple-tab-span" style="white-space:pre">       </span>ind=ind+1<br><br><br><br>#plot=pc.add_slice("B", 0)<br>_______________________________________________<br>yt-users mailing list<br><a href="mailto:yt-users@lists.spacepope.org">yt-users@lists.spacepope.org</a><br>http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br></div></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Dr. Eric J. Hallman</div><div>NSF Astronomy and Astrophysics Postdoctoral Fellow                    </div><div>Center for Astrophysics and Space Astronomy </div><div>University of Colorado at Boulder  </div><div>hallman (at) casa.colorado.edu </div><div>office(s): (303) 735-0129 / (303) 492-7484     </div><div><a href="http://solo.colorado.edu/~hallman/">http://solo.colorado.edu/~hallman/</a></div></div></div></span> </div><br></div></div></body></html>