Beispiel #1
0
def pipeline(img, isVideo=False):
    # Image Preprocessing
    undst, binary, binary_warped = PreProcessing.preprocess_image(img)

    # Lane Detection Code Start
    lanes, leftx, lefty, rightx, righty, ploty = LaneFinding.get_lane_lines(
        binary_warped, isVideo)

    lcurve, rcurve = Support.get_real_lanes_curvature(ploty, leftx, lefty,
                                                      rightx, righty)

    output = draw_lane_area(undst, binary_warped, ploty, leftx, lefty, rightx,
                            righty, isVideo)

    left_fit, right_fit, dummy = Support.fit_polylines(binary_warped.shape[0],
                                                       leftx,
                                                       lefty,
                                                       rightx,
                                                       righty,
                                                       x_scale_factor=1,
                                                       y_scale_factor=1)

    left_fitx, right_fitx = Support.get_polylines_points(
        ploty, left_fit, right_fit)

    if (isVideo is True):
        lcurve, rcurve = getSmoothedCurveData(lcurve, rcurve)
        left_fitx, right_fitx = getSmoothedLanesData(left_fitx, right_fitx)

    shiftFromLaneCenter_m, side = calculate_shift_from_lane_center(
        binary_warped, left_fitx, right_fitx)

    Font = cv2.FONT_HERSHEY_SIMPLEX
    color = (255, 255, 255)
    cv2.putText(output, 'curve = ' + str((lcurve + rcurve) / 2) + ' m',
                (10, 100), Font, 1, color, 2, cv2.LINE_AA)

    cv2.putText(
        output, 'Vehicle is ' + str(shiftFromLaneCenter_m) + ' (m) ' + side +
        ' of lane center', (10, 150), Font, 1, color, 2, cv2.LINE_AA)
    # Lane Detection Code End

    # Vehicle Detection Code Start
    cars_boxs = get_classified_cars_boxs(undst)
    classified_boxs = Visualisation.draw_boxes(undst,
                                               cars_boxs,
                                               color=(0, 0, 255),
                                               thick=6)
    filtered_boxs, heat_map = get_heat_map_boxs(cars_boxs, undst, isVideo)
    output = Visualisation.draw_boxes(output,
                                      filtered_boxs,
                                      color=(0, 0, 255),
                                      thick=6)
    # Vehicle Detection Code End

    return undst, classified_boxs, heat_map, output
Beispiel #2
0
    def __init__(self, Sfilename, model='Net1_FFN_v7', verbose=False):
        self.index = 0
        self.settingfuncs = [self.setting1, self.setting2, self.setting3,
                             self.setting4, self.setting5, self.setting6,
                             self.setting7, self.setting8]
        if isinstance(model, str):
            self.modelname = model

            self.model = FFN(model)
            self.model.Load(verbose=verbose)

        elif isinstance(model, FFN):
            self.model = model
            self.modelname = self.model.name

        mask1, pmask1 = self.model.apply_mask(Sfilename)

        rgb, self.TitleStr = Vis.FalseColour(Sfilename, False)

        scn = DL.scene_loader(Sfilename)
        scn.load(['bayes_in', 'probability_cloud_single_in'])
        bmask = DL.upscale_repeat(scn['bayes_in'].values).astype('int')
        bmask = 1 - ((bmask & 2) / 2)
        bpmask = DL.upscale_repeat(scn['probability_cloud_single_in'].values)

        self.im1 = plt.imshow(rgb)
        plt.title('False colour image\n' + self.TitleStr)

        self.im2 = plt.imshow(mask1, cmap='Blues')
        self.im2.set_visible(False)

        bmask = DL.extract_mask(Sfilename, 'bayes_in', 2)
        self.im3 = plt.imshow(bmask, cmap='Reds')
        self.im3.set_visible(False)

        mask1 = mask1.astype('bool')
        temp = np.copy(rgb)
        temp[~mask1, :] = 254 / 255, 253 / 255, 185 / 255
        self.im4 = plt.imshow(temp)
        self.im4.set_visible(False)

        rgb[mask1, :] = 74 / 255, 117 / 255, 50 / 255
        self.im5 = plt.imshow(rgb)
        self.im5.set_visible(False)

        self.im6 = plt.imshow(1 - pmask1, cmap='Oranges')
        self.im6.set_visible(False)

        self.im7 = plt.imshow(1 - bpmask, cmap='Reds')
        self.im7.set_visible(False)

        maskdiff = bmask - mask1
        self.im8 = plt.imshow(maskdiff, cmap='bwr')
        self.im8.set_visible(False)

        self.cbset = False
        self.cb = None
    def plot_pixels(self, datacol='Agree'):
        """
        Plots the value of data for each pixel on map.

        Parameters
        ----------
        datacol: str
            Name of dataframe column to use for colouring pixels on map

        Returns
        ----------
        None
        """
        if datacol in ['Agree', 'CTruth', 'Labels', 'Label_Confidence']:
            self._model_applied()

        Vis.plot_poles(self._obj['latitude_an'].values,
                       self._obj['longitude_an'].values,
                       self._obj[datacol].values)
    def plot_poles_gridded(self, datacol='Agree'):
        if datacol in ['Agree', 'CTruth', 'Labels', 'Label_Confidence']:
            self._model_applied()

        lat = self._obj['latitude_an'].values
        lon = self._obj['longitude_an'].values
        data = self._obj['Agree'].values

        lat = np.round_(lat, 1)
        lon = np.round_(lon, 1)

        pos = list(zip(lat, lon, data))

        upos = list(set(pos))
        upos.sort()

        cnt = Counter(pos)

        Tpos = list(zip(lat, lon, [True] * len(lat)))
        Fpos = list(zip(lat, lon, [False] * len(lat)))

        Tpos.sort()
        Fpos.sort()

        NTrues = []
        NFalses = []

        for i in Tpos:
            NTrues.append(cnt[i])

        for i in Fpos:
            NFalses.append(cnt[i])

        Means = []

        for i in range(len(NTrues)):
            Means.append(NTrues[i] / (NTrues[i] + NFalses[i]))

        ulat = [i[0] for i in upos]
        ulon = [i[1] for i in upos]

        Vis.plot_poles(ulat, ulon, Means, 1.5)
Beispiel #5
0
    def creerPanelMatplotlib(self):

        #initialisation de la visualisation
        self.Visu = Visualisation(self, self.model.Aquifere.getVarList())
        sizerVisu = wx.BoxSizer(wx.VERTICAL)

        #ajout d'un item avec une proportion dans le sizer (95% et 5% ici) avec comme flag wxExpand
        sizerVisu.Add(self.Visu, 95, wx.EXPAND)
        basSizer = wx.BoxSizer(wx.HORIZONTAL)
        basSizer.Add(self.Visu.GetToolBar(), 0)
        self.pos = wx.StaticText(self, -1, ' x: y:', size=(100, 40))
        self.pos.SetOwnBackgroundColour('LIGHT GRAY')
        basSizer.Add(self.pos, 5, wx.EXPAND)
        self.notify = wx.StaticText(self, -1, '')
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.notify.SetFont(font)
        self.notify.SetOwnForegroundColour('RED')
        basSizer.AddSpacer((0, 5), 0)
        basSizer.Add(self.notify, 5, wx.EXPAND)
        sizerVisu.Add(basSizer, 5, wx.EXPAND)
        self.matplot = sizerVisu
        self.model.setVisu(self.Visu)
        self.Visu.setVisu(self.model, self.model.getGlist())
Beispiel #6
0
    def visualise(self, actor_c, starting_state, delay):
            state = copy.deepcopy(starting_state)
            visualiser = Visualisation(state)
            vis = visualiser.visualise()
            plt.show()
            while state.check_game_score() == 0:
                visualiser.make_dead(state.get_board())
                vis = visualiser.visualise()
                if delay > 0:
                    plt.show(block = False)
                    plt.pause(delay)
                    plt.close()
                else: 
                    plt.show(block = True)

                action = actor_c.choose_action(state.state(), state.get_available_moves(), 0)
                state.move(action)
            visualiser.make_dead(state.get_board())
            vis = visualiser.visualise()
            plt.show()
Beispiel #7
0
    def creerPanelMatplotlib(self):

        # initialisation de la visualisation
        self.Visu = Visualisation(self, self.model.Aquifere.getVarList())
        sizerVisu = wx.BoxSizer(wx.VERTICAL)

        # ajout d'un item avec une proportion dans le sizer (95% et 5% ici) avec comme flag wxExpand
        sizerVisu.Add(self.Visu, 95, wx.EXPAND)
        basSizer = wx.BoxSizer(wx.HORIZONTAL)
        basSizer.Add(self.Visu.GetToolBar(), 0)
        self.pos = wx.StaticText(self, -1, " x: y:", size=(100, 40))
        self.pos.SetOwnBackgroundColour("LIGHT GRAY")
        basSizer.Add(self.pos, 5, wx.EXPAND)
        self.notify = wx.StaticText(self, -1, "")
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.notify.SetFont(font)
        self.notify.SetOwnForegroundColour("RED")
        basSizer.AddSpacer((0, 5), 0)
        basSizer.Add(self.notify, 5, wx.EXPAND)
        sizerVisu.Add(basSizer, 5, wx.EXPAND)
        self.matplot = sizerVisu
        self.model.setVisu(self.Visu)
        self.Visu.setVisu(self.model, self.model.getGlist())
Beispiel #8
0
from Visualisation import *
from Simulator import *
import time

# Configuratie
VISUALISATION = True

if __name__ == "__main__":
    w = World(10)
    sim = Simulator(w)

    if VISUALISATION:
        vis = Visualisation(sim)
    else:
        while True:
            # Create new world and print to screen
            print(sim.update())
            # slow down simulation
            time.sleep(0.5)
Beispiel #9
0
        Initialises all textures 
        '''
        BUFFER_LEVEL = self._bufferLevel
        BUFFER_RESOLUTION = self._length
        self._levels = list()
        
        # Creates a new textures group 
        tex = (c_uint * (BUFFER_LEVEL + 1))(0)
        glGenTextures(BUFFER_LEVEL + 1, tex)
        tex[0] = self._inputID
        
        # Make lower-resolution texture images
        for i in range(0,BUFFER_LEVEL+1):
            # Set up level object
            size = int(BUFFER_RESOLUTION / math.pow(2,i))
            # (Note: Don't reduce the last, 1x1 texture...)
            if i < BUFFER_LEVEL:
                self._levels.append(ReductionLevel(tex[i],size,tex[i+1],self._quadList))
            if i > 0:
                # Set up texture
                glBindTexture(GL_TEXTURE_2D, tex[i])
                # Set texture parameters
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)  
                # Define texture with floating point format
                glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA32F,size, size,0,GL_RGBA,GL_FLOAT,0)

if __name__=="__main__":
    import Visualisation
    Visualisation.GadgetTest()
Beispiel #10
0
def mask_debug(Sfilename, model, verbose):
    if isinstance(model, str):
        modelname = model

        model = FFN(model)
        model.Load(verbose=verbose)

    elif isinstance(model, FFN):
        modelname = model.name

    mask1, pmask = model.apply_mask(Sfilename)

    rgb, TitleStr = Vis.FalseColour(Sfilename, False)

    plt.figure()
    plt.imshow(rgb)
    plt.title('False colour image\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])

    plt.figure()
    plt.imshow(mask1, cmap='Blues')
    plt.title(modelname + ' mask\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])

    plt.figure()
    bmask = DL.extract_mask(Sfilename, 'bayes_in', 2)
    plt.imshow(bmask, cmap='Reds')
    plt.title('Bayesian mask\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])

    plt.figure()
    mask1 = mask1.astype('bool')
    rgb[~mask1, :] = 254 / 255, 253 / 255, 185 / 255
    plt.imshow(rgb)
    plt.title(modelname + ' masked false colour image\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])

    plt.figure()
    ax = plt.gca()
    im5 = plt.imshow(pmask, cmap='Oranges_r')
    plt.title(modelname + ' model output\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="5%", pad=0.1)
    plt.colorbar(im5, cax=cax)

    plt.figure()
    maskdiff = mask1 - bmask
    ax = plt.gca()
    im6 = plt.imshow(maskdiff, cmap='bwr_r')
    plt.title(modelname + ' mask - Bayesian mask\n' + TitleStr)
    plt.xlabel('km')
    plt.ylabel('km')
    plt.xticks([0, 500, 1000, 1500, 2000, 2500, 3000],
               [0, 250, 500, 750, 1000, 1250, 1500])
    plt.yticks([0, 500, 1000, 1500, 2000], [0, 250, 500, 750, 1000])
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="5%", pad=0.1)
    plt.colorbar(im6, cax=cax)

    plt.show()
Beispiel #11
0
class iPht3dGui(wx.Frame):
    ID_CHRONIQUE = 122
    ID_PROFIL = 123
    ID_OPTIONS = 125
    ID_RT3D = 126

    def __init__(self, titre, lang="fr"):
        wx.Frame.__init__(self, None, 1, title=titre, style=wx.DEFAULT_FRAME_STYLE)
        self.Maximize(True)
        self.titre = titre
        self.demo = False
        self.icones = self.creerIcones()
        self.mainDir = os.getcwd()
        self.model = iPht3dModel(self, self.mainDir)
        self.lg = langue()  # dico contient les mots et leur traduction
        self.invdico = dict()
        for i in self.lg.dict.iteritems():
            self.invdico[i[1][0]] = i[0]  # dictionneir inverse
        self.LANG = lang  # nom de la langue

        self.creerPanelMatplotlib()
        self.creerTopBar()
        self.creerPanelParametres()
        self.creerPanelAffiche()
        self.creerMenus()

        self.afficheSizer = wx.BoxSizer(wx.VERTICAL)
        self.afficheSizer.Add(self.affiche, 0, wx.EXPAND)

        frameSizer = wx.BoxSizer(wx.HORIZONTAL)
        frameSizer.Add(self.paramSizer, 12, wx.EXPAND)
        frameSizer.Add(self.matplot, 76, wx.EXPAND)
        frameSizer.Add(self.afficheSizer, 15, wx.EXPAND)

        globalSizer = wx.BoxSizer(wx.VERTICAL)
        globalSizer.Add(self.barSizer, 4)
        globalSizer.Add(frameSizer, 96, wx.EXPAND)

        globalSizer.SetSizeHints(self)
        self.SetSizer(globalSizer)
        self.control = Controller(self)
        wx.EVT_CLOSE(self, self.OnExit)

    def traduit(self, mot):
        mot2 = []
        if self.LANG == "fr":
            return mot
        if type(mot) == type("abc"):
            return self.lg.getMot(mot)  # pour l'instant que anglais donc pas choix
        else:
            for m in mot:
                mot2.append(self.lg.getMot(m))  # pour des listes
            return mot2

    def tradinverse(self, mot):
        if self.invdico.has_key(mot):
            return str(self.invdico[mot])  # pour l'instant que anglais donc pas choix
        else:
            return mot

    def OnRepondre(self, texte):
        texte = self.traduit(texte)
        message = wx.MessageDialog(self, texte, "Attention", style=wx.ICON_INFORMATION | wx.CENTRE | wx.OK | wx.CANCEL)
        retour = message.ShowModal()
        message.Destroy()
        return retour

    def OnMessage(self, text):
        if text == None:
            return
        text = self.traduit(text)
        if type(text) == type("ab"):
            w = max(len(text) * 5, 80)
            h = 1
            text = [text]
        elif type(text) == type([3, 4]):
            h = len(text)
            w = 80
            for i in range(len(text)):
                w = max(w, len(text[i]) * 5)
        dlg = wx.Dialog(self, -1, "", size=(min(w + 30, 450), h * 30 + 80))
        dlgSizer = wx.BoxSizer(wx.VERTICAL)
        for i in range(len(text)):
            dlgSizer.Add(wx.StaticText(dlg, -1, text[i]))
        dlgSizer.Add(dlg.CreateButtonSizer(wx.OK), -1, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER)
        dlg.SetSizer(dlgSizer)
        dlg.ShowModal()
        dlg.Destroy()

    ####################################################
    #                   creer menus
    ####################################################
    def creerMenus(self):
        self.menus = Menus(self)
        # file menu
        menuFichier = wx.Menu()
        menuFichier.Append(wx.ID_NEW, "&" + self.traduit("Nouveau") + "\tCTRL+n")
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_OPEN, "&" + self.traduit("Ouvrir") + "\tCTRL+o")
        menuFichier.Append(wx.ID_SAVE, "&" + self.traduit("Enregistrer") + "\tCTRL+s")
        menuFichier.Append(wx.ID_SAVEAS, "&" + self.traduit("Enregistrer sous"))
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_EXIT, "&" + self.traduit("Quitter") + "\tCTRL+q")

        wx.EVT_MENU(self, wx.ID_NEW, self.menus.OnNew)
        wx.EVT_MENU(self, wx.ID_OPEN, self.menus.OnOpen)
        wx.EVT_MENU(self, wx.ID_SAVE, self.menus.OnSave)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.menus.OnSaveAs)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        listeVar = self.model.Aquifere.getParm("Variable")[1]
        listeVar.extend(["Transport", "Tr_Rech", "PHT3D", "PH_Rech", "Observation"])

        # Import
        menuImport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportVar, id)
        menuImport.AppendMenu(710, "Grid", submenu)
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportZones, id)
        menuImport.AppendMenu(730, "Zones", submenu)
        id = menuImport.Append(-1, self.traduit("Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, id)
        id = menuImport.Append(-1, self.traduit("Solutions"))
        self.Bind(wx.EVT_MENU, self.menus.OnImportSolutions, id)
        # Export
        menuExport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            submenu.Append(751 + i, self.traduit(listeVar[i]))
        menuExport.AppendMenu(750, "Variables", submenu)
        menuExport.Append(771, self.traduit("Vitesses"))
        menuExport.Append(772, "Transport")
        menuExport.Append(773, "PHT3D")
        for i in range(len(listeVar)):
            wx.EVT_MENU(self, 751 + i, self.menus.OnExportResultat)
        for i in range(771, 774):
            wx.EVT_MENU(self, i, self.menus.OnExportResultat)

        # Outils
        menuOutils = wx.Menu()
        oc = menuOutils.Append(-1, "Options calcul")
        ov = menuOutils.Append(-1, "Options Visu")
        of = menuOutils.Append(-1, "Options Modflow")
        omt = menuOutils.Append(-1, "Options Mt3dms")
        opht = menuOutils.Append(-1, "Options Pht3d")
        oim = menuOutils.Append(-1, self.traduit("Import Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnCalcOpt, oc)
        self.Bind(wx.EVT_MENU, self.menus.OnVisuOpt, ov)
        self.Bind(wx.EVT_MENU, self.menus.OnModflowOpt, of)
        self.Bind(wx.EVT_MENU, self.menus.OnMt3dmsOpt, omt)
        self.Bind(wx.EVT_MENU, self.menus.OnPht3dOpt, opht)
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, oim)
        # Add-ins
        self.menuAddins = wx.Menu()

        # Aide
        menuAide = wx.Menu()
        if self.LANG == "fr":
            menuAide.Append(131, "Aide")
        if self.LANG == "en":
            menuAide.Append(131, "Help")
        wx.EVT_MENU(self, 131, self.menus.OnAide)
        ##        menuAide.Append(132,"Video1 Tutorial")
        ##        menuAide.Append(133,"Video2 Zones")
        ##        wx.EVT_MENU(self, 132, self.menus.OnVideo)
        ##        wx.EVT_MENU(self, 133, self.menus.OnVideo)
        menuAide.Append(133, "&Donwload new")
        wx.EVT_MENU(self, 133, self.menus.OnDownload)
        menuAide.Append(134, "&Back to old")
        wx.EVT_MENU(self, 134, self.menus.OnBackVersion)
        self.menuBarre = wx.MenuBar()

        self.menuBarre.Append(menuFichier, "&" + self.traduit("Fichier"))
        self.menuBarre.Append(menuImport, "&Import")
        self.menuBarre.Append(menuExport, "&Export")
        self.menuBarre.Append(menuOutils, "&" + self.traduit("Outils"))
        self.menuBarre.Append(self.menuAddins, "&Add-in")
        self.menuBarre.Append(menuAide, "&?")
        self.SetMenuBar(self.menuBarre)
        addin = Addins(self)
        addin.build()

    def enableMenu(self, nomM, bool):
        id = self.menuBarre.FindMenu(nomM)
        if id != -1:
            self.menuBarre.EnableTop(id, bool)  # pour les griser

    def OnExit(self, evt):
        self.menus.askSave(evt)
        self.Destroy()

    #####################################################
    #                   Panel Matplotlib
    ######################################################
    def creerPanelMatplotlib(self):

        # initialisation de la visualisation
        self.Visu = Visualisation(self, self.model.Aquifere.getVarList())
        sizerVisu = wx.BoxSizer(wx.VERTICAL)

        # ajout d'un item avec une proportion dans le sizer (95% et 5% ici) avec comme flag wxExpand
        sizerVisu.Add(self.Visu, 95, wx.EXPAND)
        basSizer = wx.BoxSizer(wx.HORIZONTAL)
        basSizer.Add(self.Visu.GetToolBar(), 0)
        self.pos = wx.StaticText(self, -1, " x: y:", size=(100, 40))
        self.pos.SetOwnBackgroundColour("LIGHT GRAY")
        basSizer.Add(self.pos, 5, wx.EXPAND)
        self.notify = wx.StaticText(self, -1, "")
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.notify.SetFont(font)
        self.notify.SetOwnForegroundColour("RED")
        basSizer.AddSpacer((0, 5), 0)
        basSizer.Add(self.notify, 5, wx.EXPAND)
        sizerVisu.Add(basSizer, 5, wx.EXPAND)
        self.matplot = sizerVisu
        self.model.setVisu(self.Visu)
        self.Visu.setVisu(self.model, self.model.getGlist())

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        # tw, th = self.Visu.GetToolBar().GetSizeTuple()
        # fw, fh = self.Visu.GetSizeTuple()
        # self.Visu.GetToolBar().SetSize(wx.Size(fw, th))

    def getModel(self):
        return self.model

    def getVisu(self):
        return self.Visu

    def onNotify(self, text):
        self.notify.SetLabel(text)

    def onPosition(self, text):
        self.pos.SetLabel(text)

    # affiche le titre ainsi que le path complet du projet
    def updateTitle(self):
        self.SetTitle(self.titre + " - " + self.model.getProjectName())

    #####################################################
    #                   Panel Top et Parametres
    #####################################################
    def creerTopBar(self):
        self.barSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.zoneBox = zoneBox(self)
        self.barSizer.Add(self.zoneBox, 0)
        self.barSizer.Add(wx.StaticLine(self, -1), 0, wx.ALIGN_CENTER | wx.EXPAND)
        self.modifBox = modifBox(self)
        self.barSizer.Add(self.modifBox, 0)

    def creerPanelParametres(self):
        # Creation des differents Panels
        self.paramSizer = wx.BoxSizer(wx.VERTICAL)
        self.parametresGui = parametresGui(self, self.model)
        self.paramSizer.Add(self.parametresGui)

    #####################################################
    #                   Panel Vue
    #####################################################
    def creerPanelAffiche(self):
        self.afficheTree = visuGui(self, self.model)
        self.affiche = wx.BoxSizer(wx.VERTICAL)
        self.affiche.Add(self.afficheTree, -1, wx.EXPAND)

    ######################## ICONES ############################
    import sys

    os.path.join(os.path.dirname(sys.executable), "utils")

    def creerIcones(self):
        noms = [
            "blanc",
            "bBleu",
            "Mo_zList",
            "Mo_Carte",
            "Mo_Domaine",
            "Mo_Grille",
            "Mo_GriVar",
            "Mo_Unites",
            "Aq_Zone",
            "Aq_layLock",
            "Aq_layUnlock",
            "Top_Point",
            "Top_Ligne",
            "Top_Rect",
            "Top_Poly",
            "Top_PolyV",
            "Top_Interp",
            "Top_move",
            "Top_modifPoly",
            "Top_modifPolyRed",
            "Top_supprime",
            "Top_zoneLay",
            "Top_Histo",
            "Top_supprimeAll",
            "Ec_SolvListe",
            "Ec_Solver",
            "Ec_Temps",
            "Ec_Write",
            "Ec_Run",
            "Ec_Particule",
            "Tr_ZoneT",
            "Tr_Transp",
            "Tr_Temps",
            "Tr_Methodes",
            "Tr_Recharge",
            "Tr_Solver",
            "Tr_Particules",
            "Tr_Write",
            "Tr_Run",
            "PH_Import",
            "PH_Chemistry",
            "PH_ZoneP",
            "PH_Write",
            "PH_Run",
            "PH_PHparm",
            "PH_Recharge",
            "PH_Immobile",
            "PH_ImmobileDisable",
            "Ob_ZoneO",
            "Vis_OriX",
            "Vis_OriY",
            "Vis_OriZ",
            "Vis_SwiImg",
            "Vis_SwiCont",
        ]
        dIcones = {}
        for n in noms:
            img = "utils" + os.sep + n + ".gif"
            dIcones[n] = wx.Bitmap(img, wx.BITMAP_TYPE_GIF)
        return dIcones
Beispiel #12
0
        glColor4f(1.0, 1.0, 1.0, 1.0)
        glEnable(GL_TEXTURE_2D)
        #glDisable(GL_TEXTURE_GEN_S)
        #glDisable(GL_TEXTURE_GEN_T)
        glBindTexture(GL_TEXTURE_2D, self._texture)
        glBegin(GL_TRIANGLES)
        glTexCoord2d(0.0, 0.0)
        glVertex3f(0.0, 0.0, 0.0)
        glTexCoord2d(1.0, 0.0)
        glVertex3f(1.0, 0.0, 0.0)
        glTexCoord2d(1.0, 1.0)
        glVertex3f(1.0, 1.0, 0.0)

        glTexCoord2d(1.0, 1.0)
        glVertex3f(1.0, 1.0, 0.0)
        glTexCoord2d(0.0, 1.0)
        glVertex3f(0.0, 1.0, 0.0)
        glTexCoord2d(0.0, 0.0)
        glVertex3f(0.0, 0.0, 0.0)
        glEnd()
        if logshade:
            self._logShader.Unbind()
        glBindTexture(GL_TEXTURE_2D, 0)
        #glDeleteTextures(self._texture)
        #glDeleteFramebuffers(2,[self._frame,self._depth])


if __name__ == "__main__":
    import Visualisation
    Visualisation.TestRamses()
import Visualisation as vis

if __name__ == '__main__':
    vis.main()
def main(nameFilename,
         debug=False,
         dataFilename=None,
         learningPaths={},
         students=None,
         period=None,
         heatMapColor="jet",
         functions=None,
         filterQuickClicks=False,
         filesToSave={
             "metaData": True,
             "nodes": True
         },
         conceptHitsParams=None,
         heatMapParams=None,
         studentGroups=None,
         **restArgs):
    Visualisation.init(nameFilename)
    settings = {}
    settings['learningpaths'] = learningPaths
    settings['students'] = students if not students is None else {
        "whitelist": False,
        "list": []
    }
    settings['period'] = period if not period is None else {"usePeriod": False}

    if dataFilename is None:
        dataFilename = [
            x for x in input(
                "which file would you like to use?(please enter the name of the excel file "
                "or files seperated by commas)\n").split(',')
        ]

    sample = {
        'learningpaths': {},
        'students': {
            'whitelist':
            True,
            'list': [{
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }, {
                'type': 'text',
                'value': '*****@*****.**'
            }]
        },
        'period': {
            'usePeriod': False,
            'startDate': datetime.datetime(2019, 9, 1, 0, 0),
            'endDate': datetime.datetime(2019, 12, 13, 0, 0)
        }
    }
    print(settings == sample)

    data = FilterData.filterAndExtractData(dataFilename, settings, debug=debug)
    if debug: print("done extracting data")

    # Annonymisation.annonymiseExtracted(data)
    # if debug: print("done making data anonymous")
    lookup = {}
    with open("inputFiles/studentsEncoded.csv", 'r') as studsEncode:
        reader = csv.reader(studsEncode)
        for name, number in reader:
            lookup[name] = number
    Annonymisation.alternateAnonymiseExtracted(data, lookup)

    output = DataProcessing.processDataExtracted(data,
                                                 settings['learningpaths'],
                                                 filterQuickClicks,
                                                 filesToSave=filesToSave,
                                                 timeOnPageCalc=True)
    # ToDo if visualisation's input is fixed, output['nodes'] can be used instead of loading nodes.json each time
    firstHit = []
    try:
        os.mkdir("outputs/hitsperday")
    except:
        pass
    try:
        os.mkdir("outputs/hoursperday")
    except:
        pass
    # for user in output["users"]:
    #     print(user)
    #     try:
    #         os.mkdir("outputs/user" + user)
    #     except:
    #         pass
    #     firstHit.append(Visualisation.hitsPerDayPerUser(output["users"], user, output["nodes"], settings))
    #     Visualisation.hoursPerDayPerUser(output['users'], user, output['nodes'], settings)
    # print(max(firstHit))
    for studentGroup in studentGroups:
        print(studentGroup)
        try:
            os.mkdir("outputs/hoursPerDayPerStudent/")
        except:
            pass
        try:
            os.mkdir("outputs/hoursPerDayPerStudent/" + studentGroup)
        except:
            pass
        print(studentGroup)
        for student in studentGroups[studentGroup]:
            student = "student " + str(student)
            Visualisation.hoursPerDayPerUserNoConcepts(
                output['users'],
                student,
                output['nodes'],
                settings,
                givenName="outputs/hoursPerDayPerStudent/" + studentGroup +
                "/" + student)

    # for path in settings['learningpaths']:
    #     Visualisation.learningpathFlowthrough(settings['learningpaths'][path])
    #     Visualisation.hitsPerDayPerLearningPath(pathId=path, settings=settings)
    #     Visualisation.heatMapOfGivenNodes(givenNodes=settings['learningpaths'][path]['list'],
    #                                       filename="heatmapPath" + str(path), colors=heatMapColor)
    #     if debug: print("done for path " + str(path))
    if debug: print(settings)
    DataProcessing.csvExports(nameFilename,
                              learningPaths=settings['learningpaths'],
                              functions=functions)

    # if not functions is None:
    #     if ("all" in functions or "allHitsPerDayPerConceptGraph" in functions) and conceptHitsParams:
    #         if debug: print("HitsPerDayPerConceptGraph same scale")
    #         Visualisation.generateSetOfPathVisits(conceptHitsParams, settings=settings,
    #                                               debug=debug, users=False, specificConcept=True)
    #     if "HitsPerDayPerConceptGraph" in functions and conceptHitsParams:
    #         if debug: print("HitsPerDayPerConceptGraph varying scales")
    #         for conceptId in conceptHitsParams:
    #             Visualisation.hitsPerDay(nodeId=conceptId)
    #     if "usersPerDayPerLearningPath" in functions:  # not all, because if we want all, they should be on the same scale
    #         if debug: print("usersPerDayPerLearningPath varying scales")
    #         for path in settings['learningpaths']:
    #             Visualisation.usersPerDayPerLearningPath(path, settings=settings)
    #     if "all" in functions or "allUsersPerDayPerLearningPath" in functions:
    #         if debug: print("UsersPerDayPerLearningPath same scale")
    #         Visualisation.generateSetOfPathVisits(pathId=list(settings['learningpaths']), settings=settings,
    #                                               debug=debug, users=True)
    #     if "all" in functions or "allHitsPerDayPerLearningPath" in functions:
    #         if debug: print("HitsPerDayPerLearningPath same scale")
    #         Visualisation.generateSetOfPathVisits(pathId=list(settings['learningpaths']), settings=settings,
    #                                               debug=debug)
    #     if "all" in functions or "allNodesFlowthrough" in functions:
    #         if debug: print("allNodesFlowthrough")
    #         Visualisation.allNodesFlowthrough(debug=debug)  # ToDo there is currently no way to properly display this
    #     if ("all" in functions or "allNodesHeatMap" in functions) and heatMapParams:
    #         if debug: print("allNodesHeatmap")
    #         Visualisation.heatMapOfGivenNodes(**heatMapParams)

    # ToDo nodes.json could be saved in such a way that the same nodes.json is not generated twice for the same settings
    if "all" not in filesToSave:  # remove any unwanted files
        if "metaData" not in filesToSave:
            if debug: print("removing metadata.json")
            os.remove("outputs/metaData.json")
        if "nodes" not in filesToSave:
            if debug: print("removing nodes.json")
            os.remove("outputs/nodes.json")
Beispiel #15
0
class iPht3dGui(wx.Frame):
    ID_CHRONIQUE = 122
    ID_PROFIL = 123
    ID_OPTIONS = 125
    ID_RT3D = 126

    def __init__(self, titre, lang="fr"):
        wx.Frame.__init__(self,
                          None,
                          1,
                          title=titre,
                          style=wx.DEFAULT_FRAME_STYLE)
        self.Maximize(True)
        self.titre = titre
        self.demo = False
        self.icones = self.creerIcones()
        self.mainDir = os.getcwd()
        self.model = iPht3dModel(self, self.mainDir)
        self.lg = langue()  #dico contient les mots et leur traduction
        self.invdico = dict()
        for i in self.lg.dict.iteritems():
            self.invdico[i[1][0]] = i[0]  # dictionneir inverse
        self.LANG = lang  # nom de la langue

        self.creerPanelMatplotlib()
        self.creerTopBar()
        self.creerPanelParametres()
        self.creerPanelAffiche()
        self.creerMenus()

        self.afficheSizer = wx.BoxSizer(wx.VERTICAL)
        self.afficheSizer.Add(self.affiche, 0, wx.EXPAND)

        frameSizer = wx.BoxSizer(wx.HORIZONTAL)
        frameSizer.Add(self.paramSizer, 12, wx.EXPAND)
        frameSizer.Add(self.matplot, 76, wx.EXPAND)
        frameSizer.Add(self.afficheSizer, 15, wx.EXPAND)

        globalSizer = wx.BoxSizer(wx.VERTICAL)
        globalSizer.Add(self.barSizer, 4)
        globalSizer.Add(frameSizer, 96, wx.EXPAND)

        globalSizer.SetSizeHints(self)
        self.SetSizer(globalSizer)
        self.control = Controller(self)
        wx.EVT_CLOSE(self, self.OnExit)

    def traduit(self, mot):
        mot2 = []
        if self.LANG == 'fr': return mot
        if type(mot) == type('abc'):
            return self.lg.getMot(
                mot)  # pour l'instant que anglais donc pas choix
        else:
            for m in mot:
                mot2.append(self.lg.getMot(m))  # pour des listes
            return mot2

    def tradinverse(self, mot):
        if self.invdico.has_key(mot):
            return str(
                self.invdico[mot])  # pour l'instant que anglais donc pas choix
        else:
            return mot

    def OnRepondre(self, texte):
        texte = self.traduit(texte)
        message = wx.MessageDialog(self,
                                   texte,
                                   "Attention",
                                   style=wx.ICON_INFORMATION | wx.CENTRE
                                   | wx.OK | wx.CANCEL)
        retour = message.ShowModal()
        message.Destroy()
        return retour

    def OnMessage(self, text):
        if text == None: return
        text = self.traduit(text)
        if type(text) == type('ab'):
            w = max(len(text) * 5, 80)
            h = 1
            text = [text]
        elif type(text) == type([3, 4]):
            h = len(text)
            w = 80
            for i in range(len(text)):
                w = max(w, len(text[i]) * 5)
        dlg = wx.Dialog(self, -1, "", size=(min(w + 30, 450), h * 30 + 80))
        dlgSizer = wx.BoxSizer(wx.VERTICAL)
        for i in range(len(text)):
            dlgSizer.Add(wx.StaticText(dlg, -1, text[i]))
        dlgSizer.Add(dlg.CreateButtonSizer(wx.OK), -1,
                     wx.ALIGN_BOTTOM | wx.ALIGN_CENTER)
        dlg.SetSizer(dlgSizer)
        dlg.ShowModal()
        dlg.Destroy()

    ####################################################
    #                   creer menus
    ####################################################
    def creerMenus(self):
        self.menus = Menus(self)
        #file menu
        menuFichier = wx.Menu()
        menuFichier.Append(wx.ID_NEW,
                           "&" + self.traduit('Nouveau') + "\tCTRL+n")
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_OPEN,
                           "&" + self.traduit('Ouvrir') + "\tCTRL+o")
        menuFichier.Append(wx.ID_SAVE,
                           "&" + self.traduit('Enregistrer') + "\tCTRL+s")
        menuFichier.Append(wx.ID_SAVEAS,
                           "&" + self.traduit('Enregistrer sous'))
        menuFichier.AppendSeparator()
        menuFichier.Append(wx.ID_EXIT,
                           "&" + self.traduit('Quitter') + "\tCTRL+q")

        wx.EVT_MENU(self, wx.ID_NEW, self.menus.OnNew)
        wx.EVT_MENU(self, wx.ID_OPEN, self.menus.OnOpen)
        wx.EVT_MENU(self, wx.ID_SAVE, self.menus.OnSave)
        wx.EVT_MENU(self, wx.ID_SAVEAS, self.menus.OnSaveAs)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)

        listeVar = self.model.Aquifere.getParm('Variable')[1]
        listeVar.extend(
            ['Transport', 'Tr_Rech', 'PHT3D', 'PH_Rech', 'Observation'])

        # Import
        menuImport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportVar, id)
        menuImport.AppendMenu(710, "Grid", submenu)
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            id = submenu.Append(-1, self.traduit(listeVar[i]))
            self.Bind(wx.EVT_MENU, self.menus.OnImportZones, id)
        menuImport.AppendMenu(730, "Zones", submenu)
        id = menuImport.Append(-1, self.traduit('Donnees'))
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, id)
        id = menuImport.Append(-1, self.traduit('Solutions'))
        self.Bind(wx.EVT_MENU, self.menus.OnImportSolutions, id)
        #Export
        menuExport = wx.Menu()
        submenu = wx.Menu()
        for i in range(len(listeVar)):
            submenu.Append(751 + i, self.traduit(listeVar[i]))
        menuExport.AppendMenu(750, "Variables", submenu)
        menuExport.Append(771, self.traduit("Vitesses"))
        menuExport.Append(772, "Transport")
        menuExport.Append(773, "PHT3D")
        for i in range(len(listeVar)):
            wx.EVT_MENU(self, 751 + i, self.menus.OnExportResultat)
        for i in range(771, 774):
            wx.EVT_MENU(self, i, self.menus.OnExportResultat)

        #Outils
        menuOutils = wx.Menu()
        oc = menuOutils.Append(-1, "Options calcul")
        ov = menuOutils.Append(-1, "Options Visu")
        of = menuOutils.Append(-1, "Options Modflow")
        omt = menuOutils.Append(-1, "Options Mt3dms")
        opht = menuOutils.Append(-1, "Options Pht3d")
        oim = menuOutils.Append(-1, self.traduit("Import Donnees"))
        self.Bind(wx.EVT_MENU, self.menus.OnCalcOpt, oc)
        self.Bind(wx.EVT_MENU, self.menus.OnVisuOpt, ov)
        self.Bind(wx.EVT_MENU, self.menus.OnModflowOpt, of)
        self.Bind(wx.EVT_MENU, self.menus.OnMt3dmsOpt, omt)
        self.Bind(wx.EVT_MENU, self.menus.OnPht3dOpt, opht)
        self.Bind(wx.EVT_MENU, self.menus.OnImportData, oim)
        #Add-ins
        self.menuAddins = wx.Menu()

        #Aide
        menuAide = wx.Menu()
        if self.LANG == "fr": menuAide.Append(131, "Aide")
        if self.LANG == "en": menuAide.Append(131, "Help")
        wx.EVT_MENU(self, 131, self.menus.OnAide)
        ##        menuAide.Append(132,"Video1 Tutorial")
        ##        menuAide.Append(133,"Video2 Zones")
        ##        wx.EVT_MENU(self, 132, self.menus.OnVideo)
        ##        wx.EVT_MENU(self, 133, self.menus.OnVideo)
        menuAide.Append(133, "&Donwload new")
        wx.EVT_MENU(self, 133, self.menus.OnDownload)
        menuAide.Append(134, "&Back to old")
        wx.EVT_MENU(self, 134, self.menus.OnBackVersion)
        self.menuBarre = wx.MenuBar()

        self.menuBarre.Append(menuFichier, "&" + self.traduit('Fichier'))
        self.menuBarre.Append(menuImport, "&Import")
        self.menuBarre.Append(menuExport, "&Export")
        self.menuBarre.Append(menuOutils, "&" + self.traduit('Outils'))
        self.menuBarre.Append(self.menuAddins, "&Add-in")
        self.menuBarre.Append(menuAide, "&?")
        self.SetMenuBar(self.menuBarre)
        addin = Addins(self)
        addin.build()

    def enableMenu(self, nomM, bool):
        id = self.menuBarre.FindMenu(nomM)
        if id != -1: self.menuBarre.EnableTop(id, bool)  # pour les griser

    def OnExit(self, evt):
        self.menus.askSave(evt)
        self.Destroy()

    #####################################################
    #                   Panel Matplotlib
    ######################################################
    def creerPanelMatplotlib(self):

        #initialisation de la visualisation
        self.Visu = Visualisation(self, self.model.Aquifere.getVarList())
        sizerVisu = wx.BoxSizer(wx.VERTICAL)

        #ajout d'un item avec une proportion dans le sizer (95% et 5% ici) avec comme flag wxExpand
        sizerVisu.Add(self.Visu, 95, wx.EXPAND)
        basSizer = wx.BoxSizer(wx.HORIZONTAL)
        basSizer.Add(self.Visu.GetToolBar(), 0)
        self.pos = wx.StaticText(self, -1, ' x: y:', size=(100, 40))
        self.pos.SetOwnBackgroundColour('LIGHT GRAY')
        basSizer.Add(self.pos, 5, wx.EXPAND)
        self.notify = wx.StaticText(self, -1, '')
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.NORMAL)
        self.notify.SetFont(font)
        self.notify.SetOwnForegroundColour('RED')
        basSizer.AddSpacer((0, 5), 0)
        basSizer.Add(self.notify, 5, wx.EXPAND)
        sizerVisu.Add(basSizer, 5, wx.EXPAND)
        self.matplot = sizerVisu
        self.model.setVisu(self.Visu)
        self.Visu.setVisu(self.model, self.model.getGlist())

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        #tw, th = self.Visu.GetToolBar().GetSizeTuple()
        #fw, fh = self.Visu.GetSizeTuple()
        #self.Visu.GetToolBar().SetSize(wx.Size(fw, th))

    def getModel(self):
        return self.model

    def getVisu(self):
        return self.Visu

    def onNotify(self, text):
        self.notify.SetLabel(text)

    def onPosition(self, text):
        self.pos.SetLabel(text)

    # affiche le titre ainsi que le path complet du projet
    def updateTitle(self):
        self.SetTitle(self.titre + " - " + self.model.getProjectName())

    #####################################################
    #                   Panel Top et Parametres
    #####################################################
    def creerTopBar(self):
        self.barSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.zoneBox = zoneBox(self)
        self.barSizer.Add(self.zoneBox, 0)
        self.barSizer.Add(wx.StaticLine(self, -1), 0,
                          wx.ALIGN_CENTER | wx.EXPAND)
        self.modifBox = modifBox(self)
        self.barSizer.Add(self.modifBox, 0)

    def creerPanelParametres(self):
        #Creation des differents Panels
        self.paramSizer = wx.BoxSizer(wx.VERTICAL)
        self.parametresGui = parametresGui(self, self.model)
        self.paramSizer.Add(self.parametresGui)

    #####################################################
    #                   Panel Vue
    #####################################################
    def creerPanelAffiche(self):
        self.afficheTree = visuGui(self, self.model)
        self.affiche = wx.BoxSizer(wx.VERTICAL)
        self.affiche.Add(self.afficheTree, -1, wx.EXPAND)

    ######################## ICONES ############################
    import sys
    os.path.join(os.path.dirname(sys.executable), 'utils')

    def creerIcones(self):
        noms = [
            'blanc', 'bBleu', 'Mo_zList', 'Mo_Carte', 'Mo_Domaine',
            'Mo_Grille', 'Mo_GriVar', 'Mo_Unites', 'Aq_Zone', 'Aq_layLock',
            'Aq_layUnlock', 'Top_Point', 'Top_Ligne', 'Top_Rect', 'Top_Poly',
            'Top_PolyV', 'Top_Interp', 'Top_move', 'Top_modifPoly',
            'Top_modifPolyRed', 'Top_supprime', 'Top_zoneLay', 'Top_Histo',
            'Top_supprimeAll', 'Ec_SolvListe', 'Ec_Solver', 'Ec_Temps',
            'Ec_Write', 'Ec_Run', 'Ec_Particule', 'Tr_ZoneT', 'Tr_Transp',
            'Tr_Temps', 'Tr_Methodes', 'Tr_Recharge', 'Tr_Solver',
            'Tr_Particules', 'Tr_Write', 'Tr_Run', 'PH_Import', 'PH_Chemistry',
            'PH_ZoneP', 'PH_Write', 'PH_Run', 'PH_PHparm', 'PH_Recharge',
            'PH_Immobile', 'PH_ImmobileDisable', 'Ob_ZoneO', 'Vis_OriX',
            'Vis_OriY', 'Vis_OriZ', 'Vis_SwiImg', 'Vis_SwiCont'
        ]
        dIcones = {}
        for n in noms:
            img = 'utils' + os.sep + n + '.gif'
            dIcones[n] = wx.Bitmap(img, wx.BITMAP_TYPE_GIF)
        return dIcones
Beispiel #16
0
print(f"Classical FK: \n{T}\n")

### Jacobian ###


def AdJoint(T):
    R = T[0:3, 0:3]
    p = T[0:3, 3]
    return np.r_[np.c_[np.transpose(R),
                       np.dot(np.transpose(R), Skew(p))], np.c_[np.zeros(
                           (3, 3)), np.transpose(R)]]


def JacobianSpace(s_list, thetas):
    Js = np.array(s_list.T).copy().astype(float)
    T_J = np.eye(4)

    for i in range(1, len(thetas)):
        se3 = Get_s_mul_theta(omega_list[i - 1], v_list[i - 1], thetas[i - 1])

        T_J = np.dot(T_J, MatrixExp6(se3))
        Js[:, i] = np.dot(AdJoint(T_J), np.array(s_list.T)[:, i])

    return Js


print(f"Jacobian spatial: \n{JacobianSpace(S_list, q)}\n")

print()
visual.Visualisation(q, links_length)