From 12c94e9bf94b0017e16bbc41f54b0e74b8533a36 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Mon, 29 Jul 2024 11:59:38 +0200 Subject: [PATCH] fix greenland --- notebooks/wp5/greenland_ice_velocity.ipynb | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/notebooks/wp5/greenland_ice_velocity.ipynb b/notebooks/wp5/greenland_ice_velocity.ipynb index df9e825..ffad46d 100644 --- a/notebooks/wp5/greenland_ice_velocity.ipynb +++ b/notebooks/wp5/greenland_ice_velocity.ipynb @@ -25,6 +25,7 @@ "source": [ "import matplotlib.colors\n", "import matplotlib.pyplot as plt\n", + "import xarray as xr\n", "from c3s_eqc_automatic_quality_control import download\n", "\n", "plt.style.use(\"seaborn-v0_8-notebook\")" @@ -140,22 +141,18 @@ "metadata": {}, "outputs": [], "source": [ - "ds = download.download_and_transform(\n", - " collection_id,\n", - " request,\n", - " chunks={\"period\": 1},\n", - " transform_func=mask_high_vel_and_compute_std,\n", - ")\n", + "datasets = []\n", + "for period in request[\"period\"]:\n", + " ds = download.download_and_transform(\n", + " collection_id,\n", + " request | {\"period\": period},\n", + " )\n", + " datasets.append(\n", + " ds.squeeze(\"source\", drop=True).expand_dims(period=[period.replace(\"_\", \"-\")])\n", + " )\n", + "ds = xr.concat(datasets, \"period\")\n", "ds = ds.chunk(y=1351, x=748)\n", "\n", - "# Rename source dim\n", - "periods = []\n", - "for source in ds[\"source\"].values.tolist():\n", - " start, stop = source.split(\"_\")[5:7]\n", - " periods.append(f\"{start[:4]}-{stop[:4]}\")\n", - "ds[\"source\"] = periods\n", - "ds = ds.rename(source=\"period\")\n", - "\n", "# Add attributes\n", "for name, da in ds.data_vars.items():\n", " if name == \"land_ice_surface_measurement_count\":\n", @@ -344,7 +341,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -358,7 +355,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4,