jdkloe / pybufr-ecmwf

a python module that allows reading and writing BUFR formatted files, where BUFR stands for Binary Universal Form for the Representation of meteorological data.
Other
29 stars 12 forks source link

Fix the call to convert_flag_values_to_text in get_subset_values #1

Closed matthieu-bernard closed 9 years ago

matthieu-bernard commented 9 years ago

The call to get_subset_values with option expand_flags was returning an error message. Call was made using an undefined variable i.

Only on call was made for all values inside one subset. Look wrong as theses values can represent different variables. Use a list comprehension to loop over the values and call convert_flag_values_to_text on each.

Tested on an ASCAT BUFR subset. Does what expected. Although because of convert_flag_values_to_text design it return a list of lists. Would it be better to have a list of values?

[['DE BILT'], [0.0], [903.0], ['METOP-2'], ['ESA/ EUMETSAT SCATTEROMETERS ASCAT ADVANCED SCATTE ROMETER'], ['DATA FROM MULTIPLE GROUND STATION (CO-LOCATED DATA)'], ['MID BEAM'],...... ['ACCEPTABLE'], ['GOOD'], .............

This part of the code was preceeded with the following comment "# this code is not yet tested, not sure if this still works".

And thanks for this package

Matthieu

jdkloe commented 9 years ago

Hi, thanks a lot for your bug report and proposed fix. Unfortunately you have used an editor which seems to have altered white space in more than 100 lines, so I will not directly pull your patch into my main branch. I choose to copy paste your fixed line and recorded your contribution in the change log. On top I added a change that fixes the nested lists and adds some unittests to make sure this will not break in future changes.