Ciao, per un programma che sto scrivendo vorrei creare un oggetto array di numpy con un numero di colonne preassegnato, per avere la comodita` di chiamare le varie colonne con array.nome invece di usare indici anonimi. Tra l'altro, questo array sara` poi incorporato in un oggetto "punto". Per il momento, l'oggetto punto gia funziona se gli passo un array normale, quindi ora voglio procedere a passargli questo array speciale. Pero` sto trovando qualche difficolta` a capire come particolarizzare questa classe, mi dareste una mano per favore? Ecco il mio tentatvo:
... # questa e` la classe del punto, che funziona per il momento class Point(object): '''The point has a cat, a ord identifier and coordinates x, y''' def __init__(self, cat, ordn, x, y, **kwargs): '''id is cat, ord is NUMERO_ORD''' self.cat = cat self.ordn = ordn self.X = x self.Y = y #self.TS = np.asarray(self) self.TS = np.asarray(TimeSeries) # questa e` la classe che voglio creare class TimeSeries(ndarray): '''This object registers for each point the following characteristics over time: * Column 0 : NIR * Column 1 : RED * Column 2 : GREEN * Column 3 : NDVI * Column 4 : SAVI ''' def __init__(self, nir, red, green, ndvi, savi): self.NIR = nir self.RED = red self.GREEN = green self.NDVI = ndvi self.SAVI = savi ... domanda: come faccio a dirgli che: 1) L'array deve avere 5 colonne e un numero indefinito di righe 2) La colonna 0 si chiama NIR, la 1 si chiama RED.. e cosi` via ? Spero di essere stata abbastanza chiara. Ho cercato informazioni in rete, ho trovato risposte anche abbastanza complicate ma nulla che somigliasse al mio esempio. Grazie in anticipo Ciao, Margherita -- Best regards, Dr. Margherita DI LEO Scientific / technical project officer European Commission - DG JRC Institute for Environment and Sustainability (IES) Via Fermi, 2749 I-21027 Ispra (VA) - Italy - TP 261 Tel. +39 0332 78 3600 margherita.di-...@jrc.ec.europa.eu Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission.
_______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python