Bonjour,

j'ai réalisé le programme suivant:

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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
import sys, fpformat, os, random, time
sys.path.append("C:\\Python26\\Lib\\site-packages")
import numpy as np
from scipy.interpolate import griddata
import matplotlib.pyplot as plt
import numpy.ma as ma
from numpy.random import uniform, seed
import numpy
from numpy import *
import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3
import PIL
import Image
import ImageOps
from matplotlib.ticker import LinearLocator, FixedLocator, FormatStrFormatter
 
def Carte_erreur_3D_surface():
 
 
    try:
        os.remove('graph température 3D surface.png')
    except:
        pass
 
    x=[]
    y=[]
    z=[]
 
 
 
    Fichier = 'C:\\Temp\\donnees image defaut nettoye.txt' # pour traiter les température
    Table=numpy.loadtxt(Fichier)
    Table=array(Table)
    for i in range((len(Table))): 
        x.append(Table[i][0]) # coord x
        y.append(Table[i][1]) # coord y
        z.append(Table[i][2]) # carte de température
        A=Table[0][0]
        B=Table[0][1]
        C=Table[len(Table)-1][0]
        D=Table[len(Table)-1][1]
        E=Table[0][2]
        F=Table[len(Table)-1][2]
 
    #===========================================================================
    # x=array(x)
    # y=array(y)
    # z=array(z)
    #===========================================================================
 
    x = np.array(x)
    y = np.array(y)
    z = np.array(z)
 
 
    # u and v are parametric variables.
    # u is an array from 0 to 2*pi, with 100 elements
    u=r_[0:2*pi:len(Table)]
    # v is an array from 0 to 2*pi, with 100 elements
    v=r_[0:2*pi:len(Table)]
    # x, y, and z are the coordinates of the points for plotting
    # each is arranged in a 100x100 array
 
    xi = np.linspace(A,C,len(Table))
    yi = np.linspace(B,D,len(Table))
 
 
    zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='cubic')
 
    #xim, yim = np.meshgrid(x, y)
 
    print(xi, yi, zi)
 
    fig=p.figure()
    ax = p3.Axes3D(fig)
 
 
 
    xi, yi, zi = p3.get_test_data(0.05) 
 
 
    print(xi, yi, zi)
 
    surf = ax.plot_surface(xi, yi, zi, rstride=1, cstride=1, cmap= plt.cm.jet)    
 
    ax.set_xlabel('X')
    #ax.set_xlim(A,C)
    ax.set_ylabel('Y')
    #ax.set_ylim(B,D)
    ax.set_zlabel('Carte de temperature')
    #ax.set_zlim3d(E, F)
 
    #===========================================================================
    # ax.w_zaxis.set_major_locator(LinearLocator(10))
    # ax.w_zaxis.set_major_formatter(FormatStrFormatter('%.03f'))    
    #===========================================================================
 
 
    p.colorbar(surf, shrink=0.8, aspect=10)
 
    p.savefig('graph température 3D surface.png')
    Img = Image.open ('graph température 3D surface.png')
    Img.save(fp=str('C:\\Temp\\graph température 3D surface.png'))
 
    p.show()
j'ai l'erreur suivante que je ne comprends pas:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
Traceback (most recent call last):
  File "C:\Documents and Settings\Elodie\Mes documents\Elodie\NIMITECH\SPIDER\Essais thermo IR classique\Traitement d'images\code python\Carte_defaut.py", line 337, in Carte_erreur_3D_surface
    surf = ax.plot_surface(xi, yi, zi, rstride=1, cstride=1, cmap= plt.cm.jet)    
  File "C:\Python26\lib\site-packages\mpl_toolkits\mplot3d\axes3d.py", line 590, in plot_surface
    ztop = a[rs][cs:min(cols, cs+cstride+1)]
IndexError: invalid index to scalar variable.
Est ce que quelqu'un pourrait me débloquer ?

Merci d'avance.
Cordialement.