def __getitem__(self, indices): if len(indices) != self.ndim: print 'indices must be ' + str(self.ndim) + ' dimensions!' return None k = indices[0] if isinstance(k, int): sidx = k eidx = k step = 1 elif isinstance(k, slice): sidx = 0 if k.start is None else k.start if sidx < 0: sidx = self.tnum + sidx eidx = self.tnum if k.stop is None else k.stop if eidx < 0: eidx = self.tnum + eidx eidx -= 1 step = 1 if k.step is None else k.step elif isinstance(k, list): sidx = self.dataset.timeindex(k[0]) if len(k) == 1: eidx = sidx step = 1 else: eidx = self.dataset.timeindex(k[1]) if len(k) == 3: tt = self.dataset.timeindex(k[0] + k[3]) step = tt - sidx else: step = 1 sfidx = self.dataset.datafileindex(sidx) si = sidx isfirst = True times = [] fidx = sfidx aa = None var = None for i in range(sidx, eidx + 1, step): times.append(miutil.date2num(self.dataset.gettime(i))) fidx = self.dataset.datafileindex(i) if fidx > sfidx: ei = i - step ddf = self.dataset[sfidx] var = ddf[self.name] ii, ssi = self.dataset.dftindex(si) ii, eei = self.dataset.dftindex(ei) eei += 1 nindices = list(indices) nindices[0] = slice(ssi, eei, step) nindices = tuple(nindices) aa = var.__getitem__(nindices) if si == ei: aa.addtdim(self.dataset.gettime(si)) if isfirst: data = aa isfirst = False else: data = minum.concatenate([data, aa]) si = i sfidx = fidx if si < eidx + 1: ei = eidx + 1 - step ddf = self.dataset[sfidx] var = ddf[self.name] ii, ssi = self.dataset.dftindex(si) ii, eei = self.dataset.dftindex(ei) eei += 1 nindices = list(indices) nindices[0] = slice(ssi, eei, step) nindices = tuple(nindices) aa = var.__getitem__(nindices) if si == ei and eidx != sidx: aa.addtdim(self.dataset.gettime(si)) if isfirst: data = aa isfirst = False else: data = minum.concatenate([data, aa]) if aa is None: sfidx = self.dataset.datafileindex(sidx) ddf = self.dataset[sfidx] var = ddf[self.name] ii, ssi = self.dataset.dftindex(sidx) nindices = list(indices) nindices[0] = slice(ssi, ssi, step) nindices = tuple(nindices) aa = var.__getitem__(nindices) return aa if isinstance(data, DimArray): return data else: dims = aa.dims dims[0].setDimValues(times) r = DimArray(data, dims, aa.fill_value, aa.proj) return r