E3SM-Project/e3sm_diags

Consider making logic for regridding to lower resolution more robust

Opened this issue · 0 comments

Overview

In this discussion, @chengzhuzhang and I talked about the logic for determining which variable has lower resolution.

My comment:

In the old version, regrid_to_lower_res(), there is a comment that says:

# use nlat to decide data resolution, higher number means higher data
# resolution. For the difference plot, regrid toward lower resolution
if len(axes1[1]) <= len(axes2[1]):

I interpreted this comment as also meaning that if the lat lengths are the same, the resolutions are the same. Is this comment incorrect or am I misinterpreting it?

Here's a comparison of the logic.

Original logic

1. If `ds_a` is lower res (a <= b): `return ds_a, ds_b_regrid`

2. Else always assume `ds_b` is lower res: `return ds_a_regrid, ds_b`

My logic

1. If `ds_a` is lower res (a < b): `return ds_a, ds_b_regrid`

2. If `ds_b` is lower res (b < a): `return ds_a_regrid, ds_b`

3. Otherwise same resolution (a = b): `return ds_a, ds_b`
   
   * Avoid unnecessary call to regridder APIs to possibly save on runtime, for example [for model-only runs ](https://github.com/E3SM-Project/e3sm_diags/blob/ae0d649eba7da29a410022f43ae9abc0d77af991/e3sm_diags/driver/lat_lon_driver.py#L87-L92) where `ds_a` and `ds_b` are the same datasets.

-- #677 (comment)

Possible Solutions:

@golaz suggested that comparing the number of grid points might be more robust. This involves taking the product of lat and lon.