I have a GRIB1 file in which I need to modify values for several datasets. I create my own np.array and want to replace values for particular dataset in existing file. Does pygrib have the options/possibility for doing that?
Thank you for your answer. We managed to create our array. The main problem is how to output it in existing GRIB file (i.e. replace the values in GRIB files by our values from the np.array). We need to modify existing file, not create the new one. The way which used conversion GRIB to/from NetCDF of HDF also is not appropriate in our case.
char. replace() function of the char module in Numpy library. The replace() function is used to return a copy of the array of strings or the string, with all occurrences of the old substring replaced by the new substring.
thank you for your answer. Maybe I do not clarify all the details. We do not have any problem with numpy and replacement the values in the array. The problem is how to replace/output these values (our own np.array, which we have already created) in the existing GRIB file. I mean how to deal with GRIB1 (which could be modified only with pygrib)
I am trying to solve the same problem. I have a GRIB file, call it grib1, that I want to change the values of to a new array that I have created, call it new_arr. I have tried going about directly setting grib1.values = new_arr (or grib1['values'] = new_arr) but neither option works. The resulting grib1.values is not the same as new_arr, rather some strange combination of the old array and new_arr. How did you solve this? Any advice is greatly appreciated!