diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 2c8656a..b3d9cbe 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-16T07:39:17","documenter_version":"1.1.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.9.3","generation_timestamp":"2023-10-18T23:01:07","documenter_version":"1.1.1"}} \ No newline at end of file diff --git a/dev/animations/index.html b/dev/animations/index.html deleted file mode 100644 index 0a8007c..0000000 --- a/dev/animations/index.html +++ /dev/null @@ -1,8 +0,0 @@ - -Animations · NCPlots.jl

Animations

Pass in an Observable

t = Observables(1)
-field = @lift(view(ds(time=$t)["pv"]) 
-fig,ax,plt = plot(field)

Then animate like

for i in 1:100
-   t[]=i 
-   sleep(0.01)
-end 
-

Recording animations

diff --git a/dev/assets/metcoop_menu.png b/dev/assets/metcoop_menu.png new file mode 100644 index 0000000..d56b369 Binary files /dev/null and b/dev/assets/metcoop_menu.png differ diff --git a/dev/cds/index.html b/dev/cds/index.html index 8bb061a..86381b7 100644 --- a/dev/cds/index.html +++ b/dev/cds/index.html @@ -1,5 +1,5 @@ -Getting data · NCPlots.jl

Getting data

ERA5

ERA5 data can be downloaded from the Climate Data Store. Requires an account

Click download data in one of the datasets to get an overview of the available data. After making a selection click Show API request which will give a Python script to download the data. You can also use CDSAPI.jl julia package

using CDSAPI 
+Getting data · NCPlots.jl

Getting data

ERA5

ERA5 data can be downloaded from the Climate Data Store. Requires an account

Click download data in one of the datasets to get an overview of the available data. After making a selection click Show API request which will give a Python script to download the data. You can also use CDSAPI.jl julia package

using CDSAPI 
 
 year = 2020
 month = 4       # use e.g. 1:12 for all months
@@ -25,4 +25,4 @@
     ),
     "era5_pressure_levels_$(join(variable,"_")).nc"
 )
-

Arctic regional reanalysis

Arctic regional reanalysis (CARRA) can be download from the climate data store

MetCoop

Harmonie Arome NetCDF file from Met Norway: todo

+

Arctic regional reanalysis

Arctic regional reanalysis (CARRA) can be download from the climate data store

MetCoop

Harmonie Arome NetCDF file from Met Norway: todo

diff --git a/dev/example/index.html b/dev/example/index.html deleted file mode 100644 index ddeb22d..0000000 --- a/dev/example/index.html +++ /dev/null @@ -1,15 +0,0 @@ - -Examples · NCPlots.jl

Examples

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

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

Control light

Access properties specular diffuse etc. in the returned plt.

Explain how to update camera, change lightposition

Mutliple plots in single axis

See docs/plotlogo.jl for an example

Plot on geopotential height surface

Multiply x, y, z by geopotential height

Plot on orography

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

CARRA

Metcoop

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)

Animated plots

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

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

Updating t wil update the plot e.g.

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

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

diff --git a/dev/examples/animations/index.html b/dev/examples/animations/index.html new file mode 100644 index 0000000..12157cb --- /dev/null +++ b/dev/examples/animations/index.html @@ -0,0 +1,8 @@ + +Animation · NCPlots.jl

Animations

Animated plots

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

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

Updating t wil update the plot e.g.

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

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

Recording animations

diff --git a/dev/examples/era5_pv/index.html b/dev/examples/era5_pv/index.html new file mode 100644 index 0000000..5ae1743 --- /dev/null +++ b/dev/examples/era5_pv/index.html @@ -0,0 +1,6 @@ + +Basic · NCPlots.jl

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

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

diff --git a/dev/examples/geopotential/index.html b/dev/examples/geopotential/index.html new file mode 100644 index 0000000..108ef7d --- /dev/null +++ b/dev/examples/geopotential/index.html @@ -0,0 +1,2 @@ + +Geopotential height · NCPlots.jl
diff --git a/dev/examples/lam/index.html b/dev/examples/lam/index.html new file mode 100644 index 0000000..3b2a634 --- /dev/null +++ b/dev/examples/lam/index.html @@ -0,0 +1,5 @@ + +Limited Area plots · NCPlots.jl

Limited area plots

CARRA

Metcoop

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)

diff --git a/dev/examples/light/index.html b/dev/examples/light/index.html new file mode 100644 index 0000000..d0ecc33 --- /dev/null +++ b/dev/examples/light/index.html @@ -0,0 +1,2 @@ + +Light · NCPlots.jl

Control light

Access properties specular diffuse etc. in the returned plt.

Explain how to update camera, change lightposition

diff --git a/dev/examples/metcoop/index.html b/dev/examples/metcoop/index.html new file mode 100644 index 0000000..5888b0b --- /dev/null +++ b/dev/examples/metcoop/index.html @@ -0,0 +1,35 @@ + +Metcoop Increments · NCPlots.jl

Metcoop

Example reading from MEPS archive at MET Norway

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)

diff --git a/dev/examples/single_axis/index.html b/dev/examples/single_axis/index.html new file mode 100644 index 0000000..ab1e99c --- /dev/null +++ b/dev/examples/single_axis/index.html @@ -0,0 +1,2 @@ + +Multiple plot in axis · NCPlots.jl
diff --git a/dev/examples/sliders_menus/index.html b/dev/examples/sliders_menus/index.html new file mode 100644 index 0000000..550487f --- /dev/null +++ b/dev/examples/sliders_menus/index.html @@ -0,0 +1,22 @@ + +Sliders and Menus · NCPlots.jl

Sliders Menus


+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

diff --git a/dev/index.html b/dev/index.html index 4187dc4..8ea5b08 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,5 +1,5 @@ -Home · NCPlots.jl

NCPlots

NCPlots is a Julia package for plotting (meteorological) data on the sphere. Datasets should conform to the CF convention and implement the CommonDataModel.jl interface like NCDatasets and GRIBDatasets

See here for some examples See Getting data how to obtain ERA5 and CARRA data.

Installation

NCPlots is in the Harmonie registry. Add the Harmonie registry (hit ] in the Julia REPL to enter package mode).

pkg> registry add https://github.com/Hirlam/HarmonieRegistry.git

Then install NCPlots with

pkg> add NCPlots 

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

julia> using NCPlots, GLMakie, NCDatasets
+Home · NCPlots.jl

NCPlots

NCPlots is a Julia package for plotting (meteorological) data on the sphere. Datasets should conform to the CF convention and implement the CommonDataModel.jl interface like NCDatasets and GRIBDatasets

See here for a basic example and Getting data how to obtain ERA5 and CARRA data.

Installation

NCPlots is in the Harmonie registry. Add the Harmonie registry (hit ] in the Julia REPL to enter package mode).

pkg> registry add https://github.com/Hirlam/HarmonieRegistry.git

Then install NCPlots with

pkg> add NCPlots 

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

julia> using NCPlots, GLMakie, NCDatasets
 julia> ds = Dataset("era5_pressure_levels_geopotential_pv.nc")
 julia> pv = view(ds,time=1)["pv"]
 pv (1440 × 721)
@@ -16,4 +16,4 @@
 plot(pv) 

The plot will update automatically with

t[]=2

to make a basic animation you can do

for ti = 1:100
    t[]=ti
    sleep(0.01)
-end 
+end
diff --git a/dev/keyboard/index.html b/dev/keyboard/index.html index 9f8a563..9224e92 100644 --- a/dev/keyboard/index.html +++ b/dev/keyboard/index.html @@ -1,2 +1,2 @@ -Keyboard control · NCPlots.jl

Keyboard controls

See Makie Camera3D documentation

Translations

KeyTranslation
rUp
fDown
aLeft
dRight
wForward
sBackward
PgUpStrech. Moving eyepostion away from lookat.
PgDnContract. moving eyeposition towards lookat.

Pan tilt roll

KeyPan, Tilt, Roll
jPan left
lPan right
iTilt up
kTilt down
eRoll clockwise
qRoll counter

Zoom

KeyZoom
uzoom in (enlarge, via fov).
ozoom out (shrink, via fov).
+Keyboard control · NCPlots.jl

Keyboard controls

See Makie Camera3D documentation

Translations

KeyTranslation
rUp
fDown
aLeft
dRight
wForward
sBackward
PgUpStrech. Moving eyepostion away from lookat.
PgDnContract. moving eyeposition towards lookat.

Pan tilt roll

KeyPan, Tilt, Roll
jPan left
lPan right
iTilt up
kTilt down
eRoll clockwise
qRoll counter

Zoom

KeyZoom
uzoom in (enlarge, via fov).
ozoom out (shrink, via fov).
diff --git a/dev/references/index.html b/dev/references/index.html index e3b92a1..e3309fc 100644 --- a/dev/references/index.html +++ b/dev/references/index.html @@ -1,3 +1,3 @@ -API reference · NCPlots.jl
NCPlots.plotFunction
fig,ax,plt = plot(var)

Plots variable var on the sphere. Returns fig ax and plt.

source
NCPlots.lonlat2xyzFunction
x,y,z = lonlat2xyz(lons,lats)

Convert lons, lats to x,y,z coordinates.

lons, lats can be either Vector or Matrix (for irregular grids in LAM models )

source
NCPlots.lonpadviewFunction
lonpadview(data::Matrix) 
-lonpadview(data::Vector)

Returns a view of data with the first row (assumed to be the longitude dimensions repeated at the end.

source
NCPlots.isperiodiclonFunction
isperiodiclon(lons)

Returns true if lons is a Vector and lons is periodic. false if lons is a Matrix (irregular grid LAM model)

source
+API reference · NCPlots.jl
NCPlots.plotFunction

fig,ax,plt = plot(ds)

Plots dataset ds

source
fig,ax,plt = plot(var)

Plots variable var on the sphere. Returns fig ax and plt.

source
NCPlots.lonlat2xyzFunction
x,y,z = lonlat2xyz(lons,lats)

Convert lons, lats to x,y,z coordinates.

lons, lats can be either Vector or Matrix (for irregular grids in LAM models )

source
NCPlots.lonpadviewFunction
lonpadview(data::Matrix) 
+lonpadview(data::Vector)

Returns a view of data with the first row (assumed to be the longitude dimensions repeated at the end.

source
NCPlots.isperiodiclonFunction
isperiodiclon(lons)

Returns true if lons is a Vector and lons is periodic. false if lons is a Matrix (irregular grid LAM model)

source
diff --git a/dev/search_index.js b/dev/search_index.js index 967a8db..e7135f3 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"references/","page":"API reference","title":"API reference","text":"NCPlots.plot\nNCPlots.plotvar!\nNCPlots.addequator!\nNCPlots.addmeridian!\nNCPlots.lonlat2xyz\nNCPlots.lonpadview\nNCPlots.isperiodiclon","category":"page"},{"location":"references/#NCPlots.plot","page":"API reference","title":"NCPlots.plot","text":"fig,ax,plt = plot(var)\n\nPlots variable var on the sphere. Returns fig ax and plt. \n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.plotvar!","page":"API reference","title":"NCPlots.plotvar!","text":"plotvar!(ax,var)\n\nPlots variables var into axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.addequator!","page":"API reference","title":"NCPlots.addequator!","text":"addequator!(ax; lat=0, kwargs...)\n\nAdds equator to axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.addmeridian!","page":"API reference","title":"NCPlots.addmeridian!","text":"addmeridian!(ax; lon=0, kwargs...)\n\nAdds meridian at lon=0 to axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.lonlat2xyz","page":"API reference","title":"NCPlots.lonlat2xyz","text":"x,y,z = lonlat2xyz(lons,lats)\n\nConvert lons, lats to x,y,z coordinates. \n\nlons, lats can be either Vector or Matrix (for irregular grids in LAM models )\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.lonpadview","page":"API reference","title":"NCPlots.lonpadview","text":"lonpadview(data::Matrix) \nlonpadview(data::Vector)\n\nReturns a view of data with the first row (assumed to be the longitude dimensions repeated at the end. \n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.isperiodiclon","page":"API reference","title":"NCPlots.isperiodiclon","text":"isperiodiclon(lons)\n\nReturns true if lons is a Vector and lons is periodic. false if lons is a Matrix (irregular grid LAM model)\n\n\n\n\n\n","category":"function"},{"location":"animations/#Animations","page":"Animations","title":"Animations","text":"","category":"section"},{"location":"animations/","page":"Animations","title":"Animations","text":"Pass in an Observable ","category":"page"},{"location":"animations/","page":"Animations","title":"Animations","text":"t = Observables(1)\nfield = @lift(view(ds(time=$t)[\"pv\"]) \nfig,ax,plt = plot(field)","category":"page"},{"location":"animations/","page":"Animations","title":"Animations","text":"Then animate like ","category":"page"},{"location":"animations/","page":"Animations","title":"Animations","text":"for i in 1:100\n t[]=i \n sleep(0.01)\nend \n","category":"page"},{"location":"animations/#Recording-animations","page":"Animations","title":"Recording animations","text":"","category":"section"},{"location":"keyboard/#Keyboard-controls","page":"Keyboard control","title":"Keyboard controls","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"See Makie Camera3D documentation","category":"page"},{"location":"keyboard/#Translations","page":"Keyboard control","title":"Translations","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Translation\nr Up\nf Down\na Left\nd Right\nw Forward\ns Backward\nPgUp Strech. Moving eyepostion away from lookat.\nPgDn Contract. moving eyeposition towards lookat.","category":"page"},{"location":"keyboard/#Pan-tilt-roll","page":"Keyboard control","title":"Pan tilt roll","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Pan, Tilt, Roll\nj Pan left\nl Pan right\ni Tilt up\nk Tilt down\ne Roll clockwise\nq Roll counter","category":"page"},{"location":"keyboard/#Zoom","page":"Keyboard control","title":"Zoom","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Zoom\nu zoom in (enlarge, via fov).\no zoom out (shrink, via fov).","category":"page"},{"location":"cds/#getting_data","page":"Getting data","title":"Getting data","text":"","category":"section"},{"location":"cds/#ERA5","page":"Getting data","title":"ERA5","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"ERA5 data can be downloaded from the Climate Data Store. Requires an account","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Complete ERA5 global atmospheric reanalysis\nERA5 hourly data on pressure levels from 1940 to present,\nERA5 hourly data on single levels from 1940 to present\nERA5-Land hourly data from 1950 to present","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Click download data in one of the datasets to get an overview of the available data. After making a selection click Show API request which will give a Python script to download the data. You can also use CDSAPI.jl julia package","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"using CDSAPI \n\nyear = 2020\nmonth = 4 # use e.g. 1:12 for all months\nday = 1:10 # use e.g. 1:31 for all days in month\ntimes = 0:1:23 # use 0:1:23 for all hours in day(s)\n\n# variable = \"mean_sea_level_pressure\" # \"surface_pressure\"\nvariable = [\"geopotential\", \"pv\"]\n\n\nCDSAPI.retrieve(\n \"reanalysis-era5-pressure-levels\",\n Dict( \n \"product_type\" => \"reanalysis\",\n \"format\" => \"netcdf\",\n \"variable\" => variable,\n \"pressure_level\" => \"500\",\n \"time\" => lpad.(times,2,\"0\") .*\":00\", # 00:00 00:06 00:12 etc \n \"day\" => lpad.(day,2,\"0\"), # 01 02 03 etc ,\n \"month\" => lpad.(month,2,\"0\"), # 01 02 03 etc\n \"year\" => \"$year\",\n # \"area\" => area # leave out for global fields\n ),\n \"era5_pressure_levels_$(join(variable,\"_\")).nc\"\n)\n","category":"page"},{"location":"cds/#Arctic-regional-reanalysis","page":"Getting data","title":"Arctic regional reanalysis","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Arctic regional reanalysis (CARRA) can be download from the climate data store ","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Artic regional reanalysis on pressure levels from 1991 to present\nArctic regional reanalysis on model levels from 1991 to present","category":"page"},{"location":"cds/#MetCoop","page":"Getting data","title":"MetCoop","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Harmonie Arome NetCDF file from Met Norway: todo","category":"page"},{"location":"#NCPlots","page":"Home","title":"NCPlots","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"NCPlots is a Julia package for plotting (meteorological) data on the sphere. Datasets should conform to the CF convention and implement the CommonDataModel.jl interface like NCDatasets and GRIBDatasets ","category":"page"},{"location":"","page":"Home","title":"Home","text":"See here for some examples See Getting data how to obtain ERA5 and CARRA data. ","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"NCPlots is in the Harmonie registry. Add the Harmonie registry (hit ] in the Julia REPL to enter package mode). ","category":"page"},{"location":"","page":"Home","title":"Home","text":"pkg> registry add https://github.com/Hirlam/HarmonieRegistry.git","category":"page"},{"location":"","page":"Home","title":"Home","text":"Then install NCPlots with ","category":"page"},{"location":"","page":"Home","title":"Home","text":"pkg> add NCPlots ","category":"page"},{"location":"#Data-requirements","page":"Home","title":"Data requirements","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"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 ","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> using NCPlots, GLMakie, NCDatasets\njulia> ds = Dataset(\"era5_pressure_levels_geopotential_pv.nc\")\njulia> pv = view(ds,time=1)[\"pv\"]\npv (1440 × 721)\n Datatype: Union{Missing, Float64}\n Dimensions: longitude × latitude\n Attributes:\n scale_factor = 1.814417934243432e-9\n add_offset = 4.442749788103522e-5\n _FillValue = -32767\n missing_value = -32767\n units = K m**2 kg**-1 s**-1\n long_name = Potential vorticity","category":"page"},{"location":"","page":"Home","title":"Home","text":"Or to control which time is shown ","category":"page"},{"location":"","page":"Home","title":"Home","text":"t = Observable(1)\npv = @lift(view(ds,time=$t)[\"pv\"])\nplot(pv) ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The plot will update automatically with ","category":"page"},{"location":"","page":"Home","title":"Home","text":"t[]=2","category":"page"},{"location":"","page":"Home","title":"Home","text":"to make a basic animation you can do","category":"page"},{"location":"","page":"Home","title":"Home","text":"for ti = 1:100\n t[]=ti\n sleep(0.01)\nend ","category":"page"},{"location":"example/#Examples","page":"Examples","title":"Examples","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"These examples use NetCDF files from the docs/src/assets directory. For the animations download larger datasets as exlained in the Getting data section. ","category":"page"},{"location":"example/#ERA5-potential-vorticity","page":"Examples","title":"ERA5 potential vorticity","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"using NCPlots, GLMakie, NCDatasets\nds = Dataset(\"assets/era5_pv_z_500hPa.nc\")\npv = view(ds, time=1)[\"pv\"]\nfig, ax, plt = plot(pv, colormap=:RdBu, colorrange=(-3e-6,3e-6))\nsave(\"assets/era5_pv_docs.png\", fig) # hide","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: ) ","category":"page"},{"location":"example/#Control-light","page":"Examples","title":"Control light","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"Access properties specular diffuse etc. in the returned plt.","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: )","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"Explain how to update camera, change lightposition ","category":"page"},{"location":"example/#Mutliple-plots-in-single-axis","page":"Examples","title":"Mutliple plots in single axis","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"See docs/plotlogo.jl for an example ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: )","category":"page"},{"location":"example/#Plot-on-geopotential-height-surface","page":"Examples","title":"Plot on geopotential height surface","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"Multiply x, y, z by geopotential height ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: )","category":"page"},{"location":"example/#Plot-on-orography","page":"Examples","title":"Plot on orography","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"See plot geopotential height. Color show temperature increments from data assimilation ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: ) ","category":"page"},{"location":"example/#CARRA","page":"Examples","title":"CARRA","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: ) (Image: )","category":"page"},{"location":"example/#Metcoop","page":"Examples","title":"Metcoop","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"archive=\"/lustre/storeB/immutable/archive/projects/metproduction/MEPS/\"\nds = Dataset(\"$archive/2023/10/01/meps_det_2_5km_20231001T00Z.nc\")\nfield = view(ds,hybrid=65,time=1)[\"air_temperature_ml\"]\nplot(field)","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: ) ","category":"page"},{"location":"example/#Animated-plots","page":"Examples","title":"Animated plots","text":"","category":"section"},{"location":"example/","page":"Examples","title":"Examples","text":"To make these animations use Observables and @lift to lift the dataset view e.g.","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"ds = Dataset(...) \nt = Observable(1)\npv = @lift(view(ds,time=$t)[\"pv\"]) \nplot(pv) ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"Updating t wil update the plot e.g.","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"for i=1:100\n t[] = i\n sleep(0.01)\nend ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: )","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"You can access eyeposition in ax.scene and update in the for loop ","category":"page"},{"location":"example/","page":"Examples","title":"Examples","text":"(Image: )","category":"page"}] +[{"location":"references/","page":"API reference","title":"API reference","text":"NCPlots.plot\nNCPlots.plotvar!\nNCPlots.addequator!\nNCPlots.addmeridian!\nNCPlots.lonlat2xyz\nNCPlots.lonpadview\nNCPlots.isperiodiclon","category":"page"},{"location":"references/#NCPlots.plot","page":"API reference","title":"NCPlots.plot","text":"fig,ax,plt = plot(ds) \n\nPlots dataset ds \n\n\n\n\n\nfig,ax,plt = plot(var)\n\nPlots variable var on the sphere. Returns fig ax and plt. \n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.plotvar!","page":"API reference","title":"NCPlots.plotvar!","text":"plotvar!(ax,var)\n\nPlots variables var into axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.addequator!","page":"API reference","title":"NCPlots.addequator!","text":"addequator!(ax; lat=0, kwargs...)\n\nAdds equator to axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.addmeridian!","page":"API reference","title":"NCPlots.addmeridian!","text":"addmeridian!(ax; lon=0, kwargs...)\n\nAdds meridian at lon=0 to axis ax\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.lonlat2xyz","page":"API reference","title":"NCPlots.lonlat2xyz","text":"x,y,z = lonlat2xyz(lons,lats)\n\nConvert lons, lats to x,y,z coordinates. \n\nlons, lats can be either Vector or Matrix (for irregular grids in LAM models )\n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.lonpadview","page":"API reference","title":"NCPlots.lonpadview","text":"lonpadview(data::Matrix) \nlonpadview(data::Vector)\n\nReturns a view of data with the first row (assumed to be the longitude dimensions repeated at the end. \n\n\n\n\n\n","category":"function"},{"location":"references/#NCPlots.isperiodiclon","page":"API reference","title":"NCPlots.isperiodiclon","text":"isperiodiclon(lons)\n\nReturns true if lons is a Vector and lons is periodic. false if lons is a Matrix (irregular grid LAM model)\n\n\n\n\n\n","category":"function"},{"location":"examples/single_axis/#Mutliple-plots-in-single-axis","page":"Multiple plot in axis","title":"Mutliple plots in single axis","text":"","category":"section"},{"location":"examples/single_axis/","page":"Multiple plot in axis","title":"Multiple plot in axis","text":"See docs/plotlogo.jl for an example ","category":"page"},{"location":"examples/single_axis/","page":"Multiple plot in axis","title":"Multiple plot in axis","text":"(Image: )","category":"page"},{"location":"examples/animations/#Animations","page":"Animation","title":"Animations","text":"","category":"section"},{"location":"examples/animations/#Animated-plots","page":"Animation","title":"Animated plots","text":"","category":"section"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"To make these animations use Observables and @lift to lift the dataset view e.g.","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"ds = Dataset(...) \nt = Observable(1)\npv = @lift(view(ds,time=$t)[\"pv\"]) \nplot(pv) ","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"Updating t wil update the plot e.g.","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"for i=1:100\n t[] = i\n sleep(0.01)\nend ","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"(Image: )","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"You can access eyeposition in ax.scene and update in the for loop ","category":"page"},{"location":"examples/animations/","page":"Animation","title":"Animation","text":"(Image: )","category":"page"},{"location":"examples/animations/#Recording-animations","page":"Animation","title":"Recording animations","text":"","category":"section"},{"location":"examples/sliders_menus/#Sliders-Menus","page":"Sliders and Menus","title":"Sliders Menus","text":"","category":"section"},{"location":"examples/sliders_menus/","page":"Sliders and Menus","title":"Sliders and Menus","text":"\ncrangedict = Dict(\n \"pv\" => (-2e-6,2e-6),\n \"z\" => (20000.0,50000.0)\n)\n\nfig = Figure()\n\nmenu = Menu(fig[1,1],options=setdiff(keys(ds),dimnames(ds)))\nmenu2 = Menu(fig[1,2], options=colorschemes)\nsl = SliderGrid(fig[2,1],\n (label=\"time\", range=1:length(ds[\"time\"]),startvalue=1,format = x-> Dates.format(ds[\"time\"][x],\"yyyymmdd-HH\"))\n )\nax = LScene(fig[3,1], show_axis=false)\ncolorrange=@lift(crangedict($(menu.selection)))\ncolormap=@lift(colorschem)\n\nds = Dataset(\"...\")\ndsv = @lift(view(ds,time=$(sl.sliders[1].value))[$(menu.selection)])\nplotvar!(ax,dsv,colorrange=colorrange,colormap=:RdBu)\n","category":"page"},{"location":"examples/sliders_menus/#Level-slider","page":"Sliders and Menus","title":"Level slider","text":"","category":"section"},{"location":"examples/metcoop/#Metcoop","page":"Metcoop Increments","title":"Metcoop","text":"","category":"section"},{"location":"examples/metcoop/","page":"Metcoop Increments","title":"Metcoop Increments","text":"Example reading from MEPS archive at MET Norway ","category":"page"},{"location":"examples/metcoop/","page":"Metcoop Increments","title":"Metcoop Increments","text":"using Glob, NCDatasets, NCPlots, GLMakie\n\narchive=\"/lustre/storeB/immutable/archive/projects/metproduction/MEPS/2023/01/30\"\n\nfiles = glob(\"meps_det_2_5km*.nc\", archive) # use e.g. \"....*00.nc\" to only match files with 00:00 UTC\n\nds = NCDatasets.Dataset(files, aggdim=\"cycle\", isnewdim=true, constvars=[\"x\",\"y\",\"hybrid\",\"time\"],deferopen=false) \n\nfig = Figure() \nfcint = 3; llmax=66; nlev=65\n\n\ntsl, lsl,csl = SliderGrid(fig[2,1], \n (label=\"LL\",range=1:(llmax-fcint),startvalue=1), \n (label=\"Level\",range=nlev:-1:1,startvalue=nlev),\n (label=\"Cycle\",range=2:length(files),startvalue=2),\n tellheight=false,\n width=350\n)\nax= Axis(fig[1,2])\n\nvarname = \"air_temperature_ml\"\nvar = ds[varname]\n\ndsv = @lift(var[:,:,$(lsl.value),$(tsl.value),$(csl.value)] -\n var[:,:,$(lsl.value),$(tsl.value)+3,$(csl.value)-1]\n )\n\ntitle = @lift(string(Analysis increment, \" \" ,varname, basename(files[$(cycle_sl.value)]))\nsubtitle = @lift(string(\" Level \", $(lsl.value), \"forecast\", $(tsl.value)-1, \" Hour\") )\n\nheatmap!(ax,dsv,colormap=:RdBu,colorrange=(-2,2))\nLabel(fig[0,:],label,tellwidth=false)\nLabel(fig[1,:],label,tellwidth=false)","category":"page"},{"location":"examples/metcoop/","page":"Metcoop Increments","title":"Metcoop Increments","text":"(Image: )","category":"page"},{"location":"examples/light/#Control-light","page":"Light","title":"Control light","text":"","category":"section"},{"location":"examples/light/","page":"Light","title":"Light","text":"Access properties specular diffuse etc. in the returned plt.","category":"page"},{"location":"examples/light/","page":"Light","title":"Light","text":"(Image: )","category":"page"},{"location":"examples/light/","page":"Light","title":"Light","text":"Explain how to update camera, change lightposition ","category":"page"},{"location":"examples/era5_pv/#example","page":"Basic","title":"Example","text":"","category":"section"},{"location":"examples/era5_pv/","page":"Basic","title":"Basic","text":"These examples use NetCDF files from the docs/src/assets directory. For the animations download larger datasets as exlained in the Getting data section. ","category":"page"},{"location":"examples/era5_pv/#ERA5-potential-vorticity","page":"Basic","title":"ERA5 potential vorticity","text":"","category":"section"},{"location":"examples/era5_pv/","page":"Basic","title":"Basic","text":"using NCPlots, GLMakie, NCDatasets\nds = Dataset(\"assets/era5_pv_z_500hPa.nc\")\npv = view(ds, time=1)[\"pv\"]\nfig, ax, plt = plot(pv, colormap=:RdBu, colorrange=(-3e-6,3e-6))\nsave(\"assets/era5_pv_docs.png\", fig) # hide","category":"page"},{"location":"examples/era5_pv/","page":"Basic","title":"Basic","text":"(Image: ) ","category":"page"},{"location":"examples/lam/#Limited-area-plots","page":"Limited Area plots","title":"Limited area plots","text":"","category":"section"},{"location":"examples/lam/#CARRA","page":"Limited Area plots","title":"CARRA","text":"","category":"section"},{"location":"examples/lam/","page":"Limited Area plots","title":"Limited Area plots","text":"(Image: ) (Image: )","category":"page"},{"location":"examples/lam/#Metcoop","page":"Limited Area plots","title":"Metcoop","text":"","category":"section"},{"location":"examples/lam/","page":"Limited Area plots","title":"Limited Area plots","text":"archive=\"/lustre/storeB/immutable/archive/projects/metproduction/MEPS/\"\nds = Dataset(\"$archive/2023/10/01/meps_det_2_5km_20231001T00Z.nc\")\nfield = view(ds,hybrid=65,time=1)[\"air_temperature_ml\"]\nplot(field)","category":"page"},{"location":"examples/lam/","page":"Limited Area plots","title":"Limited Area plots","text":"(Image: ) ","category":"page"},{"location":"cds/#getting_data","page":"Getting data","title":"Getting data","text":"","category":"section"},{"location":"cds/#ERA5","page":"Getting data","title":"ERA5","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"ERA5 data can be downloaded from the Climate Data Store. Requires an account","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Complete ERA5 global atmospheric reanalysis\nERA5 hourly data on pressure levels from 1940 to present,\nERA5 hourly data on single levels from 1940 to present\nERA5-Land hourly data from 1950 to present","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Click download data in one of the datasets to get an overview of the available data. After making a selection click Show API request which will give a Python script to download the data. You can also use CDSAPI.jl julia package","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"using CDSAPI \n\nyear = 2020\nmonth = 4 # use e.g. 1:12 for all months\nday = 1:10 # use e.g. 1:31 for all days in month\ntimes = 0:1:23 # use 0:1:23 for all hours in day(s)\n\n# variable = \"mean_sea_level_pressure\" # \"surface_pressure\"\nvariable = [\"geopotential\", \"pv\"]\n\n\nCDSAPI.retrieve(\n \"reanalysis-era5-pressure-levels\",\n Dict( \n \"product_type\" => \"reanalysis\",\n \"format\" => \"netcdf\",\n \"variable\" => variable,\n \"pressure_level\" => \"500\",\n \"time\" => lpad.(times,2,\"0\") .*\":00\", # 00:00 00:06 00:12 etc \n \"day\" => lpad.(day,2,\"0\"), # 01 02 03 etc ,\n \"month\" => lpad.(month,2,\"0\"), # 01 02 03 etc\n \"year\" => \"$year\",\n # \"area\" => area # leave out for global fields\n ),\n \"era5_pressure_levels_$(join(variable,\"_\")).nc\"\n)\n","category":"page"},{"location":"cds/#Arctic-regional-reanalysis","page":"Getting data","title":"Arctic regional reanalysis","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Arctic regional reanalysis (CARRA) can be download from the climate data store ","category":"page"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Artic regional reanalysis on pressure levels from 1991 to present\nArctic regional reanalysis on model levels from 1991 to present","category":"page"},{"location":"cds/#MetCoop","page":"Getting data","title":"MetCoop","text":"","category":"section"},{"location":"cds/","page":"Getting data","title":"Getting data","text":"Harmonie Arome NetCDF file from Met Norway: todo","category":"page"},{"location":"examples/geopotential/#Plot-on-geopotential-height-surface","page":"Geopotential height","title":"Plot on geopotential height surface","text":"","category":"section"},{"location":"examples/geopotential/","page":"Geopotential height","title":"Geopotential height","text":"Multiply x, y, z by geopotential height ","category":"page"},{"location":"examples/geopotential/","page":"Geopotential height","title":"Geopotential height","text":"(Image: )","category":"page"},{"location":"examples/geopotential/#Plot-on-orography","page":"Geopotential height","title":"Plot on orography","text":"","category":"section"},{"location":"examples/geopotential/","page":"Geopotential height","title":"Geopotential height","text":"See plot geopotential height. Color show temperature increments from data assimilation ","category":"page"},{"location":"examples/geopotential/","page":"Geopotential height","title":"Geopotential height","text":"(Image: ) ","category":"page"},{"location":"keyboard/#Keyboard-controls","page":"Keyboard control","title":"Keyboard controls","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"See Makie Camera3D documentation","category":"page"},{"location":"keyboard/#Translations","page":"Keyboard control","title":"Translations","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Translation\nr Up\nf Down\na Left\nd Right\nw Forward\ns Backward\nPgUp Strech. Moving eyepostion away from lookat.\nPgDn Contract. moving eyeposition towards lookat.","category":"page"},{"location":"keyboard/#Pan-tilt-roll","page":"Keyboard control","title":"Pan tilt roll","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Pan, Tilt, Roll\nj Pan left\nl Pan right\ni Tilt up\nk Tilt down\ne Roll clockwise\nq Roll counter","category":"page"},{"location":"keyboard/#Zoom","page":"Keyboard control","title":"Zoom","text":"","category":"section"},{"location":"keyboard/","page":"Keyboard control","title":"Keyboard control","text":"Key Zoom\nu zoom in (enlarge, via fov).\no zoom out (shrink, via fov).","category":"page"},{"location":"#NCPlots","page":"Home","title":"NCPlots","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"NCPlots is a Julia package for plotting (meteorological) data on the sphere. Datasets should conform to the CF convention and implement the CommonDataModel.jl interface like NCDatasets and GRIBDatasets ","category":"page"},{"location":"","page":"Home","title":"Home","text":"See here for a basic example and Getting data how to obtain ERA5 and CARRA data. ","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"NCPlots is in the Harmonie registry. Add the Harmonie registry (hit ] in the Julia REPL to enter package mode). ","category":"page"},{"location":"","page":"Home","title":"Home","text":"pkg> registry add https://github.com/Hirlam/HarmonieRegistry.git","category":"page"},{"location":"","page":"Home","title":"Home","text":"Then install NCPlots with ","category":"page"},{"location":"","page":"Home","title":"Home","text":"pkg> add NCPlots ","category":"page"},{"location":"#Data-requirements","page":"Home","title":"Data requirements","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"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 ","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> using NCPlots, GLMakie, NCDatasets\njulia> ds = Dataset(\"era5_pressure_levels_geopotential_pv.nc\")\njulia> pv = view(ds,time=1)[\"pv\"]\npv (1440 × 721)\n Datatype: Union{Missing, Float64}\n Dimensions: longitude × latitude\n Attributes:\n scale_factor = 1.814417934243432e-9\n add_offset = 4.442749788103522e-5\n _FillValue = -32767\n missing_value = -32767\n units = K m**2 kg**-1 s**-1\n long_name = Potential vorticity","category":"page"},{"location":"","page":"Home","title":"Home","text":"Or to control which time is shown ","category":"page"},{"location":"","page":"Home","title":"Home","text":"t = Observable(1)\npv = @lift(view(ds,time=$t)[\"pv\"])\nplot(pv) ","category":"page"},{"location":"","page":"Home","title":"Home","text":"The plot will update automatically with ","category":"page"},{"location":"","page":"Home","title":"Home","text":"t[]=2","category":"page"},{"location":"","page":"Home","title":"Home","text":"to make a basic animation you can do","category":"page"},{"location":"","page":"Home","title":"Home","text":"for ti = 1:100\n t[]=ti\n sleep(0.01)\nend ","category":"page"}] }