-
Notifications
You must be signed in to change notification settings - Fork 27
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
Quality indicators #72
Conversation
…and get_qual_flags to the parent class Reader
It appears to me like there is a test missing where the mask property is built from given quality indicators. Currently all tests replace the call to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, I really like how using an enum makes things much clearer. I just have a few questions inline.
try: | ||
from enum import IntFlag | ||
except ImportError: | ||
# python version < 3.6, use a simple object without nice representation | ||
IntFlag = object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decide that pygac is python >= 3.6 only? It would make a lot simpler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely, I would be one of the first to vote for it.
There are already a lot of special python 2 hacks and test cases that we skip, so it would totally make sense.
I don't know all PyGAC users, but nowadays it is easy to set up a python >= 3.6 environment using anaconda, so I guess no one will complain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's fine. But let's do this in a separate PR ;)
pygac/klm_reader.py
Outdated
CH_3B_RS = 2**24 | ||
CH_3B_RS_ANOMALY = 2**25 | ||
CH_4_RS = 2**26 | ||
CH_4_RS_ANOMALY = 2**27 | ||
CH_5_RS = 2**28 | ||
CH_5_RS_ANOMALY = 2**29 | ||
# using same name as for POD | ||
CH_3_CONTAMINATION = 2**24 # Channel 3 solar blackbody contamination | ||
CH_4_CONTAMINATION = 2**26 # Channel 4 solar blackbody contamination | ||
CH_5_CONTAMINATION = 2**28 # Channel 5 solar blackbody contamination |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something is fishy here, 224, 226 and 2**28 are used twice. Does this work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is possible to define several aliases, which I did to have the same names as in the POD QFlags. In this case both flags have the same meaning so it should not be very confusing. A more "critical" flag is
SYNC_INVALID = 2**10 # Frame sync word not valid
FLYWHEELING = 2**10 # Flywheeling detected during this frame
see the docstring note.
I could implement the correct Flag in the constructor after checking the date, but the static implementation is simpler and I hope that someone using this flag knows which definition is applicable...
Any suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Just to make it clearer, maybe having the pod name close the klm would help?
CH_3B_RS = 2**24 | |
CH_3B_RS_ANOMALY = 2**25 | |
CH_4_RS = 2**26 | |
CH_4_RS_ANOMALY = 2**27 | |
CH_5_RS = 2**28 | |
CH_5_RS_ANOMALY = 2**29 | |
# using same name as for POD | |
CH_3_CONTAMINATION = 2**24 # Channel 3 solar blackbody contamination | |
CH_4_CONTAMINATION = 2**26 # Channel 4 solar blackbody contamination | |
CH_5_CONTAMINATION = 2**28 # Channel 5 solar blackbody contamination | |
CH_3B_RS = 2**24 | |
# POD compatible name, Channel 3 solar blackbody contamination | |
CH_3_CONTAMINATION = 2**24 | |
CH_3B_RS_ANOMALY = 2**25 | |
CH_4_RS = 2**26 | |
# POD compatible name, Channel 4 solar blackbody contamination | |
CH_4_CONTAMINATION = 2**26 | |
CH_4_RS_ANOMALY = 2**27 | |
CH_5_RS = 2**28 | |
# POD compatible name, Channel 5 solar blackbody contamination | |
CH_5_CONTAMINATION = 2**28 | |
CH_5_RS_ANOMALY = 2**29 |
SYNC_INVALID = 2**10 # Frame sync word not valid | ||
FLYWHEELING = 2**10 # Flywheeling detected during this frame | ||
BIT_SLIPPAGE = 2**11 # Bit slippage detected during this frame | ||
TIP_PARITY = 2**23 # TIP parity error detected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, why are 12-22 not included ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply because they are not defined for KLMs
bit 20: bit slippage detected during this frame
bits 19-9: <zero fill>
bit 8: TIP parity error detected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, maybe a comment here would be nice then, just to clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, that improves readability a lot!
Edit: I think a separate test for _get_corrupt_mask
would be nice.
Source: | ||
KLM guide | ||
Table 8.3.1.3.3.1-1. Format of packed LAC/HRPT Data Sets (Version 2, pre-April 28, 2005). | ||
Table 8.3.1.3.3.2-1. Format of LAC/HRPT Data Record for NOAA-N (Version 5, post-November 14, | ||
2006, all spacecraft). | ||
Table 8.3.1.4.3.1-1. Format of packed GAC Data Record for NOAA KLM (Version 2, pre-April 28, 2005). | ||
Table 8.3.1.4.3.2-1. Format of GAC Data Record for NOAA-N (Version 4, post-January 25, 2006, | ||
all spacecraft). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
…spare quality indicator bits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@carloshorn Is this ready for merge or do you want to implement @sfinkens 's suggestion? |
The suggested test for |
LGTM! |
Ah, yes, sorry, the name of the tests confused me into thinking it was testing something else. Merging. |
This PR should close #60.
It implements the quality indicator mapping as
enum.IntFlag
for KLM and POD readers and moves the methodsreader._get_corrupt_mask
andget_qual_flags
to the parent class.