[yt-users] PlotCollection questions

John Wise jwise at physics.gatech.edu
Wed May 22 08:32:29 PDT 2013


Hi Francia,

To plot the volume in units of kpc^3, you'll need to define a new derived field either in your ~/.yt/my_plugins.py file or just place this function at the top of your script.

Something like this would work,

def _ConvertCellVolumeKpc(data):
   return data.convert("kpc")**3.0
add_field("CellVolumeKpc", units=r"\rm{kpc}^3",
         function=_CellVolume,
         convert_function=_ConvertCellVolumeKpc)

For your "empty" plot, do you have any gas with densities between 1e-26 and 1e-27 g/cm^3 in this sphere?  If there's no gas in this range, then CellVolume will be zero and will give you that error message when it tries to take the log of CellVolume.  If you want to manually inspect the CellVolume field, you can print out the following variable

pc.plots[-1].data['CellVolume']

which will give you the CellVolume as a function of the x-variable for the last plot you have added to your PlotCollection.

I hope this helps, and let us know if this solves your problems.

Cheers,
John

On 22 May 2013, at 16:11, Francia Riesco wrote:

>       Hello Everybody, 
>     first I want to thank for every time I got an answer when I write here, I really appreciate it. 
> Now I am writing because I am using PlotCollection (As you can see my code) and I have some  questions
> 
> 1) the plot is coming in cm^3 and I want to change it to kpc^3 is there a way to change it?
> 2) I am attaching the plot can I change to dot or any different symbol and color?
> 3) why some plot come "empty"? and also I get this error message
>   Data has no positive values, and therefore can not be log-scaled.
> 
> -----
> sphere = pf.h.sphere(c, (250., 'kpc')) # 250.
> levels = 8 #8
> mi, ma = sphere.quantities["Extrema"]("Density")[0]
> contour_values, connected_sets = sphere.extract_connected_sets("Density", levels, mi, ma)
> for i in connected_sets:
>    eb       =  connected_sets[i] 
>    print "level  " + str(i) + " clmsp# " + str(len(eb))
>    for j in eb:
>        obj = eb[j] 
>        com = obj.quantities["CenterOfMass"]()
>        print com
>        pc = PlotCollection(pf, com)
>        pc.add_profile_object(obj, ["Density", "Temperature"],weight="CellMassMsun") # average T(rho)
>        pc.add_profile_object(obj, ["Density", "CellVolume"], weight=None) #
>        pc.add_profile_object(obj, ["Density", "CellMassMsun"], weight=None) #
>        try:
>          pc.save("sliceplot_300_"+str(i)+"_" +str(j))
>        except Exception, e:
>           print e
>           continue
> 
> -----
> 
> Thank you in advance!!
> <sliceplot_305_1_Profile1D_1_Density_CellVolume.png><sliceplot_305_23_Profile1D_1_Density_CellVolume.png>_______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

--
John Wise
Assistant Professor of Physics
Center for Relativistic Astrophysics, Georgia Tech
http://cosmo.gatech.edu




More information about the yt-users mailing list