Skip to content
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

fix plots for southern domain #231

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions cordex/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ def map(self, projection=None):
"""
import cartopy.crs as ccrs
import cartopy.feature as cf
import cartopy.io.img_tiles as cimgt

# import cartopy.io.img_tiles as cimgt
import matplotlib.pyplot as plt

obj = self._obj
Expand All @@ -172,13 +173,20 @@ def map(self, projection=None):
mapping.grid_north_pole_longitude,
mapping.grid_north_pole_latitude,
)
transform = ccrs.RotatedPole(*pole)
central_longitude = 0.0
if obj.cf["X"].min() > 0.0:
central_longitude = 180.0

transform = ccrs.RotatedPole(*pole, central_rotated_longitude=central_longitude)

if projection is None:
projection = transform

ax = plt.axes(projection=projection)
# use google maps tiles
request = cimgt.GoogleTiles()
ax.add_image(request, 4) # , interpolation='spline36', regrid_shape=2000)
ax.stock_img()
# request = cimgt.GoogleTiles()
# ax.add_image(request, 4) # , interpolation='spline36', regrid_shape=2000)
ax.gridlines(
draw_labels=True,
linewidth=0.5,
Expand All @@ -187,10 +195,15 @@ def map(self, projection=None):
ylocs=range(-90, 90, 5),
)
ax.set_extent(
[obj.rlon.min(), obj.rlon.max(), obj.rlat.min(), obj.rlat.max()],
[
obj.rlon.min() - central_longitude,
obj.rlon.max() - central_longitude,
obj.rlat.min(),
obj.rlat.max(),
],
crs=transform,
)
ax.coastlines(resolution="50m", color="black", linewidth=1)
ax.coastlines(resolution="110m", color="black", linewidth=1)
ax.add_feature(cf.BORDERS, color="black")

return ax
Expand Down
8 changes: 7 additions & 1 deletion docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ What's New
UNRELEASED
----------

This release introduces the :py:meth:`cell_area` function and adds the ``cell_area`` keyword in :py:meth:`cordex_domain`.

New Features
~~~~~~~~~~~~

- Added :py:meth:`cell_area` which computes the cell area of a regular grid, e.g., the cell area in the rotated coordinates of a CORDEX dataset (:pull:`230`).

- New keyword ``cell_area`` in :py:meth:`cordex_domain` which will add a cell area coordinate (:pull:`230`).

Internal Changes
Expand All @@ -25,6 +26,9 @@ Internal Changes
Bugfixes
~~~~~~~~

.. currentmodule:: xarray

- Fix :py:meth:`Dataset.cx.map` for the southern hemisphere (:pull:`231`).
- Ensure ssl verification for VG2500 fetching (:pull:`206`, :pull:`212`).
- Fix ``flox`` method in cmor module (:pull:`197`).

Expand All @@ -36,6 +40,8 @@ Patch release that fixes installation and cmor issues.
Bugfixes
~~~~~~~~

.. currentmodule:: cordex

- Fix ``packages`` argument in ``setup.cfg`` (:pull:`192`).
- Fixed empty mapping_table argument in :py:meth:`cmor.cmorize_variable` (:pull:`187`).

Expand Down
Loading