[yt-dev] Splitting a compound unit into its atoms

Michael Zingale michael.zingale at stonybrook.edu
Tue Sep 30 07:44:31 PDT 2014


There is a sympy atoms method.  If x and y are symbols, then:


> a = x*y
> print a.atoms(sympy.Symbol)
set([x, y])

I suspect that this would work with the units defined in yt.  There is
probably a way to get powers too.



On Tue, Sep 30, 2014 at 10:38 AM, John ZuHone <jzuhone at gmail.com> wrote:

> This should be obvious to me, but I can't seem to figure it out.
>
> Is there a way to take a compound units expression like:
>
> dyne*cm**2/g**2
>
> and split it into its constituent parts, so that I have a list like this:
>
> [dyne, cm, g]
>
> and maybe even containing the information about the powers?
> _______________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>



-- 
Michael Zingale
Associate Professor

Dept. of Physics & Astronomy • Stony Brook University • Stony Brook, NY
11794-3800
*phone*:  631-632-8225
*e-mail*: Michael.Zingale at stonybrook.edu
*web*: http://www.astro.sunysb.edu/mzingale
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20140930/1c12dfff/attachment.html>


More information about the yt-dev mailing list