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

Fix attribute datatypes in CF Writer #867

Merged
merged 3 commits into from Aug 26, 2019

Conversation

sfinkens
Copy link
Member

@sfinkens sfinkens commented Aug 7, 2019

The CF writer currently converts all numpy integer/float attributes to Python int/float. This was originally added to facilitate serialization of complex attributes (such as raw_metadata) using json. But since it is also applied to other attributes, it causes mismatches between the type of an nc variable and its _FillValue attribute for example.

This PR preserves the datatype of attributes, if possible, and adds a separate method to support json serialization.

  • Closes #xxxx
  • Tests added and test suite added to parent suite
  • Tests passed
  • Passes flake8 satpy

Preserve datatype of scalar numpy attributes, if possible.
@sfinkens sfinkens requested a review from djhoese August 8, 2019 07:50
@sfinkens sfinkens marked this pull request as ready for review August 8, 2019 07:50
@sfinkens sfinkens requested a review from mraspaud as a code owner August 8, 2019 07:50
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.

LGTM, will merge when the tests pass

@codecov
Copy link

codecov bot commented Aug 26, 2019

Codecov Report

Merging #867 into master will decrease coverage by <.01%.
The diff coverage is 87.5%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #867      +/-   ##
==========================================
- Coverage   84.62%   84.62%   -0.01%     
==========================================
  Files         169      169              
  Lines       24988    24996       +8     
==========================================
+ Hits        21147    21152       +5     
- Misses       3841     3844       +3
Impacted Files Coverage Δ
satpy/tests/writer_tests/test_cf.py 98.54% <100%> (+0.01%) ⬆️
satpy/writers/cf_writer.py 91.43% <85%> (-0.55%) ⬇️
satpy/readers/avhrr_l1b_gaclac.py 90.14% <0%> (-1.41%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4543926...7c4ee7a. Read the comment docs.

@mraspaud mraspaud merged commit 5d98f28 into pytroll:master Aug 26, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 84.622% when pulling 7c4ee7a on sfinkens:fix-cf-writer-dtype into 4543926 on pytroll:master.

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.

None yet

3 participants