arctichoke.plot.seasonal_cycle
Functions
|
Plot a seasonal cycle of the dataset. |
|
Plot multiple seasonal cycles of different datasets. |
Module Contents
- arctichoke.plot.seasonal_cycle.plot_seasonal_cycle(datasets: [str, xarray.DataArray, xarray.Dataset], variable_id: str = None, take_mean: bool = False, ax: matplotlib.axes.Axes = None, plt_title: str = None, line_labels: [str] = None, line_styles: [str] = '-', xlims: [str, str] = None, ylims: [float, float] = None, c_map: [matplotlib.colors.ListedColormap] = mplcm.viridis_r, c_map_label: str = 'Year', save_as: str = None, test: bool = False, **kwargs)
Plot a seasonal cycle of the dataset.
Plots a seasonal cycle of the given dataset for the given variable, if applicable.
- Parameters:
datasets (list of str, xarray.DataArray, xarray.Dataset) – A list of datasets for which to make a plot.
variable_id (str) – The name of the variable ID to plot.
take_mean (bool, optional) – Whether to take the mean for each month across all the years. Default is False.
ax (matplotlib.axes.Axes, optional) – The axes on which to plot the data. If None, a new figure is created. Default is None.
plt_title (str, None, optional) – The title to use for the plot. Default is None, which uses a default title for the plot.
line_labels (list of str, None, optional) – The labels to use for the lines that are plotted if take_mean = True. Default is None.
line_styles (list of str, None, optional) – The line styles to use for the lines that are plotted if take_mean = True. Default is ‘-’.
xlims (List of float, optional) –
- The limits to use for the x-axis on the plot in the following format:
[x_min, x_max]
where x_min and x_max are strings in the format YYYY-MM-DD Default is None, which expands the x-axis to include all the data.
ylims (List of float, optional) –
- The limits to use for the y-axis on the plot in the following format:
[y_min, y_max]
Default is None, which expands the y-axis to include all the data.
c_map (matplotlib.colors.ListedColormap, optional) – The color map to use for the different lines so their order is clearer. Default is matplotlib.cm.viridis_r, the reverse of viridis.
c_map_label (str, None, optional) – The label to use on the colorbar. If None, then the colorbar will have no label. Default is Year.
save_as (str, None, optional) – The name of the file to which to save the plot. Default is None, which doesn’t save the plot to a file.
test (bool, optional) – If True, the function exists before making a plot for use in testing. Default is False.
**kwargs – Keyword arguments to pass to xr.DataArray.plot().
- Returns:
If test == False – fig ax
If test == True – dataset : xarray.DataArray
Examples
>>> from arctichoke.dataset.field_mean import get_field_mean >>> fldmean_xr = get_field_mean('example_siconc_dataset.nc') >>> from arctichoke.plot.seasonal_cycle import plot_seasonal_cycle >>> plot_seasonal_cycle(dataset = fldmean_xr, variable_id = 'siconc')
- arctichoke.plot.seasonal_cycle.multi_seasonal_cycle(source_id: str = 'EC-Earth3P-HR', variable_ids: [str] = ['siconc', 'sithick'], experiment_ids: [str] = ['hist-1950'], time_bounds_lists: dict = {'hist-1950': [[1950, 1959], [2005, 2014]], 'highres-future': [[2015, 2024], [2041, 2050]]}, variant_labels=['r1i1p2f1', 'r2i1p2f1', 'r3i1p2f1'], super_title: str = None, fig_scale: int, float = 2, save_as: str = None, test: bool = False, **kwargs)
Plot multiple seasonal cycles of different datasets.
Plots a seasonal cycle for each combination of parameters. Different experiments get their own axes, as well as different variables. Multiple time bounds and variant labels are plotted on the same axes.
- Parameters:
source_id (str) – The name of the source_id to specify the model to plot.
variable_ids (list of str) – The variable ID(s) to plot.
experiment_ids (list of str, optional) – The experiment(s) to plot. Default is [‘hist-1950’].
time_bounds_lists (dict, optional) – A dictionary of the time bounds within which to plot. Each key in the dictionary is the name of an experiment and each value is a list of pairs of years. These time bounds will be passed to select_files_by_time(). Default is shown above.
variant_labels (list of str, optional) – The variant label(s) to plot for each subplot. Default is shown above.
super_title (str, None, optional) – The title for the overall figure. Default is None.
fig_scale (int, float, optional) – The scale factor by which to resize the figure. Default is 2.
save_as (str, None, optional) – The name of the file to which to save the plot. Default is None, which doesn’t save the plot to a file.
test (bool, optional) – If True, the function exists before making a plot for use in testing. Default is False.
**kwargs – Keyword arguments to pass to xr.DataArray.plot().
- Return type:
None
Examples
>>> from arctichoke.plot.seasonal_cycle import multi_seasonal_cycle >>> multi_seasonal_cycle( source_id = 'EC-Earth3P-HR', variable_ids = ['siconc'], super_title = 'Seasonal Cycles', )