[yt-users] changing units for data in a projection container

Ricarda Beckmann ricarda.beckmann at astro.ox.ac.uk
Wed Jun 10 16:08:33 PDT 2015


Hi Phil,

I think you were almost there. Instead of changing the units of the plot, change them once you have the frb:

ds=yt.load(…)
prj=ds.proj(‘density’,2)
frb=prj.to_frb((10,’pc’),(1024,1024))

#now, instead of changing directly to a numpy array, first extract the field and change the units

dens=frb[‘density’]         #For me, this comes out in g/cm**2 already
dens=dens.in_units(‘kg/m**2’)     #here you can change the units to anything you want. Or just skip it if you are happy with g/cm**2

surfdens=np.array(dens)         	#and here is the plotable array, in the right units.


I hope this helped,
Ricarda

> On 10 Jun 2015, at 18:58, mc knabbits <elknabbits at googlemail.com> wrote:
> 
> hi, 
> I have the simple problem that I cant figure out how to change the units for data within a YTQuadTreeProjBase. so I'm stuck with code units all along. heres my script part:
> 
> 
>     ds = yt.load(some ramses data)                       
>                 
>     prj = ds.proj("Density", 2)
>     prj.apply_units(arr,'g/cm**2')   #maybe it's all because I dont know what to put in for "arr"
>                
>     frb=prj.to_frb((10,'pc'),(1024,1024))
>     surfdense=np.array(frb[density])
> 
> 
>     
>  as you can see the unit I need is g/cm**2 but the method applied above dont work!?
> 
> thanx for your help
> 
> phil
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20150611/79ee7e84/attachment.html>


More information about the yt-users mailing list