{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# How to use EarthDataLab.jl to do large scale computations\n", "\n", "* This notebook is available at https://github.com/JuliaDataCubes/ESDLTutorials" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## NFDI4Earth\n", "\n", "- National Research Data Infrastructure in Germany\n", "- FAIR Data Access\n", "- Cultural shift in Earth System sciences towards openness\n", "- Provide a one-stop access point and a user support network\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Why Julia?\n", "\n", "* Scripting and High Performance in the same language\n", "* Multiple Dispatch\n", "* Introspection into other peoples code" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Load the relevant packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Documents/ESDLTutorials`\n" ] } ], "source": [ "]activate ." ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "using EarthDataLab" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "using Pkg" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "using Statistics" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "using Plots" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "slideshow": { "slide_type": "fragment" } }, "outputs": [ { "data": { "application/vnd.webio.node+json": { "children": [], "instanceArgs": { "namespace": "html", "tag": "div" }, "nodeType": "DOM", "props": {}, "type": "node" }, "text/html": [ "
\n", "

The WebIO Jupyter extension was not detected. See the\n", "\n", " WebIO Jupyter integration documentation\n", "\n", "for more information.\n", "

\n" ], "text/plain": [ "WebIO._IJuliaInit()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "using ESDLPlots" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "using Dates" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "using YAXArrays" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "using WeightedOnlineStats" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Use data larger than RAM\n", "* Uses *DiskArrays.jl* in the background\n", "* Load only the data that is really needed\n", "* Use chunks of the data\n", "* Use NetCDF or Zarr or GDAL to load data\n", "* Load data locally or from the cloud" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "# Do not run, this is only an example\n", "\n", "# using Zarr\n", "# cube = Cube(\"../somepath.zarr\");" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "┌ Warning: In the future, fill values will not be interpreted as missing values by default. \n", "│ Please set the keyword argument `fill_as_missing` to a boolean accordingly. Setting to `true`\n", "│ for now, but in the future `false` will be the default.\n", "└ @ Zarr /home/fcremer/.julia/packages/Zarr/tmr2s/src/metadata.jl:182\n" ] }, { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 1440 Elements from -179.875 to 179.875\n", "lat Axis with 720 Elements from 89.875 to -89.875\n", "time Axis with 1840 Elements from 1979-01-05T00:00:00 to 2018-12-31T00:00:00\n", "Variable Axis with 69 elements: leaf_area_index sensible_heat .. snow_sublimation Rg \n", "units: W m-2\n", "Total size: 490.37 GB\n" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "c = esdc(res=\"low\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Subsets happen lazily" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 172 Elements from -9.875 to 32.875\n", "lat Axis with 140 Elements from 69.875 to 35.125\n", "time Axis with 782 Elements from 2000-01-05T00:00:00 to 2016-12-30T00:00:00\n", "Variable Axis with 3 elements: air_temperature_2m net_ecosystem_exchange surface_moisture \n", "units: W m-2\n", "Total size: 215.5 MB\n" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "europe = subsetcube(c, region=\"Europe\", time=2000:2016, \n", "\tVariable=[\"air_temperature_2m\", \"net_ecosystem\", \"surface_moisture\"])" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(europe.time.values,europe[Variable=\"air_temperature_2m\", lat=50, lon=11].data)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Make computations on every element of the cube\n", "* Computations are only registered\n", "* Computations are done with other computations together" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 172 Elements from -9.875 to 32.875\n", "lat Axis with 140 Elements from 69.875 to 35.125\n", "time Axis with 782 Elements from 2000-01-05T00:00:00 to 2016-12-30T00:00:00\n", "units: W m-2\n", "Total size: 143.67 MB\n" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "celsiuscube = map(europe[Variable=\"air_temperature_2m\"]) do x\n", "\tx - 273.15\n", "end\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "scrolled": true }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(europe.time.values, celsiuscube[lat=50, lon=11].data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Make computations along named Axes\n", "* User defined functions\n", "* Use the whole Julia Ecosystem" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "prange (generic function with 1 method)" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function prange(pix_prange, pix,threshold)\n", " \tq5, q95 = quantile(pix, [threshold, 1-threshold])\n", " \tpix_prange .=q95 - q5\n", "end" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:07\u001b[39m\n" ] }, { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 48 Elements from 6.625 to 18.375\n", "lat Axis with 46 Elements from 46.875 to 35.625\n", "Total size: 17.25 KB\n" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smalldata = subsetcube(celsiuscube, region=\"Italy\") \n", "prange_italy = mapCube(prange, smalldata, .05, indims = InDims(\"Time\"), outdims = OutDims())" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 15.0\n", " \n", "\n", "\n", " \n", " 17.5\n", " \n", "\n", "\n", " \n", " 20.0\n", " \n", "\n", "\n", " \n", " 22.5\n", " \n", "\n", "\n", " \n", " 25.0\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n" ], "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 15.0\n", " \n", "\n", "\n", " \n", " 17.5\n", " \n", "\n", "\n", " \n", " 20.0\n", " \n", "\n", "\n", " \n", " 22.5\n", " \n", "\n", "\n", " \n", " 25.0\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n", "\n" ], "text/plain": [ "Compose.Context(BBox{l,t,r,b,w,h = 0.0w,0.0h, 1.0w,1.0h, 1.0w,1.0h}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,1.0h + -max(0.1h, 16.0mm), 1cx,1.0h + -max(0.1h, 16.0mm) + max(0.1h, 16.0mm), 1cx,max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.25cy, 0.9500000000000001cx,0.35cy, 0.9cx,0.1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.LinePrimitive}(Compose.LinePrimitive[Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.17768897821597288cx, 0.1cy), (0.17768897821597288cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.36289446881722387cx, 0.1cy), (0.36289446881722387cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.5480999594184749cx, 0.1cy), (0.5480999594184749cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.7333054500197258cx, 0.1cy), (0.7333054500197258cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.9185109406209768cx, 0.1cy), (0.9185109406209768cx, 0.9cy)])], Symbol(\"\"))]), List([Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0cy, 0.9500000000000001cx,0.2cy, 0.9cx,0.2cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}}(Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}[Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.17768897821597288cx, 1cy), \"15.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.36289446881722387cx, 1cy), \"17.5\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.5480999594184749cx, 1cy), \"20.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.7333054500197258cx, 1cy), \"22.5\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.9185109406209768cx, 1cy), \"25.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm))], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.35cy, 0.9500000000000001cx,0.9cy, 0.9cx,0.55cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}}(Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}[Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.0cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.01cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.02cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.03cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.04cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.05cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.06cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.07cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.08cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.09cx, 0cy), 0.010101010101010102cx, 1cy) … Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.9cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.91cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.92cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.93cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.94cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.95cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.96cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.97cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.98cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.99cx, 0cy), 0.010101010101010102cx, 1cy)], Symbol(\"\"))]), List([Compose.Property{Compose.SVGAttributePrimitive}(Compose.SVGAttributePrimitive[Compose.SVGAttributePrimitive(\"shape-rendering\", \"crispEdges\")]), Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,0.0))]), Compose.Property{Compose.FillPrimitive}(Compose.FillPrimitive[Compose.FillPrimitive(RGBA{Float64}(0.001462,0.000466,0.013866,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.004017545454545455,0.0029070909090909095,0.02807930303030303,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.007961606060606061,0.006374939393939395,0.048094636363636374,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.013359000000000003,0.010731909090909094,0.06957054545454547,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.020304515151515157,0.01575906060606061,0.09136093939393941,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.02899090909090909,0.021239727272727275,0.11356754545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.03975209090909092,0.026929181818181824,0.13628154545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.05178960606060607,0.03253748484848485,0.15953157575757576,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.0643648484848485,0.037750000000000006,0.18329048484848487,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.07760518181818182,0.04216372727272727,0.20752445454545457,1.0)) … Compose.FillPrimitive(RGBA{Float64}(0.9609698181818183,0.8576884545454545,0.2957438181818181,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9561103333333332,0.8770599090909093,0.3292925757575759,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9515965757575758,0.8960052727272727,0.3651949393939394,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9480890000000001,0.9142508181818183,0.40367590909090934,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9463933333333334,0.9315365151515151,0.44433366666666674,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9476236666666666,0.947508909090909,0.48643933333333317,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9525006363636364,0.962034909090909,0.5286097272727274,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9612186666666667,0.9751783939393939,0.5695537878787879,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9734312727272727,0.9871787878787879,0.608350484848485,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.988362,0.998364,0.644924,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 0cx + 1.0w,0cy + 1.0h + -max(0.1h, 16.0mm), 1.0w,1.0h + -max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 1cx,1cy, 1cx,1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}}(Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}[Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}(\"image/png\", UInt8[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00 … 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82], (0cx, 0cy), 1cx, 1cy)], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plotMAP(prange_italy)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Make Moving Window Computations\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "movingmean (generic function with 2 methods)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function movingmean(xout, xin)\n", " xout .= mean(xin)\n", "end\n", "\n", "function movingmean(cube::YAXArray)\n", " indims = InDims(MovingWindow(\"lat\", 1,1),MovingWindow(\"lon\", 1,1))\n", " outdims=OutDims()\n", " mapCube(movingmean, cube; indims=indims, outdims=outdims)\n", "end" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 48 Elements from 6.625 to 18.375\n", "lat Axis with 46 Elements from 46.875 to 35.625\n", "Total size: 17.25 KB\n" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "movingavgprange = movingmean(prange_italy)" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 15.0\n", " \n", "\n", "\n", " \n", " 17.5\n", " \n", "\n", "\n", " \n", " 20.0\n", " \n", "\n", "\n", " \n", " 22.5\n", " \n", "\n", "\n", " \n", " 25.0\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n" ], "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 15.0\n", " \n", "\n", "\n", " \n", " 17.5\n", " \n", "\n", "\n", " \n", " 20.0\n", " \n", "\n", "\n", " \n", " 22.5\n", " \n", "\n", "\n", " \n", " 25.0\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n", "\n" ], "text/plain": [ "Compose.Context(BBox{l,t,r,b,w,h = 0.0w,0.0h, 1.0w,1.0h, 1.0w,1.0h}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,1.0h + -max(0.1h, 16.0mm), 1cx,1.0h + -max(0.1h, 16.0mm) + max(0.1h, 16.0mm), 1cx,max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.25cy, 0.9500000000000001cx,0.35cy, 0.9cx,0.1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.LinePrimitive}(Compose.LinePrimitive[Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.17628358426681723cx, 0.1cy), (0.17628358426681723cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.36944450150031954cx, 0.1cy), (0.36944450150031954cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.5626054187338217cx, 0.1cy), (0.5626054187338217cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.7557663359673241cx, 0.1cy), (0.7557663359673241cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.9489272532008264cx, 0.1cy), (0.9489272532008264cx, 0.9cy)])], Symbol(\"\"))]), List([Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0cy, 0.9500000000000001cx,0.2cy, 0.9cx,0.2cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}}(Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}[Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.17628358426681723cx, 1cy), \"15.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.36944450150031954cx, 1cy), \"17.5\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.5626054187338217cx, 1cy), \"20.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.7557663359673241cx, 1cy), \"22.5\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.9489272532008264cx, 1cy), \"25.0\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm))], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.35cy, 0.9500000000000001cx,0.9cy, 0.9cx,0.55cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}}(Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}[Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.0cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.01cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.02cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.03cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.04cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.05cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.06cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.07cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.08cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.09cx, 0cy), 0.010101010101010102cx, 1cy) … Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.9cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.91cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.92cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.93cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.94cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.95cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.96cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.97cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.98cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.99cx, 0cy), 0.010101010101010102cx, 1cy)], Symbol(\"\"))]), List([Compose.Property{Compose.SVGAttributePrimitive}(Compose.SVGAttributePrimitive[Compose.SVGAttributePrimitive(\"shape-rendering\", \"crispEdges\")]), Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,0.0))]), Compose.Property{Compose.FillPrimitive}(Compose.FillPrimitive[Compose.FillPrimitive(RGBA{Float64}(0.001462,0.000466,0.013866,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.004017545454545455,0.0029070909090909095,0.02807930303030303,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.007961606060606061,0.006374939393939395,0.048094636363636374,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.013359000000000003,0.010731909090909094,0.06957054545454547,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.020304515151515157,0.01575906060606061,0.09136093939393941,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.02899090909090909,0.021239727272727275,0.11356754545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.03975209090909092,0.026929181818181824,0.13628154545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.05178960606060607,0.03253748484848485,0.15953157575757576,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.0643648484848485,0.037750000000000006,0.18329048484848487,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.07760518181818182,0.04216372727272727,0.20752445454545457,1.0)) … Compose.FillPrimitive(RGBA{Float64}(0.9609698181818183,0.8576884545454545,0.2957438181818181,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9561103333333332,0.8770599090909093,0.3292925757575759,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9515965757575758,0.8960052727272727,0.3651949393939394,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9480890000000001,0.9142508181818183,0.40367590909090934,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9463933333333334,0.9315365151515151,0.44433366666666674,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9476236666666666,0.947508909090909,0.48643933333333317,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9525006363636364,0.962034909090909,0.5286097272727274,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9612186666666667,0.9751783939393939,0.5695537878787879,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9734312727272727,0.9871787878787879,0.608350484848485,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.988362,0.998364,0.644924,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 0cx + 1.0w,0cy + 1.0h + -max(0.1h, 16.0mm), 1.0w,1.0h + -max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 1cx,1cy, 1cx,1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}}(Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}[Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}(\"image/png\", UInt8[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00 … 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82], (0cx, 0cy), 1cx, 1cy)], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plotMAP(movingavgprange)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cube Axes are cubes as well\n", "\n", "* Use Cube Axes in the inner functions \n", "* Combine multiple cubes\n", "* Define the output dimension" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "using LombScargle" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "clombscargle (generic function with 1 method)" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function clombscargle(xout, xin, times)\n", " ind = .!ismissing.(xin)\n", " ts = collect(nonmissingtype(eltype(xin)), xin[ind])\n", " x = times[ind]\n", " if length(ts) < 10\n", " @show length(ts)\n", " xout .= missing\n", " return\n", " end\n", " datediff = Date.(x) .- Date(x[1])\n", " dateint = getproperty.(datediff, :value)\n", " pl = LombScargle.plan(dateint, ts)\n", " pgram = LombScargle.lombscargle(pl)\n", " lsperiod= findmaxperiod(pgram)\n", " lspower = findmaxpower(pgram)\n", " lsnum = LombScargle.M(pgram)\n", " perval = isempty(lsperiod) ? missing : lsperiod[1] \n", " xout .= [lsnum, perval, lspower]\n", "end" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "function LombScargle.lombscargle(cube::YAXArray, kwargs...)\n", " indims = InDims(\"Time\")\n", " lombax = CategoricalAxis(\"LombScargle\", [\"Number of Frequencies\", \"Period with maximal power\", \"Maximal Power\"])\n", " #@show cube\n", " timeax = YAXArrays.getAxis(\"Time\", cube)\n", " od = OutDims(lombax)\n", " mapCube(clombscargle, (cube, timeax), indims=(indims, indims), outdims=od)\n", "end" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:12\u001b[39m\n" ] }, { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "LombScargle Axis with 3 elements: Number of Frequencies Period with maximal power Maximal Power \n", "lon Axis with 48 Elements from 6.625 to 18.375\n", "lat Axis with 46 Elements from 46.875 to 35.625\n", "Total size: 51.75 KB\n" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lombitaly = lombscargle(celsiuscube[region=\"Italy\"])" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 0.84\n", " \n", "\n", "\n", " \n", " 0.86\n", " \n", "\n", "\n", " \n", " 0.88\n", " \n", "\n", "\n", " \n", " 0.90\n", " \n", "\n", "\n", " \n", " 0.92\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n" ], "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", " 0.84\n", " \n", "\n", "\n", " \n", " 0.86\n", " \n", "\n", "\n", " \n", " 0.88\n", " \n", "\n", "\n", " \n", " 0.90\n", " \n", "\n", "\n", " \n", " 0.92\n", " \n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "\n", " \n", "\n", "\n", "\n" ], "text/plain": [ "Compose.Context(BBox{l,t,r,b,w,h = 0.0w,0.0h, 1.0w,1.0h, 1.0w,1.0h}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,1.0h + -max(0.1h, 16.0mm), 1cx,1.0h + -max(0.1h, 16.0mm) + max(0.1h, 16.0mm), 1cx,max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.25cy, 0.9500000000000001cx,0.35cy, 0.9cx,0.1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.LinePrimitive}(Compose.LinePrimitive[Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.16210151906793535cx, 0.1cy), (0.16210151906793535cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.35468107455280345cx, 0.1cy), (0.35468107455280345cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.5472606300376704cx, 0.1cy), (0.5472606300376704cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.7398401855225386cx, 0.1cy), (0.7398401855225386cx, 0.9cy)]), Compose.LinePrimitive{Tuple{Measures.Measure, Measures.Measure}}(Tuple{Measures.Measure, Measures.Measure}[(0.9324197410074067cx, 0.1cy), (0.9324197410074067cx, 0.9cy)])], Symbol(\"\"))]), List([Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0cy, 0.9500000000000001cx,0.2cy, 0.9cx,0.2cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}}(Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}[Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.16210151906793535cx, 1cy), \"0.84\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.35468107455280345cx, 1cy), \"0.86\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.5472606300376704cx, 1cy), \"0.88\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.7398401855225386cx, 1cy), \"0.90\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm)), Compose.TextPrimitive{Tuple{Measures.Length{:cx, Float64}, Measures.Length{:cy, Int64}}, Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}, Tuple{Measures.AbsoluteLength, Measures.AbsoluteLength}}((0.9324197410074067cx, 1cy), \"0.92\", Compose.HCenter(), Compose.VBottom(), Compose.Rotation{Tuple{Measures.Length{:w, Float64}, Measures.Length{:h, Float64}}}(0.0, (0.5w, 0.5h)), (0.0mm, 0.0mm))], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0.05cx,0.35cy, 0.9500000000000001cx,0.9cy, 0.9cx,0.55cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}}(Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}[Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.0cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.01cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.02cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.03cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.04cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.05cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.06cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.07cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.08cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.09cx, 0cy), 0.010101010101010102cx, 1cy) … Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.9cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.91cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.92cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.93cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.94cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.95cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.96cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.97cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.98cx, 0cy), 0.010101010101010102cx, 1cy), Compose.RectanglePrimitive{Tuple{Measures.Measure, Measures.Measure}, Measures.Measure, Measures.Measure}((0.99cx, 0cy), 0.010101010101010102cx, 1cy)], Symbol(\"\"))]), List([Compose.Property{Compose.SVGAttributePrimitive}(Compose.SVGAttributePrimitive[Compose.SVGAttributePrimitive(\"shape-rendering\", \"crispEdges\")]), Compose.Property{Compose.StrokePrimitive}(Compose.StrokePrimitive[Compose.StrokePrimitive(RGBA{Float64}(0.0,0.0,0.0,0.0))]), Compose.Property{Compose.FillPrimitive}(Compose.FillPrimitive[Compose.FillPrimitive(RGBA{Float64}(0.001462,0.000466,0.013866,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.004017545454545455,0.0029070909090909095,0.02807930303030303,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.007961606060606061,0.006374939393939395,0.048094636363636374,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.013359000000000003,0.010731909090909094,0.06957054545454547,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.020304515151515157,0.01575906060606061,0.09136093939393941,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.02899090909090909,0.021239727272727275,0.11356754545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.03975209090909092,0.026929181818181824,0.13628154545454546,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.05178960606060607,0.03253748484848485,0.15953157575757576,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.0643648484848485,0.037750000000000006,0.18329048484848487,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.07760518181818182,0.04216372727272727,0.20752445454545457,1.0)) … Compose.FillPrimitive(RGBA{Float64}(0.9609698181818183,0.8576884545454545,0.2957438181818181,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9561103333333332,0.8770599090909093,0.3292925757575759,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9515965757575758,0.8960052727272727,0.3651949393939394,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9480890000000001,0.9142508181818183,0.40367590909090934,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9463933333333334,0.9315365151515151,0.44433366666666674,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9476236666666666,0.947508909090909,0.48643933333333317,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9525006363636364,0.962034909090909,0.5286097272727274,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9612186666666667,0.9751783939393939,0.5695537878787879,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.9734312727272727,0.9871787878787879,0.608350484848485,1.0)), Compose.FillPrimitive(RGBA{Float64}(0.988362,0.998364,0.644924,1.0))])]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\")), Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 0cx + 1.0w,0cy + 1.0h + -max(0.1h, 16.0mm), 1.0w,1.0h + -max(0.1h, 16.0mm)}, nothing, nothing, nothing, nothing, List([Compose.Context(BBox{l,t,r,b,w,h = 0cx,0cy, 1cx,1cy, 1cx,1cy}, nothing, nothing, nothing, nothing, List([]), List([Compose.Form{Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}}(Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}[Compose.BitmapPrimitive{Tuple{Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}, Measures.Length{:cx, Int64}, Measures.Length{:cy, Int64}}(\"image/png\", UInt8[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00 … 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82], (0cx, 0cy), 1cx, 1cy)], Symbol(\"\"))]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))]), List([]), List([]), 0, false, false, false, false, nothing, nothing, 0.0, Symbol(\"\"))" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plotMAP(lombitaly[LombScargle=\"Maximal Power\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load Reference polygons" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "lon Axis with 172 Elements from -9.875 to 32.875\n", "lat Axis with 140 Elements from 69.875 to 35.125\n", "labels: Dict{Int32, String}(55 => \"Spain\", 32 => \"United Kingdom\", 219 => \"Belarus\", 185 => \"Czechia\", 104 => \"Morocco\", 62 => \"Slovenia\", 183 => \"Faeroe Is.\", 218 => \"Belgium\", 173 => \"Estonia\", 235 => \"Andorra\"…)\n", "Total size: 94.06 KB\n" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "countrycube = cubefromshape(\"data/ne_50m_admin_0_countries\",europe, labelsym=:NAME)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use table interface\n", "* Use data as a dataframe\n", "* Combine multiple cubes in one table" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [], "source": [ "table = CubeTable(tair=celsiuscube, country=countrycube);#, include_axes=(\"lon\",\"lat\",\"time\"));" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fit Online Statistics" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "Label Axis with 47 elements: Spain United Kingdom .. Malta Netherlands \n", "Category2 Axis with 12 elements: 1 2 .. 11 12 \n", "Total size: 4.41 KB\n" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r = cubefittable(table, WeightedMean, :tair, weight=(i->abs(cosd.(i.lat))), by=(:country,r->month(r.time)))" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "Country Axis with 47 elements: Spain United Kingdom .. Malta Netherlands \n", "Month Axis with 12 elements: January February .. November December \n", "Total size: 4.41 KB\n" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "renameaxis!(r, \"Category2\" => CategoricalAxis(\"Month\", monthname.(1:12)))\n", "renameaxis!(r, \"Label\"=> \"Country\")\n" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plotXY(r[Country=[\"Sweden\", \"France\",\"Germany\", \"Greece\", \"Spain\", \"Italy\"]], \n", " group=\"Country\", xaxis=\"Month\", label=\"\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use Python Packages\n", "* Use PyCall to have access to the python ecosystem\n", "* Use RCall for R packages" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "using PyCall" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PyObject " ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pyimport_conda(\"scipy.ndimage\", \"scipy\")" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "PyObject " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scipyndimage = pyimport(\"scipy.ndimage\")" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "gaussian_smooth (generic function with 1 method)" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function gaussian_smooth(xout, xin)\n", " missinds = ismissing.(xin)\n", " smooth = scipyndimage.gaussian_filter(xin[.!missinds], sigma=4)\n", " xout[.!missinds] .= smooth\n", "end" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "time Axis with 46 Elements from 2010-01-05T00:00:00 to 2010-12-31T00:00:00\n", "units: W m-2\n", "Total size: 184.0 bytes\n" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "gpp_jena_2010 = c[lat = 50.92878, lon = 11.5899, time = (DateTime(2010), DateTime(2011)), Variable=\"gross_primary_productivity\"]" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "time Axis with 46 Elements from 2010-01-05T00:00:00 to 2010-12-31T00:00:00\n", "Total size: 184.0 bytes\n" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smoothcube = mapCube(gaussian_smooth, gpp_jena_2010, indims=InDims(\"time\"), outdims=OutDims(\"time\"))" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", " \n", " \n", " \n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "plot(smoothcube.time.values, smoothcube.data)\n", "plot!(gpp_jena_2010.time.values, gpp_jena_2010.data)" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:36\u001b[39m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 39.351719 seconds (70.07 M allocations: 5.462 GiB, 5.80% gc time, 13.14% compilation time: 5% of which was recompilation)\n" ] }, { "data": { "text/plain": [ "YAXArray with the following dimensions\n", "time Axis with 782 Elements from 2000-01-05T00:00:00 to 2016-12-30T00:00:00\n", "lon Axis with 172 Elements from -9.875 to 32.875\n", "lat Axis with 140 Elements from 69.875 to 35.125\n", "Variable Axis with 3 elements: air_temperature_2m net_ecosystem_exchange surface_moisture \n", "Total size: 215.5 MB\n" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@time smoothcube = mapCube(gaussian_smooth, europe, indims=InDims(\"time\"), outdims=OutDims(\"time\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Easy parallelization on multiple cores and multiple nodes¶\n", "* Use threads on a single computer \n", "* Use Distributed on multiple computers\n", "* Works also with ClusterManagers like SLURM\n", "\n", "Note: This might not work on binder." ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [], "source": [ "using Distributed" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3-element Vector{Int64}:\n", " 2\n", " 3\n", " 4" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "addprocs(3) # This doesn't work on Binder, because of memory size" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " From worker 3:\t\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Documents/ESDLTutorials`\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Documents/ESDLTutorials`\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " From worker 2:\t\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Documents/ESDLTutorials`\n", " From worker 4:\t\u001b[32m\u001b[1m Activating\u001b[22m\u001b[39m project at `~/Documents/ESDLTutorials`\n" ] } ], "source": [ "@everywhere begin\n", " using Pkg\n", " Pkg.activate(\".\")\n", "end" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "@everywhere begin\n", " using EarthDataLab, Statistics\n", " function prange(pix_prange, pix,threshold)\n", " q5, q95 = quantile(pix, [threshold, 1-threshold])\n", " pix_prange .=q95 - q5\n", " end\n", "end" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32mProgress: 100%|█████████████████████████████████████████| Time: 0:00:28\u001b[39m\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " 37.576647 seconds (45.12 M allocations: 2.478 GiB, 1.06% gc time, 32.29% compilation time: 1% of which was recompilation)\n" ] } ], "source": [ "@time prangecelsius = mapCube(prange, celsiuscube, .05, indims = InDims(\"Time\"), outdims = OutDims());" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Questions ?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Installation instructions\n", "\n", "This shouldn't be needed." ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [], "source": [ "#] add https://github.com/esa-esdl/ESDL.jl/ https://github.com/esa-esdl/ESDLPlots.jl" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [], "source": [ "#]dev --local YAXArrays" ] } ], "metadata": { "@webio": { "lastCommId": null, "lastKernelId": null }, "kernelspec": { "display_name": "Julia 1.8.0", "language": "julia", "name": "julia-1.8" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.8.0" } }, "nbformat": 4, "nbformat_minor": 4 }