• File: texmanager.pyo
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyo
  • Date Modified: 07/22/2015 11:41 PM
  • File size: 19.61 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit

)Uc@sHdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
yddlmZWn!e
k
rddlmZnXddlZddlZddlZddlmZddlmZddljZddlZeZejjdr"dZnd	Zd
Zdd
dYZ dS(s
This module supports embedded TeX expressions in matplotlib via dvipng
and dvips for the raster and postscript backends.  The tex and
dvipng/dvips information is cached in ~/.matplotlib/tex.cache for reuse between
sessions

Requirements:

* latex
* \*Agg backends: dvipng
* PS backend: latex w/ psfrag, dvips, and Ghostscript 8.51
  (older versions do not work properly)

Backends:

* \*Agg
* PS
* PDF

For raster output, you can get RGBA numpy arrays from TeX expressions
as follows::

  texmanager = TexManager()
  s = '\TeX\ is Number $\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!'
  Z = self.texmanager.get_rgba(s, size=12, dpi=80, rgb=(1,0,0))

To enable tex rendering of all text in your matplotlib figure, set
text.usetex in your matplotlibrc file (http://matplotlib.sf.net/matplotlibrc)
or include these two lines in your script::

  from matplotlib import rc
  rc('text', usetex=True)

iN(tPopentPIPEtSTDOUT(tmd5(trcParams(tread_pngtwint&t;c
Cstddtdtdtdtdtjdk}|j|j}}xl|D]d}|jdrM|j	d	}t
jjd
|dt
jj|}|t
jjdkSqMWt
jjd
dtS(Nsdvipng -versiontshelltstdintstdouttstderrt	close_fdstwin32sdvipng isFound dvipng version %sthelpfuls1.6sNo dvipng was found(RtTrueRRtsystplatformR
Rt
startswithtsplittmpltverbosetreportt	distutilstversiontLooseVersiontFalse(tpR
RtlineR((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytdvipng_hack_alpha9s
t
TexManagercBsfeZdZejZed?kr3ejZnej	j
edZejZ
ej	j
e
dZej	jerejdeefIJejeenej	jesejend?ZiZiZiZdZd@ZdAZdBZdCZdZdDZidEd6dFd6dGd6dHd6dId6dJd
6dKd6dLd6dMd6dNd!6dOd$6dPd'6dQd6dRd(6dSd)6dTd*6Z d?Z!dUe"gdVeD]Z#d-e#^qZ$d.Z%d?d/Z&d0Z'd1Z(d2Z)d3Z*d4Z+e,j-d5Z.d6Z/d7Z0d8Z1d9Z2d:Z3d;Z4d?d?d<Z5d?d?dWd=Z6d?d>Z7RS(XsZ
    Convert strings to dvi files using TeX, caching the results to a
    working dir
    s
.tex.caches	tex.cachesmWARNING: found a TeX cache dir in the deprecated location "%s".
  Moving it to the new default location "%s".itcmrttcmsstcmtttpzcs\usepackage{chancery}tserifs
sans-seriftcursivet	monospacetpncs\renewcommand{\rmdefault}{pnc}snew century schoolbooktpbks\renewcommand{\rmdefault}{pbk}tbookmantptms\usepackage{mathptmx}ttimestppls\usepackage{mathpazo}tpalatinos
zapf chancerytpchs\usepackage{charter}tchartertphvs\usepackage{helvet}t	helveticatpags\usepackage{avant}savant gardetpcrs\usepackage{courier}tcourierscomputer modern romanscomputer modern sans serifscomputer modern typewriterstext.latex.preambletfamilysfont.cCsHtjj|js(tj|jntdj}||jkrS||_n t	j
jd|dd|_|jg}xg|jD]}||jddf^qD]\}}xtd|D]}|j|j
kr@|j
|j}t|||j
|jtr<d|||j
|jfGHnPqtrd	GHqqWt	j
jd
|dt|||j
||jt||dqWdj||_|jd
|jd
|jd
g}|jdkr|j|jd
nxd|kr|jdqWdj|}djd|dg|_dS(Nsfont.familysOThe %s font family is not compatible with LaTeX. serif will be used by default.RR%t-t_sfont.sfamily: %s, font: %s, info: %ss%$s font is not compatible with usetexsQNo LaTeX-compatible font found for the %s font family in rcParams. Using default.iR!iR&s\usepackage{type1cm}s
s\usepackage{textcomp}(tostpathtisdirttexcachetmkdirRtlowert
font_familiestfont_familyRRRtreplacet	font_infotsetattrtDEBUGtappendtgetattrtjoint_fontconfigR%t
sans_serifR'R&tremovet_font_preamble(tselftfft
fontconfigR@tfont_family_attrtfontt
found_fonttcmd((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyt__init__sB	8	$cCsqdj||jd||jt|p.dg}t|jd}tjj|jt	|j
S(sU
        returns a filename based on a hash of the string, fontsize, and dpi
        R!s%fsutf-8(RGtget_font_configtget_custom_preambletstrtunicodetencodeR9R:R<Rt	hexdigest(RLttextfontsizetdpitstbytes((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_basefiles!cCs|jdkr=tg|jD]}|df^q|_ng|jD]#}t||j|krG|^qG}|rtrdG|GHnxN|D]F}trd||j|t|fGHntjt||j|<qWtrdG|jGHn|j	ntrdG|jGHn|jS(s8Reinitializes self if relevant rcParams on have changed.sDEBUG following keys changed:sDEBUG %-20s: %-10s -> %-10ssDEBUG RE-INIT
old fontconfig:sDEBUG fontconfig:N(
t	_rc_cachetNonetdictt_rc_cache_keysRRDtcopytdeepcopyRHRS(RLtktpartchanged((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyRTs$.

cCs|jS(sU
        returns a string containing font configuration for the tex preamble
        (RK(RL((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_font_preamblescCsdjtdS(s>returns a string containing user additions to the tex preambles
stext.latex.preamble(RGR(RL((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyRUscGsRtjdkr2dtjj|jdg}ng}|j|dj|S(s
        On windows, changing directories can be complicated by the presence of
        multiple drives. get_shell_cmd deals with this issue.
        Rs%sis && (RRR9R:t
splitdriveR<textendRG(RLtargstcommand((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyt_get_shell_cmds
#
cCs|j||}d|}t|d}|j}idd6dd6j|jd}||}tdrwd	}nd
}d|j||||d|f}	tdr|j|	jd
n=y|j|	Wn)t	k
r}
t
jjddnX|j
|S(su
        Generate a tex file to render the tex string at a specific font size

        returns the file name
        s%s.textws{\sffamily %s}s
sans-serifs{\ttfamily %s}R's{\rmfamily %s}stext.latex.unicodes-\usepackage{ucs}
\usepackage[utf8x]{inputenc}R!s\documentclass{article}
%s
%s
%s
\usepackage[papersize={72in,72in}, body={70in,70in}, margin={1in,1in}]{geometry}
\pagestyle{empty}
\begin{document}
\fontsize{%f}{%f}%s
\end{document}
g?tutf8sbYou are using unicode and latex, but have not enabled the matplotlib 'text.latex.unicode' rcParam.R(R_tfileRUtgetR@RRKtwriteRXtUnicodeEncodeErrorRRRtclose(RLRZR[tbasefilettexfiletfhtcustom_preambletfontcmdtunicode_preambleR]terr((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytmake_texs.

	

	

s3MatplotlibBox:\(([\d.]+)pt\+([\d.]+)pt\)x([\d.]+)ptcCs|j||}d|}t|d}|j}idd6dd6j|jd}||}tdrwd	}nd
}d|j||||d|f}	tdr|j|	jd
n=y|j|	Wn)t	k
r}
t
jjddnX|j
|S(s
        Generate a tex file to render the tex string at a specific
        font size.  It uses the preview.sty to determin the dimension
        (width, height, descent) of the output.

        returns the file name
        s%s.texRos{\sffamily %s}s
sans-serifs{\ttfamily %s}R's{\rmfamily %s}stext.latex.unicodes-\usepackage{ucs}
\usepackage[utf8x]{inputenc}R!s\documentclass{article}
%s
%s
%s
\usepackage[active,showbox,tightpage]{preview}
\usepackage[papersize={72in,72in}, body={70in,70in}, margin={1in,1in}]{geometry}

%% we override the default showbox as it is treated as an error and makes
%% the exit status not zero
\def\showbox#1{\immediate\write16{MatplotlibBox:(\the\ht#1+\the\dp#1)x\the\wd#1}}

\begin{document}
\begin{preview}
{\fontsize{%f}{%f}%s}
\end{preview}
\end{document}
g?RpsbYou are using unicode and latex, but have not enabled the matplotlib 'text.latex.unicode' rcParam.R(R_RqRURrR@RRKRsRXRtRRRRu(RLRZR[RvRwRxRyRzR{R]R|((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytmake_tex_previews.

	

	

c
Cstdr|j||S|j||}d|}tsOtjj|r|j||}|d}|jd|j	dtjj
|d|f}tjj
|dtj|}y&t|}	|	j}
|	jWntk
rd}
nXytj|t}Wntk
r0t}nX|s>|r[td	t||
ntjj
|
dxgtj|d
D]O}|jdrq|jdrqytj|Wqtk
rqXqWn|S(
sm
        generates a dvi file containing latex's layout of tex string

        returns the file name
        stext.latex.previews%s.dvis.outputscd "%s"s(latex -interaction=nonstopmode %s > "%s"itdebugs No latex error report available.seLaTeX was not able to process the following string:
%s
Here is the full report generated by LaTeX: 

t*tdviRZ(Rtmake_dvi_previewR_RDR9R:texistsR}RnR<RRRRtsystemRqtreadRutIOErrortstatRtOSErrorRtRuntimeErrortreprtglobtendswithRJ(
RLRZR[RvtdvifileRwtoutfileRmtexit_statusRxRRtfname((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytmake_dviPsJ


 







cCs|j||}d|}d|}tsRtjj|sRtjj|r|j||}|d}|jd|jdtjj|d|f}t	j
j|dtj|}	y&t
|}
|
j}|
jWntk
rd}nX|	r&td	t||nt	j
j|dtjj|}t|d
djdj|jxytj|d
D]a}
|
jdrq|
jdrq|
jdrqytj|
Wqtk
rqXqWn|S(s
        generates a dvi file containing latex's layout of tex
        string. It calls make_tex_preview() method and store the size
        information (width, height, descent) in a separte file.

        returns the file name
        s%s.dvis%s.baselines.outputscd "%s"s(latex -interaction=nonstopmode %s > "%s"iRs No latex error report available.seLaTeX was not able to process the following string:
%s
Here is the full report generated by LaTeX: 

s	.baselineRot RRRZtbaseline(R_RDR9R:RR~RnR<RRRRRRqRRuRRRRt_re_vboxtsearchtopenRsRGtgroupsRRRJR(RLRZR[RvRtbaselinefileRwRRmRRxRtmR((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyRsH


 

)
cCs[|j|||}d|}ts8tjj|rW|j||}|d}|jd|jd|tjj|dtjj|d|f}t	j
j|dtj|}	y&t
|}
|
j}|
jWntk
rd}nX|	rtd||nt	j
j|dytj|WqWtk
rSqWXn|S(	so
        generates a png file containing latex's rendering of tex string

        returns the filename
        s%s.pngs.outputscd "%s"sQdvipng -bg Transparent -D %s -T tight -o                         "%s" "%s" > "%s"iRs!No dvipng error report available.sedvipng was not able to process the following file:
%s
Here is the full report generated by dvipng: 

(R_RDR9R:RRRnR<RRRRRRqRRuRRRJR(RLRZR[R\RvtpngfileRRRmRRxR((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytmake_pngs2

 


c
Cs|j||}d|}ts5tjj|r|j||}|d}|jd|jdtjj|dtjj|d|f}t	j
j|dtj|}t
|}	|rtd||	jnt	j
j|	jd|	jtj|n|S(sw
        generates a postscript file containing latex's rendering of tex string

        returns the file name
        s%s.epsfs.outputscd "%s"sdvips -q -E -o "%s" "%s" > "%s"iRscdvipng was not able to process the flowing file:
%s
Here is the full report generated by dvipng: 

(R_RDR9R:RRRnR<RRRRRRqRRRuRJ(
RLRZR[RvtpsfileRRRmRRx((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytmake_pss&

 
cCsy|j||}t|}xD|D]<}|jdr%g|jdD]}t|^qKSq%Wtd|dS(sw
        returns a list containing the postscript bounding box for latex's
        rendering of the tex string
        s%%BoundingBox:isCould not parse %sN(RRqRRtintR(RLRZR[RtpsRtval((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_ps_bboxs
+c	Cs||j||f}|jj|}|dkr|j|||}ttjj|j	|}t
ddk	rt
d}n'tjdkrt
t_ntj}|rd|dddddf}n|dddddf}||j|<n|S(sreturns the alpha channelstext.dvipnghackiNii(RTtgrey_arraydRrRaRRR9R:RGR<RRt_dvipng_hack_alphaR(	RLRZR[R\tkeytalphaRtXthack((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_greys
	&cCsE|std}n|s&td}n|\}}}||j||t|f}|jj|}	|	dkrA|j|||}
tj|
j	d|
j	ddftj
}	||	dddddf<||	dddddf<||	dddddf<|
|	dddddf<|	|j|<n|	S(	sN
        Returns latex's rendering of the tex string as an rgba array
        s	font.sizessavefig.dpiiiiNii(RRTttupletrgba_arraydRrRaRtnptzerostshapetfloat(RLRZR[R\trgbtrtgtbRtZR((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_rgba+s 

!,cCsB|jdkrdS|r.|jd}nd}tdr|j||}d|}tsstjj|r|j||}nt	|j
j}g|D]}	t|	|^q\}
}}||
||fS|j
||}tj|d|}
t|
j}|
j|j|j|j|jfSdS(	s?
        return width, heigth and descent of the text.
        R!ig?stext.latex.previews%s.baselineiHN(iii(tstriptpoints_to_pixelsRR_RDR9R:RRRRRRRtdvireadtDvititertnextRutwidththeighttdescent(RLRZR[trenderertdpi_fractionRvRRtltl1RtdepthRRtpage((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pytget_text_width_height_descentCs$

,
N(R R!(R"R!(R#R!(R$s\usepackage{chancery}(sserifs
sans-serifscursives	monospace(R(s\renewcommand{\rmdefault}{pnc}(R)s\renewcommand{\rmdefault}{pbk}(R+s\usepackage{mathptmx}(R-s\usepackage{mathpazo}(R$s\usepackage{chancery}(R$s\usepackage{chancery}(R/s\usepackage{charter}(R R!(R"R!(R1s\usepackage{helvet}(R3s\usepackage{avant}(R4s\usepackage{courier}(R#R!(R R!(R"R!(R#R!(stext.latex.preamble(R6(iii(8t__name__t
__module__t__doc__Rtget_hometoldpathRat
get_data_pathR9R:RGtoldcachet
get_configdirt	configdirR<RRRtshutiltmoveR=RRRtpostscriptdtpscntR%RIR'R&R@R?RBR`RtnRcRSR_RTRiRURnR}tretcompileRR~RRRRRRRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyRHsz
(	)
					0	?	/	0	#		0((!RRdRR9RRtwarningst
subprocessRRRthashlibRtImportErrortdistutils.versionRtnumpyRt
matplotlibRRtmatplotlib._pngRtmatplotlib.dvireadRRRRDRRt	cmd_splitRR(((sH/opt/alt/python27/lib64/python2.7/site-packages/matplotlib/texmanager.pyt<module>"s&H