def convertGribToTiff(listeFile,listParam,listLevel,liststep,grid,startDate,endDate,outFolder):
dicoValues={}<EOL>for l in listeFile:<EOL><INDENT>grbs = pygrib.open(l)<EOL>grbs.seek(<NUM_LIT:0>)<EOL>index=<NUM_LIT:1><EOL>for j in range(len(listLevel),<NUM_LIT:0>,-<NUM_LIT:1>):<EOL><INDENT>for i in range(len(listParam)-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>grb = grbs[index]<EOL>p=grb.name.replace('<STR_LIT:U+0020>','<STR_LIT:_>')<EOL>if grb.level != <NUM_LIT:0>:<EOL><INDENT>l=str(grb.level)+'<STR_LIT:_>'+grb.typeOfLevel<EOL><DEDENT>else:<EOL><INDENT>l=grb.typeOfLevel<EOL><DEDENT>if p+'<STR_LIT:_>'+l not in dicoValues.keys():<EOL><INDENT>dicoValues[p+'<STR_LIT:_>'+l]=[]<EOL><DEDENT>dicoValues[p+'<STR_LIT:_>'+l].append(grb.values)<EOL>shape=grb.values.shape<EOL>lat,lon=grb.latlons()<EOL>geoparam=(lon.min(),lat.max(),grid,grid)<EOL>index+= <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>nbJour=(endDate-startDate).days+<NUM_LIT:1><EOL>for s in range(<NUM_LIT:0>, (len(liststep)*nbJour-len(listeFile))):<EOL><INDENT>for k in dicoValues.keys():<EOL><INDENT>dicoValues[k].append(np.full(shape, np.nan))<EOL><DEDENT><DEDENT>for i in range(len(dicoValues.keys())-<NUM_LIT:1>,-<NUM_LIT:1>,-<NUM_LIT:1>):<EOL><INDENT>dictParam=dict((k,dicoValues[dicoValues.keys()[i]][k]) for k in range(<NUM_LIT:0>,len(dicoValues[dicoValues.keys()[i]])))<EOL>sorted(dictParam.items(), key=lambda x: x[<NUM_LIT:0>])<EOL>outputImg=outFolder+'<STR_LIT:/>'+dicoValues.keys()[i]+'<STR_LIT:_>'+startDate.strftime('<STR_LIT>')+'<STR_LIT:_>'+endDate.strftime('<STR_LIT>')+'<STR_LIT>'<EOL>writeTiffFromDicoArray(dictParam,outputImg,shape,geoparam)<EOL><DEDENT>for f in listeFile:<EOL><INDENT>os.remove(f)<EOL><DEDENT>
Convert GRIB to Tif