3/22/17


In [1]:
cd ~/projects/zapdos/problems


/home/lindsayad/projects/zapdos/problems

In [2]:
import yt
ds = yt.load("shape_side_uo_physics_test_out.e", step=-1)
ad = ds.all_data()

In [3]:
sigma_mat = ad[('all','sigma')]

In [4]:
sigma_aux = ad[('all', 'sigma_aux')]

In [5]:
print(sigma_mat.min())
print(sigma_mat.max())
print(sigma_aux.min())
print(sigma_aux.max())


-0.45977878967135954 dimensionless
1.09966589224996 dimensionless
-0.45977878967135966 dimensionless
1.09966589224996 dimensionless

4/3/17


In [1]:
cd ~/projects/zapdos/tests/TM10_circular_wg/gold/


/home/lindsayad/projects/zapdos/tests/TM10_circular_wg/gold

In [7]:
from matplotlib import rc
rc('font',**{'family':'serif'})
rc('text', usetex=True)

In [2]:
import yt
ds = yt.load("TM_steady_out.e", step=-1)
ad = ds.all_data()

In [8]:
ds.field_list


Out[8]:
[('all', 'Electric_z'),
 ('all', 'Er'),
 ('all', 'Hphi'),
 ('all', 'Hphi_mag'),
 ('connect1', 'Electric_z'),
 ('connect1', 'Er'),
 ('connect1', 'Hphi'),
 ('connect1', 'Hphi_mag')]

In [9]:
field_list = [('all', 'Er'), ('all', 'Electric_z'), ('all', 'Hphi')]
field_label = {'Er' : 'Er (V/m)', 'Electric_z' : 'Ez (V/m)', 'Hphi' : 'Hphi (A/m)'}

In [10]:
for field in field_list:
    field_type, field_name = field
    slc = yt.SlicePlot(ds, 'z', field)
    slc.set_log(field, False)
    slc.set_xlabel("r (mm)")
    slc.set_ylabel("z (mm)")
    slc.set_colorbar_label(field, field_label[field_name])
    slc.set_figure_size(1.2)
    slc.set_width((.015, .09))
    slc.save("/home/lindsayad/Pictures/" + field_name + ".png")

In [3]:
def f(x,y):
    return x**3 + 2 * y**3

print(f(0,6))
print(f(2, 6))
print(f(4, 6))


432
440
496

In [4]:
6*6**2


Out[4]:
216

In [5]:
6*4**2


Out[5]:
96

In [2]:
import yt
ds = yt.load("/home/lindsayad/projects/zapdos/tests/TM10_circular_wg/gold/TM_steady_out.e", step=-1)
ad = ds.all_data()

from matplotlib import rcParams
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 17
rcParams['font.serif'] = ['Computer Modern Roman']
# rcParams['text.usetex'] = True

field_list = [('all', 'Er'), ('all', 'Electric_z'), ('all', 'Hphi')]
field_label = {'Er' : r'E$_r$ (V/m)', 'Electric_z' : 'E$_z$ (V/m)', 'Hphi' : 'H$_\phi$ (A/m)'}

for field in field_list:
# field = field_list[0]
    field_type, field_name = field
    slc = yt.SlicePlot(ds, 'z', field)
    slc.set_log(field, False)
    slc.set_xlabel("r (mm)")
    slc.set_ylabel("z (mm)")
    slc.set_colorbar_label(field, field_label[field_name])
    slc.set_figure_size(1.2)
    slc.set_width((.015, .09))
#     slc.show()
    slc.save("/home/lindsayad/Pictures/tex" + field_name + ".png")


/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))

In [12]:
%debug


> /home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/texmanager.py(320)make_tex()
    318                                        "'text.latex.unicode' rcParam.",
    319                                        'helpful')
--> 320                     raise
    321 
    322         return texfile

ipdb> p s
'\\documentclass{article}\n\\usepackage{type1cm}\n\\renewcommand{\\rmdefault}{pnc}\n\\usepackage{helvet}\n\\usepackage{courier}\n\\usepackage{textcomp}\n\n\n\\usepackage[papersize={72in,72in},body={70in,70in},margin={1in,1in}]{geometry}\n\\pagestyle{empty}\n\\begin{document}\n\\fontsize{18.000000}{22.500000}{\\sffamily $−50$}\n\\end{document}\n'
ipdb> quit

In [3]:
import matplotlib.pyplot as plt
plt.rc('font', family='serif')

In [4]:
import numpy as np
import matplotlib.pyplot as plt


# Example data
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(4 * np.pi * t) + 2

plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.plot(t, s)

plt.xlabel(r'\textbf{time} (s)')
plt.ylabel(r'\textit{voltage} (mV)',fontsize=16)
plt.title(r"\TeX\ is Number "
          r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
          fontsize=16, color='gray')
# Make room for the ridiculously large title.
plt.subplots_adjust(top=0.8)

plt.savefig('tex_demo')
plt.show()


/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/font_manager.py:1297: UserWarning: findfont: Font family ['serif'] not found. Falling back to DejaVu Sans
  (prop.get_family(), self.defaultFamily[fontext]))
---------------------------------------------------------------------------
ParseFatalException                       Traceback (most recent call last)
/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/mathtext.py in parse(self, s, fonts_object, fontsize, dpi)
   2516         try:
-> 2517             result = self._expression.parseString(s)
   2518         except ParseBaseException as err:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseString(self, instring, parseAll)
   1215                 # catch and re-raise exception from here, clears out pyparsing internal stack trace
-> 1216                 raise exc
   1217         else:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseString(self, instring, parseAll)
   1205         try:
-> 1206             loc, tokens = self._parse( instring, 0 )
   1207             if parseAll:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2800         if self.expr is not None:
-> 2801             return self.expr._parse( instring, loc, doActions, callPreParse=False )
   2802         else:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2543             else:
-> 2544                 loc, exprtokens = e._parse( instring, loc, doActions )
   2545             if exprtokens or exprtokens.haskeys():

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2969         try:
-> 2970             return super(ZeroOrMore, self).parseImpl(instring, loc, doActions)
   2971         except (ParseException,IndexError):

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2922             try_not_ender(instring, loc)
-> 2923         loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
   2924         try:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2526         # pre-parsed the string as part of our And pre-parsing
-> 2527         loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
   2528         errorStop = False

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1097                 for fn in self.parseAction:
-> 1098                     tokens = fn( instring, tokensStart, retTokens )
   1099                     if tokens is not None:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in wrapper(*args)
    818             try:
--> 819                 ret = func(*args[limit[0]:])
    820                 foundArity[0] = True

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/mathtext.py in math_string(self, s, loc, toks)
   2587         # print "math_string", toks[0][1:-1]
-> 2588         return self._math_expression.parseString(toks[0][1:-1])
   2589 

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseString(self, instring, parseAll)
   1215                 # catch and re-raise exception from here, clears out pyparsing internal stack trace
-> 1216                 raise exc
   1217         else:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseString(self, instring, parseAll)
   1205         try:
-> 1206             loc, tokens = self._parse( instring, 0 )
   1207             if parseAll:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2800         if self.expr is not None:
-> 2801             return self.expr._parse( instring, loc, doActions, callPreParse=False )
   2802         else:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2922             try_not_ender(instring, loc)
-> 2923         loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
   2924         try:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2800         if self.expr is not None:
-> 2801             return self.expr._parse( instring, loc, doActions, callPreParse=False )
   2802         else:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1071                 try:
-> 1072                     loc,tokens = self.parseImpl( instring, preloc, doActions )
   1073                 except IndexError:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in parseImpl(self, instring, loc, doActions)
   2657             try:
-> 2658                 ret = e._parse( instring, loc, doActions )
   2659                 return ret

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseCache(self, instring, loc, doActions, callPreParse)
   1136             try:
-> 1137                 value = self._parseNoCache( instring, loc, doActions, callPreParse )
   1138                 ParserElement._exprArgCache[ lookup ] = (value[0],value[1].copy())

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in _parseNoCache(self, instring, loc, doActions, callPreParse)
   1097                 for fn in self.parseAction:
-> 1098                     tokens = fn( instring, tokensStart, retTokens )
   1099                     if tokens is not None:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/pyparsing.py in wrapper(*args)
    818             try:
--> 819                 ret = func(*args[limit[0]:])
    820                 foundArity[0] = True

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/mathtext.py in unknown_symbol(self, s, loc, toks)
   2693         c = toks[0]
-> 2694         raise ParseFatalException(s, loc, "Unknown symbol: %s" % c)
   2695 

ParseFatalException: Unknown symbol: \displaystyle (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-4-67f57575cd9e> in <module>()
     19 plt.subplots_adjust(top=0.8)
     20 
---> 21 plt.savefig('tex_demo')
     22 plt.show()

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)
    695 def savefig(*args, **kwargs):
    696     fig = gcf()
--> 697     res = fig.savefig(*args, **kwargs)
    698     fig.canvas.draw_idle()   # need this if 'transparent=True' to reset colors
    699     return res

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/figure.py in savefig(self, *args, **kwargs)
   1570             self.set_frameon(frameon)
   1571 
-> 1572         self.canvas.print_figure(*args, **kwargs)
   1573 
   1574         if frameon:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2242                 orientation=orientation,
   2243                 bbox_inches_restore=_bbox_inches_restore,
-> 2244                 **kwargs)
   2245         finally:
   2246             if bbox_inches and restore_bbox:

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs)
    543 
    544     def print_png(self, filename_or_obj, *args, **kwargs):
--> 545         FigureCanvasAgg.draw(self)
    546         renderer = self.get_renderer()
    547         original_dpi = renderer.dpi

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw(self)
    462 
    463         try:
--> 464             self.figure.draw(self.renderer)
    465         finally:
    466             RendererAgg.lock.release()

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/figure.py in draw(self, renderer)
   1141 
   1142             mimage._draw_list_compositing_images(
-> 1143                 renderer, self, dsu, self.suppressComposite)
   1144 
   1145             renderer.close_group('figure')

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, dsu, suppress_composite)
    137     if not_composite or not has_images:
    138         for zorder, a in dsu:
--> 139             a.draw(renderer)
    140     else:
    141         # Composite any adjacent images together

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py in draw(self, renderer, inframe)
   2407             renderer.stop_rasterizing()
   2408 
-> 2409         mimage._draw_list_compositing_images(renderer, self, dsu)
   2410 
   2411         renderer.close_group('axes')

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, dsu, suppress_composite)
    137     if not_composite or not has_images:
    138         for zorder, a in dsu:
--> 139             a.draw(renderer)
    140     else:
    141         # Composite any adjacent images together

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)
     61     def draw_wrapper(artist, renderer, *args, **kwargs):
     62         before(artist, renderer)
---> 63         draw(artist, renderer, *args, **kwargs)
     64         after(artist, renderer)
     65 

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/text.py in draw(self, renderer)
    800                     textrenderer.draw_text(gc, x, y, clean_line,
    801                                            textobj._fontproperties, angle,
--> 802                                            ismath=ismath, mtext=mtext)
    803 
    804         gc.restore()

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw_text(self, gc, x, y, s, prop, angle, ismath, mtext)
    188 
    189         if ismath:
--> 190             return self.draw_mathtext(gc, x, y, s, prop, angle)
    191 
    192         flags = get_hinting_flag()

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py in draw_mathtext(self, gc, x, y, s, prop, angle)
    173                                      'debug-annoying')
    174         ox, oy, width, height, descent, font_image, used_characters = \
--> 175             self.mathtext_parser.parse(s, self.dpi, prop)
    176 
    177         xd = descent * sin(radians(angle))

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/mathtext.py in parse(self, s, dpi, prop)
   3287             self.__class__._parser = Parser()
   3288 
-> 3289         box = self._parser.parse(s, font_output, fontsize, dpi)
   3290         font_output.set_canvas_size(box.width, box.height, box.depth)
   3291         result = font_output.get_results(box)

/home/lindsayad/miniconda3/lib/python3.6/site-packages/matplotlib/mathtext.py in parse(self, s, fonts_object, fontsize, dpi)
   2521                         err.line,
   2522                         " " * (err.column - 1) + "^",
-> 2523                         six.text_type(err)]))
   2524         self._state_stack = None
   2525         self._em_width_cache = {}

ValueError: 
\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}
^
Unknown symbol: \displaystyle (at char 0), (line:1, col:1)

In [15]:
import numpy as np
import matplotlib.pyplot as plt


# Example data
t = np.arange(0.0, 1.0 + 0.01, 0.01)
s = np.cos(4 * np.pi * t) + 2

from matplotlib import rcParams
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 17
rcParams['font.serif'] = ['Computer Modern Roman']
rcParams['text.usetex'] = True

plt.plot(t, s)
plt.xlabel(r'\textbf{time} (s)')
plt.ylabel(r'\textit{voltage} (mV)',fontsize=16)
plt.title(r"\TeX\ is Number "
          r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
          fontsize=16, color='gray')
# Make room for the ridiculously large title.
plt.subplots_adjust(top=0.8)

plt.savefig('tex_demo')
plt.show()



In [19]:
pwd


Out[19]:
'/home/lindsayad/projects/zapdos/tests/TM10_circular_wg/gold'

In [21]:
ls


current_carrying_wire_out.e

In [1]:
cd /home/lindsayad/projects/zapdos/tests/current_carrying_wire/gold/


/home/lindsayad/projects/zapdos/tests/current_carrying_wire/gold

In [2]:
import yt

dscc = yt.load("current_carrying_wire_out.e", step=-1)
dscc.field_list

import numpy as np
import matplotlib.pyplot as plt

from yt.geometry.coordinates.cartesian_coordinates import CartesianCoordinateHandler

handler = CartesianCoordinateHandler(dscc)

arc_length, values = handler.line_plot(('all', 'Bphi'), np.array([0, 0, 0.]), np.array([2, 0, 0.]), 100)
plt.plot(arc_length, values)
plt.show()



In [8]:
slc = yt.SlicePlot(dscc, 'z', ('all', 'Bphi'))
slc.set_log(('all', 'Bphi'), False)
# slc.set_xlabel("r (mm)")
# slc.set_ylabel("z (mm)")
# slc.set_colorbar_label(field, field_label[field_name])
# slc.set_figure_size(1.2)
# slc.set_width((.015, .09))
slc.show()




In [9]:
dir(dscc)


Out[9]:
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__iter__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__weakref__',
 '_add_object_class',
 '_apply_displacement',
 '_arr',
 '_assign_unit_system',
 '_checksum',
 '_create_unit_registry',
 '_field_info_class',
 '_get_current_time',
 '_get_elem_names',
 '_get_field_info',
 '_get_fluid_types',
 '_get_glo_names',
 '_get_nod_names',
 '_get_unique_identifier',
 '_guess_candidates',
 '_handle',
 '_hash',
 '_index_class',
 '_index_proxy',
 '_instantiated',
 '_instantiated_index',
 '_is_valid',
 '_last_finfo',
 '_last_freq',
 '_load_domain_edge',
 '_load_info_records',
 '_max_level',
 '_mrep',
 '_override_code_units',
 '_parse_parameter_file',
 '_particle_type_counts',
 '_quan',
 '_read_connectivity',
 '_read_coordinates',
 '_read_glo_var',
 '_set_code_unit_attributes',
 '_set_derived_attrs',
 '_setup_classes',
 '_setup_coordinate_handler',
 '_setup_filtered_type',
 '_setup_particle_type',
 '_setup_particle_types',
 '_skip_cache',
 'add_deposited_particle_field',
 'add_field',
 'add_gradient_fields',
 'add_particle_filter',
 'add_particle_union',
 'add_smoothed_particle_field',
 'all_data',
 'arbitrary_grid',
 'arr',
 'backup_filename',
 'basename',
 'bool',
 'box',
 'checksum',
 'close',
 'conversion_factors',
 'coordinates',
 'cosmological_simulation',
 'covering_grid',
 'create_field_info',
 'current_redshift',
 'current_time',
 'cut_region',
 'cutting',
 'data_collection',
 'dataset_type',
 'default_field',
 'default_fluid_type',
 'define_unit',
 'derived_field_list',
 'dimensionality',
 'directory',
 'disk',
 'displacements',
 'domain_center',
 'domain_dimensions',
 'domain_left_edge',
 'domain_right_edge',
 'domain_width',
 'ellipsoid',
 'field_dependencies',
 'field_info',
 'field_list',
 'field_units',
 'fields',
 'file_style',
 'filtered_particle_types',
 'find_field_values_at_point',
 'find_field_values_at_points',
 'find_max',
 'find_min',
 'fluid_types',
 'fullpath',
 'geometry',
 'get_smallest_appropriate_unit',
 'get_unit_from_registry',
 'h',
 'halo',
 'has_key',
 'hierarchy',
 'hub_upload',
 'hubble_constant',
 'index',
 'index_filename',
 'intersection',
 'ires_factor',
 'known_filters',
 'length_unit',
 'mass_unit',
 'max_level',
 'min_level',
 'no_cgs_equiv_length',
 'num_steps',
 'object_types',
 'objects',
 'omega_lambda',
 'omega_matter',
 'ortho_ray',
 'parameter_filename',
 'parameters',
 'particle_fields_by_type',
 'particle_type_counts',
 'particle_types',
 'particle_types_raw',
 'particle_unions',
 'particles_exist',
 'periodicity',
 'plots',
 'point',
 'print_key_parameters',
 'print_stats',
 'proj',
 'quan',
 'r',
 'ray',
 'read_from_backup',
 'refine_by',
 'region',
 'region_expression',
 'relative_refinement',
 'set_code_units',
 'set_units',
 'setup_deprecated_fields',
 'slice',
 'smoothed_covering_grid',
 'sphere',
 'step',
 'storage_filename',
 'streamline',
 'surface',
 'time_unit',
 'union',
 'unique_identifier',
 'unit_registry',
 'unit_system',
 'units_override']

In [11]:
dscc.domain_width


Out[11]:
YTArray([ 2.4,  1. ,  1. ]) code_length

In [20]:
dscc.index.meshes[0].connectivity_coords.max()


Out[20]:
2.0

In [17]:
dir(dscc.index.meshes[0])


Out[17]:
['__add__',
 '__and__',
 '__class__',
 '__delattr__',
 '__delitem__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__getitem__',
 '__gt__',
 '__hash__',
 '__init__',
 '__init_subclass__',
 '__invert__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__or__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__setitem__',
 '__sizeof__',
 '__str__',
 '__sub__',
 '__subclasshook__',
 '__weakref__',
 '__xor__',
 '_activate_cache',
 '_check_consistency',
 '_chunk_info',
 '_chunked_read',
 '_compute_extrema',
 '_con_args',
 '_connectivity_length',
 '_container_fields',
 '_count_particles',
 '_current_chunk',
 '_current_fluid_type',
 '_current_particle_type',
 '_data_source',
 '_debug',
 '_determine_fields',
 '_dimensionality',
 '_distributed',
 '_extrema_cache',
 '_field_cache',
 '_field_lock',
 '_field_parameter_state',
 '_field_type_state',
 '_finalize_parallel',
 '_generate_container_field',
 '_generate_field',
 '_generate_fields',
 '_generate_fluid_field',
 '_generate_particle_field',
 '_generate_spatial_fluid',
 '_get_grid_objs',
 '_get_grids',
 '_get_objs',
 '_get_selector_mask',
 '_grids',
 '_hash',
 '_identify_dependencies',
 '_index',
 '_index_offset',
 '_initialize_cache',
 '_initialize_parallel',
 '_is_default_field_parameter',
 '_key_fields',
 '_last_count',
 '_last_mask',
 '_last_selector_id',
 '_locked',
 '_num_ghost_zones',
 '_parameter_iterate',
 '_reshape_vals',
 '_selector',
 '_set_center',
 '_set_default_field_parameters',
 '_skip_add',
 '_sort_by',
 '_spatial',
 '_tds_attrs',
 '_tds_fields',
 '_tree',
 '_type_name',
 'apply_units',
 'argmax',
 'argmin',
 'blocks',
 'chunks',
 'clear_data',
 'clone',
 'comm',
 'connectivity_coords',
 'connectivity_indices',
 'convert',
 'count',
 'count_particles',
 'deposit',
 'ds',
 'fcoords',
 'fcoords_vertex',
 'field_data',
 'field_parameters',
 'filename',
 'fwidth',
 'get_data',
 'get_dependencies',
 'get_field_parameter',
 'get_global_startindex',
 'has_field_parameter',
 'has_key',
 'icoords',
 'index',
 'integrate',
 'ires',
 'keys',
 'max',
 'mean',
 'mesh_id',
 'min',
 'partition_index_2d',
 'partition_index_3d',
 'partition_index_3d_bisection_list',
 'partition_region_3d',
 'pf',
 'profile',
 'ptp',
 'save_as_dataset',
 'save_object',
 'select',
 'select_blocks',
 'select_fcoords',
 'select_fcoords_vertex',
 'select_fwidth',
 'select_icoords',
 'select_ires',
 'select_particles',
 'select_tcoords',
 'selector',
 'set_field_parameter',
 'shape',
 'std',
 'sum',
 'tiles',
 'to_dataframe',
 'to_glue',
 'write_out']

Conclusions

  • Don't use text.usetex = True when creating yt-plots. Just use matplotlibs built-in mathtext parser. The reason not to use text.usetex = True is related to the hacky way that yt uses matplotlib and a current bug in matplotlib. See here
  • The built-in mathtext parser doesn't have font.family = 'serif' so don't try to use it. You'll just get a warning and it will fall back to a different font
  • You can run with these rcParams settings in a MPL-only and a yt plotting script. The former will execute without warning (or error) while the latter will warn that it couldn't assign font.family = 'serif'. This must be due to yt using MPL's 'classic' plotting style or something like that
    from matplotlib import rcParams
    rcParams['text.usetex'] = True
    rcParams['font.family'] = 'serif'
    rcParams['font.size'] = 17
    rcParams['font.serif'] = ['Computer Modern Roman']
    

In [ ]: