Пример #1
0
    def calc_autocorrelation(self):
        autocor = np.abs(np.fft.fftshift(np.fft.ifft2(
            self.array))) / (len(self.array) * len(self.array))

        if self.plot_graphs == True:
            pq.show(autocor)
            wait = input("AUTO_COR: PRESS ENTER TO FINISH..")
Пример #2
0
def dark_frame():
    ccdop.params.setandapply("LIGHT", 0)
    ccdop.params.setandapply("LED_ENABLE", 0)
    ccdop.integration_time = 1.0
    frame, en = ccdop.capture_frame_integrated_radiometry_manual(tb)
    pg.show(frame, title="dark frame")
    print(en)

    with ccdop.backbias_context(-30.0):
        frame = ccdop.capture_frame_simple()

    return frame
Пример #3
0
def light_frame():
    ccdop.params.setandapply("LED_ENABLE", 1)
    ccdop.integration_time = 1.0
    frame, en = ccdop.capture_frame_integrated_radiometry_manual(tb)
    pg.show(frame, title="light frame")
    print(en)

    with ccdop.backbias_context(-60.0):
        frame = ccdop.capture_frame_simple()

    ccdop.params.setandapply("WIDEINT", 1)

    return frame
Пример #4
0
 def angular_profile_rayave(self,
                            ray_width=1,
                            ang_incr=1,
                            ray_ir=0,
                            ray_or=70):
     '''
     Returns the angular profile of pixel averages within rays.
     Arguments:
         ray_width = Width in pixels of the ray to be summed over (default=1)
         ang_incr = Angular increment of ray iterative rotation (default=1)
         ray_ir = Ray start position as pixels from center (default=0)
         ray_or = Ray end position as pixels from center (default=70)
     Returns:
         2 x 360 / ang_incr array of angles and pixel averages
     '''
     self.calc_r_map()
     self.array = self.array / self.r_map
     self.log_array = np.log(self.array)
     if self.plot_graphs == True:
         pq.show(self.log_array)
         #wait = input("THIS PRESS ENTER TO FINISH..")
     x, y = np.indices(self.log_array.shape)
     center = np.array([(x.max() - x.min()) / 2.0,
                        (x.max() - x.min()) / 2.0])
     x = x - center[0]
     y = y - center[1]
     r = np.hypot(x, y)
     px_angle = np.degrees(np.arctan2(y, x))
     ray_hw = np.floor(ray_width / 2)
     n_rays = 180 / ang_incr
     r_s = center[0] - ray_ir  # ray starting x index
     r_f = center[0] - ray_or  # ray finishing x index
     ray_x = x[(center[0] - ray_hw):(center[0] + ray_hw + 1), r_f:r_s]
     ray_y = y[(center[0] - ray_hw):(center[0] + ray_hw + 1), r_f:r_s]
     ray_r = np.sqrt(ray_x**2 + ray_y**2)
     ray_ang = np.arctan2(ray_y, ray_x)
     output = np.zeros((2, n_rays))
     for i in range(n_rays):
         angle = np.pi * i * ang_incr / 180
         ray_x_rt = np.round((ray_r) * np.cos(ray_ang + angle) + center[0])
         ray_y_rt = np.round((ray_r) * np.sin(ray_ang + angle) + center[1])
         ray_sum = np.sum(self.log_array[ray_x_rt.astype(int),
                                         ray_y_rt.astype(int)])
         output[0, i] = 180 * angle / np.pi
         output[1, i] = ray_sum / len(ray_x)
     self.ang_prof = output
     #normalize
     self.ang_prof[1] = (self.ang_prof[1] - self.ang_prof[1].min()) / (
         self.ang_prof[1].max() - self.ang_prof[1].min())
Пример #5
0
 def plotAttention(self):
     self.attention = getAttention(self)
     self.attention_im = pg.ImageItem(
         self.attention[self.boolWindow.currentIndex]
     )  #this image item is updated with where the rodent is looking
     self.attention_im.setCompositionMode(QPainter.CompositionMode_Plus)
     self.boolWindow.imageview.addItem(self.attention_im)
     self.attentionHeatMap = show(np.mean(self.attention, 0))
def show_sum_with_subtraction(filenames, filenames_to_subtract, factor=1.0):

    total_sum = None

    for filename in filenames:

        print 'Summing file', filename

        file_ = h5py.File(filename, 'r')
        print 'Opened file:', filename
        data = file_['/entry/data/data'][:]
        file_.close()

        print 'Summing', data.shape[0], "frames"
        sum_ = data.sum(axis=0)

        if total_sum is None:
            total_sum = sum_
        else:
            total_sum += sum_

    masked_total_sum = total_sum * mask

    total_sum_to_subtract = None

    for filename in filenames_to_subtract:

        print 'Summing file for subtraction', filename

        file_ = h5py.File(filename, 'r')
        print 'Opened file:', filename
        data = file_['/entry/data/data'][:]
        file_.close()

        print 'Summing', data.shape[0], "frames"
        sum_to_s = data.sum(axis=0)

        if total_sum_to_subtract is None:
            total_sum_to_subtract = sum_to_s
        else:
            total_sum_to_subtract += sum_to_s

    masked_total_sum_to_subtract = total_sum_to_subtract * mask

    subtracted = masked_total_sum - (masked_total_sum_to_subtract * factor)
    image_window = pyqtgraph.show(subtracted)
def show_sum(filenames):

    total_sum = None

    for filename in filenames:

        print 'Summing file', filename

        file_ = h5py.File(filename, 'r')
        print 'Opened file:', filename
        data = file_['/entry/data/data'][:]
        file_.close()

        print 'Summing', data.shape[0], "frames"
        sum_ = data.sum(axis=0)

        if total_sum is None:
            total_sum = sum_
        else:
            total_sum += sum_

    masked_total_sum = total_sum * mask
    image_window = pyqtgraph.show(masked_total_sum)
Пример #8
0
import get_events as ge
import pyqtgraph as pq
import numpy as np
import sys

e=ge.Events(run=131)
frameslist = np.array([54, 159, 1120, 1227, 1228, 3868])
e.get_frameslist(frameslist, False)

n_frames = len(e.frames)
for i in range(0,n_frames):
    pq.show(e.assemble_frame(e.frames[i]))

wait = input("PRESS ENTER TO CONTINUE..")
    
Пример #9
0
import initExample ## Add path to library (just for examples; you do not need this)

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg

app = QtGui.QApplication([])


data = np.random.normal(size=1000)
pg.plot(data, title="Simplest possible plotting example")

data = np.random.normal(size=(500,500))
pg.show(data, title="Simplest possible image example")


## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
    import sys
    if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
        app.exec_()
Пример #10
0
import initExample  ## Add path to library (just for examples; you do not need this)

from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg

app = QtGui.QApplication([])

data = np.random.normal(size=1000)
pg.plot(data, title="Simplest possible plotting example")

data = np.random.normal(size=(500, 500))
pg.show(data, title="Simplest possible image example")

## Start Qt event loop unless running in interactive mode or using pyside.
import sys
if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
    app.exec_()
dd = np.linalg.norm(h_pos_a[ii]-t_pos_a[ii], axis = 1)

plt.figure(70); plt.clf();
plt.plot(dd)



#show the movie

imgs = exp.load_img(t=range(t0,t1));
#imgs = exp.load_img(t=ii);

import pyqtgraph as pg

pg.show(np.transpose(imgs, [0,1,2]))






### pca on oriented head / tail data


center = data["center"].copy();

for i in range(ntimes):
  if reverse[i]:
    center[i] = center[i,::-1];
Пример #12
0
                #wait = input("PRESS ENTER TO FINISH..")
                #print "DONE"

            if merge_data == True:
                m.cummul_sum_det(0, assembled_frame)
                #m.merge_RZ(rotated_image, 0, 0, True)
            if verbose_mode == True:
                print hits1[i].frame, hits1[i].roi_px_mean, hits1[
                    i].phi, '(', hits1[i].phi_peak_to_mean, hits1[
                        i].n_phi_vals, ')  ', hits1[i].sym_res_ave

np.save(file_name, hits1)
print 'Total ', m.frame_count, ' frames merged'

if merge_data == True:
    pq.show(m.cumm_sum / m.frame_count)
    #pq.show(m.merged_data)

#m.merged_data[m.merged_data < 0] = 0
#print np.min(m.merged_data)
#pq.show(m.merged_data)

#p.figure()
#maxval = np.max(m.cumm_sum)
#thresh = 0.05 * 100 / 200
#if thresh < 0.05:
#    thresh = 0.05
#m.cumm_sum[m.cumm_sum > 0.2 * maxval] = 0.2 * maxval
#m.cumm_sum[875,887] = thresh *maxval
#p.matshow(m.cumm_sum, cmap='gnuplot', vmin=0, origin="lower")
#p.show()
Пример #13
0
 def plotAttention(self):
     self.attention=getAttention(self)
     self.attention_im=pg.ImageItem(self.attention[self.boolWindow.currentIndex]) #this image item is updated with where the rodent is looking
     self.attention_im.setCompositionMode(QPainter.CompositionMode_Plus)
     self.boolWindow.imageview.addItem(self.attention_im)
     self.attentionHeatMap=show(np.mean(self.attention,0))
Пример #14
0
        xh = np.arange(0, 10, 0.5)
        yh = np.random.randint(0, 12, 20)
        cu = pg.PlotCurveItem(xh, yh, pen=pg.mkPen('r'))
        bg = pg.BarGraphItem(x0=xh, height=yh, width=0.5, brush='c', pen=None)
        sp = pg.ScatterPlotItem(xh,
                                10 * np.random.random(20),
                                symbol='o',
                                brush=pg.mkBrush('c'))
        #pl = pg.PlotWidget()
        pl1 = win.addPlot(row=0, col=0)
        pl1.addItem(cu)
        pl3 = win.addPlot(row=0, col=1)
        pl3.addItem(sp)
        pl2 = win.addPlot(row=1, col=1)
        pl2.addItem(bg)
        pg.show()
        matplotlibExport(object=win, title=None, show=True)

    if arg == 'gl':
        win = pg.GraphicsWindow()
        gl = QtGui.QGridLayout()
        #   wid = QtGui.QWidget()
        win.setLayout(gl)
        xh = np.arange(0, 10, 0.5)
        yh = np.random.randint(0, 12, 20)
        cu = pg.PlotCurveItem(xh, yh, pen=pg.mkPen('r'))
        bg = pg.BarGraphItem(x0=xh, height=yh, width=0.25, brush='c')
        sp = pg.ScatterPlotItem(xh,
                                10 * np.random.random(20),
                                symbol='o',
                                brush=pg.mkBrush('c'))
Пример #15
0
    if arg == 'win':
        win = pg.GraphicsWindow()
        gl = win.ci.layout # this is a QGraphicsGridLayout()
        xh = np.arange(0, 10, 0.5)
        yh = np.random.randint(0, 12, 20)
        cu = pg.PlotCurveItem(xh, yh, pen=pg.mkPen('r'))
        bg = pg.BarGraphItem(x0=xh, height=yh, width=0.5, brush='c', pen=None)
        sp = pg.ScatterPlotItem(xh, 10*np.random.random(20), symbol='o', brush=pg.mkBrush('c'))
        #pl = pg.PlotWidget()
        pl1 = win.addPlot(row=0, col=0)
        pl1.addItem(cu)
        pl3 = win.addPlot(row=0, col=1)
        pl3.addItem(sp)
        pl2 = win.addPlot(row=1, col=1)
        pl2.addItem(bg)
        pg.show()
        matplotlibExport(object=win, title=None, show=True)

    if arg == 'gl':
        win = pg.GraphicsWindow()
        gl = QtGui.QGridLayout()
     #   wid = QtGui.QWidget()
        win.setLayout(gl)
        xh = np.arange(0, 10, 0.5)
        yh = np.random.randint(0, 12, 20)
        cu = pg.PlotCurveItem(xh, yh, pen=pg.mkPen('r'))
        bg = pg.BarGraphItem(x0=xh, height=yh, width=0.25, brush='c')
        sp = pg.ScatterPlotItem(xh, 10*np.random.random(20), symbol='o', brush=pg.mkBrush('c'))
        pl = pg.PlotWidget()
        gl.addWidget(pl, 0, 0)
        pl.addItem(cu)
plt.axis('equal')

dd = np.linalg.norm(h_pos_a[ii] - t_pos_a[ii], axis=1)

plt.figure(70)
plt.clf()
plt.plot(dd)

#show the movie

imgs = exp.load_img(t=range(t0, t1))
#imgs = exp.load_img(t=ii);

import pyqtgraph as pg

pg.show(np.transpose(imgs, [0, 1, 2]))

### pca on oriented head / tail data

center = data["center"].copy()

for i in range(ntimes):
    if reverse[i]:
        center[i] = center[i, ::-1]

center_file = os.path.join(data_path, 'oriented_center.npy')
np.save(center_file, center)

#calculate new thetas etc

theta_file = os.path.join(data_path, 'oriented_theta.npy')
Пример #17
0
    def setupUi(self, MainWindow):

        # Exemple de liste d'actions
        self.nomsActions = ["Entreprise 1", "Entreprise 2", "Entreprise 3"]

        # Matrice de covariance

        self.Sigma = np.array([[20, -13, 0], [-13, 25, 0], [0, 0, 23]])
        self.Sigma = self.Sigma.astype('d')
        # Retours sur l'investissement moyens

        self.Mu = np.array([1.5, -0.2, 1.3])
        self.Mu = self.Mu.astype('d')

        # Nombre d'assets

        self.nbActions = len(self.nomsActions)

        # Nombre de périodes
        self.nbPer = 400
        # Prix initiaux
        self.init = np.array([40, 40, 40])
        # Risk-free rate
        self.Rf = 0.5
        # Coefficient multiplicatif reliant alpha et 1/lambda
        uns = np.ones(self.nbActions)
        self.coeff_de_prop = np.dot(
            uns, np.dot(np.linalg.inv(self.Sigma), self.Mu)
        )  # Coefficient de proportionalité entre gamma et 1/alpha

        MainWindow.setObjectName("Théorie du Portefeuille de Markovitz")
        MainWindow.resize(1600, 950)
        self.centralWidget = QtWidgets.QWidget(MainWindow)
        self.centralWidget.setObjectName("centralWidget")

        ## Premier onglet:
        self.tabWidget = QtWidgets.QTabWidget(self.centralWidget)
        self.tabWidget.setGeometry(QtCore.QRect(0, 10, 1600, 900))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")

        # On crée une VBox à gauche
        self.VBoxGWidget = QtWidgets.QWidget(self.tab)
        self.VBoxGWidget.setGeometry(QtCore.QRect(30, 10, 300, 600))
        self.VBoxGWidget.setObjectName("VBoxGWidget")
        self.VBoxG = QtWidgets.QVBoxLayout(self.VBoxGWidget)
        self.VBoxG.setContentsMargins(11, 11, 11, 11)
        self.VBoxG.setSpacing(3)
        self.VBoxG.setObjectName("VBoxG")

        # On lui ajoute un label qui servira à guider l'utilisateur
        self.indic_label = QtWidgets.QLabel(self.VBoxGWidget)
        self.indic_label.setMinimumSize(QtCore.QSize(300, 80))
        self.indic_label.setMaximumSize(QtCore.QSize(300, 80))
        self.indic_label.setObjectName("indic_label")
        self.VBoxG.addWidget(self.indic_label)

        # On ajoute les champs des actions à la VBox, un bouton "Valider" et un bouton "Retour"
        self.addChamps(self.nbActions)

        self.validerBouton = QtWidgets.QPushButton(self.tab)
        self.validerBouton.setGeometry(QtCore.QRect(130, 600, 88, 34))
        self.validerBouton.setObjectName("validerBouton")
        self.validerBouton.raise_()

        self.retourBouton = QtWidgets.QPushButton(self.tab)
        self.retourBouton.setGeometry(QtCore.QRect(130, 600, 88, 34))
        self.retourBouton.setObjectName("retourBouton")
        self.retourBouton.raise_()

        self.VBoxGWidget.raise_()

        # On rajoute les n graphiques des actifs
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.tab)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(
            600, 50, 800, 700))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(11, 11, 11, 11)
        self.horizontalLayout.setSpacing(40)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setSpacing(6)
        self.verticalLayout.setObjectName("verticalLayout")

        self.add_N_Graphiques(self.nbActions)

        # On rajoute le repère sur lequel on va représenter les courbes des n actifs
        self.horizontalLayout.addLayout(self.verticalLayout)
        self.graphicsView_n_graphiques = PlotWidget(
            self.horizontalLayoutWidget)
        self.graphicsView_n_graphiques.setObjectName(
            "graphicsView_n_graphiques")
        self.horizontalLayout.addWidget(self.graphicsView_n_graphiques)

        # On fait de même avec le repère où l'on va tracer la frontière de Markovitz

        self.graphicsView_frontiere = PlotWidget(self.horizontalLayoutWidget)
        self.graphicsView_frontiere.setObjectName("graphicsView_frontiere")
        self.horizontalLayout.addWidget(self.graphicsView_frontiere)

        self.tabWidget.addTab(self.tab, "")

        ## Deuxième onglet

        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")

        # On crée une VBox à gauche
        self.VBoxGWidget_2 = QtWidgets.QWidget(self.tab_2)
        self.VBoxGWidget_2.setGeometry(QtCore.QRect(30, 10, 300, 600))
        self.VBoxGWidget_2.setObjectName("VBoxGWidget_2")
        self.VBoxG_2 = QtWidgets.QVBoxLayout(self.VBoxGWidget_2)
        self.VBoxG_2.setContentsMargins(11, 11, 11, 11)
        self.VBoxG_2.setSpacing(3)
        self.VBoxG_2.setObjectName("VBoxG_2")

        # On lui ajoute un label qui servira à guider l'utilisateur
        self.indic_label_2 = QtWidgets.QLabel(self.VBoxGWidget_2)
        self.indic_label_2.setMinimumSize(QtCore.QSize(300, 80))
        self.indic_label_2.setMaximumSize(QtCore.QSize(300, 80))
        self.indic_label_2.setObjectName("indic_label_2")
        self.VBoxG_2.addWidget(self.indic_label_2)

        # On ajoute les champs des actions à la VBox, un bouton "Valider" et un bouton "Retour"
        self.addChamps_2(self.nbActions)

        self.validerBouton_2 = QtWidgets.QPushButton(self.tab_2)
        self.validerBouton_2.setGeometry(QtCore.QRect(130, 600, 88, 34))
        self.validerBouton_2.setObjectName("validerBouton_2")
        self.validerBouton_2.raise_()

        self.retourBouton_2 = QtWidgets.QPushButton(self.tab_2)
        self.retourBouton_2.setGeometry(QtCore.QRect(130, 600, 88, 34))
        self.retourBouton_2.setObjectName("retourBouton_2")
        self.retourBouton_2.raise_()

        self.VBoxGWidget_2.raise_()

        # On rajoute les n graphiques des actifs
        self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.tab_2)
        self.horizontalLayoutWidget_2.setGeometry(
            QtCore.QRect(400, 50, 821, 651))
        self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(
            self.horizontalLayoutWidget_2)
        self.horizontalLayout_2.setContentsMargins(11, 11, 11, 11)
        self.horizontalLayout_2.setSpacing(6)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout()
        self.verticalLayout_2.setSpacing(6)
        self.verticalLayout_2.setObjectName("verticalLayout_2")

        self.add_N_Graphiques_2(self.nbActions)

        # On rajoute le repère sur lequel on va représenter les courbes des n actifs
        self.horizontalLayout_2.addLayout(self.verticalLayout_2)
        self.graphicsView_n_graphiques_2 = PlotWidget(
            self.horizontalLayoutWidget_2)
        self.graphicsView_n_graphiques_2.setObjectName(
            "graphicsView_n_graphiques_2")
        self.horizontalLayout_2.addWidget(self.graphicsView_n_graphiques_2)

        # On fait de même avec le repère où l'on va tracer la frontière de Markovitz

        self.graphicsView_frontiere_2 = PlotWidget(
            self.horizontalLayoutWidget_2)
        self.graphicsView_frontiere_2.setObjectName("graphicsView_frontiere_2")
        self.horizontalLayout_2.addWidget(self.graphicsView_frontiere_2)

        self.tabWidget.addTab(self.tab_2, "")

        # Troisième onglet: paramètres
        self.tab_3 = QtWidgets.QWidget()
        self.tab_3.setObjectName("tab_3")

        # Code pour l'onglet "Paramètres"

        # Liste des paramètres modifiables:
        self.params = [
            {
                'name':
                'Paramètres principaux',
                'type':
                'group',
                'children': [
                    {
                        'name': "Nombre d'actifs considérés",
                        'type': 'int',
                        'value': 3
                    },
                    {
                        'name': "Nombre de périodes",
                        'type': 'int',
                        'value': 400
                    },
                    {
                        'name': "Taux d'intérêt de l'actif sans risque",
                        'type': 'float',
                        'value': 0.5,
                        'step': 0.1
                    },
                    {
                        'name': "Secteurs considérés",
                        'type': 'list',
                        'values':
                        ["Tous", "Banque", "Automobile", "High Tech"],
                        'value': 2
                    },
                    {
                        'name': 'Numéro de poste',
                        'type': 'int',
                        'value': 1
                    },
                    {
                        'name': 'Aversion au risque imposée',
                        'type': 'bool',
                        'value': False,
                        'tip': "Aversion au risque imposée"
                    },
                    {
                        'name': 'Modifier la matrice de covariance',
                        'type': 'action'
                    },
                ]
            },
            {
                'name':
                'Sauvegarder paramètres/Annuler modifications actuelles',
                'type':
                'group',
                'children': [
                    {
                        'name': 'Sauvegarder',
                        'type': 'action'
                    },
                    {
                        'name': 'Annuler modifications actuelles',
                        'type': 'action'
                    },
                ]
            },
            #{'name': 'Aversion au risque imposée', 'type': 'float', 'value': 1.2e6, 'siPrefix': True, 'suffix': 'Unités', 'readonly': True},
            ComplexParameter(
                self.coeff_de_prop,
                name=
                'Aversion au risque et proportion du portefeuille de marché')
        ]

        # On crée un arbre de paramètres:

        self.p = Parameter.create(name='params',
                                  type='group',
                                  children=self.params)
        self.p.sigTreeStateChanged.connect(self.change)

        # On connecte chaque champ de paramètre à la fonction valueChanging, qui gère
        # ce qui se passe quand on modifie le champ

        for child in self.p.children():
            child.sigValueChanging.connect(self.valueChanging)
            for ch2 in child.children():
                ch2.sigValueChanging.connect(self.valueChanging)
        self.p.param('Sauvegarder paramètres/Annuler modifications actuelles',
                     'Sauvegarder').sigActivated.connect(self.save)
        self.p.param('Sauvegarder paramètres/Annuler modifications actuelles',
                     'Annuler modifications actuelles').sigActivated.connect(
                         self.restore)
        self.p.param('Paramètres principaux',
                     'Modifier la matrice de covariance').sigActivated.connect(
                         self.matrice_de_cov)

        # On crée le widget associé à l'arbre de paramètres

        self.t = ParameterTree()
        self.t.setParameters(self.p, showTop=False)
        self.t.setWindowTitle('Arbre de paramètres')
        self.layout = QtGui.QGridLayout()
        self.tab_3.setLayout(self.layout)
        self.layout.addWidget(self.t, 1, 0, 1, 1)

        # test sauvegarder/rétablir
        self.s = self.p.saveState()
        self.p.restoreState(self.s)

        if parametres == True:
            self.tabWidget.addTab(self.tab_3, "")

        # Quatrième onglet: mesurer l'aversion au risque

        self.tab_4 = QtWidgets.QWidget()
        self.tab_4.setObjectName("tab_4")
        if aversion_au_risque == True:
            self.tabWidget.addTab(self.tab_4, "")

#######################################CHANTIER#########################################
        vb = pg.ViewBox()
        vb.setAspectLocked(True)
        img = pg.ImageItem(np.zeros((200, 200)))
        vb.addItem(img)
        vb.setRange(QtCore.QRectF(0, 0, 200, 200))

        # Coefficient multiplicatif reliant alpha et 1/lambda
        uns = np.ones(self.nbActions)
        self.coeff_de_prop = np.dot(
            uns, np.dot(np.linalg.inv(self.Sigma), self.Mu)
        )  # Coefficient de proportionalité entre gamma et 1/alpha

        ## start drawing with 3x3 brush
        kern = np.array([[0.0, 10, 0.0], [10, 10.0, 10], [0.0, 10, 0.0]])
        img.setDrawKernel(kern, mask=kern, center=(1, 1), mode='add')
        img.setLevels([0, 10])
        ##        yScale = pg.AxisItem(orientation='left', linkView=vb)
        if chantier:
            pg.show()
#        xScale = pg.AxisItem(orientation='bottom', linkView=vb)
##        l.addItem(xScale, 1, 1)
##        l.addItem(yScale, 0, 0)
#        pw = pg.PlotWidget(self.tab_4,viewBox=vb, axisItems={'bottom': xScale}, enableMenu=False, title="PlotItem with custom axis and ViewBox<br>Menu disabled, mouse behavior changed: left-drag to zoom, right-click to reset zoom")
#        pw.show()
#        pw = pg.PlotWidget(self.tab_4,viewBox=vb, axisItems={'bottom': xScale}, enableMenu=False, title="PlotItem with custom axis and ViewBox<br>Menu disabled, mouse behavior changed: left-drag to zoom, right-click to reset zoom")
#        pw.show()

## On crée une fenêtre avec un Widget GraphicsView
#        self.w = pg.GraphicsView(self.tab_4)
#        self.w.show()
#        self.w.resize(800,800)
#        self.w.setWindowTitle('pyqtgraph example: Draw')
#
#        self.view = pg.ViewBox()
#        self.w.setCentralItem(self.view)
#
#        ## lock the aspect ratio
#        self.view.setAspectLocked(True)
#
#        ## Create image item
#        self.img = pg.ImageItem(np.zeros((200,200)))
#        self.view.addItem(self.img)
#
#
#
#        ## Set initial view bounds
#        self.view.setRange(QtCore.QRectF(0, 0, 200, 200))
#
#        ## start drawing with 3x3 brush
#        kern = np.array([
#                [0.0, 10, 0.0],
#                [10, 10.0, 10],
#                [0.0, 10, 0.0]
#                ])
#        self.img.setDrawKernel(kern, mask=kern, center=(1,1), mode='add')
#        self.img.setLevels([0, 10])
#
#        self.view.setMouseEnabled(False,False)
##        self.layout_gamma = QtGui.QGridLayout()
##        self.tab_4.setLayout(self.layout_gamma)
##        self.layout_gamma.addWidget(self.w, 1, 0, 1, 1)

#####FINCHANTIER
# Autres

        MainWindow.setCentralWidget(self.centralWidget)
        self.menuBar = QtWidgets.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 1212, 26))
        self.menuBar.setObjectName("menuBar")
        MainWindow.setMenuBar(self.menuBar)
        self.mainToolBar = QtWidgets.QToolBar(MainWindow)
        self.mainToolBar.setObjectName("mainToolBar")
        MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QtWidgets.QStatusBar(MainWindow)
        self.statusBar.setObjectName("statusBar")
        MainWindow.setStatusBar(self.statusBar)

        self.retranslateUi(MainWindow)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)