@@ -2,6 +2,7 @@ export climscatter, climscatter!, climsurface!, climsurface, climplot
2
2
3
3
"""
4
4
climplot(A::ClimArray; kwargs...) → fig, ax, el, cb
5
+
5
6
Main plotting function that dispatches to [`climscatter!`](@ref) if `A` has
6
7
an [`CoordinateSpace`](@ref) dimension, or to [`climsurface!`](@ref) for [`OrthogonalSpace`](@ref).
7
8
@@ -13,85 +14,9 @@ Plotting from ClimateBase.jl also works with `Observable`s that enclose a `ClimA
13
14
You can update the values of the observable with another `ClimArray` with the same spatial
14
15
dimension, and the plot will be updated. See documentation online for examples.
15
16
"""
16
- function climplot (A, args... ; scatter = spacestructure (A) == CoordinateSpace (),
17
- source = " +proj=longlat +datum=WGS84" , dest = " +proj=eqearth" ,
18
- colorbar = true , name = string (DimensionalData. name (A)), kwargs... )
19
-
20
- # TODO : Perhaps setting custom colorrange leads to better plots?
21
- # vmin = haskey(kwargs, :vmin) ? kwargs[:vmin] : quantile(data, 0.025)
22
- # vmax = haskey(kwargs, :vmax) ? kwargs[:vmax] : quantile(data, 0.975)
23
-
24
- fig = GeoMakie. Figure ()
25
- ax = GeoMakie. GeoAxis (fig[1 ,1 ]; source, dest, title = GeoMakie. Observable (" " ))
26
-
27
- coastplot = lines! (ax, GeoMakie. coastlines (); color = :black , overdraw = true , coastkwargs... )
28
- translate! (coastplot, 0 , 0 , 99 ) # ensure they are on top of other plotted elements
29
-
30
- # TODO : @assert A has only space dimension
31
-
32
- if scatter
33
- el = climscatter! (ax, A; kwargs... )
34
- else
35
- el = climsurface! (ax, A; kwargs... )
36
- end
37
-
38
- if colorbar
39
- cb = GeoMakie. Colorbar (fig[1 , 2 ], el; label = name)
40
- else
41
- cb = nothing
42
- end
43
- return fig, ax, el, cb
44
- end
45
-
46
- # #########################################################################################
47
- # # Scatter
48
- # #########################################################################################
49
- # Notice that `A` is not declared as `ClimArray`, but assumed to be.
50
- # Duck-typing for Observables.
51
- function climscatter! (ax, A; colormap = :dense , kwargs... )
52
- if hasdim (A, Coord)
53
- lonlat = dims (A, Coord). val
54
- elseif dims (A)[1 ] isa Lon
55
- londim = dims (A, Lon)
56
- latdim = dims (A, Lat)
57
- lonlat = [GeoMakie. Point2f0 (l,lat) for lat in latdim for l in londim]
58
- else
59
- error (" Unknown spatial dimensions for input." )
60
- end
61
- data = GeoMakie. lift (A -> vec (A. data), A)
62
- GeoMakie. scatter! (ax, lonlat; color = data, colormap, kwargs... )
63
- end
64
-
65
- # #########################################################################################
66
- # # Surface
67
- # #########################################################################################
68
- # TODO : Change this to `contourf`
69
-
70
- # Notice that `A` is not declared as `ClimArray`, but assumed to be.
71
- # Duck-typing for Observables.
72
- function climsurface! (ax, A; colormap = :dense , kwargs... )
73
- # TODO : @assert A has only space
74
- if hasdim (A, Coord)
75
- # TODO : @pkeil this is for you
76
- error (" Surface plots for `Coord` arrays are not supported yet!" )
77
- end
78
- # TODO : This needs to depend on lon_0 or use the "meridian cut" function
79
- B = GeoMakie. lift (A -> longitude_circshift (A), A)
80
- lon = dims (B, Lon). val
81
- lat = dims (B, Lat). val
82
- data = GeoMakie. lift (B -> B. data, B)
83
- GeoMakie. surface! (ax, lon, lat, data; shading = false , colormap, kwargs... )
84
- end
85
-
86
-
87
- # #########################################################################################
88
- # # Observables overloads
89
- # #########################################################################################
90
- # These overloads allows me to write generic code that does not care if input
91
- # is observable or not. This leads to simple, clean, small, elegant code for
92
- # animating fields by simply replacing them with their observables.
17
+ function climplot end
93
18
94
- GeoMakie . lift (f, x :: ClimArray ) = f (x)
95
- DimensionalData . dims (o :: GeoMakie.Observable , args ... ) = dims (o . val, args ... )
96
- DimensionalData . name (o :: GeoMakie.Observable , args ... ) = name (o . val, args ... )
97
- spacestructure (A :: GeoMakie.Observable ) = spacestructure (A . val)
19
+ function climscatter end
20
+ function climscatter! end
21
+ function climsurface end
22
+ function climsurface! end
0 commit comments