-
Notifications
You must be signed in to change notification settings - Fork 44
Fix erroneous use of grid_latitude and grid_longitude and cleaned ocean grid fixes
#1092
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
03f39b8
Fixed ocean grid fix
schlunma 5c652e7
Merge remote-tracking branch 'origin/master' into fix_ocean_grid_fix
schlunma 4588b58
Adapted points and bounds of index coordinates
schlunma 8e9eec7
Generalized retrieving of coordinate dimensions for 1D index coordinates
schlunma a7c1d87
Added warning if data for fix is not 3D and added comment with link tβ¦
schlunma 0205d81
Extended comment in OceanFixGrid
schlunma 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,68 +1,7 @@ | ||
| """Fixes for bcc-csm1-1.""" | ||
| import numpy as np | ||
| from scipy.interpolate import InterpolatedUnivariateSpline | ||
| from scipy.ndimage import map_coordinates | ||
|
|
||
| from ..common import ClFixHybridPressureCoord | ||
| from ..fix import Fix | ||
|
|
||
| from ..common import ClFixHybridPressureCoord, OceanFixGrid | ||
|
|
||
| Cl = ClFixHybridPressureCoord | ||
|
|
||
|
|
||
| class Tos(Fix): | ||
| """Fixes for tos.""" | ||
|
|
||
| def fix_data(self, cube): | ||
| """Fix data. | ||
|
|
||
| Calculate missing latitude/longitude boundaries using interpolation. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| cube: iris.cube.Cube | ||
| Input cube to fix. | ||
|
|
||
| Returns | ||
| ------- | ||
| iris.cube.Cube | ||
|
|
||
| """ | ||
| rlat = cube.coord('grid_latitude').points | ||
| rlon = cube.coord('grid_longitude').points | ||
|
|
||
| # Transform grid latitude/longitude to array indices [0, 1, 2, ...] | ||
| rlat_to_idx = InterpolatedUnivariateSpline(rlat, | ||
| np.arange(len(rlat)), | ||
| k=1) | ||
| rlon_to_idx = InterpolatedUnivariateSpline(rlon, | ||
| np.arange(len(rlon)), | ||
| k=1) | ||
| rlat_idx_bnds = rlat_to_idx(cube.coord('grid_latitude').bounds) | ||
| rlon_idx_bnds = rlon_to_idx(cube.coord('grid_longitude').bounds) | ||
|
|
||
| # Calculate latitude/longitude vertices by interpolation | ||
| lat_vertices = [] | ||
| lon_vertices = [] | ||
| for (i, j) in [(0, 0), (0, 1), (1, 1), (1, 0)]: | ||
| (rlat_v, rlon_v) = np.meshgrid(rlat_idx_bnds[:, i], | ||
| rlon_idx_bnds[:, j], | ||
| indexing='ij') | ||
| lat_vertices.append( | ||
| map_coordinates(cube.coord('latitude').points, | ||
| [rlat_v, rlon_v], | ||
| mode='nearest')) | ||
| lon_vertices.append( | ||
| map_coordinates(cube.coord('longitude').points, | ||
| [rlat_v, rlon_v], | ||
| mode='wrap')) | ||
| lat_vertices = np.array(lat_vertices) | ||
| lon_vertices = np.array(lon_vertices) | ||
| lat_vertices = np.moveaxis(lat_vertices, 0, -1) | ||
| lon_vertices = np.moveaxis(lon_vertices, 0, -1) | ||
|
|
||
| # Copy vertices to cube | ||
| cube.coord('latitude').bounds = lat_vertices | ||
| cube.coord('longitude').bounds = lon_vertices | ||
|
|
||
| return cube | ||
| Tos = OceanFixGrid |
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 |
|---|---|---|
| @@ -1,9 +1,7 @@ | ||
| """Fixes for bcc-csm1-1-m.""" | ||
| from ..common import ClFixHybridPressureCoord | ||
| from .bcc_csm1_1 import Tos as BaseTos | ||
|
|
||
| from ..common import ClFixHybridPressureCoord, OceanFixGrid | ||
|
|
||
| Cl = ClFixHybridPressureCoord | ||
|
|
||
|
|
||
| Tos = BaseTos | ||
| Tos = OceanFixGrid |
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
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.