Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder authored Feb 8, 2024
1 parent 3dd5cd6 commit 4be04bf
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
6 changes: 3 additions & 3 deletions e3sm_diags/driver/zonal_mean_2d_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,7 @@ def _create_metrics_dict(
"""Calculate metrics using the variable in the datasets.
Metrics include min value, max value, spatial average (mean), standard
deviation, correlation (pearson_r), and RMSE. The default value for
optional metrics is None.
deviation, correlation (pearson_r), and RMSE.
Parameters
----------
Expand All @@ -310,7 +309,8 @@ def _create_metrics_dict(
The reference dataset.
ds_ref_regrid : xr.Dataset
The regridded reference dataset.
The difference between ``ds_test_regrid`` and ``ds_ref_regrid``.
ds_diff : xr. Dataset
The difference between ``ds_test_regrid`` and ``ds_ref_regrid``.
Returns
-------
Expand Down
4 changes: 2 additions & 2 deletions e3sm_diags/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def _get_dims(da: xr.DataArray, axis: List[Axis]) -> List[str]:
da : xr.DataArray
The array.
axis : List[Axis]
The list of axes to get dimensions for, by default ["X", "Y"].
Valid strings include "X", "Y", and "Z".
The list of axes to get dimensions for. Valid strings
include "X", "Y", and "Z".
Returns
-------
Expand Down
7 changes: 4 additions & 3 deletions e3sm_diags/plot/cartopy/zonal_mean_2d_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def plot(
da_diff: xr.DataArray,
metrics_dict: MetricsDict,
):
"""Plot the variable's metrics generated for the lat_lon set.
"""Plot the variable's metrics generated by the zonal_mean_2d set.
Parameters
----------
Expand All @@ -49,8 +49,9 @@ def plot(
The test data.
da_ref : xr.DataArray
The reference data.
ds_diff : xr.DataArray
The difference between ``ds_test_regrid`` and ``ds_ref_regrid``.
da_diff : xr.DataArray
The difference between `da_test` and `da_ref` (both are regridded to
the lower resolution of the two beforehand).
metrics_dict : Metrics
The metrics.
"""
Expand Down
23 changes: 13 additions & 10 deletions e3sm_diags/plot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,14 @@ def _add_contour_plot(
The coordinates of the X axis for the plot.
y : xr.DataArray
The coordinates of the Y axis for the plot.
color_map : str
The color map file path.
projection : ccrs.PlateCarree | None
The optional cartopy projection.
norm : colors.BoundaryNorm | None
The optional norm boundaries.
c_levels : List[float] | None
The optional contour levels.
color_map : str
The color map file path.
Returns
-------
Expand Down Expand Up @@ -488,7 +488,7 @@ def _configure_titles(
Parameters
----------
ax : matplotlib.axes.Axes
The axes objects.
The figure axes object.
title : Tuple[str | None, str, str]
A tuple of strings to form the title of the colormap, in the format
(<optional> years, title, units).
Expand Down Expand Up @@ -523,17 +523,17 @@ def _configure_x_and_y_axes(
Parameters
----------
ax : matplotlib.axes.Axes
The axes object.
The figure axes object.
x_ticks : np.ndarray
The array of X ticks.
y_ticks : np.ndarray | None
The optional array of Y ticks. Some set plotters pass None to configure
the Y axis ticks using other ticks such as Z axis plevs instead.
projection : ccrs.PlateCarree | None
The optional cartopy projection to use for X and Y ticks.
set_name : set_name
The name of the current set which determines whether the latitude and
longitude major formatters are used.
projection : ccrs.PlateCarree | None
The optional cartopy projection to use for X and Y ticks.
"""
# For `ax.set_xticks` and `ax.set_yticks`, `crs` cannot be `None` and we
# must split up arguments passed to these methods using a conditional
Expand Down Expand Up @@ -578,12 +578,15 @@ def _add_colorbar(
----------
fig : plt.Figure
The figure object.
contour_plot : mcontour.QuadContourSet
The contour plot object.
subplot_num : int
The subplot number.
panel_configs : PanelConfig
A list of panel configs consisting of positions and sizes, with each
element representing a panel.
contour_plot : mcontour.QuadContourSet
The contour plot object.
c_levels : List[float] | None
The optional contour level used for configure the colobar.
The optional contour levels used to configure the colorbar.
"""
cbax = fig.add_axes(
(
Expand Down Expand Up @@ -666,7 +669,7 @@ def _add_min_mean_max_text(
metrics : Tuple[float, ...]
The tuple of metrics, with the first three elements being max, mean,
and min.
set_name : str | None, optional
set_name : str | None
The optional set name used to determine float format, by default None.
fontsize : float
The text font size, by default 9.5.
Expand Down

0 comments on commit 4be04bf

Please sign in to comment.