Repository: AI4S2S/s2spy (language: python)

Issue:
Default setting of min_area_km2 
As a new user, it can be unexpected that some regions are removed by default. The min_area_km2 argument is now 3000**2 by default. You can get region 1 and 3 and think, where is region 2? 

I also noticed there is a small error in the calculation of the area. I was testing at which area_in_km2 a small region of two grid cells of 5x5 would be removed (demonstrated in [tutorial Notebook](https://github.com/AI4S2S/s2spy/blob/main/notebooks/tutorial_RGDR.ipynb)). A back on the envelop calculation would be that this should roughly occur at the following value:

1 degree at equator is ~111 km, at 47,5 degree north this would be:
111 (km) * np.radians(47,5) ~ 92km . So a 5 by 5 grid cell would roughly have an area of (5*92)**2=211.600 km2. 

However, the current calculation of a single grid cell is 1.91e8 km2.

I checked the area calculation [here](https://www.engr.scu.edu/~emaurer/tools/calc_cell_area_cgi.pl), and the answer should be 208763 km2: 

The correct way of calculating the area, following [this](https://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2004/msg00023.html) formula.:

```
lat = data.latitude
dlat = np.abs(data.latitude.values[1] - data.latitude.values[0])
dlon = np.abs(data.longitude.values[1] - data.longitude.values[0])

lat_s = np.radians(data.latitude - dlat/2)
lat_n = np.radians(data.latitude + dlat/2)

spherical_area = (np.pi/180) * RADIUS_EARTH_KM**2 * np.abs(np.sin(lat_s) - np.sin(lat_n)) * np.abs(dlon)
```

Which renders and area of 208763 km2 (exactly matching the calculation of the tool above). 

Hence, this issue highlights two things.
- Correction of the function [spherical_area](https://github.com/AI4S2S/s2spy/blob/40475a6d7a36280d262ce5a8c055b85a351ea266/s2spy/rgdr/rgdr.py#L22-L43)
- Suggestion to change the default value of min_area_km2 to 0. 

Could these changes be incorporated in #111 or do we need to raise a new PR?


Discussion / hints:
Ps: please let me know if you have any feedback on the clarity of this issue :)
@semvijverberg Thanks for finding these bugs and adding a clear explanation. @BSchilperoort and @jannesvaningen could you please inspect the calculation in our package? I think we shall raise a new PR and add this into the unit tests related to RGDR.
> Ps: please let me know if you have any feedback on the clarity of this issue :)

Overall it is clear to me 👍 . Personally, I'd open two different issue for the bug and the suggestion. That keeps the discussion focused. In the description of the bug, it would be very helpful if you could include 1 or 2 lines of code to show how you obtained "the current calculation of a single grid cell is 1.91e8 km2".
Hi Sem, thanks for noticing this. I found the bug in the calculation. It's on the following line:
https://github.com/AI4S2S/s2spy/blob/40475a6d7a36280d262ce5a8c055b85a351ea266/s2spy/rgdr/rgdr.py#L41

This should instead be:
```python
    spherical_area = h * dlon / np.pi / 4 
```

This will then give the correct answer.

For example, the 5x5 degree gridcell centered at 47.5 N:
```py
>>> spherical_area(lat=45, dlat=5, dlon=5)

218506
```

There can be slight differences depending on how you approximate the earth to be spherical. The (corrected) code calculates what the relative area of a square gridcell on a unit sphere would be, and scales this to the actual surface area of earth.

<hr>

> Could these changes be incorporated in https://github.com/AI4S2S/s2spy/pull/111 or do we need to raise a new PR?

I will open a new PR to fix the accuracy of the area calculation.

The default setting can be fixed in a separate PR, as we will have to change some of the notebooks/tests for this. The default value was mostly there to ease testing and development of the RGDR module.

Fix patch:
diff --git a/notebooks/tutorial_RGDR.ipynb b/notebooks/tutorial_RGDR.ipynb
index 0f8213a..4a96d0f 100644
--- a/notebooks/tutorial_RGDR.ipynb
+++ b/notebooks/tutorial_RGDR.ipynb
@@ -69,7 +69,7 @@
     "target_timeseries = target_resampled.sel(cluster=3).ts.isel(i_interval=0)\n",
     "precursor_field = field_resampled.sst.isel(i_interval=slice(1,5)) # Multiple lags: 1 through 4\n",
     "\n",
-    "rgdr = RGDR(eps_km=600, alpha=0.05, min_area_km2=3000**2)"
+    "rgdr = RGDR(eps_km=600, alpha=0.05, min_area_km2=800**2)"
    ]
   },
   {
@@ -83,17 +83,17 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "[<matplotlib.collections.QuadMesh at 0x1a0501cb6d0>,\n",
-       " <matplotlib.collections.QuadMesh at 0x1a063a29270>]"
+       "[<matplotlib.collections.QuadMesh at 0x1b1a41653f0>,\n",
+       " <matplotlib.collections.QuadMesh at 0x1b1a41a9de0>]"
       ]
      },
-     "execution_count": 7,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     },
@@ -126,16 +126,16 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 4,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "<matplotlib.collections.QuadMesh at 0x1a063c76b60>"
+       "<matplotlib.collections.QuadMesh at 0x1b1a436bbb0>"
       ]
      },
-     "execution_count": 6,
+     "execution_count": 4,
      "metadata": {},
      "output_type": "execute_result"
     },
@@ -155,11 +155,11 @@
    "source": [
     "fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(12, 2))\n",
     "\n",
-    "RGDR(eps_km=600, min_area_km2=3000**2).preview_clusters(precursor_field,\n",
+    "RGDR(eps_km=600, alpha=0.05, min_area_km2=800**2).preview_clusters(precursor_field,\n",
     "                                                        target_timeseries,\n",
     "                                                        lag=1, ax=ax1)\n",
     "\n",
-    "RGDR(eps_km=600, min_area_km2=None).preview_clusters(precursor_field,\n",
+    "RGDR(eps_km=600, alpha=0.05, min_area_km2=None).preview_clusters(precursor_field,\n",
     "                                                     target_timeseries,\n",
     "                                                     lag=1, ax=ax2)"
    ]
@@ -542,7 +542,7 @@
        "    longitude       (cluster_labels) float64 223.9 185.4 221.8 190.2 217.8 219.3\n",
        "Attributes:\n",
        "    data:         Clustered data with Response Guided Dimensionality Reduction.\n",
-       "    coordinates:  Latitudes and longitudes are geographical centers associate...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'sst'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>anchor_year</span>: 39</li><li><span class='xr-has-index'>cluster_labels</span>: 6</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-b9814065-77d7-499d-bf20-524974fa3294' class='xr-array-in' type='checkbox' ><label for='section-b9814065-77d7-499d-bf20-524974fa3294' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>290.8 298.9 287.8 296.6 286.0 284.9 ... 298.2 288.4 296.6 286.9 285.1</span></div><div class='xr-array-data'><pre>array([[290.79588914, 298.94548042, 287.83356654, 296.5913755 ,\n",
+       "    coordinates:  Latitudes and longitudes are geographical centers associate...</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'>'sst'</div><ul class='xr-dim-list'><li><span class='xr-has-index'>anchor_year</span>: 39</li><li><span class='xr-has-index'>cluster_labels</span>: 6</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-ed1b4a4e-f91d-4176-ba7c-69c37f63963c' class='xr-array-in' type='checkbox' ><label for='section-ed1b4a4e-f91d-4176-ba7c-69c37f63963c' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>290.8 298.9 287.8 296.6 286.0 284.9 ... 298.2 288.4 296.6 286.9 285.1</span></div><div class='xr-array-data'><pre>array([[290.79588914, 298.94548042, 287.83356654, 296.5913755 ,\n",
        "        286.03044129, 284.87776786],\n",
        "       [290.970545  , 298.92119198, 288.55306112, 296.90258837,\n",
        "        286.41065088, 285.21587978],\n",
@@ -582,13 +582,13 @@
        "       [291.45966391, 299.19568083, 288.59732323, 296.99780806,\n",
        "        286.61949986, 284.98540926],\n",
        "       [291.37066195, 298.21053747, 288.43352188, 296.60848274,\n",
-       "        286.90046576, 285.06801918]])</pre></div></div></li><li class='xr-section-item'><input id='section-8ab02218-59be-4b93-a221-54e4749a4c78' class='xr-section-summary-in' type='checkbox'  checked><label for='section-8ab02218-59be-4b93-a221-54e4749a4c78' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>anchor_year</span></div><div class='xr-var-dims'>(anchor_year)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1980 1981 1982 ... 2016 2017 2018</div><input id='attrs-e7d9a151-f6d5-4bdc-8098-860833f05ce3' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-e7d9a151-f6d5-4bdc-8098-860833f05ce3' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4933660f-689b-4cff-bf5a-9f595f3ddc32' class='xr-var-data-in' type='checkbox'><label for='data-4933660f-689b-4cff-bf5a-9f595f3ddc32' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,\n",
+       "        286.90046576, 285.06801918]])</pre></div></div></li><li class='xr-section-item'><input id='section-83023fb1-3e2e-4c03-94a6-c2fbc1871899' class='xr-section-summary-in' type='checkbox'  checked><label for='section-83023fb1-3e2e-4c03-94a6-c2fbc1871899' class='xr-section-summary' >Coordinates: <span>(4)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>anchor_year</span></div><div class='xr-var-dims'>(anchor_year)</div><div class='xr-var-dtype'>int32</div><div class='xr-var-preview xr-preview'>1980 1981 1982 ... 2016 2017 2018</div><input id='attrs-1bd886dc-72a4-44ab-9ca9-836c7c3c3285' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-1bd886dc-72a4-44ab-9ca9-836c7c3c3285' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-f2cd9a25-f574-475f-8d15-02bdd364d903' class='xr-var-data-in' type='checkbox'><label for='data-f2cd9a25-f574-475f-8d15-02bdd364d903' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,\n",
        "       1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,\n",
        "       2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,\n",
-       "       2016, 2017, 2018])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>cluster_labels</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>&lt;U20</div><div class='xr-var-preview xr-preview'>&#x27;lag:1_cluster:-2&#x27; ... &#x27;lag:4_cl...</div><input id='attrs-a3775c40-6ebc-4a42-bf0e-e3037a18ad11' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-a3775c40-6ebc-4a42-bf0e-e3037a18ad11' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2c65aa63-0d9f-479a-9a52-6235fdbe351c' class='xr-var-data-in' type='checkbox'><label for='data-2c65aa63-0d9f-479a-9a52-6235fdbe351c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;lag:1_cluster:-2&#x27;, &#x27;lag:1_cluster:1&#x27;, &#x27;lag:2_cluster:-1&#x27;,\n",
-       "       &#x27;lag:2_cluster:1&#x27;, &#x27;lag:3_cluster:-1&#x27;, &#x27;lag:4_cluster:-2&#x27;], dtype=&#x27;&lt;U20&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>latitude</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>36.05 29.44 37.33 29.58 38.14 39.78</div><input id='attrs-5ec3591f-c5c0-42d9-a37e-83f52120d27f' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-5ec3591f-c5c0-42d9-a37e-83f52120d27f' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b117a3f9-382c-430a-a83c-273c78962a08' class='xr-var-data-in' type='checkbox'><label for='data-b117a3f9-382c-430a-a83c-273c78962a08' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([36.0508552 , 29.4398051 , 37.33257702, 29.58134561, 38.13773082,\n",
-       "       39.78162825])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>longitude</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>223.9 185.4 221.8 190.2 217.8 219.3</div><input id='attrs-b30326c1-962c-4973-abcb-0fffdd76751c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-b30326c1-962c-4973-abcb-0fffdd76751c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-ca106886-bf06-4ac2-a980-c3df7cff353c' class='xr-var-data-in' type='checkbox'><label for='data-ca106886-bf06-4ac2-a980-c3df7cff353c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([223.86658208, 185.40970765, 221.82516648, 190.20336403,\n",
-       "       217.7810629 , 219.30300121])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-df1be5c8-b32f-4819-812f-7c3936f2b85e' class='xr-section-summary-in' type='checkbox'  checked><label for='section-df1be5c8-b32f-4819-812f-7c3936f2b85e' class='xr-section-summary' >Attributes: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>data :</span></dt><dd>Clustered data with Response Guided Dimensionality Reduction.</dd><dt><span>coordinates :</span></dt><dd>Latitudes and longitudes are geographical centers associated with clusters.</dd></dl></div></li></ul></div></div>"
+       "       2016, 2017, 2018])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>cluster_labels</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>&lt;U20</div><div class='xr-var-preview xr-preview'>&#x27;lag:1_cluster:-2&#x27; ... &#x27;lag:4_cl...</div><input id='attrs-79e240ff-ef41-48b9-a9bc-465a59a67996' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-79e240ff-ef41-48b9-a9bc-465a59a67996' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4420724b-d688-4bf0-84f6-ed99b9c09f87' class='xr-var-data-in' type='checkbox'><label for='data-4420724b-d688-4bf0-84f6-ed99b9c09f87' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([&#x27;lag:1_cluster:-2&#x27;, &#x27;lag:1_cluster:1&#x27;, &#x27;lag:2_cluster:-1&#x27;,\n",
+       "       &#x27;lag:2_cluster:1&#x27;, &#x27;lag:3_cluster:-1&#x27;, &#x27;lag:4_cluster:-2&#x27;], dtype=&#x27;&lt;U20&#x27;)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>latitude</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>36.05 29.44 37.33 29.58 38.14 39.78</div><input id='attrs-a976876a-68bc-472d-a471-e7f63c145c73' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-a976876a-68bc-472d-a471-e7f63c145c73' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-b053296a-2595-4b52-ad5a-6090fd3ad28f' class='xr-var-data-in' type='checkbox'><label for='data-b053296a-2595-4b52-ad5a-6090fd3ad28f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([36.0508552 , 29.4398051 , 37.33257702, 29.58134561, 38.13773082,\n",
+       "       39.78162825])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>longitude</span></div><div class='xr-var-dims'>(cluster_labels)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>223.9 185.4 221.8 190.2 217.8 219.3</div><input id='attrs-16a201e1-55eb-4c67-be51-d49092d905b0' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-16a201e1-55eb-4c67-be51-d49092d905b0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2e3cd7ad-038f-438b-b119-cdab7b9e6054' class='xr-var-data-in' type='checkbox'><label for='data-2e3cd7ad-038f-438b-b119-cdab7b9e6054' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([223.86658208, 185.40970765, 221.82516648, 190.20336403,\n",
+       "       217.7810629 , 219.30300121])</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-80fbff01-e212-45e9-aac7-9e8e44162afa' class='xr-section-summary-in' type='checkbox'  checked><label for='section-80fbff01-e212-45e9-aac7-9e8e44162afa' class='xr-section-summary' >Attributes: <span>(2)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'><dt><span>data :</span></dt><dd>Clustered data with Response Guided Dimensionality Reduction.</dd><dt><span>coordinates :</span></dt><dd>Latitudes and longitudes are geographical centers associated with clusters.</dd></dl></div></li></ul></div></div>"
       ],
       "text/plain": [
        "<xarray.DataArray 'sst' (anchor_year: 39, cluster_labels: 6)>\n",
@@ -630,7 +630,7 @@
     {
      "data": {
       "text/plain": [
-       "<matplotlib.legend.Legend at 0x1c0c3e6b850>"
+       "<matplotlib.legend.Legend at 0x1b1a4439fc0>"
       ]
      },
      "execution_count": 6,
@@ -670,7 +670,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
@@ -1034,10 +1034,10 @@
        "  * i_interval  (i_interval) int64 1 2 3 4\n",
        "  * latitude    (latitude) float64 47.5 42.5 37.5 32.5 27.5\n",
        "  * longitude   (longitude) float64 177.5 182.5 187.5 ... 227.5 232.5 237.5\n",
-       "    area        (latitude) float64 3.34e+06 3.645e+06 ... 4.169e+06 4.385e+06\n",
+       "    area        (latitude) float64 2.088e+05 2.278e+05 ... 2.606e+05 2.741e+05\n",
        "    tfreq       int64 5\n",
        "    n_clusters  int64 6\n",
-       "    cluster     int64 3</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'></div><ul class='xr-dim-list'><li><span class='xr-has-index'>latitude</span>: 5</li><li><span class='xr-has-index'>longitude</span>: 13</li><li><span class='xr-has-index'>i_interval</span>: 4</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-420d8bed-40b7-4777-abcf-2c09c8b76ead' class='xr-array-in' type='checkbox' ><label for='section-420d8bed-40b7-4777-abcf-2c09c8b76ead' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>0.01618 -0.2187 -0.2194 -0.2663 ... -0.3984 -0.38 -0.3063 -0.1126</span></div><div class='xr-array-data'><pre>array([[[ 0.01617516, -0.21868534, -0.21941745, -0.26630719],\n",
+       "    cluster     int64 3</pre><div class='xr-wrap' style='display:none'><div class='xr-header'><div class='xr-obj-type'>xarray.DataArray</div><div class='xr-array-name'></div><ul class='xr-dim-list'><li><span class='xr-has-index'>latitude</span>: 5</li><li><span class='xr-has-index'>longitude</span>: 13</li><li><span class='xr-has-index'>i_interval</span>: 4</li></ul></div><ul class='xr-sections'><li class='xr-section-item'><div class='xr-array-wrap'><input id='section-311479bc-fd99-4a68-b527-5cd63ae25872' class='xr-array-in' type='checkbox' ><label for='section-311479bc-fd99-4a68-b527-5cd63ae25872' title='Show/hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-array-preview xr-preview'><span>0.01618 -0.2187 -0.2194 -0.2663 ... -0.3984 -0.38 -0.3063 -0.1126</span></div><div class='xr-array-data'><pre>array([[[ 0.01617516, -0.21868534, -0.21941745, -0.26630719],\n",
        "        [ 0.02414245, -0.12315571, -0.21464621, -0.18191947],\n",
        "        [-0.1105048 , -0.23253951, -0.4007449 , -0.25372747],\n",
        "        [-0.24520611, -0.35037825, -0.46371192, -0.35772739],\n",
@@ -1077,9 +1077,9 @@
        "        [-0.41354082, -0.4202639 , -0.34898835, -0.11634853],\n",
        "        [-0.37029449, -0.43487533, -0.35672934, -0.1791453 ],\n",
        "        [-0.40753351, -0.42768064, -0.34349675, -0.21013388],\n",
-       "        [-0.39836497, -0.37996126, -0.3062787 , -0.11258559]]])</pre></div></div></li><li class='xr-section-item'><input id='section-fa2fda83-c99e-417a-8f36-df966d53fc7f' class='xr-section-summary-in' type='checkbox'  checked><label for='section-fa2fda83-c99e-417a-8f36-df966d53fc7f' class='xr-section-summary' >Coordinates: <span>(7)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>i_interval</span></div><div class='xr-var-dims'>(i_interval)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>1 2 3 4</div><input id='attrs-05b3da1b-4dbc-4156-9810-fc5c2536ae1b' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-05b3da1b-4dbc-4156-9810-fc5c2536ae1b' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-4750df8e-ff1d-49cf-8c3a-73e1781348ff' class='xr-var-data-in' type='checkbox'><label for='data-4750df8e-ff1d-49cf-8c3a-73e1781348ff' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([1, 2, 3, 4], dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>latitude</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>47.5 42.5 37.5 32.5 27.5</div><input id='attrs-5dc96415-86e8-47db-83c9-2ba4a1c1daa6' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-5dc96415-86e8-47db-83c9-2ba4a1c1daa6' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-2edfc74c-d2b8-42bd-a888-fb5bc152816c' class='xr-var-data-in' type='checkbox'><label for='data-2edfc74c-d2b8-42bd-a888-fb5bc152816c' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([47.5, 42.5, 37.5, 32.5, 27.5])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>longitude</span></div><div class='xr-var-dims'>(longitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>177.5 182.5 187.5 ... 232.5 237.5</div><input id='attrs-eb1cc3e1-d454-4e45-8b8e-147c60eab798' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-eb1cc3e1-d454-4e45-8b8e-147c60eab798' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-6243d329-5917-4487-90b6-680c4621ee68' class='xr-var-data-in' type='checkbox'><label for='data-6243d329-5917-4487-90b6-680c4621ee68' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([177.5, 182.5, 187.5, 192.5, 197.5, 202.5, 207.5, 212.5, 217.5, 222.5,\n",
-       "       227.5, 232.5, 237.5])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>area</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>3.34e+06 3.645e+06 ... 4.385e+06</div><input id='attrs-61c0ee69-fbcc-47fe-8498-3f24bf3a405a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-61c0ee69-fbcc-47fe-8498-3f24bf3a405a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-00f507f0-341a-4c02-8721-40b9b0ab92f8' class='xr-var-data-in' type='checkbox'><label for='data-00f507f0-341a-4c02-8721-40b9b0ab92f8' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([3339800.84283772, 3644753.05166713, 3921966.48901128,\n",
-       "       4169331.39322594, 4384965.16802703])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>tfreq</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>5</div><input id='attrs-8c0f5aac-772d-4c8e-8e28-d05843c168d0' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-8c0f5aac-772d-4c8e-8e28-d05843c168d0' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-98695b91-dd7e-401b-9167-a67d74ab8e62' class='xr-var-data-in' type='checkbox'><label for='data-98695b91-dd7e-401b-9167-a67d74ab8e62' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(5, dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>n_clusters</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>6</div><input id='attrs-ccf5d767-d518-4df4-8e1b-47e31111af9c' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-ccf5d767-d518-4df4-8e1b-47e31111af9c' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-e11d594d-5e70-4bfb-b766-84db0639c9db' class='xr-var-data-in' type='checkbox'><label for='data-e11d594d-5e70-4bfb-b766-84db0639c9db' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(6, dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>cluster</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>3</div><input id='attrs-56288bf7-23ee-4a56-a121-e561a5fb98f1' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-56288bf7-23ee-4a56-a121-e561a5fb98f1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-19ac81fa-703f-4610-80e3-f932c99d5df1' class='xr-var-data-in' type='checkbox'><label for='data-19ac81fa-703f-4610-80e3-f932c99d5df1' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(3, dtype=int64)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-60650f8e-73b5-4cda-adda-8dc4aed5eb47' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-60650f8e-73b5-4cda-adda-8dc4aed5eb47' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
+       "        [-0.39836497, -0.37996126, -0.3062787 , -0.11258559]]])</pre></div></div></li><li class='xr-section-item'><input id='section-b0c0cbb2-cc8b-44eb-93e7-f5747f3eede5' class='xr-section-summary-in' type='checkbox'  checked><label for='section-b0c0cbb2-cc8b-44eb-93e7-f5747f3eede5' class='xr-section-summary' >Coordinates: <span>(7)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><ul class='xr-var-list'><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>i_interval</span></div><div class='xr-var-dims'>(i_interval)</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>1 2 3 4</div><input id='attrs-0075b551-0610-4aa8-80f4-146150eff276' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-0075b551-0610-4aa8-80f4-146150eff276' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-cd1bbbbb-5e5e-48ed-ae11-c096b3517219' class='xr-var-data-in' type='checkbox'><label for='data-cd1bbbbb-5e5e-48ed-ae11-c096b3517219' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([1, 2, 3, 4], dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>latitude</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>47.5 42.5 37.5 32.5 27.5</div><input id='attrs-053cb7ec-6803-44de-be84-7b808ef5b49a' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-053cb7ec-6803-44de-be84-7b808ef5b49a' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-35f7a590-0738-4a5a-bd9a-e3b93574e15f' class='xr-var-data-in' type='checkbox'><label for='data-35f7a590-0738-4a5a-bd9a-e3b93574e15f' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([47.5, 42.5, 37.5, 32.5, 27.5])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span class='xr-has-index'>longitude</span></div><div class='xr-var-dims'>(longitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>177.5 182.5 187.5 ... 232.5 237.5</div><input id='attrs-58191516-c7d6-4121-bd8e-a7f8a621a2e8' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-58191516-c7d6-4121-bd8e-a7f8a621a2e8' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-16b054cb-cd55-43c5-86db-bacd6ea84eb8' class='xr-var-data-in' type='checkbox'><label for='data-16b054cb-cd55-43c5-86db-bacd6ea84eb8' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([177.5, 182.5, 187.5, 192.5, 197.5, 202.5, 207.5, 212.5, 217.5, 222.5,\n",
+       "       227.5, 232.5, 237.5])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>area</span></div><div class='xr-var-dims'>(latitude)</div><div class='xr-var-dtype'>float64</div><div class='xr-var-preview xr-preview'>2.088e+05 2.278e+05 ... 2.741e+05</div><input id='attrs-bf344b4d-cdac-4659-8042-33ffdadae1b1' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-bf344b4d-cdac-4659-8042-33ffdadae1b1' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-faf670b2-51ea-4af1-b7a9-2de62decf833' class='xr-var-data-in' type='checkbox'><label for='data-faf670b2-51ea-4af1-b7a9-2de62decf833' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array([208767.02150832, 227829.22531495, 245157.51114987, 260620.0002948 ,\n",
+       "       274099.01387082])</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>tfreq</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>5</div><input id='attrs-7c841d53-952e-4269-9f2a-6af571f5a675' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-7c841d53-952e-4269-9f2a-6af571f5a675' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-60d3e2d7-bffb-4fa7-9c9d-bfcf19973e1a' class='xr-var-data-in' type='checkbox'><label for='data-60d3e2d7-bffb-4fa7-9c9d-bfcf19973e1a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(5, dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>n_clusters</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>6</div><input id='attrs-c168fb67-483d-45e6-b5b6-4aa01cad7d36' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-c168fb67-483d-45e6-b5b6-4aa01cad7d36' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-a2924064-4a0a-4b24-841b-07f6a895e6d2' class='xr-var-data-in' type='checkbox'><label for='data-a2924064-4a0a-4b24-841b-07f6a895e6d2' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(6, dtype=int64)</pre></div></li><li class='xr-var-item'><div class='xr-var-name'><span>cluster</span></div><div class='xr-var-dims'>()</div><div class='xr-var-dtype'>int64</div><div class='xr-var-preview xr-preview'>3</div><input id='attrs-b152ab84-bc8a-4ca5-af35-02c024eca3a9' class='xr-var-attrs-in' type='checkbox' disabled><label for='attrs-b152ab84-bc8a-4ca5-af35-02c024eca3a9' title='Show/Hide attributes'><svg class='icon xr-icon-file-text2'><use xlink:href='#icon-file-text2'></use></svg></label><input id='data-6a3a9c3a-473f-4ba8-ba72-254a42cfb51a' class='xr-var-data-in' type='checkbox'><label for='data-6a3a9c3a-473f-4ba8-ba72-254a42cfb51a' title='Show/Hide data repr'><svg class='icon xr-icon-database'><use xlink:href='#icon-database'></use></svg></label><div class='xr-var-attrs'><dl class='xr-attrs'></dl></div><div class='xr-var-data'><pre>array(3, dtype=int64)</pre></div></li></ul></div></li><li class='xr-section-item'><input id='section-def2f999-b29a-4859-b122-4f9baf394c82' class='xr-section-summary-in' type='checkbox' disabled ><label for='section-def2f999-b29a-4859-b122-4f9baf394c82' class='xr-section-summary'  title='Expand/collapse section'>Attributes: <span>(0)</span></label><div class='xr-section-inline-details'></div><div class='xr-section-details'><dl class='xr-attrs'></dl></div></li></ul></div></div>"
       ],
       "text/plain": [
        "<xarray.DataArray (latitude: 5, longitude: 13, i_interval: 4)>\n",
@@ -1088,13 +1088,13 @@
        "  * i_interval  (i_interval) int64 1 2 3 4\n",
        "  * latitude    (latitude) float64 47.5 42.5 37.5 32.5 27.5\n",
        "  * longitude   (longitude) float64 177.5 182.5 187.5 ... 227.5 232.5 237.5\n",
-       "    area        (latitude) float64 3.34e+06 3.645e+06 ... 4.169e+06 4.385e+06\n",
+       "    area        (latitude) float64 2.088e+05 2.278e+05 ... 2.606e+05 2.741e+05\n",
        "    tfreq       int64 5\n",
        "    n_clusters  int64 6\n",
        "    cluster     int64 3"
       ]
      },
-     "execution_count": 18,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -1106,16 +1106,16 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "<matplotlib.collections.QuadMesh at 0x1a068ef16f0>"
+       "<matplotlib.collections.QuadMesh at 0x1b1906aa8c0>"
       ]
      },
-     "execution_count": 27,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     },
@@ -1151,7 +1151,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
diff --git a/s2spy/rgdr/rgdr.py b/s2spy/rgdr/rgdr.py
index 605add3..dd7b0b3 100644
--- a/s2spy/rgdr/rgdr.py
+++ b/s2spy/rgdr/rgdr.py
@@ -15,11 +15,11 @@
 
 
 RADIUS_EARTH_KM = 6371
-SURFACE_AREA_EARTH_KM2 = 5.1e8
+SURFACE_AREA_EARTH_KM2 = 5.10072e8
 XrType = TypeVar("XrType", xr.DataArray, xr.Dataset)
 
 
-def spherical_area(latitude: float, dlat: float, dlon: float = None) -> float:
+def spherical_area(latitude: float, dlat: float, dlon: Optional[float] = None) -> float:
     """Approximate the area of a square grid cell on a spherical (!) earth.
     Returns the area in square kilometers of earth surface.
 
@@ -38,7 +38,7 @@ def spherical_area(latitude: float, dlat: float, dlon: float = None) -> float:
 
     lat = np.radians(latitude)
     h = np.sin(lat + dlat / 2) - np.sin(lat - dlat / 2)
-    spherical_area = h * dlon / np.pi * 4
+    spherical_area = h * dlon / (np.pi * 4)
 
     return spherical_area * SURFACE_AREA_EARTH_KM2
 
@@ -243,7 +243,7 @@ def masked_spherical_dbscan(
 
     precursor = _find_clusters(precursor, corr, p_val, dbscan_params)
 
-    if dbscan_params["min_area"]:
+    if dbscan_params["min_area"] is not None:
         precursor = remove_small_area_clusters(precursor, dbscan_params["min_area"])
 
     # Make sure a cluster is present in each lag
@@ -327,24 +327,36 @@ class RGDR:
     """Response Guided Dimensionality Reduction."""
 
     def __init__(
-        self, eps_km: float = 600, alpha: float = 0.05, min_area_km2: float = 3000**2
+        self,
+        eps_km: float,
+        alpha: float,
+        min_area_km2: Optional[float] = None,
     ) -> None:
         """Response Guided Dimensionality Reduction (RGDR).
 
-        Dimensionality reduction based on the correlation between precursor field and target timeseries.
+        Dimensionality reduction based on the correlation between precursor field and
+        target timeseries.
 
         Args:
             alpha (float): p-value below which the correlation is considered significant
                 enough for a location to be included in a cluster.
-            eps_km (float): The maximum distance (in km) between two samples for one to
-                be considered as in the neighborhood of the other. This is not a maximum
-                bound on the distances of points within a cluster. This is the most
-                important DBSCAN parameter to choose appropriately.
-            min_area_km2 (float): The minimum area of a cluster. Clusters smaller than
-                this minimum area will be discarded.
+            eps_km (float): The maximum distance (in km) between two grid cells for them
+                to be considered to be in the same cluster. This is not a maximum bound
+                on the distances between grid cells within a cluster.
+
+                The minimum appropriate value is equal to the maximum width/height of a
+                grid cell (i.e. the width of the grid cell closest to the equator).
+                The upper bound depends on when cells or clusters would still be
+                considered to be part of the same climate signal (i.e., precursor region).
+
+                Higher values can lead to fewer clusters, but also clusters in which the
+                cells of the same cluster are separated by large geographical distances.
+            min_area_km2 (float): The minimum area of a cluster (in square km). Clusters
+                smaller than this minimum area will be discarded.
 
         Attributes:
-            corr_map (float): correlation coefficient map of given precursor field and target series
+            corr_map (float): correlation coefficient map of given precursor field and
+                target series.
             pval_map (float): p-values map of correlation
             cluster_map (U20): cluster labels for precursor field masked by p-values
         """
diff --git a/setup.cfg b/setup.cfg
index 8943f67..dc0c456 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -59,7 +59,7 @@ dev =
     sphinx
     sphinx_rtd_theme
     sphinx-autoapi
-    bokeh
+    bokeh < 3.0.0
     tox
 publishing =
     twine


Test patch:
diff --git a/tests/test_rgdr/test_rgdr.py b/tests/test_rgdr/test_rgdr.py
index c8cdf51..e091096 100644
--- a/tests/test_rgdr/test_rgdr.py
+++ b/tests/test_rgdr/test_rgdr.py
@@ -75,6 +75,22 @@ def expected_labels():
     )
 
 
+class TestUtils:
+    """Validates the various utility functions used in RGDR"""
+
+    testdata = [ # lat, dlat, dlon, area
+        (-1, 2, 2, 49500),
+        (45, 5, 5, 218500),
+        (45, 5, 2.5, 109250)
+    ]
+
+    @pytest.mark.parametrize("lat,dlat,dlon,expected", testdata)
+    def test_spherical_area(self, lat, dlat, dlon, expected):
+        np.testing.assert_allclose(
+            rgdr.spherical_area(lat, dlat, dlon), expected, rtol=0.05
+            )
+
+
 class TestCorrelation:
     """Validates that the correlation ufunc works, as well as the input checks."""
 
@@ -149,7 +165,7 @@ class TestDBSCAN:
 
     @pytest.fixture(autouse=True)
     def dummy_dbscan_params(self):
-        return {"alpha": 0.05, "eps": 600, "min_area": 1000**2}
+        return {"alpha": 0.05, "eps": 600, "min_area": None}
 
     def test_dbscan(
         self, example_corr, example_field, dummy_dbscan_params, expected_labels
@@ -168,7 +184,7 @@ def test_dbscan_min_area(
     ):
         corr, p_val = example_corr
         dbscan_params = dummy_dbscan_params
-        dbscan_params["min_area"] = 3000**2
+        dbscan_params["min_area"] = 1000**2
         clusters = rgdr.masked_spherical_dbscan(
             example_field, corr, p_val, dbscan_params
         )
@@ -184,10 +200,10 @@ class TestRGDR:
 
     @pytest.fixture(autouse=True)
     def dummy_rgdr(self):
-        return RGDR(min_area_km2=1000**2)
+        return RGDR(eps_km=600, alpha=0.05, min_area_km2=1000**2)
 
     def test_init(self):
-        rgdr = RGDR(min_area_km2=1000**2)
+        rgdr = RGDR(eps_km=600, alpha=0.05, min_area_km2=1000**2)
         assert isinstance(rgdr, RGDR)
 
     def test_transform_before_fit(self, dummy_rgdr, example_field):
@@ -203,38 +219,36 @@ def test_transform(self, dummy_rgdr, example_field, example_target):
         dummy_rgdr.fit(example_field, example_target)
         clustered_data = dummy_rgdr.transform(example_field)
         clustered_data = utils.cluster_labels_to_ints(clustered_data)
-        cluster_labels = np.array([-1, -2, 1])
-        np.testing.assert_array_equal(clustered_data["cluster_labels"], cluster_labels)
+        expected_labels = np.array([-2,  1])
+        np.testing.assert_array_equal(clustered_data["cluster_labels"], expected_labels)
 
     def test_fit_transform_fits(self, example_field, example_target):
         # Ensures that after fit_transform, the rgdr object is fit.
-        rgdr = RGDR()
+        rgdr = RGDR(eps_km=600, alpha=0.05)
         _ = rgdr.fit_transform(example_field, example_target)
         assert rgdr._area is not None
 
     def test_fit_transform(self, example_field, example_target):
-        rgdr = RGDR(min_area_km2=1000**2)
+        rgdr = RGDR(eps_km=600, alpha=0.05, min_area_km2=1000**2)
         clustered_data = rgdr.fit_transform(example_field, example_target)
-        cluster_labels = np.array(
-            ["lag:1_cluster:-1", "lag:1_cluster:-2", "lag:1_cluster:1"]
+        expected_labels = np.array(
+            ["lag:1_cluster:-2", "lag:1_cluster:1"]
         )
-        np.testing.assert_array_equal(clustered_data["cluster_labels"], cluster_labels)
+        np.testing.assert_array_equal(clustered_data["cluster_labels"], expected_labels)
 
     def test_fit_transform_multiple_lags(
         self, example_field_multiple_lags, example_target
     ):
-        rgdr = RGDR()
+        rgdr = RGDR(eps_km=600, alpha=0.05)
         clustered_data = rgdr.fit_transform(example_field_multiple_lags, example_target)
-        cluster_labels = np.array(
+        expected_labels = np.array(
             [
-                "lag:1_cluster:-2",
-                "lag:1_cluster:1",
-                "lag:2_cluster:-1",
-                "lag:2_cluster:1",
-                "lag:3_cluster:-1",
+               "lag:1_cluster:-1", "lag:1_cluster:-2", "lag:1_cluster:1",
+               "lag:2_cluster:-1", "lag:2_cluster:1",
+               "lag:3_cluster:-1", "lag:3_cluster:1"
             ]
         )
-        np.testing.assert_array_equal(clustered_data["cluster_labels"], cluster_labels)
+        np.testing.assert_array_equal(clustered_data["cluster_labels"], expected_labels)
 
     def test_corr_preview(self, dummy_rgdr, example_field, example_target):
         dummy_rgdr.preview_correlation(example_field, example_target)