ValueError: key present and new value is different...
See original GitHub issue@darrenleeweber has reported on #2 a problem that deserves it’s own issue:
Thanks, also bumped into this while trying to read a GFS grib2 file, e.g.
import cfgrib
ds = cfgrib.Dataset.frompath('gfs_4_20110807_0000_000.grb2')
# snipped traceback
~/anaconda3/lib/python3.6/site-packages/cfgrib/dataset.py in enforce_unique_attributes(index, attributes_keys)
113 values = index[key]
114 if len(values) > 1:
--> 115 raise ValueError("multiple values for unique attribute %r: %r" % (key, values))
116 if values and values[0] not in ('undef', 'unknown'):
117 attributes['GRIB_' + key] = values[0]
ValueError: multiple values for unique attribute 'typeOfLevel': ['isobaricInhPa', 'tropopause', 'maxWind', 'isothermZero', 'unknown', 'potentialVorticity']
The work around seems to work, but hits another snag for this particular data example, i.e.
ds = cfgrib.Dataset.frompath('gfs_4_20110807_0000_000.grb2', filter_by_keys={'typeOfLevel': 'isobaricInhPa'})
# snipped traceback
~/anaconda3/lib/python3.6/site-packages/cfgrib/dataset.py in build_dataset_components(stream, encode_parameter, encode_time, encode_vertical, encode_geography, filter_by_keys)
374 vars = collections.OrderedDict([(short_name, data_var)])
375 vars.update(coord_vars)
--> 376 dict_merge(dimensions, dims)
377 dict_merge(variables, vars)
378 attributes = enforce_unique_attributes(index, GLOBAL_ATTRIBUTES_KEYS)
~/anaconda3/lib/python3.6/site-packages/cfgrib/dataset.py in dict_merge(master, update)
353 else:
354 raise ValueError("key present and new value is different: "
--> 355 "key=%r value=%r new_value=%r" % (key, master[key], value))
356
357
ValueError: key present and new value is different: key='air_pressure' value=26 new_value=25
It’s not easy to figure out if this is cfgrib or the data is not conforming.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
python - Why do I get a ValueError when trying to create an ...
Why do I get a ValueError when trying to create an OrderedDict with a single key/value pair? ... Do you guys know how...
Read more >cfgrib · PyPI
Opening a non-conformant GRIB file will fail with a ValueError: key present and new value is different... error message, see #13.
Read more >How to correct a #VALUE! error - Microsoft Support
The following might solve your problem: First do a quick test. In a new workbook, type a 2 in cell A1. Type a...
Read more >Python KeyError Exceptions and How to Handle Them
Here, there is a difference in checking to see if the error key exists in the response and getting a default value from...
Read more >pandas.Series.replace — pandas 1.5.2 documentation
For a DataFrame a dict can specify that different values should be replaced in different columns. For example, {'a': 1, 'b': 'z'} looks...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Raising or ignoring the exception is now configurable via the
errors
option inbackend_kwargs
. The default isstrict
that keep the exception but can be set toignore
to just drop the offending hypecubes.It worked this time (FYI I added
--no-sign-request
), you can take the file down. Thanks!