Skip to content

ECOSTRESS database does string comparison without converting to lowercase first #191

Backlog

Description

@MayaMaya4096

Hi,

I believe I found a bug in ECOSTRESS database code, I came across it by accident. When I was looking at different spectra, I noticed that there were several typos that made automatic processing difficult, like "Tansmission", "Transmittence" and "Reflectence". I assumed that SPy didn't do any cleanup, so I did my own cleanup and moved on. Then while I was looking at spectral/database/ecostress.py for something unrelated, I noticed that SPy actually does cleanup:

This is at line 194:

            yUnit = m['y units']
            if yUnit.find('reflectence') > -1:
                yUnit = 'reflectance (percent)'
            elif yUnit.find('trans') == 0:
                yUnit = 'transmittance (percent)'
            measurement = m['measurement']
            if measurement[0] == 't':
                measurement = 'transmittance'
            self._add_signature(id, -1, instrument, environment, measurement,
                                m['x units'], yUnit, m['first x value'],
                                m['last x value'], sig.x, sig.y)

However the database I built by spectral.EcostressDatabase.create("ecostress.db", "ecostress") did not have any of these fixes.

Looking at the code, I traced the issue to the function metaline_to_pair at line 26: The function does not do any lowercase conversion, unlike the ASTER database equivalent function read_pair in spectral/database/aster.py at line 38. As the typo checks at line 194 all use lowercase, they don't catch typos with mismatching case.

I didn't create a merge request because I'm not sure if this is intended behavior or not, and I'm not sure what would be the desired way to fix it (the lowercase conversion could be added to both to the metaline_to_pair function and to the typo checks). If this is indeed not desired behavior, and you have a preferred fix, I can quickly create a merge request.

Have a nice day!

Activity

  1. changed the title [-]ECOSTRESS database "metaline" processing does string comparison without converting to lowercase first[/-] [+]ECOSTRESS database does string comparison without converting to lowercase first[/+] on Nov 30, 2026
  2. tboggs commented on Nov 30, 2026

    @tboggs
    Member

    Hello,

    For each of the library formats, there is some code to deal with idiosyncrasies of the library. If you think there is a reasonable solution to fix those typos, please feel free to make a merge request. It can either be a global check for typo in any entry or, if there are a few pathological cases, they could be handled as a conditional statement for those entries (and handle the possibility that the typos are fixed in a future version of the library).

    Thanks!

  3. MayaMaya4096 commented on Dec 1, 2026

    @MayaMaya4096
    Author

    Hello,

    For each of the library formats, there is some code to deal with idiosyncrasies of the library. If you think there is a reasonable solution to fix those typos, please feel free to make a merge request. It can either be a global check for typo in any entry or, if there are a few pathological cases, they could be handled as a conditional statement for those entries (and handle the possibility that the typos are fixed in a future version of the library).

    Thanks!

    Hi,

    Firstly I'm sorry, I'm not great at explaining things and I guess I phrased the issue really badly. I was not suggesting new fixes for typos, but was trying to say that the typo fixes that are already implemented for the ECOSTRESS database are not working due to a missing lowercase conversion. So for instance if yUnit.find('reflectence') > -1 always returns -1 because yUnit is not converted to lowercase, and in the ECOSTRESS library it's always "Reflectence", not "reflectence".

    The checks are identical to the ASTER code but the ASTER code correctly converts the yUnit (and everything else) to lowercase, the issue only happens in ECOSTRESS code.

    Regardless given that this is not intended behavior, I'll quickly make a merge request, thanks for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions