pygrib
pygrib copied to clipboard
Issue replacing values in a gribmessage
Hello,
I am trying to change the values associated with a gribmessage.
Say 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.
Example: Original value in grib file: 2015.5 The value I want in the grib file: 215.6476593 The value that is in the grib file after setting it (grib1.values = new_arr): 216.33317871 Of course the example is just of a single value but it is happening everywhere in the array.
I checked and the precision of arrays all equal float64. Do you have to the same number of significant digits when trying to replace the old values with the new values?
How did you solve this? Any advice is greatly appreciated!
-Chris
Sorry typo: Original value in grib file: 215.5
might have to do with the grib compression which is 'lossy'
What is the solution to this, I am having the same issue.