0

I'm using python and trying to calculate trends of SIC of different season. So i need to cut every season from all the months from 1979 to 2009

print sic.shape
 (372, 180, 360)

sics=sic[90,:,:]
sicm=[]
for i in range(0,12):
    sicj=sic[i::12,:,:]
    sicm.append(sicj)
    del sicj
sics[0::3,:,:]=sicm[11][:30,:,:]
sics[1::3,:,:]=sicm[0][1:,:,:]
sics[2::3,:,:]=sicm[1][1:,:,:]

then the result showed that

IndexErrorTraceback (most recent call last) in () ----> 1 sics[0::3,:,:]=sicm[11][:30,:,:]

/home/charcoalp/anaconda2/envs/pyn_test/lib/python2.7/site-packages/numpy/ma/core.pyc in setitem(self, indx, value) 3299 _mask = self._mask 3300 # Set the data, then the mask -> 3301 _data[indx] = dval 3302 _mask[indx] = mval 3303 elif hasattr(indx, 'dtype') and (indx.dtype == MaskType):

IndexError: too many indices for array

My way is to cut every Jan,Feb,Mar...and make a new array to combine 3 months as the same season data. Is the problem can be solved or just my way is wrong?

Thanks a lot if you can help me

Yuhang Pan
  • 35
  • 1
  • 1
  • 6
  • 1
    Unrelated note: if you have an array with multiple dimensions and you just want to index the first or the last, you can use an ellipsis for better readability for the non-index axes; e.g. `sics[1::3,:,:]=sicm[0][1:,:,:]` could be `sics[1:3, ...] = sicm[0][1:, ...]` – alkasm Jan 10 '18 at 11:15
  • I have solved it myself. Thanks – Yuhang Pan Jan 11 '18 at 00:25

0 Answers0