IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

boucle python sous paraview


Sujet :

Python

  1. #1
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2024
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Juillet 2024
    Messages : 2
    Points : 3
    Points
    3
    Par défaut boucle python sous paraview
    Bonjour j'utilise paraview pour visualiser des fichiers de simulation mécanique
    Afin d'automatiser l'ouverture et le traitement des images j'ai réalisé un script fonctionnel :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    import pvsimple
    pvsimple.ShowParaviewView()
    # trace generated using paraview version 5.9.0
     
    #### import the simple module from the paraview
    from pvsimple import *
    #### disable automatic camera reset on 'Show'
    pvsimple._DisableFirstRenderCameraReset()
    i = 0
    # create a new 'MED Reader'
    bassin0med = MEDReader(registrationName='bassin' + str(i) + '.med', FileName='/media/vesvard211/Crucial X8/resultat_FSI/0.6S/maillage (1)/bassin' + str(i) + '.med')
     
    # get animation scene
    animationScene1 = GetAnimationScene()
     
    # update animation scene based on data timesteps
    animationScene1.UpdateAnimationUsingDataTimeSteps()
     
    # Properties modified on bassin0med
    bassin0med.AllArrays = ['TS0/bassin/ComSup0/Velocity@@][@@P0']
     
    # get active view
    renderView1 = GetActiveViewOrCreate('RenderView')
     
    # show data in view
    bassin0medDisplay = Show(bassin0med, renderView1, 'UnstructuredGridRepresentation')
     
    # trace defaults for the display properties.
    bassin0medDisplay.Representation = 'Surface'
     
    # reset view to fit data
    renderView1.ResetCamera()
     
    # get the material library
    materialLibrary1 = GetMaterialLibrary()
     
    # update the view to ensure updated data information
    renderView1.Update()
     
    # set scalar coloring
    ColorBy(bassin0medDisplay, ('CELLS', 'Velocity', 'Magnitude'))
     
    # rescale color and/or opacity maps used to include current data range
    bassin0medDisplay.RescaleTransferFunctionToDataRange(True, False)
     
    # show color bar/color legend
    bassin0medDisplay.SetScalarBarVisibility(renderView1, True)
     
    # get color transfer function/color map for 'Velocity'
    velocityLUT = GetColorTransferFunction('Velocity')
     
    # get opacity transfer function/opacity map for 'Velocity'
    velocityPWF = GetOpacityTransferFunction('Velocity')
     
    #### saving camera placements for all active views
     
    # current camera placement for renderView1
    renderView1.CameraPosition = [0.12, 0.0, 1.7787239526758387]
    renderView1.CameraFocalPoint = [0.12, 0.0, 0.1500000000000064]
    renderView1.CameraParallelScale = 0.4215447781671621
    Mais quand je tente de créer une boucle afin d'ouvrir plusieurs images il ne fonctionne plus
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    import pvsimple
    pvsimple.ShowParaviewView()
    # trace generated using paraview version 5.9.0
     
    #### import the simple module from the paraview
    from pvsimple import *
    #### disable automatic camera reset on 'Show'
    pvsimple._DisableFirstRenderCameraReset()
    b = [None]
    d = [None]
    for i in range(0 ,2, 30 ):
    # create a new 'MED Reader'
    b.append("bassin/%s" % i)
    d.append("bassin/%s" % i + "Display" )
    b[i] = MEDReader(registrationName='bassin' + str(i) + '.med', FileName='/media/vesvard211/Crucial X8/resultat_FSI/0.6S/maillage (1)/bassin' + str(i) + '.med')
     
    # get animation scene
    animationScene1 = GetAnimationScene()
     
    # update animation scene based on data timesteps
    animationScene1.UpdateAnimationUsingDataTimeSteps()
     
    # Properties modified on bassin0med
    b[i].AllArrays = ['TS0/bassin/ComSup0/Velocity@@][@@P0']
     
    # get active view
    renderView1 = GetActiveViewOrCreate('RenderView')
     
    # show data in view
    d[i] = Show(b[i], renderView1, 'UnstructuredGridRepresentation')
     
    # trace defaults for the display properties.
    d[i].Representation = 'Surface'
     
    # reset view to fit data
    renderView1.ResetCamera()
     
    # get the material library
    materialLibrary1 = GetMaterialLibrary()
     
    # update the view to ensure updated data information
    renderView1.Update()
     
    # set scalar coloring
    ColorBy(d[i], ('CELLS', 'Velocity', 'Magnitude'))
     
    # rescale color and/or opacity maps used to include current data range
    d[i].RescaleTransferFunctionToDataRange(True, False)
     
    # show color bar/color legend
    d[i].SetScalarBarVisibility(renderView1, True)
     
    # get color transfer function/color map for 'Velocity'
    velocityLUT = GetColorTransferFunction('Velocity')
     
    # get opacity transfer function/opacity map for 'Velocity'
    velocityPWF = GetOpacityTransferFunction('Velocity')
     
    #### saving camera placements for all active views
     
    # current camera placement for renderView1
    renderView1.CameraPosition = [0.12, 0.0, 1.7787239526758387]
    renderView1.CameraFocalPoint = [0.12, 0.0, 0.1500000000000064]
    renderView1.CameraParallelScale = 0.4215447781671621
    Si quelqu'un à une idée cela m'aiderait grandement

  2. #2
    Membre actif
    Homme Profil pro
    Animateur Numérique
    Inscrit en
    Février 2013
    Messages
    140
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Animateur Numérique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Février 2013
    Messages : 140
    Points : 208
    Points
    208
    Par défaut
    Salut,
    Problème d'indentation de ta boucle for ....

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    1 232
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 1 232
    Points : 1 798
    Points
    1 798
    Par défaut
    et problème d'utilisation du range => range(start,stop,step) (tu demandes de commencer à 0, de finir à 2 et d'incrémenter de 30 entre chaque itération; conclusion, si la boucle se fait, ce sera une seule fois (pour i =0).

    Et "ça ne fonctionne plus" ça ne veut pas dire grand chose:
    il y a des messages d'erreur?
    ça ne marche pas comme attendu donc ça fait quoi au lieu de faire quoi?
    ..

    Donc commence par corriger le problème du range et l'indentation de ta boucle, et dis nous ensuite ce qui ne fonctionne plus (si ça ne marche toujours pas)

  4. #4
    Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2024
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 25
    Localisation : France, Calvados (Basse Normandie)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Juillet 2024
    Messages : 2
    Points : 3
    Points
    3
    Par défaut
    Merci de votre aide
    effectivement avec l'indentation et la syntaxe correcte pour le for ça marche :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    import pvsimple
    pvsimple.ShowParaviewView()
    # trace generated using paraview version 5.9.0
     
    #### import the simple module from the paraview
    from pvsimple import *
    #### disable automatic camera reset on 'Show'
    pvsimple._DisableFirstRenderCameraReset()
    b = [None]
    d = [None]
    for i in range(6):
    	# create a new 'MED Reader'
    	b.append("bassin/%d" % i)
    	d.append("bassin/%d" % i + "Display" )
    	b[i] = MEDReader(registrationName='bassin' + str(i) + '.med', FileName='/media/vesvard211/Crucial X8/resultat_FSI/0.6S/maillage (1)/bassin' + str(i) + '.med')
     
    # get animation scene
    	animationScene1 = GetAnimationScene()
     
    # update animation scene based on data timesteps
    	animationScene1.UpdateAnimationUsingDataTimeSteps()
     
    # Properties modified on bassin0med
    	b[i].AllArrays = ['TS0/bassin/ComSup0/Velocity@@][@@P0']
     
    # get active view
    	renderView1 = GetActiveViewOrCreate('RenderView')
     
    # show data in view
    	d[i] = Show(b[i], renderView1, 'UnstructuredGridRepresentation')
     
    # trace defaults for the display properties.
    	d[i].Representation = 'Surface'
     
    # reset view to fit data
    	renderView1.ResetCamera()
     
    # get the material library
    	materialLibrary1 = GetMaterialLibrary()
     
    # update the view to ensure updated data information
    	renderView1.Update()
     
    # set scalar coloring
    	ColorBy(d[i], ('CELLS', 'Velocity', 'Magnitude'))
     
    # rescale color and/or opacity maps used to include current data range
    	d[i].RescaleTransferFunctionToDataRange(True, False)
     
    # show color bar/color legend
    	d[i].SetScalarBarVisibility(renderView1, True)
     
    # get color transfer function/color map for 'Velocity'
    	velocityLUT = GetColorTransferFunction('Velocity')
     
    # get opacity transfer function/opacity map for 'Velocity'
    	velocityPWF = GetOpacityTransferFunction('Velocity')
     
    #### saving camera placements for all active views
     
    # current camera placement for renderView1
    	renderView1.CameraPosition = [0.12, 0.0, 1.7787239526758387]
    	renderView1.CameraFocalPoint = [0.12, 0.0, 0.1500000000000064]
    	renderView1.CameraParallelScale = 0.4215447781671621

    Nom : q1.png
Affichages : 15
Taille : 144,4 Ko
    Bonne journée

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. recompiler python sous windows
    Par Freyja dans le forum Déploiement/Installation
    Réponses: 2
    Dernier message: 21/07/2006, 09h38
  2. [Tkinter] Python sous Linux
    Par PMdomine dans le forum Tkinter
    Réponses: 7
    Dernier message: 06/03/2006, 20h56
  3. Réponses: 4
    Dernier message: 10/02/2006, 13h49
  4. probleme apache+module python sous windows
    Par gaussprodada dans le forum Réseau/Web
    Réponses: 1
    Dernier message: 02/11/2004, 21h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo