Skip to content

Commit 27483f4

Browse files
committed
add regionalisation
1 parent 407e8c4 commit 27483f4

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

notebooks/wp5/steric_sea_level_ora5.ipynb

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"import gsw_xarray as gsw\n",
5555
"import matplotlib.pyplot as plt\n",
5656
"import xarray as xr\n",
57-
"from c3s_eqc_automatic_quality_control import diagnostics, download\n",
57+
"from c3s_eqc_automatic_quality_control import diagnostics, download, utils\n",
5858
"\n",
5959
"plt.style.use(\"seaborn-v0_8-notebook\")"
6060
]
@@ -92,8 +92,13 @@
9292
},
9393
"outputs": [],
9494
"source": [
95+
"# Time\n",
9596
"year_start = 2004\n",
96-
"year_stop = 2023"
97+
"year_stop = 2023\n",
98+
"\n",
99+
"# Space\n",
100+
"lat_slice = slice(-60, 60)\n",
101+
"lon_slice = slice(-180, 180)"
97102
]
98103
},
99104
{
@@ -216,10 +221,13 @@
216221
" return ssl\n",
217222
"\n",
218223
"\n",
219-
"def compute_ssl(collection_id, request, prefix, **download_kwargs):\n",
224+
"def compute_ssl(\n",
225+
" collection_id, request, prefix, lon_slice, lat_slice, **download_kwargs\n",
226+
"):\n",
220227
" ds = download.download_and_transform(\n",
221228
" collection_id, request, transform_func=compute_gsw_ds, **download_kwargs\n",
222229
" )\n",
230+
" ds = utils.regionalise(ds, lon_slice=lon_slice, lat_slice=lat_slice)\n",
223231
" if prefix == \"\":\n",
224232
" rho = ds[\"rho\"]\n",
225233
" elif prefix == \"thermo\":\n",
@@ -232,8 +240,22 @@
232240
"\n",
233241
"\n",
234242
"@cacholote.cacheable\n",
235-
"def compute_ssl_timeseries(collection_id, request, prefix, **download_kwargs):\n",
236-
" ssl = compute_ssl(collection_id, request, prefix, **download_kwargs)\n",
243+
"def compute_ssl_timeseries(\n",
244+
" collection_id,\n",
245+
" request,\n",
246+
" prefix,\n",
247+
" lon_slice,\n",
248+
" lat_slice,\n",
249+
" **download_kwargs,\n",
250+
"):\n",
251+
" ssl = compute_ssl(\n",
252+
" collection_id,\n",
253+
" request,\n",
254+
" prefix,\n",
255+
" lon_slice=lon_slice,\n",
256+
" lat_slice=lat_slice,\n",
257+
" **download_kwargs,\n",
258+
" )\n",
237259
" return diagnostics.spatial_weighted_mean(ssl)"
238260
]
239261
},
@@ -273,7 +295,14 @@
273295
"dataarrays = []\n",
274296
"for prefix in [\"\", \"thermo\", \"halo\"]:\n",
275297
" name = \"_\".join(([prefix] if prefix else []) + [\"ssl\"])\n",
276-
" da = compute_ssl_timeseries(*request_reanalysis, prefix=prefix, **download_kwargs)\n",
298+
" print(f\"{name = }\")\n",
299+
" da = compute_ssl_timeseries(\n",
300+
" *request_reanalysis,\n",
301+
" prefix=prefix,\n",
302+
" lon_slice=lon_slice,\n",
303+
" lat_slice=lat_slice,\n",
304+
" **download_kwargs,\n",
305+
" )\n",
277306
" dataarrays.append(da.rename(name))\n",
278307
"ds_reanalysis = xr.merge(dataarrays)\n",
279308
"\n",

0 commit comments

Comments
 (0)