Skip to content

Conversation

@gerritholl
Copy link
Member

@gerritholl gerritholl commented May 4, 2020

Add support for reading pixel quality, closing #1171

Read pixel quality ancillary variables. This is done with a small hack, because the data variables have the same name in each group, so Satpy doesn't know where to look when simply told to look for pixel_quality. This may change later when dynamic dataset ids are introduced (see #1088) but so far this is not supported. Therefore, when reading the parent variable, the filehandler rewrites the ancillary_variables variable attribute to prepend the channel name, such that when the same filehandler is called a little later for the variable name, it knows where to find it. See also the discussion in #1171.

Add a test to ensure that using the FCI reader does not lead to any log
messages at warning level or above.

Although I expect this test to fail as I haven't fixed pytroll#1171 yet, it is
currently failing for the wrong reason as despite running with pytest,
it doesn't seem to understand using the caplog fixture.
@gerritholl gerritholl force-pushed the fci-pixel-quality branch from 6998973 to 1503d3c Compare May 4, 2020 14:34
gerritholl added a commit to gerritholl/satpy that referenced this pull request May 4, 2020
Migrate FCI tests to pytest.  This enables the more flexible set of
fixtures available there.  This will be needed by at least one of the
tests to be added in pytroll#1177
@gerritholl gerritholl mentioned this pull request May 4, 2020
5 tasks
gerritholl added 2 commits May 5, 2020 10:52
Merging branches, resolving merge conflict.
In FCI reader, rewrite pixel_quality in get_dataset, such that context
about the channel it belongs to is available within the dataset name.
@mraspaud mraspaud added component:readers enhancement code enhancements, features, improvements labels May 5, 2020
gerritholl added 5 commits May 5, 2020 15:25
The branch fci-goes-pytest is needed for fci-pixel-quality.  Merge this
while resolving the merge conflicts.
The ancillary_variables was missing from the fake data in the FCI test,
causing a failure in reading channel ir_38.  Add attribute for this one
too.
Add pixel quality for channel vis_04 for the fci_l1c_fdhsi reader.
Currently this leads to recursion errors.
Add pixel quality fields for FCI reading.  This currently relies on a
small hack rewriting the ancillary_variables fields, because the data
variable pixel_quality has the same name in different groups, and Satpy
doesn't currently have a good way of keeping track of what group this
belongs to.

Fixes 1171.
@gerritholl gerritholl marked this pull request as ready for review May 6, 2020 09:12
@gerritholl gerritholl changed the title Make FCI reader not logs warnings such as about pixel_quality Add support for reading pixel_quality ancillary variables, FCI reader no longer logs warnings May 6, 2020
Add documentation and warning about reading pixel quality from FCI
files.
@coveralls
Copy link

coveralls commented May 6, 2020

Coverage Status

Coverage increased (+0.06%) to 89.678% when pulling 9c0adbc on gerritholl:fci-pixel-quality into ef24f29 on pytroll:master.

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #1177 into master will increase coverage by 0.05%.
The diff coverage is 98.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1177      +/-   ##
==========================================
+ Coverage   89.61%   89.67%   +0.05%     
==========================================
  Files         200      200              
  Lines       29523    29722     +199     
==========================================
+ Hits        26458    26654     +196     
- Misses       3065     3068       +3     
Impacted Files Coverage Δ
satpy/readers/fci_l1c_fdhsi.py 98.06% <94.11%> (+1.68%) ⬆️
satpy/tests/reader_tests/test_fci_l1c_fdhsi.py 100.00% <100.00%> (ø)
satpy/readers/avhrr_l1b_gaclac.py 93.33% <0.00%> (-1.34%) ⬇️
satpy/readers/hrit_jma.py 97.94% <0.00%> (-1.22%) ⬇️
satpy/writers/cf_writer.py 93.77% <0.00%> (-0.03%) ⬇️
satpy/writers/geotiff.py 90.74% <0.00%> (ø)
satpy/readers/netcdf_utils.py 100.00% <0.00%> (ø)
satpy/readers/seviri_l1b_native.py 71.96% <0.00%> (ø)
satpy/tests/reader_tests/test_ahi_hrit.py 100.00% <0.00%> (ø)
satpy/tests/reader_tests/test_seviri_l1b_native.py 95.16% <0.00%> (ø)
... and 9 more

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 ef24f29...9c0adbc. Read the comment docs.

gerritholl added 2 commits May 6, 2020 12:28
Improve test coverage in FCI reader, covering various "bad data" cases
that weren't covered before.
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.

Thanks for adding the pixel quality datasets, it'll be crucial for the validation of the data when the satellite launches. I just have a couple of style suggestions, otherwise LGTM.

As per comments from @mraspaud, reformulate some error messages in the
FCI L1C FDHSI file handler.
Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

This looks overall good to me. I had one comment inline about handling the ancillary_variables attribute, but one other point that I think @mraspaud made on slack over somewhere: What do you think about using available_datasets in the file handler to define these new datasets instead of listing them in the YAML?

I am also not a huge fan of sensor: being defined for each dataset. I feel like that should come from the file handler.

Rewrite the ancillare_variables pixel_quality value more flexibly,
allowing for multiple variables to be listed here.
@gerritholl
Copy link
Member Author

Sorry, didn't notice until now you'd left comments here.

There seem to be many readers defining sensor: in the yaml file, I just followed the precedent there.

What is the advantage of available_datasets() over defining the format in the yaml file if every file must have the same content? We don't need to read the file to know what should be in it, and if any of those datasets are not in it, it is a bug. Isn't the whole point of the yaml file to keep the definition of what's in the file out of the source code?

@djhoese
Copy link
Member

djhoese commented May 13, 2020

Isn't the whole point of the yaml file to keep the definition of what's in the file out of the source code?

Yes. You could also see it as the YAML helps us define things that aren't known from reading the file. For example, the wavelengths of a band are normally in the YAML because they aren't defined in the data files. I think defining the datasets you have in YAML is fine since you've already done it, but available_datasets could be nice to automatically support future datasets if they are added to the files (assuming resolution and other metadata can be determined from the files). With FCI having so many files per time step though it is probably better to keep it in the YAML or we could end up with a recursion limit problem of calling available_datasets for every file handler.

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

Labels

component:readers enhancement code enhancements, features, improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add reading of pixel_quality variable to FCI FDHSI reader

4 participants