-
Notifications
You must be signed in to change notification settings - Fork 116
Add capability to created wanted variables list with an explicit list of paths #508
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
Open
andypbarrett
wants to merge
15
commits into
development
Choose a base branch
from
add-variable-path-list
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
38968f9
add path_list kwarg to append
a40f104
parse path_list in var_list, beam_list and keyword_list
00ca183
Replace assertion with if statement. Add extra kwarg check
0f9f579
add example to docstring
1342525
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 456bb30
GitHub action UML generation auto-update
rwegener2 f5bac72
Update icepyx/core/variables.py
andypbarrett acb5a52
Update icepyx/core/variables.py
andypbarrett 4dd740b
Apply suggestions from code review
andypbarrett 7603309
Merge branch 'development' into add-variable-path-list
JessicaS11 74fac11
remove non-module warning for append
4054e1f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4824bd4
Merge branch 'development' into add-variable-path-list
JessicaS11 1d868bd
add path_list examples to notebook
JessicaS11 e294e31
clear some cell outputs
JessicaS11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -429,7 +429,14 @@ def _iter_paths(self, sum_varlist, req_vars, vgrp, beam_list, keyword_list): | |
| return req_vars | ||
|
|
||
| # DevGoal: we can ultimately add an "interactive" trigger that will open the not-yet-made widget. Otherwise, it will use the var_list passed by the user/defaults | ||
| def append(self, defaults=False, var_list=None, beam_list=None, keyword_list=None): | ||
| def append( | ||
| self, | ||
| defaults=False, | ||
| var_list=None, | ||
| beam_list=None, | ||
| keyword_list=None, | ||
| path_list=None, | ||
| ): | ||
| """ | ||
| Add to the list of desired variables using user specified beams and variable list. | ||
| A pregenerated default variable list can be used by setting defaults to True. | ||
|
|
@@ -457,6 +464,9 @@ def append(self, defaults=False, var_list=None, beam_list=None, keyword_list=Non | |
| the product that include that keyword in their path. A list of availble keywords can be obtained by | ||
| entering `keyword_list=['']` into the function. | ||
|
|
||
| path_list : list of strings, default None | ||
| A list of variable path names given as a the full path from the H5 root path. | ||
|
|
||
| Notes | ||
| ----- | ||
| See also the `IS2_data_access2-subsetting | ||
|
|
@@ -482,25 +492,59 @@ def append(self, defaults=False, var_list=None, beam_list=None, keyword_list=Non | |
| To add all variables and paths in ancillary_data | ||
|
|
||
| >>> reg_a.order_vars.append(keyword_list=['ancillary_data']) # doctest: +SKIP | ||
|
|
||
| To add variables as a list of explicit paths | ||
|
|
||
| >>> path_list = ['gt1l/heights/delta_time', | ||
| 'gt1l/heights/dist_ph_across', | ||
| 'gt1l/heights/dist_ph_along', | ||
| 'gt1l/heights/h_ph', | ||
| 'gt1l/heights/lat_ph', | ||
| 'gt1l/heights/lon_ph'] | ||
andypbarrett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| >>> region_a.order_vars.append(path_list=path_list) # doctest: +SKIP | ||
|
|
||
| """ | ||
|
|
||
| assert not ( | ||
| defaults == False | ||
| and var_list == None | ||
| and beam_list == None | ||
| and keyword_list == None | ||
| ), "You must enter parameters to add to a variable subset list. If you do not want to subset by variable, ensure your is2.subsetparams dictionary does not contain the key 'Coverage'." | ||
| # Check that at least one allowable combination of keywords are set | ||
| if ( | ||
| not defaults | ||
| and not (var_list or beam_list or keyword_list) | ||
| and not path_list | ||
| ): | ||
| raise ValueError( | ||
| "Either default or path_list, or at least one of var_list, " | ||
| "beam_list or keyword_list must be set\n" | ||
| "If you do not want to subset by variable, " | ||
| "ensure your is2.subsetparams dictionary does " | ||
| "not contain the key 'Coverage'." | ||
andypbarrett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| # Check that only path_list, or only var_list, beam_list or keyword_list | ||
| # are set. | ||
| if (var_list or beam_list or keyword_list) and path_list: | ||
| raise ValueError( | ||
| "path_list cannot be set if var_list or " | ||
| "beam_list or keyword_list are set" | ||
| ) | ||
|
|
||
| final_vars = {} | ||
|
|
||
| if path_list: | ||
| _, (beams, keywords, variables) = self.parse_var_list( | ||
| path_list, tiered_vars=True | ||
| ) | ||
| var_list = list(set(variables)) | ||
| beam_list = list(set(beams)) | ||
| keyword_list = list(set(keywords)) | ||
|
Comment on lines
+533
to
+535
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I went to add the new example in the docstring to the variables tutorial notebook it raised 2 issues:
I haven't reminded myself of how we handle this in general in the module, so that may recommend a solution for (2). (1) is easy if we just sub in another list. |
||
|
|
||
| vgrp, allpaths = self.avail(options=True, internal=True) | ||
| self._check_valid_lists(vgrp, allpaths, var_list, beam_list, keyword_list) | ||
|
|
||
| # Instantiate self.wanted to an empty dictionary if it doesn't exist | ||
| # Instantiate self.wanted to an empty dictionaryto an if it doesn't exist | ||
andypbarrett marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if not hasattr(self, "wanted") or self.wanted == None: | ||
| self.wanted = {} | ||
|
|
||
| # DEVGOAL: add a secondary var list to include uncertainty/error information for lower level data if specific data variables have been specified... | ||
| # DEVGOAL: add a secondary var list to include uncertainty/error information for lower level data if specific data variables have been specified... | ||
|
|
||
| # generate a list of variable names to include, depending on user input | ||
| sum_varlist = self._get_sum_varlist(var_list, vgrp.keys(), defaults) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.