Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key/value not found error for keys that exists #46

Closed
liamtill opened this issue Mar 20, 2023 · 4 comments · Fixed by #48
Closed

Key/value not found error for keys that exists #46

liamtill opened this issue Mar 20, 2023 · 4 comments · Fixed by #48

Comments

@liamtill
Copy link

Hi,

I've recently starting implementing pdbufr in my BUFR decoding. It has been working well until testing on a larger sample of files. I have encountered the error:

gribapi.errors.KeyValueNotFoundError: Key/value not found

Whilst trying to extract using:

pdbufr.read_bufr(bufr_file, columns=('stationNumber', 'timePeriod', 'maximumWindGustDirection', 'maximumWindGustSpeed'))

The data are BUFR files provided by the Met Office. Using bufr_dump on (one of) the BUFR files I can see that the keys do exists and have determined that is is the timePeriod key causing the error:

A sample from bufr_dump showing the keys existing. The keys exist for all stations within the file. :

[

                                                                    {
                                                                      "key" : "timePeriod",
                                                                      "value" : -10,
                                                                      "units" : "min"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustDirection",
                                                                      "value" : 190,
                                                                      "units" : "deg"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustSpeed",
                                                                      "value" : 4.9,
                                                                      "units" : "m/s"
                                                                    }
                                                                  ],
                                                                  [

                                                                    {
                                                                      "key" : "timePeriod",
                                                                      "value" : -60,
                                                                      "units" : "min"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustDirection",
                                                                      "value" : 190,
                                                                      "units" : "deg"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustSpeed",
                                                                      "value" : 5.8,
                                                                      "units" : "m/s"
                                                                    }
                                                                  ],
                                                                  [

                                                                    {
                                                                      "key" : "timePeriod",
                                                                      "value" : -180,
                                                                      "units" : "min"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustDirection",
                                                                      "value" : 210,
                                                                      "units" : "deg"
                                                                    },
                                                                    {
                                                                      "key" : "maximumWindGustSpeed",
                                                                      "value" : 8.4,
                                                                      "units" : "m/s"
                                                                    }
                                                                  ],

I noted issue #24 stating a similar issue, however I am using build of eccodes 2.29.0 built from source with pdbufr 0.9.0. The user in #24 stated updating solved their issue, but in this case I was already using 2.16.0 and updated to 2.29.0 to see if that resolved the issue.

Any ideas what might be causing this error given keys exists in the file?

Thanks

@sandorkertesz
Copy link
Collaborator

Hi Liam,

Thank you for reporting this issue. Please can I ask you to share either the input data (at least a few messages) or the full bufr dump for a given message with us?

Many thanks,
Sandor

@liamtill
Copy link
Author

Hi Sandor,

Thanks for your reply. I have attached the BUFR file causing the issue. I use both UK and EU data and there are a few files where, as with this file, the extraction fails for the same Key/Value not found. I have renamed the file from .dat to .txt to upload here.

syWEU_BUFR_0705.txt

Thanks,
Liam

@sandorkertesz
Copy link
Collaborator

sandorkertesz commented Mar 21, 2023

Hi Liam,

Thank you for the example file. I can conclude that the error comes from message 51 (if we count from 1) where one of the timePeriod values cannot be accessed, so this is probably a badly encoded BUFR message. Unfortunately, pdfbufr crashes without correctly reporting the real nature of the problem.

Thanks,
Sandor

@liamtill
Copy link
Author

Hi Sandor,

OK great, thanks for investigating. Yes, I think still being able to extract all other messages and even all the other data for a given station message even if a key is missing would be great. Also having a way to raise this as an exception such that other data can be extracted but we know the which key is missing and can decide on what to do by catching the exception.

Thanks for your great work.

Liam

iainrussell added a commit that referenced this issue Mar 28, 2023
…-key-missing-in-bufr-message

Do not fail when key value is not available in BUFR message #47 #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants