-
Notifications
You must be signed in to change notification settings - Fork 6
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 qc handling #136
fix qc handling #136
Conversation
hgloeckner
commented
Jan 17, 2025
- fix the ancillary vars in l3
- add the 'all' flag to the example config
4954cfb
to
7e33069
Compare
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.
Could you help me understand the default behaviour of the function add_qc_to_interim_l3
?
- If nothing is explicitly specified
keep
would bekeep=["sonde_qc"]
. - you'd end up in the
else
-block (line1512) and something will happen to all var != "sonde_id" theds[var].attrs
- and now, would you not end up again in the
else
-block line 1533 and get the warning? keep would be reset tokeep=[]
keep=[]
would be appended again by ["sonde_qc"] before ds_qc is created
This seems strange and I am pretty sure I have a bug in my thinking somewhere. Could you go through the default behaviour once and point me to my bug? 😅
if var != "sonde_id": | ||
ds[var].attrs.pop("ancillary_variables", None) |
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 cannot follow here: do you remove the key "ancillary_variables" from the dict?
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. if not all qc variables from level2 to level3, then the entry in the attributes of the variables is deleted (otherwise it would be referring to qc variables that are no longer in the dataset).
The attribute is just a string, so I thought it would be easier to completely remove it first and then add it again later with the qc flags that actually made it into the dataset.
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.
Makes sense :)
for var in self.qc.qc_by_var.keys(): | ||
ds = hx.add_ancillary_var(ds, var, var + "_qc") | ||
if (not np.isin("q", self.qc.qc_vars)) and np.isin( | ||
"rh", self.qc.qc_vars | ||
): | ||
ds = hx.add_ancillary_var(ds, "q", "rh_qc") | ||
if (not np.isin("theta", self.qc.qc_vars)) and np.isin( | ||
"ta", self.qc.qc_vars | ||
): | ||
ds = hx.add_ancillary_var(ds, "theta", "ta_qc") |
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 I can follow here. However, from the previous changes to add_variable_flags_to_ds
I had thought that you'd be able to handle those explicitly stated cases with add_variable_flags_to_ds(add_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.
theoretically yes, but the if is necessary anyways right? And this is already the case where all the qc details are dropped, so it doesn't make a difference. (or am i missing something?).
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.
sorry, maybe in other words: the change above is such that one can add all the qc flags from one variable to another. For example, rh_qc, rh_near_surface_count, rh_profile_fullness can be added with this one liner as ancillaries to q. It also calculates the aggregated qc flag for a variable, which is not necessary here since the aggregated flag already exists.
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 I understand now better the different QCs :) thanks!
You are completly right. the default should be None. |
7e33069
to
aa61020
Compare
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.
The changes seem fine to me :)
Working my way through the QC also reminded me of the advantage of adding more info on QC handling to the documentation "soonish", maybe when the QC related PRs are merged.
if var != "sonde_id": | ||
ds[var].attrs.pop("ancillary_variables", None) |
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.
Makes sense :)
for var in self.qc.qc_by_var.keys(): | ||
ds = hx.add_ancillary_var(ds, var, var + "_qc") | ||
if (not np.isin("q", self.qc.qc_vars)) and np.isin( | ||
"rh", self.qc.qc_vars | ||
): | ||
ds = hx.add_ancillary_var(ds, "q", "rh_qc") | ||
if (not np.isin("theta", self.qc.qc_vars)) and np.isin( | ||
"ta", self.qc.qc_vars | ||
): | ||
ds = hx.add_ancillary_var(ds, "theta", "ta_qc") |
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 I understand now better the different QCs :) thanks!
58034ea
to
23606ba
Compare
23606ba
to
0d54277
Compare