
Okay, so I just commited trunk r1449 that does two things. First, the colorbars should now update correctly (see Dave's comment above about having to save twice). Second, support for tickmarks in linear space has been improved a bit. Now when you want a given number nticks, it will find them in linear space if the field is a non-log field. Anyways, running the following script in yt/tests/DD0010 seems to make figures that have values that go from negative to positive, and show up correctly. I had to make a fairly strange field so that I could get negative and positive values, but that's besides the point. That said, plot1=pc.add_projection(...) and then editing plot1 will not work, as Dave pointed out above. My suggestion is that if you need to specify different limits, save each one and then do a pc.clear_plots() and continue to the next field. Let me know if this doesn't help. from yt.mods import * import numpy as na def _LinearDensity(field,data): return (na.log10(data['Density']) + 24)**5 yt.lagos.add_field("LinearDensity", function=_LinearDensity,take_log=False) pf = load('moving7_0010') pc = PlotCollection(pf,center=[0.5]*3) pc.add_projection('LinearDensity',0, weight_field='Density') pc.save('original') print pc.plots[0].data.data['LinearDensity'].min() On Tue, Sep 15, 2009 at 4:06 PM, David Collins <dcollins@physics.ucsd.edu> wrote:
Do you have a field with negative and positive values? I can get this to work with only positive valued fields, but not negative.
I believe that I've gotten this to work with non-positive fields and/or take_log=False, but I don't have any ready examples on hand, and my memory is fond of telling me untrue things (I think it gets bored) Let me poke around and see if I can either break it or if I had done something different.
d.
Also, I have found that when adding a field that has negative or zero values, it is helpful to define it as a take_log=False:
def _LinearDensity(field,data): return data['Density'] yt.lagos.add_field("LinearDensity", function=_LinearDensity,take_log=False)
Otherwise you can end up taking logs of 0 or negative numbers and it can cause problems. Dave, do you use the take_log=False in your case?
Sam
On Tue, Sep 15, 2009 at 2:34 PM, David Collins <dcollins@physics.ucsd.edu> wrote:
I've fought with this myself. Here's what I've come up with that works.
1.) This doesn't work pc=raven.PlotColleciton( ... ) plot=pc.add_projection( ... ) plot.set_zlim( a, b) # Doesn't work pc.save(filename)
2.) Calling set_zlim on the plot collection does work pc=raven.PlotColleciton( ... ) plot=pc.add_projection( ... ) pc.set_zlim(a,b) #does work. pc.save(filename)
3.) If you change the colormap *and* zlim, the colorbar won't reflect the new colormap (try it with "gray", it's most noticable) You can get around this by doing an extra "save" before set_zlim
4.) My general script looks something like this:
pf=lagos.EnzoStaticOutput(path) for field in field_list: pc=raven.PlotCollection(pf) plot = pc.add_projection(field,axis,weight) pc.set_cmap('ZebraStripes') #or maybe a more useful cmap pc.save(Filename) pc.set_zlim(0,1) pc.save(Filename)
On Tue, Sep 15, 2009 at 12:46 PM, Eric Hallman <Eric.Hallman@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@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@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@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 _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@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