spectralpython / spectral

Python module for hyperspectral image processing
MIT License
571 stars 139 forks source link

Unable to parse bad band list (bbl) in header as integers. #95

Closed admercs closed 3 years ago

admercs commented 4 years ago

Hello, I'm getting the warning Unable to parse bad band list (bbl) in header as integers. while loading ENVI header files and I would like to suppress this warning with a flag in the function to hide all warnings. Is this currently possible? This warning is filling up my log files...

tboggs commented 4 years ago

Can you post the value of bbl from your header file? Also, what version of spectral are you using?

lewismc commented 4 years ago

Reminds me of work we did in #67

admercs commented 4 years ago

Precisely.

Booleans are a subclass on integers in Python, so the ‘bbl’ could be parsed as either an integer or Boolean array. I believe the ‘bbl’ is only used to mask bad bands though, so a Boolean array may be more semantically accurate.

On Thu, Nov 28, 2019 at 14:57 Lewis John McGibbney notifications@github.com wrote:

Reminds me of work we did in #67 https://github.com/spectralpython/spectral/issues/67

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spectralpython/spectral/issues/95?email_source=notifications&email_token=ABL4FIHTBVAD3UZTTAWIRJDQWAPCPA5CNFSM4JN6FGS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFNLQWQ#issuecomment-559593562, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABL4FIAEXWGLMETM47Y225LQWAPCPANCNFSM4JN6FGSQ .

tboggs commented 4 years ago

@adam-erickson, as @lewismc mentioned, this issue was addressed recently in another issue. I can change the print statements to logging messages so they can be easily avoided but I'd first like to understand why you are getting those warnings. If you could post the bbl line from your header file and the version of spectral you are using, that should be sufficient to figure it out.

admercs commented 4 years ago

I apologize for the slow reply. The band band list is simply empty: bbl = [] and the output of spectral.__version__ is '0.20'.

tboggs commented 4 years ago

That is confusing to me. Is the line literally

bbl = []

in the header file? First, that doesn't appear to be correct syntax for an ENVI header file because arrays use curly braces ({}) to define arrays. Second, I've never seen an empty bbl list because if it is present, it normally has as many elements as there are bands.

Can you confirm that is literally how it appears in the header (.hdr) file and also how the header was generated (e.g., by ENVI or from some other script)?

admercs commented 4 years ago

Yep, that’s literally what’s in the header file, which was output by a non-standard program. I can create an issue in that repo instead, but this issue could potentially arise again from another program.

On Fri, Dec 6, 2019 at 18:30 Thomas Boggs notifications@github.com wrote:

That is confusing to me. Is the line literally

bbl = []

in the header file? First, that doesn't appear to be correct syntax for an ENVI header file because arrays use curly braces ({}) to define arrays. Second, I've never seen an empty bbl list because if it is present, it normally has as many elements as there are bands.

Can you confirm that is literally how it appears in the header (.hdr) file and also how the header was generated (e.g., by ENVI or from some other script)?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spectralpython/spectral/issues/95?email_source=notifications&email_token=ABL4FIDA355AL6BSRLSUAADQXLOB7A5CNFSM4JN6FGS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGFVZHY#issuecomment-562781343, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABL4FIBZG7VF3WMEUAY4FEDQXLOB7ANCNFSM4JN6FGSQ .

tboggs commented 4 years ago

Yes, please create an issue for the other program. That line breaks the syntax of the ENVI file format. The spectral module interprets that line as meaning the bbl parameter is the string "[]" (I'm not sure how ENVI would handle it). Beyond using the wrong syntax, it isn't even clear what the empty list is supposed to mean. Are all bands bad or none? And if there were some bad bands, would it be listing only the indices of the bad bands?

The issue @lewismc referred to was related to the bbl values being 1.0 or 0.0 (instead of 1 or 0), causing a typecasting issue, which was easy enough to handle (and was consistent with the documented ENVI file format). But even in that situation, there were still as many bbl elements as there were bands (i.e., bbl is intepreted as a mask array).

Is the code for the other program hosted online? If so, I'd be curious to take a look at it.

As I mentioned before, I will migrate some of the print statements to logging statements so that one can simply change the logging level to avoid those repeated warnings.

tboggs commented 3 years ago

Closing due to lack of activity.