Unexpected value: 14

Issue #9 new
Gustavo Bayma created an issue

Hi everybody.

What does  Unexpected value: 14 mean in MESMA procedure?

I look forward to hearing from you

Comments (2)

  1. Julian Podgorski

    Hello!

    I did encounter the same problem and after half a day diving in MESMA code I found the problem and managed to create a band-aid which makes the plugin work.

    Tl;dr: GDAL resampling algorithm parser receives invalid value (which equals 14), we need to replace the raise error clause (line 3144 inhubdc/core.py) with definition of an algorithm identical as the valid cases (e.g. paste resampleAlg = 'bilinear' after else and comment out or delete the raise TypeError('unexpected value: {}'.format(resampleAlg)) and things will work again)

    In the filehubdc/core.py in the class ResampleAlgHandler on the line 3144 is the error raising clause, which has the words "unexpected value:". It sits inside a method, whose purpose is to convert integer IDs of GDAL interpolation algorithms into their names compliant with GDAL input requirements. The problem is, that the function (ResampleAlgHandler.toString()) does only allow 13 different integers (0-12) and throws the "unexpected value:" error when it gets any number from outside the range.

    Right below this piece of code sits another method of the same class - resampleAlgorithms. Its purpose is to fetch integer codes of all resampling algorithms available in the gdal module and return a list of numbers to be passed to the toString()method mentioned above. The problem is, that the list comprehension used pulls from the GDAL library of things not just the resampling methods valid for the toString() method, but also things, which either aren't even a resampling algorithm OR were added to GDAL after the MESMA plugin became deprecated, so the plugin can't account for them. Among them is a value of "14". And our toStringmethod doesn't know what "14" means so it throws the error.

    Since the error doesn’t have any ramifications downstream and it’s located in a simple function we can rather safely remove the entire error-causing clause (line 3144). We need to put something in its place (so that the plugin won’t do something weird next time we run it), so let’s just replace it with a definition of an interpolation algorithm we like and consider safe to use in unpredicted cases. In my case it’s the bilinear interpolation. So in the line 3144 I’m putting the following: resampleAlg = 'bilinear' an expression identical to the one assigned to the value of “1”. 1 is a valid input for the problematic method, so in effect my replacement eliminates the erroneous behaviour caused by unexpected numbers (not just 14, but any of them). Of course we need to eliminate the error-thrower, so just comment the content we had in the line 3144 before (raise TypeError('unexpected value: {}'.format(resampleAlg))) or delete it altogether.

  2. Log in to comment