-
Notifications
You must be signed in to change notification settings - Fork 30
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
Derived variables structure update #326
base: main
Are you sure you want to change the base?
Conversation
Pull these checks and calculations out of `adf-diag.py` to clean that file up.
Now call the `adf_derive.py` script for derived variables
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 cleanup! Just have a few suggestions.
else: | ||
self.debug_log(constit_errmsg) |
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.
Instead of checking whether constit_list
is a list type below, would it possibly be safer to just add a logical that skips writing the constit_errmsg
if you have already written it here?
# End if | ||
|
||
# Log if this variable can be derived but is missing list of constituents | ||
if isinstance(constit_list, list) and not constit_list: |
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.
If you use the logical method suggested above, then you can probably get rid of the isinstance
check here.
Move the calculation of derived variables out of
adf_daig.py
into an external script. This is a placeholder until a more robust variable derivations scheme is implemented.This will help declutter
adf_diag.py
in the hopes of keeping non-essential methods separate.adf_derive.py
has two main methods:check_derive
andderive_variable
check_derive
- called in variable loop; will check on each available variableFor incoming variable, look for list of constituents if available as a list in variable defaults yaml file
If the variable does not have the argument
derivable_from
orderivable_from_cam_chem
,then it will be assumed not to be a derivable variable, just missing from history file
If the variable does have the argument
derivable_from
orderivable_from_cam_chem
,first check cam-chem, then regular cam and add all constituents to
diag_var_list
for time series generation.NOTE: this will only modify
diag_var_list
for use inadf_diag.py
, it will not modify the yaml variable list used in other scripts.derive_variable
- called after variable loop and time series generation; loop over dictionary containing derived variables as keys and list of constituents as values.This will then be called in a loop of accepted derived variables and will be generated from constituent time series files.