[yt-users] Problem with zlim setting in yt slices

Sam Skillman samskillman at gmail.com
Tue Sep 15 12:56:03 PDT 2009


Hi Fen and Eric,

Looks like there is definitely something wrong with setting zlim for
linear-space plots (especially with negative values).  I think it has
to do with the way the tick marks are defined in PlotTypes.py, but I'm
not quite sure yet.  I've done some stuff with set_zlim so I'll take a
deeper look but this is definitely a bug.

Best,
Sam

On Tue, Sep 15, 2009 at 1:46 PM, Eric Hallman <Eric.Hallman at colorado.edu> wrote:
> 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...
>
>
> On Sep 15, 2009, at 1:34 PM, Fen Zhao wrote:
>
> Hi all,
>
> I've recently been having problems setting the colorbar max and min in
> yt, and would appreciate some help figuring out what the problem might
> be.  Full python code attached at the end, but the important parts
> are:
>
>        pf=lagos.EnzoStaticOutput(thefile)
> pc = PlotCollection(pf, center=[c1, c2, c3])
>
>
> plot1=pc.add_slice("B", 0)
> plot2=pc.add_slice("Density", 0)
> plot3=pc.add_slice("Velocity_Vorticity1", 0)
> plot3.set_log_field(False)
> plot3.set_zlim(-200, 500)
> thefile2=(output % ind) +"large"
> pc.save(thefile2)
>
> plot1.set_width(haloradius*2,1)
> plot2.set_width(haloradius*2,1)
> plot3.set_width(haloradius*2,1)
> plot3.set_log_field(False)
> plot3.set_zlim(-200, 500)
> thefile2=(output  % ind) + "halo"
> pc.save(thefile2)
>
>
> Neither the "large" or "halo" have the colorbar set correctly.
>
> Cheers,
> Fen
>
>
>
> Context of code:
>
>
> import sys
> sys.path = ["/usr/work/mturk/local-testing/lib/python2.5/site-packages/"] +
> \
>           sys.path
>
> from yt.config import ytcfg; ytcfg["lagos","serialize"] = "False"
> from yt.mods import *
>
> #import yt.lagos as lagos
> #import yt.raven as raven
> #import os.path
>
> def write_out_binned_vals(plot, fn):
> vals = plot.vals
> x = plot.x_bins
> y = plot.y_bins
> print "Opening",fn, vals.shape, x.shape, y.shape
> f=open(fn,"w")
> for i in range(x.shape[0]):
> for j in range(y.shape[0]):
> print i,j
> f.write("%0.5e\t%0.5e\t%0.5e\n" % (x[i],y[j],vals[i,j]))
> f.close()
>
> #ind=71
> #inputDir="/a/wain027/g.ki.ki01/fenzhao/data/nobackup/vorticity/correct"
> inputDir="/lustre/ki/orange/fenzhao/vorticity/try2"
> outputDir="/a/wain027/g.ki.ki01/fenzhao/data/nobackup/vorticity/analysis/slices/data/images/other"
> outputName="lustreversion"
>
> start=40
> end=40
>
> ind=start
>
> while ind<=end:
> thefile= inputDir + "/star_%04i.dir/star_%04i" % (ind,ind)
> output= outputDir + "/" + outputName+ "%04i"
>
> pf=lagos.EnzoStaticOutput(thefile)
>
> timeUnits=pf["years"]
> DensityUnits=pf["Density"]
> LengthUnits=pf["cm"]
> VelocityUnits=pf["x-velocity"]
>
> newred=pf["CosmologyCurrentRedshift"]
> a=1/(1+newred)
>
> k=1.3806503e-16
> c=2.99792e10
> e=4.8032068e-10
> me=9.1093897e-28
> mh=1.66053886e-24
>
> pressure=k*(DensityUnits/mh)
> density=DensityUnits/mh
> graddensity=density/LengthUnits
> gradpressure=pressure/LengthUnits
> bbunits=(c/e)*graddensity*gradpressure/(density**2)
>
> vorticityUnits=VelocityUnits/LengthUnits
> alpha=mh*c/e/(1+1e-4)
>
> def Vorticity(field,data):
> return
> (((data["Velocity_Vorticity1"]**2)+(data["Velocity_Vorticity2"]**2)+(data["
> Velocity_Vorticity3"]**2))**0.5)*vorticityUnits
> lagos.add_field("Vorticity", units=r"\rm{s}^{-1}",function=Vorticity)
>
>
> import numpy as na
> def B(field, data):
> return na.clip(alpha*(data["Vorticity"]),1e-30,1e30)
> lagos.add_field("B", units=r"\rm{Gauss}", function=B)
>
>
> haloradius=0.013
>
> halo = pf.h.sphere([0.5, 0.5, 0.5], haloradius*2.0)
> v, i, c1, c2, c3, gi = halo.quantities["MaxLocation"]("Density",
> lazy_reader=True)
>
>
>
> pc = PlotCollection(pf, center=[c1, c2, c3])
>
>
> plot1=pc.add_slice("B", 0)
> plot2=pc.add_slice("Density", 0)
> plot3=pc.add_slice("Velocity_Vorticity1", 0)
> plot3.set_log_field(False)
> plot3.set_zlim(-200, 500)
> thefile2=(output % ind) +"large"
> pc.save(thefile2)
>
> plot1.set_width(haloradius*2,1)
> plot2.set_width(haloradius*2,1)
> plot3.set_width(haloradius*2,1)
> plot3.set_log_field(False)
> plot3.set_zlim(-200, 500)
> thefile2=(output  % ind) + "halo"
> pc.save(thefile2)
>
> ind=ind+1
>
>
>
> #plot=pc.add_slice("B", 0)
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
> Dr. Eric J. Hallman
> NSF Astronomy and Astrophysics Postdoctoral Fellow
> Center for Astrophysics and Space Astronomy
> University of Colorado at Boulder
> hallman (at) casa.colorado.edu
> office(s): (303) 735-0129 / (303) 492-7484
> http://solo.colorado.edu/~hallman/
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>



-- 
Samuel W. Skillman
DOE Computational Science Graduate Fellow
Center for Astrophysics and Space Astronomy
University of Colorado at Boulder
samuel.skillman[at]colorado.edu



More information about the yt-users mailing list