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

Return 3.x um reflectance with the same dtype as the NIR data #206

Merged
merged 16 commits into from
Nov 27, 2023

Conversation

pnuu
Copy link
Member

@pnuu pnuu commented Nov 21, 2023

This PR keeps the dtype of the input NIR data for the calculated reflected portion of it. For non-Numpy/Dask inputs float64 is used.

The approach is pretty simplistic, I didn't want to start passing dtype to the parent class of the Calculator (RadTbConverter)

@pnuu pnuu self-assigned this Nov 21, 2023
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (6f3b523) 89.96% compared to head (234ac91) 89.92%.

Files Patch % Lines
pyspectral/tests/unittest_helpers.py 50.00% 5 Missing ⚠️
pyspectral/radiance_tb_conversion.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   89.96%   89.92%   -0.04%     
==========================================
  Files          23       23              
  Lines        2580     2571       -9     
==========================================
- Hits         2321     2312       -9     
  Misses        259      259              
Flag Coverage Δ
unittests 89.92% <94.23%> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mraspaud
Copy link
Member

I don't think we need to pass the dtype to the class constructor, we can just use the temp dtype directly in tb2radiance right?
I think it would look better, and that way we avoid upscaling and downscaling again, if we ensure that the planck function doesn't do the upscaling to start with.

@pnuu
Copy link
Member Author

pnuu commented Nov 23, 2023

As @mraspaud suggested, I now handle the type conversion/preservation in blackbody and rad2bt methods. Along the way I needed to convert some tests to pytest so I could parametrize the dtype stuff.

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I just have a few comments inline.

pyspectral/blackbody.py Outdated Show resolved Hide resolved
pyspectral/blackbody.py Outdated Show resolved Hide resolved
pyspectral/tests/test_blackbody.py Outdated Show resolved Hide resolved
pyspectral/tests/test_blackbody.py Show resolved Hide resolved
pyspectral/tests/unittest_helpers.py Outdated Show resolved Hide resolved
Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for all the effort @pnuu !

@mraspaud
Copy link
Member

@adybbroe do you want to have a last look before we merge thist?

Copy link
Collaborator

@adybbroe adybbroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nothing to add, nice work.

@djhoese djhoese merged commit 681967d into pytroll:main Nov 27, 2023
16 of 17 checks passed
@pnuu pnuu deleted the fix-nir-reflectance-dtype branch November 28, 2023 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Near infrared reflectance calculation does not preserve input dtype
4 participants