Hi,
I have a selafin file with space varying rainfall values for one time step. The shape of the array is (1, 24821)
I want to add values of more time steps. shape: (19,24821)
but while doing that I got the same error as Costas "IndexError: too many indices for array".
Can someone please help me to resolve this issue?
Best Regards,
Nitesh
from pputils_master.ppmodules.selafin_io_pp import *
# read *.slf file
slf = ppSELAFIN('Raini_15_12.slf')
slf.readHeader()
slf.readTimes()
# store into arrays
times = slf.getTimes()
vnames = slf.getVarNames()
vunits = slf.getVarUnits()
float_type,float_size = slf.getPrecision()
NELEM, NPOIN, NDP, IKLE, IPOBO, x, y = slf.getMesh()
vunits.clear()
vunits.append('mm')
times.clear()
times.extend(range(0, 19))
vnames.clear()
vnames.append('RAINI')
# read the variables for the time step 0
slf.readVariables(0)
results = slf.getVarValues()
print (results)
print(type(results))
results.shape
#[[1.61982179 1.60806787 1.63061941 ... 1.87916398 1.87916398 1.87916398]]
#<class 'numpy.ndarray'>
#(1, 24821)
results1 = np.concatenate((results, ar), axis=0)
results2=np.delete(results1,0,0)
results2.shape
#(19, 24821)
# write *.slf file
slf2 = ppSELAFIN('file_to_be_written.slf')
slf2.setPrecision(float_type,float_size)
slf2.setTitle('created with pputils')
slf2.setVarNames(vnames)
slf2.setVarUnits(vunits)
slf2.setIPARAM([1, 0, 0, 0, 0, 0, 0, 0, 0, 1])
slf2.setMesh(NELEM, NPOIN, NDP, IKLE, IPOBO, x, y)
slf2.writeHeader()
for i in range (0,19):
slf2.writeVariables(i, results2[i,:])
---> 14 slf2.writeVariables(i, results2[i,:])
IndexError: too many indices for array