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

Unit prefix d is used as key for *decameter* and *decimeter* in str_to_nm definition. #3

Open
KelSolaar opened this issue Mar 30, 2024 · 0 comments

Comments

@KelSolaar
Copy link

Hello,

I noticed that d is used as key for decameter (dam) and decimeter (dm) in the str_to_nm definition:

def str_to_nm(value, multiplier, units):
    v = float(value.replace(',', '.'))

    # avoid rounding errors if the value is already in nanometres
    if multiplier == 'n' and units == 'm':
        return v

    unit_prefix = { 'Y':1e24, 'Z':1e21, 'E':1e18, 'P':1e15, 'T':1e12, 'G':1e9, 'M':1e6, 'k':1e3, 'h':1e2, 'd':1e1, '': 1, 'd':1e-1, 'c':1e-2, 'm':1e-3, 'u':1e-6, 'n':1e-9, 'p':1e-12}

    v *= unit_prefix[multiplier]

    if units == 'Hz':
        v = 299792458. / v * 1e9
    elif units == 'm':
        v *= 1e9
    else:
        raise ValueError

    return v

The C++ code uses da for decameter: https://github.com/afichet/spectral-exr/blob/master/lib/Util.h#L82C17-L82C19

Cheers,

Thomas

KelSolaar added a commit to KelSolaar/spectral-exr that referenced this issue Mar 30, 2024
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

No branches or pull requests

1 participant