-
Notifications
You must be signed in to change notification settings - Fork 16
Coordinate cleanup #436
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
ocsmit
wants to merge
14
commits into
podaac:develop
Choose a base branch
from
ocsmit:coordinate-cleanup
base: develop
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
Coordinate cleanup #436
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c94bd9a
fix: drop coordinate/dimension variables which are not used
ocsmit 731b9f3
refactor: lineage depricated in favor of parents
ocsmit 5a4ceef
test: refactor variable tests for clarity and correctness
ocsmit e50752b
style: remove bit of commented code
ocsmit 442305a
refactor: uneeded anon func for getting vars. duplicated code
ocsmit d18c715
refactor: unguarded string coercion, simplify'
ocsmit fdf3a8d
refactor: set logic instead
ocsmit 1103569
chore: changelog
ocsmit e84ba0f
fix: lineage and parents behavior is not the same
ocsmit 4fc047a
refactor: handle keyerror in case of variable path not being present
ocsmit 27cb8a7
chore: typo in doc string
ocsmit 1bc7640
refactor: redundant recursion code, move variable utils, old normalize
ocsmit 06e117b
fix: test for parent/lineage fix
ocsmit 36aefd3
fix: test mock new func
ocsmit 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
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
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
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 |
|---|---|---|
|
|
@@ -184,7 +184,6 @@ def subset_with_bbox( | |
| iterator = zip(lat_var_names, lon_var_names, time_var_names) | ||
|
|
||
| for lat_var_name, lon_var_name, time_var_name in iterator: | ||
|
|
||
| lat_path = file_utils.get_path(lat_var_name) | ||
| lon_path = file_utils.get_path(lon_var_name) | ||
|
|
||
|
|
@@ -376,13 +375,11 @@ def subset( | |
|
|
||
| if args["decode_times"]: | ||
| with xr.open_datatree(file_to_subset, decode_times=False) as dataset: | ||
|
|
||
| lat_var_names, lon_var_names, time_var_names = coordinate_utils.get_coordinate_variable_names( | ||
| dataset=dataset, lat_var_names=lat_var_names, lon_var_names=lon_var_names, time_var_names=time_var_names | ||
| ) | ||
|
|
||
| for time in time_var_names: | ||
|
|
||
| time_var = dataset[time] | ||
| var_name = os.path.basename(time) | ||
| group_path = os.path.dirname(time) | ||
|
|
@@ -408,7 +405,6 @@ def subset( | |
| args["decode_times"] = False | ||
|
|
||
| with xr.open_datatree(file_to_subset, **args) as dataset: | ||
|
|
||
| if hdf_type: | ||
| dataset = hdf_utils.rename_phony_dims(dataset) | ||
|
|
||
|
|
@@ -439,21 +435,21 @@ def subset( | |
| if hdf_type and (min_time or max_time): | ||
| dataset, _ = tree_time_converting.convert_to_datetime(dataset, time_var_names, hdf_type) | ||
|
|
||
| all_vars = variables_utils.get_all_variable_names_from_dtree(dataset) | ||
| all_vars = variables_utils.get_vars_with_paths(dataset) | ||
| if variables: | ||
| # Drop variables that aren't explicitly requested, except lat_var_name and | ||
| # lon_var_name which are needed for subsetting | ||
| normalized_variables = [f"/{s.replace('__', '/').lstrip('/')}".upper() for s in variables] | ||
| # add in root "/" to variable path if not present so that | ||
| # matching with `all_data_variables` is works correctly | ||
| normalized_variables = variables_utils.normalize_candidate_paths_against_dtree(variables, all_vars) | ||
|
|
||
|
Collaborator
Author
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. Since we are not flattening data anymore, I don't think there is a need to check for |
||
| keep_variables = normalized_variables + lon_var_names + lat_var_names + time_var_names | ||
| keep_variables = variables_utils.normalize_candidate_paths_against_dtree(keep_variables, all_vars) | ||
|
|
||
| all_data_variables = datatree_subset.get_vars_with_paths(dataset) | ||
| drop_variables = [ | ||
| var for var in all_data_variables if var not in keep_variables and var.upper() not in keep_variables | ||
| ] | ||
| keep_coords = coordinate_utils.collect_coordinate_variables(dataset, keep_variables) | ||
|
|
||
| keep_set = set(keep_variables) | keep_coords | ||
|
|
||
| drop_variables = all_vars - keep_set | ||
|
|
||
| dataset = datatree_subset.drop_vars_by_path(dataset, drop_variables) | ||
| variables_utils.drop_vars_by_path(dataset, drop_variables) | ||
|
|
||
| lon_var_names = variables_utils.normalize_candidate_paths_against_dtree(lon_var_names, all_vars) | ||
| lat_var_names = variables_utils.normalize_candidate_paths_against_dtree(lat_var_names, all_vars) | ||
|
|
||
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
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
Oops, something went wrong.
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.