Skip to content

Commit

Permalink
fix greenland
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Jul 29, 2024
1 parent f0bb424 commit 12c94e9
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions notebooks/wp5/greenland_ice_velocity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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\")"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -344,7 +341,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -358,7 +355,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 12c94e9

Please sign in to comment.