Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mostly doc update #3

Merged
merged 8 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.1"

[deps]
CommonDataModel = "1fbeeb36-5f17-413c-809b-666fb144f157"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"

[compat]
Expand Down
13 changes: 12 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ makedocs(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://Hirlam.github.io/NCPlots.jl",
edit_link="main",
collapselevel = 1,
assets=String[],
),
pages=[
"Home" => "index.md",
"Examples" => "example.md",
"Examples" => [
"Basic" => "examples/era5_pv.md",
"Light" => "examples/light.md",
"Animation" => "examples/animations.md",
"Multiple plot in axis" => "examples/single_axis.md",
"Geopotential height" => "examples/geopotential.md",
"Limited Area plots" => "examples/lam.md",
"Metcoop Increments" => "examples/metcoop.md"
"Sliders and Menus" => "examples/sliders_menus.md",

],
"Getting data" => "cds.md",
"Keyboard control" => "keyboard.md",
"API reference" => "references.md"
Expand Down
22 changes: 0 additions & 22 deletions docs/src/animations.md

This file was deleted.

Binary file added docs/src/assets/metcoop_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 0 additions & 94 deletions docs/src/example.md

This file was deleted.

31 changes: 31 additions & 0 deletions docs/src/examples/animations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Animations



## Animated plots

To make these animations use Observables and `@lift` to lift the dataset view e.g.

```julia
ds = Dataset(...)
t = Observable(1)
pv = @lift(view(ds,time=$t)["pv"])
plot(pv)
```

Updating `t` wil update the plot e.g.

```julia
for i=1:100
t[] = i
sleep(0.01)
end
```

![](../assets/pv_era5_2.gif)

You can access eyeposition in `ax.scene` and update in the for loop

![](../assets/test.mp4)

## Recording animations
19 changes: 19 additions & 0 deletions docs/src/examples/era5_pv.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# [Example](@id example)



These examples use NetCDF files from the `docs/src/assets` directory. For the animations download larger datasets as exlained in the Getting data section.


## ERA5 potential vorticity

```julia
using NCPlots, GLMakie, NCDatasets
ds = Dataset("assets/era5_pv_z_500hPa.nc")
pv = view(ds, time=1)["pv"]
fig, ax, plt = plot(pv, colormap=:RdBu, colorrange=(-3e-6,3e-6))
save("assets/era5_pv_docs.png", fig) # hide
```

![](../assets/era5_pv_docs.png)
18 changes: 18 additions & 0 deletions docs/src/examples/geopotential.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

# Plot on geopotential height surface

Multiply `x`, `y`, `z` by geopotential height

![](../assets/logo2.png)


## Plot on orography

See plot geopotential height. Color show temperature increments from data assimilation

![](../assets/envar_2019081803.png)





21 changes: 21 additions & 0 deletions docs/src/examples/lam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Limited area plots

## CARRA


![](../assets/east_domain.png)
![](../assets/east_west_domain.png)

## Metcoop

```julia
archive="/lustre/storeB/immutable/archive/projects/metproduction/MEPS/"
ds = Dataset("$archive/2023/10/01/meps_det_2_5km_20231001T00Z.nc")
field = view(ds,hybrid=65,time=1)["air_temperature_ml"]
plot(field)
```



![](../assets/metcoop.png)

7 changes: 7 additions & 0 deletions docs/src/examples/light.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Control light

Access properties `specular` `diffuse` etc. in the returned `plt`.

![](../assets/marble2.png)

Explain how to update camera, change lightposition
42 changes: 42 additions & 0 deletions docs/src/examples/metcoop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Metcoop

Example reading from MEPS archive at MET Norway

```julia
using Glob, NCDatasets, NCPlots, GLMakie

archive="/lustre/storeB/immutable/archive/projects/metproduction/MEPS/2023/01/30"

files = glob("meps_det_2_5km*.nc", archive) # use e.g. "....*00.nc" to only match files with 00:00 UTC

ds = NCDatasets.Dataset(files, aggdim="cycle", isnewdim=true, constvars=["x","y","hybrid","time"],deferopen=false)

fig = Figure()
fcint = 3; llmax=66; nlev=65


tsl, lsl,csl = SliderGrid(fig[2,1],
(label="LL",range=1:(llmax-fcint),startvalue=1),
(label="Level",range=nlev:-1:1,startvalue=nlev),
(label="Cycle",range=2:length(files),startvalue=2),
tellheight=false,
width=350
)
ax= Axis(fig[1,2])

varname = "air_temperature_ml"
var = ds[varname]

dsv = @lift(var[:,:,$(lsl.value),$(tsl.value),$(csl.value)] -
var[:,:,$(lsl.value),$(tsl.value)+3,$(csl.value)-1]
)

title = @lift(string(Analysis increment, " " ,varname, basename(files[$(cycle_sl.value)]))
subtitle = @lift(string(" Level ", $(lsl.value), "forecast", $(tsl.value)-1, " Hour") )

heatmap!(ax,dsv,colormap=:RdBu,colorrange=(-2,2))
Label(fig[0,:],label,tellwidth=false)
Label(fig[1,:],label,tellwidth=false)
```

![](../assets/metcoop_menu.png)
6 changes: 6 additions & 0 deletions docs/src/examples/single_axis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

# Mutliple plots in single axis

See `docs/plotlogo.jl` for an example

![](../assets/logo.png)
33 changes: 33 additions & 0 deletions docs/src/examples/sliders_menus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Sliders Menus



```julia

crangedict = Dict(
"pv" => (-2e-6,2e-6),
"z" => (20000.0,50000.0)
)

fig = Figure()

menu = Menu(fig[1,1],options=setdiff(keys(ds),dimnames(ds)))
menu2 = Menu(fig[1,2], options=colorschemes)
sl = SliderGrid(fig[2,1],
(label="time", range=1:length(ds["time"]),startvalue=1,format = x-> Dates.format(ds["time"][x],"yyyymmdd-HH"))
)
ax = LScene(fig[3,1], show_axis=false)
colorrange=@lift(crangedict($(menu.selection)))
colormap=@lift(colorschem)

ds = Dataset("...")
dsv = @lift(view(ds,time=$(sl.sliders[1].value))[$(menu.selection)])
plotvar!(ax,dsv,colorrange=colorrange,colormap=:RdBu)

```


## Level slider



7 changes: 3 additions & 4 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
NCPlots is a Julia package for plotting (meteorological) data on the sphere. Datasets should conform to the CF convention and implement the [CommonDataModel.jl](https://github.com/JuliaGeo/CommonDataModel.jl) interface like [NCDatasets](https://github.com/Alexander-Barth/NCDatasets.jl) and [GRIBDatasets](https://github.com/JuliaGeo/GRIBDatasets.jl)


See [here](@ref Examples) for some examples
See [Getting data](@ref getting_data) how to obtain ERA5 and CARRA data.
See [here](@ref example) for a basic example and [Getting data](@ref getting_data) how to obtain ERA5 and CARRA data.

## Installation
### Installation

NCPlots is in the Harmonie registry.
Add the Harmonie registry (hit `]` in the Julia REPL to enter package mode).
Expand All @@ -22,7 +21,7 @@ Then install NCPlots with
pkg> add NCPlots
```

## Data requirements
### Data requirements

Variables should only have dimensions `longitude` and `latitude`. If there are additional dimensions create a view
e.g. for a dataset `ds` that contains a variable `pv` where `pv` in addition to `longitude` and `latitude` also has dimension `time` do
Expand Down
Loading
Loading