itur.plotting package¶
itur.plotting
provides convenient function to plot maps in ITU-Rpy.
This submodule uses matplotlib
and cartopy
as the default library to
plot maps. Alternatively, the user can use basemap
(if installed).
The example below shows the use of plot_in_map
to display the mean surface
temperature on the Earth.
import itur
# Generate a regular grid of latitude and longitudes with 0.1 degree
# resolution.
lat, lon = itur.utils.regular_lat_lon_grid(resolution_lat=0.1,
resolution_lon=0.1)
# Compute the surface mean temperature
T = itur.models.itu1510.surface_mean_temperature(lat, lon)
# Display the results in a map (using cartopy)
ax = itur.plotting.plot_in_map(
T, lat, lon, cmap='jet', vmin=230, vmax=310,
cbar_text='Annual mean surface temperature [K]')
# Display the results in a map (using basemap)
ax = itur.plotting.plot_in_map_basemap(
T, lat, lon, cmap='jet', vmin=230, vmax=310,
cbar_text='Annual mean surface temperature [K]')
-
itur.plotting.
plot_in_map
(data, lat=None, lon=None, lat_min=None, lat_max=None, lon_min=None, lon_max=None, cbar_text='', ax=None, figsize=(6, 4), **kwargs)[source]¶ Plot the values in data in a map using
cartopy
.The map uses an PlateCarree projection. Either {
lat
,lon
} or {lat_min
,lat_max
,lon_min
,lon_max
} need to be provided as inputs. This function requires thatcartopy
andmatplotlib
are installed.Parameters: - data (np.ndarray) – Data values to be plotted.
- lat (np.ndarray) – Matrix with the latitudes for each point in data (deg N)
- lon (np.ndarray) – Matrix with the longitudes for each point in data (deg E)
- lat_min (float) – Minimum latitude of the data (deg N)
- lat_max (float) – Maximum latitude of the data (deg N)
- lon_min (float) – Minimum longitude of the data (deg E)
- lat_max – Maximum longitude of the data (deg E)
- cbar_text (string) – Colorbar text caption.
- ax (Axes) – matplotlib axes where the data will be plotted.
- figsize (tuple) – Dimensions of the Figure
- **kwargs (dict) – Key-value arguments that will be passed to the contourf function.
Returns: ax – The matploltib axes object
Return type: Axes
-
itur.plotting.
plot_in_map_basemap
(data, lat=None, lon=None, lat_min=None, lat_max=None, lon_min=None, lon_max=None, cbar_text='', ax=None, figsize=(6, 4), **kwargs)[source]¶ Plot the values in data in a map using
basemap
.The map uses an equidistant cylindrical projection. Either {
lat
,lon
} or {lat_min
,lat_max
,lon_min
,lon_max
} to be provided as inputs. This function requires thatbasemap
andmatplotlib
are installed.Parameters: - data (np.ndarray) – Data values to be plotted.
- lat (np.ndarray) – Matrix with the latitudes for each point in data (deg N)
- lon (np.ndarray) – Matrix with the longitudes for each point in data (deg E)
- lat_min (float) – Minimum latitude of the data (deg N)
- lat_max (float) – Maximum latitude of the data (deg N)
- lon_min (float) – Minimum longitude of the data (deg E)
- lat_max – Maximum longitude of the data (deg E)
- cbar_text (string) – Colorbar text caption.
- ax (Axes) – matplotlib axes where the data will be plotted.
- figsize (tuple) – Dimensions of the Figure
- **kwargs (dict) – Key-value arguments that will be passed to the imshow function.
Returns: m – The map object generated by Basemap
Return type: Basemap