Preparation


In [1]:
% pylab
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import matplotlib.patches as mpatches
plt.rc('text', usetex=True)
plt.rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})

def draw_bbox_fancy(ax, bb, bbBol, fbBol, BoxS, Ec, Fc,lw=1.,ls='solid',zorder=1):
    # ax = axe
    # bb = bbox instance
    # bbBol, fbBol = Booleans, if true the bbox itself and/or the fancybox is plotted
    # BoxSDic = boxstyle dictionary to be used for the fancybox
    
    if bbBol:
        p_bbox = mpatches.FancyBboxPatch((bb.xmin, bb.ymin), abs(bb.width), abs(bb.height),
                                boxstyle="square,pad=0.", ec="k", fc="none", zorder=10.,lw=lw,ls=ls)
        ax.add_patch(p_bbox)
        
    if fbBol:
        p_fbbox = mpatches.FancyBboxPatch((bb.xmin, bb.ymin), abs(bb.width), abs(bb.height),boxstyle=BoxS,ec=Ec,fc=Fc, zorder=zorder,lw=lw,ls=ls)
        ax.add_patch(p_fbbox)
        plt.draw()
        return p_fbbox


def common_bbox(ax, txt):
    # ax = axe
    # txt = list of text instances
    
    plt.draw()
    Xmin, Ymin, Xmax, Ymax = [], [], [], []
    for Tx in txt:
        try:
            Txw = Tx.get_window_extent(renderer=None,dpi=None)
        except TypeError:
            Txw = Tx.patch.get_bbox()
        TxwData = Txw.transformed(ax.transData.inverted())
        Xmin.append(TxwData.xmin)
        Ymin.append(TxwData.ymin)
        Xmax.append(TxwData.xmax)
        Ymax.append(TxwData.ymax)
  
    Xmin, Ymin, Xmax, Ymax = min(Xmin), min(Ymin), max(Xmax), max(Ymax)
    bb = mtransforms.Bbox([[Xmin, Ymin], [Xmax, Ymax]])
    return bb


def link_fancyArrow(ax, bb1, Coordbb1, bb2, Coordbb2, arrowprops):
    # ax = axe
    # bb1, bb2 = bbox or patch instance
    # Coordbb1, Coordbb2 = (x,y) tuple normalised coordinates (with respect to x/ymax and x/ymin of bb1/bb2)
    
    if isinstance(bb1,matplotlib.patches.FancyBboxPatch):
        print('The input args should be Bbox instances, not patches!\n Associated Bbox used instead')
        bb1, bb2 = bb1.get_bbox(), bb2.get_bbox()
        
    if isinstance(bb1,matplotlib.transforms.Bbox):
        x1, y1 = Coordbb1[0]*(bb1.xmax-bb1.xmin)+bb1.xmin, Coordbb1[1]*(bb1.ymax-bb1.ymin)+bb1.ymin
        x2, y2 = Coordbb2[0]*(bb2.xmax-bb2.xmin)+bb2.xmin, Coordbb2[1]*(bb2.ymax-bb2.ymin)+bb2.ymin
    
    p_a = mpatches.FancyArrowPatch((x1,y1),(x2,y2),**arrowprops)
    ax.add_patch(p_a)
    return p_a
    
def hide_image(patch, ax, Dict):
    Txw = patch.get_bbox()
    TxwData = Txw.transformed(ax.transData.inverted())
    Pts = TxwData.get_points()
    xy, W, H = Pts[0,:], np.diff(Pts,axis=0)[0,0], np.diff(Pts,axis=0)[0,1]
    p_a = mpatches.Rectangle( xy, W, H, zorder=100, **Dict)
    ax.add_patch(p_a)
    return p_a


Using matplotlib backend: MacOSX
Populating the interactive namespace from numpy and matplotlib

Exercice Type de schema


In [2]:
figW, figH = 8, 5
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, Fc, Ec, Alpha = "round,pad=0.01", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
ConnectStyle = 'angle3,angleA=90,angleB=0'
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",connectionstyle=ConnectStyle,color='k',mutation_scale=10)
Name_tparams={'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}

Fle = ax.text(0.2,0.4,"bla", color='k', size=20, zorder=10., **Name_tparams)
Tx = ax.text(0.4,0.3, "Bli", color='k', size=12, zorder=11., **Name_tparams)

Fle2 = ax.text(0.6,0.8,"bla", color='k', size=20, zorder=10., **Name_tparams)
Tx2 = ax.text(0.7,0.2, "Bli", color='k', size=12, zorder=11., **Name_tparams)

Txt = [Fle, Tx]
Txt2 = [Fle2, Tx2]
bb1 = common_bbox(ax, Txt)
bb2 = common_bbox(ax, Txt2)
fb1 = draw_bbox_fancy(ax, bb1, True, True, BoxS, Ec, Fc)
fb2 = draw_bbox_fancy(ax, bb2, False, True, BoxS, Ec, Fc)

A1 = link_fancyArrow(ax, fb1, (0.5,1.), fb2, (0.,0.5), arrowprops)
draw()


The input args should be Bbox instances, not patches!
 Associated Bbox used instead

Droit de la Guerre


In [3]:
figW, figH = 7, 2.5
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, Fc, Ec, Alpha = "round,pad=0.02", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
Title_tparams={'size':15,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Title_tparams2={'size':12,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Com_tparams = {'size':10,'ha':'left', 'va':'top', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=2)
arrowprops2 = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=5)


Title, Com, Pos, Color, Box, Tparams, Arrw = [], [], [], [], [], [], []

######################

Title.append("Droit de la Guerre")
Com.append("")
Pos.append((0.5,0.9)), Color.append((0.,0.,0.,1.)), Box.append(False), Tparams.append(Title_tparams), Arrw.append(arrowprops2)

Title.append("Jus ad bellum ou DSI")
Com.append("Regit recours a force armee\nMais DSI inclut aussi droit des alliances en paix")
Pos.append((0.25,0.65)), Color.append((0.,0.,0.,1.)), Box.append(True), Tparams.append(Title_tparams), Arrw.append(arrowprops2)

Title.append("Jus in bello ou DIH")
Com.append("Regit usage de force armee\nMais DIH inclut aussi droit humanitaire en paix")
Pos.append((0.75,0.65)), Color.append((0.,0.,0.,1.)), Box.append(True), Tparams.append(Title_tparams), Arrw.append(arrowprops2)

Title.append("Troubles internes")
Com.append("")
Pos.append((0.25,0.35)), Color.append((0.,0.,0.,1.)), Box.append(True), Tparams.append(Title_tparams2), Arrw.append(arrowprops)

Title.append("CANI")
Com.append("")
Pos.append((0.15,0.15)), Color.append((0.,0.,0.,1.)), Box.append(True), Tparams.append(Title_tparams2), Arrw.append(arrowprops)

Title.append("CAI")
Com.append("")
Pos.append((0.35,0.15)), Color.append((0.,0.,0.,1.)), Box.append(True), Tparams.append(Title_tparams2), Arrw.append(arrowprops)

TxTitle, TxCom, bb, fb = [], [], [], []
for i in range(0,len(Title)):
    TxTitle.append(ax.text(Pos[i][0],Pos[i][1], Title[i], color=Color[i], **Tparams[i]))
    TxCom.append(ax.text(Pos[i][0],Pos[i][1]-0.01, Com[i], color=Color[i], **Com_tparams))
    
plt.draw()
ListBox = []
for i in range(0,len(Title)):
    Txpatch = TxCom[i].get_window_extent()   
    Lim = Txpatch.transformed(ax.transData.inverted())
    DX = Lim.xmax-Lim.xmin
    TxCom[i].set_x(Pos[i][0]-DX/2.)
    bb.append(common_bbox(ax, [TxTitle[i], TxCom[i]]))
    fb.append(draw_bbox_fancy(ax, bb[i], False, Box[i], BoxS, Color[i], 'w'))
 
ArCol, ArAng, ArBox, ArPos = [], [], [], []

ArB = [0, 0, 3, 3, 4, 4, 5, 5]
ArCol.append(Color[0]), ArBox.append([bb[0],bb[1]]), ArAng.append((20,40)), ArPos.append([(0.2,0.),(0.8,1.)])
ArCol.append(Color[0]), ArBox.append([bb[0],bb[2]]), ArAng.append((-20,-40)), ArPos.append([(0.8,0.),(0.2,1.)])
ArCol.append(Color[3]), ArBox.append([bb[3],bb[4]]), ArAng.append((20,90)), ArPos.append([(0.,0.5),(0.5,1.)])
ArCol.append(Color[3]), ArBox.append([bb[3],bb[5]]), ArAng.append((-80,-40)), ArPos.append([(0.8,0.),(0.2,1.)])
ArCol.append(Color[4]), ArBox.append([bb[4],bb[3]]), ArAng.append((40,80)), ArPos.append([(0.8,1.),(0.2,0.)])
ArCol.append(Color[4]), ArBox.append([bb[4],bb[5]]), ArAng.append((-20,20)), ArPos.append([(1.,0.2),(0.,0.2)])
ArCol.append(Color[5]), ArBox.append([bb[5],bb[3]]), ArAng.append((90,-20)), ArPos.append([(0.5,1.),(1.,0.5)])
ArCol.append(Color[5]), ArBox.append([bb[5],bb[4]]), ArAng.append((-20,20)), ArPos.append([(0.,0.8),(1.,0.8)])

Ar = []
for i in range(0,len(ArCol)):
    arrowpropsi = Arrw[ArB[i]]
    arrowpropsi['color'] = ArCol[i]
    arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(ArAng[i][0]) + ',angleB=' + str(ArAng[i][1])
    Ar.append(link_fancyArrow(ax, ArBox[i][0], ArPos[i][0], ArBox[i][1], ArPos[i][1], arrowpropsi))
    
plt.draw()  

#fig.savefig('Schema_DDLG.png', bbox_inches=0)

Trois niveaux de conflictualité


In [4]:
figW, figH = 9, 6
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, Fc, Ec, Alpha = "round,pad=0.01", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
Title_tparams={'size':15,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Com_tparams = {'size':10,'ha':'left', 'va':'top', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams1 = {'size':10,'ha':'center', 'va':'center', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams2 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams3 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=10)

Title, Com, Pos, Color, Box = [], [], [], [], []

Title.append("TTI (droit interne)")
Com.append("Emeutes, greves\nViolences (isoles, peu structures)\nMesures administratives et judiciaire")
Pos.append((0.5,0.9)), Color.append((0.,0.,0.,1.)), Box.append(True)

Title.append("CANI")
Com.append("Confine au territoire d'un Etat\nArmee reguliere vs Insurrection\nGuerre civile")
Pos.append((0.15,0.2)), Color.append((0.,0.,1.,1.)), Box.append(True)

Title.append("CAI")
Com.append("Guerre inter-etatique\nLutte de liberation\n(coloniale, post-coloniale, apartheid)\nArmee vs entite non-etatique")
Pos.append((0.85,0.2)), Color.append((1.,0.,0.,1.)), Box.append(True)

TxTitle, TxCom, bb, fb = [], [], [], []
for i in range(0,len(Title)):
    TxTitle.append(ax.text(Pos[i][0],Pos[i][1], Title[i], color=Color[i], **Title_tparams))
    TxCom.append(ax.text(Pos[i][0],Pos[i][1]-0.01, Com[i], color=Color[i], **Com_tparams))
    
plt.draw()
for i in range(0,len(Title)):
    Txpatch = TxCom[i].get_window_extent()   
    Lim = Txpatch.transformed(ax.transData.inverted())
    DX = Lim.xmax-Lim.xmin
    TxCom[i].set_x(Pos[i][0]-DX/2.)
    bb.append(common_bbox(ax, [TxTitle[i], TxCom[i]]))
    fb.append(draw_bbox_fancy(ax, bb[i], False, True, BoxS, Color[i], 'w'))
 
ArCol, ArAng, ArBox, ArPos = [], [], [], []

ArCol.append(Color[0]), ArBox.append([bb[0],bb[1]]), ArAng.append((40,90)), ArPos.append([(0.,0.5),(0.5,1.)])
ArCol.append(Color[0]), ArBox.append([bb[0],bb[2]]), ArAng.append((-80,-40)), ArPos.append([(0.8,0.),(0.2,1.)])
ArCol.append(Color[1]), ArBox.append([bb[1],bb[0]]), ArAng.append((40,80)), ArPos.append([(0.8,1.),(0.2,0.)])
ArCol.append(Color[1]), ArBox.append([bb[1],bb[2]]), ArAng.append((-20,20)), ArPos.append([(1.,0.2),(0.,0.2)])
ArCol.append(Color[2]), ArBox.append([bb[2],bb[0]]), ArAng.append((90,-40)), ArPos.append([(0.5,1.),(1.,0.5)])
ArCol.append(Color[2]), ArBox.append([bb[2],bb[1]]), ArAng.append((-20,20)), ArPos.append([(0.,0.8),(1.,0.8)])

Ar = []
for i in range(0,len(ArCol)):
    arrowpropsi = arrowprops
    arrowpropsi['color'] = ArCol[i]
    arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(ArAng[i][0]) + ',angleB=' + str(ArAng[i][1])
    Ar.append(link_fancyArrow(ax, ArBox[i][0], ArPos[i][0], ArBox[i][1], ArPos[i][1], arrowpropsi))
    
    
bboxstyle = dict(boxstyle="round4,pad=0.5,rounding_size=0.2", fc="w", ec="w", lw=1)
TransTrCANI = ax.text(0.21,0.55, "Reconnaissance CANI par Etat ou CSNU\n(Repression brutale, insurrection)", 
                      color=Color[0], rotation=60., bbox=bboxstyle, **Ar_tparams1)
TransCANITr = ax.text(0.35,0.50, "Dissolution groupes armes\nAccord de paix\nCessez-le-feu", 
                      color=Color[1], rotation=60., bbox=bboxstyle, **Ar_tparams1)
TransCANICAI = ax.text(0.5,0.08, "IME / ONU coerc.\nInsur. control. par Etat tiers.\nEntite non-etat. depuis ter. etran.\nSecession", 
                       color=Color[1], rotation=0., bbox=bboxstyle, **Ar_tparams1)
TransCAICANI = ax.text(0.5,0.26, "Discorde interieure\nAccord paix avec etranger", 
                       color=Color[2], rotation=0., bbox=bboxstyle, **Ar_tparams1)
TransCAITr = ax.text(0.8,0.55, "Discorde interieure\n Accord paix avec etranger", 
                     color=Color[2], rotation=-60, bbox=bboxstyle, **Ar_tparams1)
TransTrCAI = ax.text(0.65,0.50, "IME / ONU coerc.\nEntit. non-etat. dep. ter. etran.\nInsur. pilotes par etran.", 
                     color=Color[0], rotation=-60, bbox=bboxstyle, **Ar_tparams1)   
    
plt.draw()  

#fig.savefig('Schema_Conflictualite.png', bbox_inches=0)

Frises Chronologiques


In [108]:
######## Théorie des RI : Vue d'ensemble ###########

figW, figH = 17, 8
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

Xmin, Xmax = 1900,2014
Ymin, Ymax = 0, 10
DX, DY = Xmax-Xmin, Ymax-Ymin
LimY1 = Ymax-DY/4.
ax.set_xlim(Xmin,Xmax)
ax.set_ylim(Ymin,Ymax)

Ec = [(1.,1.,1.,1.), (0.,0.,0.,1.), (0.8,0.8,0.8,1.) ]
Fc = [(1.,1.,1.,1.), (0.,0.,0.,1.), (0.8,0.8,0.8,1.), (1.,0.8,0.8,1.), (0.8,1.,0.8,1.), (0.8,0.8,1.,1.), (0.,0.8,0.8,1.), (0.8,0.,0.8,1.), (0.8,0.8,0.,1.) ] 
Boxstyle = ["square,pad=0.0", "round,pad=0.0,rounding_size=0.5", "round,pad=0.5,rounding_size=0.5"]
FSize = [8, 10, 12, 15, 18, 20]
FontDict = {'va':'center','ha':'center'}

################## Debats
RotDeb = 60.
X1, X2, Y1, Y2 = 1918, 1939, LimY1, Ymax
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[2], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$1^{ier}$ debat :}\\"Pourquoi ?"\\$=>$ Realistes vs Idealistes', size=FSize[2], color='k', rotation=RotDeb,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1955, 1965, LimY1, Ymax
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[2], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$2^{ieme}$ debat :}\\"Comment ?"\\$=>$ Behaviouralistes', size=FSize[2], color='k', rotation=RotDeb,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1970, 1980, LimY1, Ymax
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[2], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$3^{ieme}$ debat :}\\"Sur quoi ?"\\$=>$ Neo-Realistes vs Globalistes', size=FSize[2], color='k', rotation=RotDeb,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1995, 2005, LimY1, Ymax
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[2], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$4^{ieme}$ debat :}\\"Faisable ?"\\$=>$ (Post-)positivistes', size=FSize[2], color='k', rotation=RotDeb,**FontDict)
ax.add_patch(p_Deb)

###################### Courants
Inc = DY/10.
X1, X2, Y1, Y2 = 1900, 2014, LimY1-Inc, LimY1
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[3], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Realisme :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1918, 2014, LimY1-2.*Inc, LimY1-Inc
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[4], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Liberalisme :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1970, 2014, LimY1-3.*Inc, LimY1-2.*Inc
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[5], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Transnationalisme :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1970, 2014, LimY1-4.*Inc, LimY1-3.*Inc
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[6], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Marxisme :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1990, 2014, LimY1-5.*Inc, LimY1-4.*Inc
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[7], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Approches radicales :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 2000, 2014, LimY1-6.*Inc, LimY1-5.*Inc
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc=Fc[8], zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{Constructivisme :}', size=FSize[2], color='k', rotation=0,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1914, 1918, Ymax-2.*DY/3., LimY1
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc='y', zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$1^{iere}$ Guerre Mondiale}', size=FSize[3], color='k', rotation=80.,**FontDict)
ax.add_patch(p_Deb)

X1, X2, Y1, Y2 = 1939, 1945, Ymax-2.*DY/3., LimY1
Bb_Deb = mtransforms.Bbox([[X1, Y1], [X2, Y2]])
p_Deb = mpatches.FancyBboxPatch((Bb_Deb.xmin, Bb_Deb.ymin), abs(Bb_Deb.width), abs(Bb_Deb.height),boxstyle=Boxstyle[0],ec=Ec[1],fc='y', zorder=1.)
t_Deb = ax.text((X1+X2)/2.,(Y1+Y2)/2.,r'\underline{$2^{ieme}$ Guerre Mondiale}', size=FSize[3], color='k', rotation=80.,**FontDict)
ax.add_patch(p_Deb)


####### Auteurs ##########

class Auteurs():
    def __init__(self,Name,Birth,Death,Publis):
        self.Name, self.BD, self.Publis = Name, Birth+"-"+Death, Publis

class Publis():
    def __init__(self,Title,Trend,Year):
        self.Title, self.Trend, self.Year = Title, Trend, Year
        
HM1 = Publis("In Defense of the National Interest","Realiste",1951)
HM = Auteurs("H. Morgenthau","1904","1980",[HM1])
RA1 = Publis("Qu'est-ce qu'une théorie des Relations Internationales","Realiste-Liberal",1967)
RA = Auteurs("R. Aron","1905","1983",[RA1])
KW1 = Publis("Theory of international politics", "Neo-Realiste", 1971)   
KW = Auteurs("K. Waltz","1924","2013",[KW1])
JM1 = Publis("The tragedy of Great Power Politics","Realiste offensif",2001)
JM = Auteurs("J. Mearsheimer","1947","...",[JM1])
RG1 = Publis("War and Change in World Politics","Neo-Realiste",1981)
RG = Auteurs("R. Gilpin","1930","...",[RG1])

Aut = [HM,RA,KW,JM,RG]    
Ar = dict(arrowstyle="-",connectionstyle="arc3,rad=0.0")
for Au in Aut:
    for Pub in Au.Publis:
        ax.plot(Pub.Year,(Ymax+Ymin)/2.,marker="o",color="k")
        YT = Ymax-5*DY/6.-DY/100.
        t = ax.text(Pub.Year,YT,Au.Name+" ("+str(Pub.Year)+")",rotation=30.,ha="right",va="top")
        ax.annotate("", xy=(1.,1.), xycoords=t, xytext=(Pub.Year,(Ymin+Ymax)/2.), textcoords='data',arrowprops=Ar)

plt.draw()

ToFu


In [34]:
# Global picture, v1

from matplotlib._png import read_png
from matplotlib.cbook import get_sample_data
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox

figW, figH = 14.5, 9
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, BoxToFu, Fc, Ec, Alpha = "round,pad=0.01", "round,pad=0.02", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
Title_tparams = {'size':15,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Com_tparams = {'size':10,'ha':'center', 'va':'top', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ann_tparams = {'size':13,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams1 = {'size':10,'ha':'center', 'va':'center', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams2 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams3 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=10)

Title, Com, Pos, Color, Box, ls = [], [], [], [], [], []       

Title.append(r"ToFu\_Geom v0.1")
Com.append("3D geometry of the diagnostic\nComputes geometrical quantities\nProvides visualisation tools")
Pos.append((0.27,0.85)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Mesh v0.1")
Com.append("B-splines + variable mesh\nProvides visualisation tools")
Pos.append((0.26,0.46)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_MatComp v0.1")
Com.append("Geometry matrix computation\n3D or LOS approach\nFitting tools for synthetic diag.\nProvides visualisation tools")
Pos.append((0.45,0.65)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Inv v0")
Com.append("Various algorithms available\nProvides visualisation tools")
Pos.append((0.58,0.45)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Data")
Com.append("Data treatment\nVisualisation")
Pos.append((0.60,0.60)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"General\_Geom v0.1")
Com.append("Provides general geometry tools")
Pos.append((0.27,0.63)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('dashed')

Title.append(r"Pigasus / CAID")
Com.append("Advanced adaptative mesh")
Pos.append((0.35,0.30)), Color.append((0.,1.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Experimental measurements")
Com.append("+ constraints (e.g: magnetic field)")
Pos.append((0.90,0.55)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Simulated emissivity")
Com.append("Impurity transport (TRANSP...)\nMHD code (JOREK...)\nGirokinetics (GYSELA...)\nFast electrons (LUKE...)\nOthers...")
Pos.append((0.40,0.15)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Inversions + GUI")
Com.append("(from experiment)")
Pos.append((0.64,0.23)), Color.append((1.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Synthetic measurements")
Com.append("(from simulated emissivity)")
Pos.append((0.90,0.86)), Color.append((1.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Input geometry")
Com.append("(position of all detectors)")
Pos.append((0.09,0.85)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Discretisation")
Com.append("(mesh + basis functions)")
Pos.append((0.09,0.45)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Choice of inversion method")
Com.append("(Phillips-Tikhonov type)")
Pos.append((0.90,0.42)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_PathFile")
Com.append("(small module handling paths/files\nmay be called by any module)")
Pos.append((0.63,0.94)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Default")
Com.append("(Default parameters storage\nfor computation and plotting)")
Pos.append((0.63,0.84)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Load")
Com.append("Tokamak-specific\ndata loading\n(AUG\nJET\nWEST\nCompass...)")
Pos.append((0.72,0.64)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

TxTitle, TxCom, bb, fb = [], [], [], []
Zorder = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,101]
for i in range(0,len(Title)):
    TxTitle.append(ax.text(Pos[i][0],Pos[i][1], Title[i], color=Color[i], zorder=Zorder[i], **Title_tparams))
    TxCom.append(ax.text(Pos[i][0],Pos[i][1]-0.01, Com[i], color=Color[i], zorder=Zorder[i], **Com_tparams))

plt.draw()

RootPath = "/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/"
imf = [RootPath+"Tutor_Geom.png",RootPath+"Tutor_Mesh.png",RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Meas.png", RootPath+"Tutor_Meas.png"]
imz = [0.16, 0.16, 0.2, 0.2, 0.3, 0.3]
imP = [(0.37,0.84), (0.35,0.45), (0.52,0.11), (0.63,0.11), (0.89,0.77), (0.89,0.64)]

imb, ab = [], []
for ii in range(0,len(imf)):
    fn = get_sample_data(imf[ii], asfileobj=False)
    arr_lena = read_png(fn)
    imb.append(OffsetImage(arr_lena, zoom=imz[ii]))
    ab.append(AnnotationBbox(imb[ii], imP[ii],xybox=imP[ii],xycoords='data',boxcoords="data",pad=0., bboxprops={'ls':None,'ec':'w'}))
    ax.add_artist(ab[ii])

Im = [[ab[0]],[ab[1]],[],[],[],[],[],[ab[5]],[ab[2]],[ab[3]],[ab[4]],[],[],[],[],[],[]]
Zorder = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,100]
for i in range(0,len(Title)):
    Txpatch = TxCom[i].get_window_extent()   
    Lim = Txpatch.transformed(ax.transData.inverted())
    DX = Lim.xmax-Lim.xmin
    #TxCom[i].set_x(Pos[i][0]-DX/2.)
    bb.append(common_bbox(ax, [TxTitle[i], TxCom[i]]+Im[i]))
    fb.append(draw_bbox_fancy(ax, bb[i], False, True, BoxS, Color[i], 'w', ls=ls[i],zorder=Zorder[i]))
    
TxToFu = ax.text(0.45,0.92, r"ToFu", color='k', size=30,ha='center',va='bottom') 
bbToFu = common_bbox(ax, [TxToFu]+TxTitle[:6]+TxCom[:6]+TxTitle[14:16]+TxCom[14:16]+ab[:2])
fbToFu = draw_bbox_fancy(ax, bbToFu, False, True, BoxToFu, 'k', 'w',lw=2.,zorder=0)    

ArCol, ArAng, ArBox, ArPos = [], [], [], []

ArCol.append('k'), ArBox.append([bb[5],bb[0]]), ArAng.append((55,80)), ArPos.append([(0.5,1.),(0.5,0.)])
#ArCol.append('k'), ArBox.append([bb[5],bb[1]]), ArAng.append((-55,100)), ArPos.append([(0.5,0.),(0.5,1.)])
ArCol.append('k'), ArBox.append([bb[5],bb[2]]), ArAng.append((10,170)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Color[0]), ArBox.append([bb[0],bb[2]]), ArAng.append((-20,110)), ArPos.append([(1.,0.5),(0.2,1.)])
ArCol.append('r'), ArBox.append([bb[0],bb[10]]), ArAng.append((-20,180)), ArPos.append([(1.,0.1),(0.,0.3)])
ArCol.append(Color[1]), ArBox.append([bb[1],bb[2]]), ArAng.append((20,-110)), ArPos.append([(1.,0.5),(0.2,0.)])
ArCol.append(Color[2]), ArBox.append([bb[2],bb[3]]), ArAng.append((-20,110)), ArPos.append([(1.,0.3),(0.3,1.)])
ArCol.append(Color[7]), ArBox.append([bb[7],bb[4]]), ArAng.append((160,20)), ArPos.append([(0.,0.6),(1.,0.6)])
ArCol.append(Color[4]), ArBox.append([bb[4],bb[3]]), ArAng.append((-140,90)), ArPos.append([(0.5,0.),(0.6,1.)])
ArCol.append('r'), ArBox.append([bb[4],bb[7]]), ArAng.append((-20,-160)), ArPos.append([(1.,0.4),(0.,0.4)])
ArCol.append('r'), ArBox.append([bb[3],bb[9]]), ArAng.append((-100,130)), ArPos.append([(0.5,0.),(0.4,1.)])
ArCol.append('r'), ArBox.append([bb[2],bb[10]]), ArAng.append((40,-180)), ArPos.append([(1.,0.7),(0.,0.3)])
ArCol.append('b'), ArBox.append([bb[11],bb[0]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append('b'), ArBox.append([bb[12],bb[1]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append('b'), ArBox.append([bb[8],bb[2]]), ArAng.append((100,-130)), ArPos.append([(0.35,1.),(0.5,0.)])
ArCol.append('b'), ArBox.append([bb[8],bb[1]]), ArAng.append((150,-120)), ArPos.append([(0.,0.5),(0.4,0.)])
ArCol.append('b'), ArBox.append([bb[13],bb[3]]), ArAng.append((160,20)), ArPos.append([(0.,0.5),(1.,0.5)])
ArCol.append('b'), ArBox.append([bb[8],bb[0]]), ArAng.append((163,-148)), ArPos.append([(0.,0.5),(0.,0.1)])

Ar = []
for i in range(0,len(ArCol)):
    arrowpropsi = arrowprops
    arrowpropsi['color'] = ArCol[i]
    arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(ArAng[i][0]) + ',angleB=' + str(ArAng[i][1])
    Ar.append(link_fancyArrow(ax, ArBox[i][0], ArPos[i][0], ArBox[i][1], ArPos[i][1], arrowpropsi))
    
fb[6].set_zorder(100)
TxTitle[6].set_zorder(101)
TxCom[6].set_zorder(102)    

In, In2 = ax.text(0.9,0.1, r"Inputs", color='b', **Title_tparams), ax.text(0.80,0.1, r"R", color='w', **Title_tparams)
Out, Out2 = ax.text(0.9,0.05, r"Outputs", color='r', **Title_tparams), ax.text(0.80,0.05, r"R", color='w', **Title_tparams)
arrowpropsi = arrowprops
arrowpropsi['color'] = 'b'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(170) + ',angleB=' + str(10)
link_fancyArrow(ax, common_bbox(ax,[In]), (0.,0.5), common_bbox(ax,[In2]), (1.,0.5), arrowpropsi)
arrowpropsi['color'] = 'r'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(10) + ',angleB=' + str(170)
link_fancyArrow(ax, common_bbox(ax,[Out2]), (1.,0.5), common_bbox(ax,[Out]), (0.,0.5), arrowpropsi)

bbox_props = dict(boxstyle="round,pad=0.2", fc="w", ec="w", lw=None)
ax.text(0.125,0.23, r"Direct", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.19,0.23, r"or", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.27,0.223, r"Projected", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.34,0.23, r"or", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.40,0.23, r"Built-in", color='b', bbox=bbox_props, **Ann_tparams)

plt.draw()  
fig.savefig("/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/Fig_Tutor_BigPicture_General.pdf",frameon=None,bbox_inches=0)

In [38]:
# Global picture, v2 (Synthetic diagnostic)

from matplotlib._png import read_png
from matplotlib.cbook import get_sample_data
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox

figW, figH = 14.5, 9
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, BoxToFu, Fc, Ec, Alpha = "round,pad=0.01", "round,pad=0.02", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
Title_tparams = {'size':15,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Com_tparams = {'size':10,'ha':'center', 'va':'top', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ann_tparams = {'size':13,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams1 = {'size':10,'ha':'center', 'va':'center', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams2 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams3 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=10)

Title, Com, Pos, Color, Box, ls = [], [], [], [], [], []
Grey = (0.9,0.9,0.9,1.)

Title.append(r"ToFu\_Geom v0.1")
Com.append("3D geometry of the diagnostic\nComputes geometrical quantities\nProvides visualisation tools")
Pos.append((0.27,0.85)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Mesh v0.1")
Com.append("B-splines + variable mesh\nProvides visualisation tools")
Pos.append((0.26,0.46)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_MatComp v0.1")
Com.append("Geometry matrix computation\n3D or LOS approach\nFitting tools for synthetic diag.\nProvides visualisation tools")
Pos.append((0.45,0.65)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Inv v0")
Com.append("Various algorithms available\nProvides visualisation tools")
Pos.append((0.58,0.45)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Data")
Com.append("Data treatment\nVisualisation")
Pos.append((0.60,0.60)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"General\_Geom v0.1")
Com.append("Provides general geometry tools")
Pos.append((0.27,0.63)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"Pigasus / CAID")
Com.append("Advanced adaptative mesh")
Pos.append((0.35,0.30)), Color.append((0.,1.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Experimental measurements")
Com.append("+ constraints (e.g: magnetic field)")
Pos.append((0.90,0.55)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Simulated emissivity")
Com.append("Impurity transport (TRANSP...)\nMHD code (JOREK...)\nGirokinetics (GYSELA...)\nFast electrons (LUKE...)\nOthers...")
Pos.append((0.40,0.15)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Inversions + GUI")
Com.append("(from experiment)")
Pos.append((0.64,0.23)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Synthetic measurements")
Com.append("(from simulated emissivity)")
Pos.append((0.90,0.86)), Color.append((1.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Input geometry")
Com.append("(position of all detectors)")
Pos.append((0.09,0.85)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Discretisation")
Com.append("(mesh + basis functions)")
Pos.append((0.09,0.45)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Choice of inversion method")
Com.append("(Phillips-Tikhonov type)")
Pos.append((0.90,0.42)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_PathFile")
Com.append("(small module handling paths/files\nmay be called by any module)")
Pos.append((0.63,0.94)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Default")
Com.append("(Default parameters storage\nfor computation and plotting)")
Pos.append((0.63,0.84)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Load")
Com.append("Tokamak-specific\ndata loading\n(AUG\nJET\nWEST\nCompass...)")
Pos.append((0.72,0.64)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

TxTitle, TxCom, bb, fb = [], [], [], []
Zorder = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,201]
for i in range(0,len(Title)):
    TxTitle.append(ax.text(Pos[i][0],Pos[i][1], Title[i], color=Color[i], **Title_tparams))
    TxCom.append(ax.text(Pos[i][0],Pos[i][1]-0.01, Com[i], color=Color[i], **Com_tparams))

plt.draw()

RootPath = "/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/"
imf = [RootPath+"Tutor_Geom.png",RootPath+"Tutor_Mesh.png",RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Meas.png", RootPath+"Tutor_Meas.png"]
imz = [0.16, 0.16, 0.2, 0.2, 0.3, 0.3]
imP = [(0.37,0.84), (0.35,0.45), (0.52,0.11), (0.63,0.11), (0.89,0.77), (0.89,0.64)]

imb, ab = [], []
for ii in range(0,len(imf)):
    fn = get_sample_data(imf[ii], asfileobj=False)
    arr_lena = read_png(fn)
    imb.append(OffsetImage(arr_lena, zoom=imz[ii]))
    ab.append(AnnotationBbox(imb[ii], imP[ii],xybox=imP[ii],xycoords='data',boxcoords="data",pad=0., bboxprops={'ls':None,'ec':'w'}))
    ax.add_artist(ab[ii])

plt.draw()
Patchdict = dict(alpha=0.9, ec='w', fc='w', visible=True)
bla = hide_image(ab[0].patch, ax, Patchdict)
bla = hide_image(ab[3].patch, ax, Patchdict)

Im = [[ab[0]],[ab[1]],[],[],[],[],[],[ab[5]],[ab[2]],[ab[3]],[ab[4]],[],[],[],[],[],[]]
Zorder = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,200]
for i in range(0,len(Title)):
    Txpatch = TxCom[i].get_window_extent()   
    Lim = Txpatch.transformed(ax.transData.inverted())
    DX = Lim.xmax-Lim.xmin
    #TxCom[i].set_x(Pos[i][0]-DX/2.)
    bb.append(common_bbox(ax, [TxTitle[i], TxCom[i]]+Im[i]))
    fb.append(draw_bbox_fancy(ax, bb[i], False, True, BoxS, Color[i], 'w', ls=ls[i]))
    
TxToFu = ax.text(0.45,0.92, r"ToFu", color='k', size=30,ha='center',va='bottom')
bbToFu = common_bbox(ax, [TxToFu]+TxTitle[:6]+TxCom[:6]+TxTitle[14:16]+TxCom[14:16]+ab[:2])
fbToFu = draw_bbox_fancy(ax, bbToFu, False, True, BoxToFu, 'k', 'w',lw=2.,zorder=0)    

ArCol, ArAng, ArBox, ArPos = [], [], [], []

ArCol.append(Grey), ArBox.append([bb[5],bb[0]]), ArAng.append((55,80)), ArPos.append([(0.5,1.),(0.5,0.)])
#ArCol.append(Grey), ArBox.append([bb[5],bb[1]]), ArAng.append((-55,100)), ArPos.append([(0.5,0.),(0.5,1.)])
ArCol.append(Grey), ArBox.append([bb[5],bb[2]]), ArAng.append((10,170)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Grey), ArBox.append([bb[0],bb[2]]), ArAng.append((-20,110)), ArPos.append([(1.,0.5),(0.2,1.)])
ArCol.append('r'), ArBox.append([bb[0],bb[10]]), ArAng.append((-20,180)), ArPos.append([(1.,0.1),(0.,0.3)])
ArCol.append('k'), ArBox.append([bb[1],bb[2]]), ArAng.append((20,-110)), ArPos.append([(1.,0.5),(0.2,0.)])
ArCol.append(Grey), ArBox.append([bb[2],bb[3]]), ArAng.append((-20,110)), ArPos.append([(1.,0.3),(0.3,1.)])
ArCol.append(Color[7]), ArBox.append([bb[7],bb[4]]), ArAng.append((160,20)), ArPos.append([(0.,0.6),(1.,0.6)])
ArCol.append(Grey), ArBox.append([bb[4],bb[3]]), ArAng.append((-140,90)), ArPos.append([(0.5,0.),(0.6,1.)])
ArCol.append('r'), ArBox.append([bb[4],bb[7]]), ArAng.append((-20,-160)), ArPos.append([(1.,0.4),(0.,0.4)])
ArCol.append(Grey), ArBox.append([bb[3],bb[9]]), ArAng.append((-100,130)), ArPos.append([(0.5,0.),(0.4,1.)])
ArCol.append('r'), ArBox.append([bb[2],bb[10]]), ArAng.append((40,-180)), ArPos.append([(1.,0.7),(0.,0.3)])
ArCol.append(Grey), ArBox.append([bb[11],bb[0]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Grey), ArBox.append([bb[12],bb[1]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append('b'), ArBox.append([bb[8],bb[2]]), ArAng.append((100,-130)), ArPos.append([(0.35,1.),(0.5,0.)])
ArCol.append('b'), ArBox.append([bb[8],bb[1]]), ArAng.append((150,-120)), ArPos.append([(0.,0.5),(0.4,0.)])
ArCol.append(Grey), ArBox.append([bb[13],bb[3]]), ArAng.append((160,20)), ArPos.append([(0.,0.5),(1.,0.5)])
ArCol.append('b'), ArBox.append([bb[8],bb[0]]), ArAng.append((163,-148)), ArPos.append([(0.,0.5),(0.,0.1)])

Ar = []
for i in range(0,len(ArCol)):
    arrowpropsi = arrowprops
    arrowpropsi['color'] = ArCol[i]
    arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(ArAng[i][0]) + ',angleB=' + str(ArAng[i][1])
    Ar.append(link_fancyArrow(ax, ArBox[i][0], ArPos[i][0], ArBox[i][1], ArPos[i][1], arrowpropsi))
    
fb[6].set_zorder(100)
TxTitle[6].set_zorder(101)
TxCom[6].set_zorder(102)    
fb[16].set_zorder(200)
TxTitle[16].set_zorder(201)
TxCom[16].set_zorder(202) 

In, In2 = ax.text(0.9,0.1, r"Inputs", color='b', **Title_tparams), ax.text(0.80,0.1, r"R", color='w', **Title_tparams)
Out, Out2 = ax.text(0.9,0.05, r"Outputs", color='r', **Title_tparams), ax.text(0.80,0.05, r"R", color='w', **Title_tparams)
arrowpropsi = arrowprops
arrowpropsi['color'] = 'b'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(170) + ',angleB=' + str(10)
link_fancyArrow(ax, common_bbox(ax,[In]), (0.,0.5), common_bbox(ax,[In2]), (1.,0.5), arrowpropsi)
arrowpropsi['color'] = 'r'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(10) + ',angleB=' + str(170)
link_fancyArrow(ax, common_bbox(ax,[Out2]), (1.,0.5), common_bbox(ax,[Out]), (0.,0.5), arrowpropsi)

bbox_props = dict(boxstyle="round,pad=0.2", fc="w", ec="w", lw=None)
ax.text(0.125,0.23, r"Direct", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.19,0.23, r"or", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.27,0.223, r"Projected", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.34,0.23, r"or", color='b', bbox=bbox_props, **Ann_tparams)
ax.text(0.40,0.23, r"Built-in", color='b', bbox=bbox_props, **Ann_tparams)

plt.draw()  
fig.savefig("/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/Fig_Tutor_BigPicture_SynthDiag.pdf",frameon=None,bbox_inches=0)

In [43]:
# Global picture, v3 (Tomography)

from matplotlib._png import read_png
from matplotlib.cbook import get_sample_data
from matplotlib.offsetbox import TextArea, DrawingArea, OffsetImage, AnnotationBbox

figW, figH = 14.5, 9
figdpi = 80
fig = plt.figure(facecolor="w",figsize=(figW,figH), dpi=figdpi)
axcolor = 'w'
ax = plt.axes([0, 0, 1, 1],frameon=False, axisbg=axcolor)
ax.axis('off')

BoxS, BoxToFu, Fc, Ec, Alpha = "round,pad=0.01", "round,pad=0.02", (1.,0.5,1.,0.2), (1.,0.2,1.,1.), 0.5
Title_tparams = {'size':15,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'bold','fontstyle':'italic'}
Com_tparams = {'size':10,'ha':'center', 'va':'top', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ann_tparams = {'size':13,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams1 = {'size':10,'ha':'center', 'va':'center', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams2 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
Ar_tparams3 = {'size':10,'ha':'center', 'va':'bottom', 'family':'sans-serif','fontweight':'normal','fontstyle':'italic'}
arrowprops = dict(arrowstyle="fancy,head_length=1,head_width=1,tail_width=0.5",mutation_scale=10)

Title, Com, Pos, Color, Box, ls = [], [], [], [], [], []
Grey = (0.9,0.9,0.9,1.)

Title.append(r"ToFu\_Geom v0.1")
Com.append("3D geometry of the diagnostic\nComputes geometrical quantities\nProvides visualisation tools")
Pos.append((0.27,0.85)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Mesh v0.1")
Com.append("B-splines + variable mesh\nProvides visualisation tools")
Pos.append((0.26,0.46)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_MatComp v0.1")
Com.append("Geometry matrix computation\n3D or LOS approach\nFitting tools for synthetic diag.\nProvides visualisation tools")
Pos.append((0.45,0.65)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Inv v0")
Com.append("Various algorithms available\nProvides visualisation tools")
Pos.append((0.58,0.45)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_Data")
Com.append("Data treatment\n Visualisation")
Pos.append((0.60,0.60)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"General\_Geom v0.1")
Com.append("Provides general geometry tools")
Pos.append((0.27,0.63)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"Pigasus / CAID")
Com.append("Advanced adaptative mesh")
Pos.append((0.35,0.30)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Experimental measurements")
Com.append("+ constraints (e.g: magnetic field)")
Pos.append((0.90,0.55)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Simulated emissivity")
Com.append("Impurity transport (TRANSP...)\nMHD code (JOREK...)\nGirokinetics (GISELA...)\nFast electrons (LUKE...)\nOthers...")
Pos.append((0.40,0.15)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Inversions + GUI")
Com.append("(from experiment)")
Pos.append((0.64,0.23)), Color.append((1.,0.,0.,1.)), Box.append(True), ls.append('solid')

Title.append(r"Synthetic measurements")
Com.append("(from simulated emissivity)")
Pos.append((0.90,0.86)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Input geometry")
Com.append("(position of all detectors)")
Pos.append((0.09,0.85)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Discretisation")
Com.append("(mesh + basis functions)")
Pos.append((0.09,0.45)), Color.append(Grey), Box.append(True), ls.append('solid')

Title.append(r"Choice of inversion method")
Com.append("(Phillips-Tikhonov type)")
Pos.append((0.90,0.42)), Color.append((0.,0.,1.,1.)), Box.append(True), ls.append('solid')

Title.append(r"ToFu\_PathFile")
Com.append("(small module handling paths/files\nmay be called by any module)")
Pos.append((0.63,0.94)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Default")
Com.append("(Default parameters storage\nfor computation and plotting)")
Pos.append((0.63,0.84)), Color.append(Grey), Box.append(True), ls.append('dashed')

Title.append(r"ToFu\_Load")
Com.append("Tokamak-specific\ndata loading\n(AUG\nJET\nWEST\nCompass...)")
Pos.append((0.72,0.64)), Color.append((0.,0.,0.,1.)), Box.append(True), ls.append('solid')

TxTitle, TxCom, bb, fb = [], [], [], []
for i in range(0,len(Title)):
    TxTitle.append(ax.text(Pos[i][0],Pos[i][1], Title[i], color=Color[i], **Title_tparams))
    TxCom.append(ax.text(Pos[i][0],Pos[i][1]-0.01, Com[i], color=Color[i], **Com_tparams))
    
plt.draw()

RootPath = "/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/"
imf = [RootPath+"Tutor_Geom.png",RootPath+"Tutor_Mesh.png",RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Emiss.png", RootPath+"Tutor_Meas.png", RootPath+"Tutor_Meas.png"]
imz = [0.16, 0.16, 0.2, 0.2, 0.3, 0.3]
imP = [(0.37,0.84), (0.35,0.45), (0.52,0.11), (0.63,0.11), (0.89,0.77), (0.89,0.64)]

imb, ab = [], []
for ii in range(0,len(imf)):
    fn = get_sample_data(imf[ii], asfileobj=False)
    arr_lena = read_png(fn)
    imb.append(OffsetImage(arr_lena, zoom=imz[ii]))
    ab.append(AnnotationBbox(imb[ii], imP[ii],xybox=imP[ii],xycoords='data',boxcoords="data",pad=0., bboxprops={'ls':None,'ec':'w'}))
    ax.add_artist(ab[ii])

plt.draw()
Patchdict = dict(alpha=0.9, ec='w', fc='w', visible=True)
bla = hide_image(ab[0].patch, ax, Patchdict)
bla = hide_image(ab[1].patch, ax, Patchdict)
bla = hide_image(ab[4].patch, ax, Patchdict)

Im = [[ab[0]],[ab[1]],[],[],[],[],[],[ab[5]],[ab[2]],[ab[3]],[ab[4]],[],[],[],[],[],[]]

for i in range(0,len(Title)):
    Txpatch = TxCom[i].get_window_extent()   
    Lim = Txpatch.transformed(ax.transData.inverted())
    DX = Lim.xmax-Lim.xmin
    #TxCom[i].set_x(Pos[i][0]-DX/2.)
    bb.append(common_bbox(ax, [TxTitle[i], TxCom[i]]+Im[i]))
    fb.append(draw_bbox_fancy(ax, bb[i], False, True, BoxS, Color[i], 'w', ls=ls[i]))
    
TxToFu = ax.text(0.45,0.92, r"ToFu", color='k', size=30,ha='center',va='bottom')
bbToFu = common_bbox(ax, [TxToFu]+TxTitle[:6]+TxCom[:6]+TxTitle[14:16]+TxCom[14:16]+ab[:2])
fbToFu = draw_bbox_fancy(ax, bbToFu, False, True, BoxToFu, 'k', 'w',lw=2.,zorder=0)    

ArCol, ArAng, ArBox, ArPos = [], [], [], []

ArCol.append(Grey), ArBox.append([bb[5],bb[0]]), ArAng.append((55,80)), ArPos.append([(0.5,1.),(0.5,0.)])
#ArCol.append(Grey), ArBox.append([bb[5],bb[1]]), ArAng.append((-55,100)), ArPos.append([(0.5,0.),(0.5,1.)])
ArCol.append(Grey), ArBox.append([bb[5],bb[2]]), ArAng.append((10,170)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Grey), ArBox.append([bb[0],bb[2]]), ArAng.append((-20,110)), ArPos.append([(1.,0.5),(0.2,1.)])
ArCol.append(Grey), ArBox.append([bb[0],bb[10]]), ArAng.append((-20,180)), ArPos.append([(1.,0.1),(0.,0.3)])
ArCol.append(Grey), ArBox.append([bb[1],bb[2]]), ArAng.append((20,-110)), ArPos.append([(1.,0.5),(0.2,0.)])
ArCol.append('k'), ArBox.append([bb[2],bb[3]]), ArAng.append((-20,110)), ArPos.append([(1.,0.3),(0.3,1.)])
ArCol.append(Color[7]), ArBox.append([bb[7],bb[4]]), ArAng.append((160,20)), ArPos.append([(0.,0.6),(1.,0.6)])
ArCol.append('k'), ArBox.append([bb[4],bb[3]]), ArAng.append((-140,90)), ArPos.append([(0.5,0.),(0.6,1.)])
ArCol.append(Grey), ArBox.append([bb[4],bb[7]]), ArAng.append((-20,-160)), ArPos.append([(1.,0.4),(0.,0.4)])
ArCol.append('r'), ArBox.append([bb[3],bb[9]]), ArAng.append((-100,130)), ArPos.append([(0.5,0.),(0.4,1.)])
ArCol.append(Grey), ArBox.append([bb[2],bb[10]]), ArAng.append((40,-180)), ArPos.append([(1.,0.7),(0.,0.3)])
ArCol.append(Grey), ArBox.append([bb[11],bb[0]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Grey), ArBox.append([bb[12],bb[1]]), ArAng.append((0,160)), ArPos.append([(1.,0.5),(0.,0.5)])
ArCol.append(Grey), ArBox.append([bb[8],bb[2]]), ArAng.append((100,-130)), ArPos.append([(0.35,1.),(0.5,0.)])
ArCol.append(Grey), ArBox.append([bb[8],bb[1]]), ArAng.append((150,-120)), ArPos.append([(0.,0.5),(0.4,0.)])
ArCol.append('b'), ArBox.append([bb[13],bb[3]]), ArAng.append((160,20)), ArPos.append([(0.,0.5),(1.,0.5)])
ArCol.append(Grey), ArBox.append([bb[8],bb[0]]), ArAng.append((163,-148)), ArPos.append([(0.,0.5),(0.,0.1)])

Ar = []
for i in range(0,len(ArCol)):
    arrowpropsi = arrowprops
    arrowpropsi['color'] = ArCol[i]
    arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(ArAng[i][0]) + ',angleB=' + str(ArAng[i][1])
    Ar.append(link_fancyArrow(ax, ArBox[i][0], ArPos[i][0], ArBox[i][1], ArPos[i][1], arrowpropsi))
    
fb[6].set_zorder(100)
TxTitle[6].set_zorder(101)
TxCom[6].set_zorder(102)    
fb[16].set_zorder(200)
TxTitle[16].set_zorder(201)
TxCom[16].set_zorder(202)

In, In2 = ax.text(0.9,0.1, r"Inputs", color='b', **Title_tparams), ax.text(0.80,0.1, r"R", color='w', **Title_tparams)
Out, Out2 = ax.text(0.9,0.05, r"Outputs", color='r', **Title_tparams), ax.text(0.80,0.05, r"R", color='w', **Title_tparams)
arrowpropsi = arrowprops
arrowpropsi['color'] = 'b'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(170) + ',angleB=' + str(10)
link_fancyArrow(ax, common_bbox(ax,[In]), (0.,0.5), common_bbox(ax,[In2]), (1.,0.5), arrowpropsi)
arrowpropsi['color'] = 'r'
arrowpropsi['connectionstyle'] = 'angle3,angleA=' + str(10) + ',angleB=' + str(170)
link_fancyArrow(ax, common_bbox(ax,[Out2]), (1.,0.5), common_bbox(ax,[Out]), (0.,0.5), arrowpropsi)

bbox_props = dict(boxstyle="round,pad=0.2", fc="w", ec="w", lw=None)
ax.text(0.125,0.23, r"Direct", color=Grey, bbox=bbox_props, **Ann_tparams)
ax.text(0.19,0.23, r"or", color=Grey, bbox=bbox_props, **Ann_tparams)
ax.text(0.27,0.223, r"Projected", color=Grey, bbox=bbox_props, **Ann_tparams)
ax.text(0.34,0.23, r"or", color=Grey, bbox=bbox_props, **Ann_tparams)
ax.text(0.40,0.23, r"Built-in", color=Grey, bbox=bbox_props, **Ann_tparams)

plt.draw()  
fig.savefig("/Users/didiervezinet/Documents/Travail/Fusion/PostDoc_AUG/Python_ToFu/Figures/Fig_Tutor_BigPicture_Tomo.png",frameon=None,bbox_inches=0)

In [233]:


In [ ]: