import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs

x = np.linspace(337, 377, 25)
y = np.linspace(-18.7, 25.3, 35)
x2d, y2d = np.meshgrid(x, y)
   
data = np.cos(np.deg2rad(y2d) * 4) + np.sin(np.deg2rad(x2d) * 4)

"""
Explanation: Exercise 1:
The following snippet of code produces coordinate arrays and some data in a rotated pole coordinate system. The coordinate system for the x and y values, which is similar to that found in the some limited area models of Europe, has a projection "north pole" at 193.0 longitude and 41.0 latitude.
End of explanation
"""


rotated_pole = ccrs.RotatedPole(pole_longitude=193.0, pole_latitude=41.0)

"""
Explanation: 1. Define a cartopy coordinate reference system which represents a rotated pole with a pole longitude of 193.0 and a pole latitude of 41.0.
End of explanation
"""


ax = plt.axes(projection=rotated_pole)
ax.coastlines()
plt.show()

"""
Explanation: 2. Produce a map, with coastlines, using the coordinate reference system created in #1.
End of explanation
"""


ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()

plt.pcolormesh(x2d, y2d, data, transform=rotated_pole)

plt.show()

"""
Explanation: 3. Produce a map, with coastlines, in a Plate Carree projection with a pcolormesh of the data generated by the code snippet provided at the beginning of the exercise. Remember the data is supplied in the rotated coordinate system defined in #1.
End of explanation
"""


