-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed2b045
commit 45bfdf0
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from cartopy import crs as ccrs | ||
|
||
crs_map = { | ||
"rotated_latitude_longitude": { | ||
"crs": ccrs.RotatedPole, | ||
"kwargs": { | ||
"pole_longitude": "grid_north_pole_longitude", | ||
"pole_latitude": "grid_north_pole_latitude", | ||
"central_rotated_longitude": 0.0, | ||
}, | ||
} | ||
} | ||
|
||
|
||
def _ccrs_from_cf(mapping): | ||
crs = crs_map.get(mapping.grid_mapping_name) | ||
kwargs = {kw: (mapping.attrs.get(v) or v) for kw, v in crs["kwargs"].items()} | ||
return crs["crs"](**kwargs) | ||
|
||
|
||
def get_ccrs(ds): | ||
mapping = ds.cf["grid_mapping"] | ||
return _ccrs_from_cf(mapping) |