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

Near infrared reflectance calculation does not preserve input dtype #205

Closed
pnuu opened this issue Nov 20, 2023 · 0 comments · Fixed by #206
Closed

Near infrared reflectance calculation does not preserve input dtype #205

pnuu opened this issue Nov 20, 2023 · 0 comments · Fixed by #206

Comments

@pnuu
Copy link
Member

pnuu commented Nov 20, 2023

Code Sample, a minimal, complete, and verifiable piece of code

import dask.config
import dask.array as da
import numpy as np
from satpy.tests.utils import CustomScheduler

from pyspectral.near_infrared_reflectance import Calculator


with dask.config.set(scheduler=CustomScheduler(max_computes=0)):
    calc = Calculator("Meteosat-10", "seviri", 3.9)
    sunz = da.array([80.], dtype=np.float32)
    tb3 = da.array([290.], dtype=np.float32)
    tb4 = da.array([282.], dtype=np.float32)
    res = calc.reflectance_from_tbs(sunz, tb3, tb4)
    assert res.dtype == np.float32

Problem description

If the input data passed to Calculator are as float32, the return value is upcast to float64 by the calculator.

Expected Output

Get the NIR reflectance with the same dtype as the inputs.

Actual Result, Traceback if applicable

Result has dtype=np.float64.

Versions of Python, package at hand and relevant dependencies

Python 3.11, current Pyspectral main, current Satpy main.

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

Successfully merging a pull request may close this issue.

1 participant