Hi Mike,<div><br></div><div>Units are no longer LaTeX strings in yt 3.0. Now unit strings are parsed to generate a symbolic unit object for each field. Try instead "units=g/cm**2".  Note that powers need to be in python syntax (** instead of ^) since sympy is parsing the unit string and converting it into a symbolic unit object.</div>
<div><br></div><div>Take a look at the following doc page:</div><div><br></div><div><a href="http://yt-project.org/docs/dev-3.0/analyzing/units/data_selection_and_fields.html">http://yt-project.org/docs/dev-3.0/analyzing/units/data_selection_and_fields.html</a><br>
</div><div><br></div>That said, I'm not sure this will actually work for your code snippet for two reasons.  First, unless you are using an Enzo dataset, it's likely that the Density field is not defined.  We've renamed the "standard" field names to be more rational.  Try "density" instead. See:<div>
<br></div><div><a href="http://ytep.readthedocs.org/en/latest/YTEPs/YTEP-0003.html">http://ytep.readthedocs.org/en/latest/YTEPs/YTEP-0003.html</a><br></div><div><br></div><div>Even if you are using Enzo, it will still likely give the wrong answer since the Density field is in internal code units by default (code_mass/code_length**3). Assigning units of g/cm**2 to an alias of Density won't work since the unit dimensionalities won't match.<br>
<div><br></div><div>If you are just using this field to make a ProjectionPlot use Sigma as the display name for the projected field instead of Density, you might need to say that it's units are g/cm**3 and let the ProjectionPlot do the unit conversion for you if you are doing an unweighted projection.<br>
</div><div><br></div><div>This might seem more complicated, but this will also prevent you from creating plots with buggy units - which would have happened if you tried to create a slice of your Sigma field under the old unit system.</div>
<div><br></div><div>Best,</div><div><br></div><div>Nathan<span></span></div><div><div><div><br>On Friday, June 6, 2014, Mike Butler <<a href="mailto:mbutler.astro@gmail.com">mbutler.astro@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>Hello, I am using the latest version of yt-3.0 and am having some problems defining a new field.  Here is an example of a field that produces an error:<br>def _Sigm(field,data): return data["Density"]<br>

add_field("Sigma",function=_Sigm,units=r"\rm{g}/\rm{cm}^{2}",display_name=r"\Sigma")<br><br></div>and this is the error I get when I try to do a projection of it:<br><br>  File "<string>", line 1<br>

    \Symbol ('rm' ,positive =True ){Symbol ('g' ,positive =True )}/\Symbol ('rm' ,positive =True ){Symbol ('cm' ,positive =True )}^{Integer (2 )}<br>                                                                                                                                                ^<br>

SyntaxError: unexpected character after line continuation character<br><br></div>It works fine on the stable and dev versions of yt.  Has something changed for defining fields in 3.0?<br><br>Thanks,<br><br>Mike<br></div>

</blockquote></div></div></div></div>