Plot basic things

This guide is organized as follows

In this guide we will focus on how-to plot things using AIBECS' built-in recipes for Plots.jl. These recipes are implemented using RecipesBase.jl, which are explained in Plots.jl's documentation.

Throughout we will use the OCIM2 grid and we will create a dummy tracer as a function of location to showcase each plot, just for the sake of the examples herein.

using Plots
using AIBECS
grd, _ = OCIM2.load()
dummy = cosd.(latvec(grd))
200160-element Vector{Float64}:
 0.3221204417984906
 0.3546048870425357
 0.38666674294141884
 0.41826780077556525
 0.44937040096716135
 0.4799374779597864
 0.5099326043901359
 0.5393200344991993
 0.5680647467311559
 0.5961324854692254
 ⋮
 0.8854560256532099
 0.8688879687250066
 0.9154080085253663
 0.9009688679024191
 0.8854560256532099
 0.8688879687250066
 0.9154080085253663
 0.9009688679024191
 0.8854560256532099

Horizontal plots

Horizontal slice

The most common thing you plot after a simulation of marine tracers is a horizontal slice. In this case, you just need to provide the tracer (dummy here), the grid object grd, and the depth at which you want to plot.

plothorizontalslice(dummy, grd, depth=10)
Example block output

You can supply units for the depth at which you want to see the horizontal slice.

plothorizontalslice(dummy, grd, depth=10u"m")
Example block output

And the units should be understood under the hood.

plothorizontalslice(dummy, grd, depth=3u"km")
Example block output

If your tracer is supplied with units, those will show in the colorbar label

plothorizontalslice(dummy * u"mol/m^3", grd, depth=10u"m")
Example block output

The advantage of Plots.jl recipes like this one is that you can specify other pieces of the plot as you would with built-in functions. The advantage of Plots.jl recipes like this one is that you can specify other pieces of the plot as you would with built-in functions. For example, you can chose the colormap with the color keyword argument.

dummy .*= cosd.(lonvec(grd))
plt = plothorizontalslice(dummy, grd, depth=100, color=:balance)
Example block output

And you can finetune attributes after the plot is created.

plot!(plt, xlabel="Lon", ylabel="Lat", colorbar_title="dummy value", title="The pacific as a whole")
Example block output

Vertical plots

Exploring the vertical distribution of tracers is important after all.

Zonal slices

You must specify the longitude

dummy = cosd.(latvec(grd))
dummy .+= sqrt.(depthvec(grd)) / 30
plotmeridionalslice(dummy, grd, lon=330)
Example block output

Zonal averages

Global zonal average

zonalaverage(dummy, grd)
91×24 Matrix{Float64}:
 NaN         NaN         NaN         …  NaN        NaN        NaN  NaN  NaN
 NaN         NaN         NaN            NaN        NaN        NaN  NaN  NaN
 NaN         NaN         NaN            NaN        NaN        NaN  NaN  NaN
 NaN         NaN         NaN            NaN        NaN        NaN  NaN  NaN
 NaN         NaN         NaN            NaN        NaN        NaN  NaN  NaN
 NaN         NaN         NaN         …  NaN        NaN        NaN  NaN  NaN
   0.364207    0.469204    0.545227     NaN        NaN        NaN  NaN  NaN
   0.397726    0.502722    0.578745     NaN        NaN        NaN  NaN  NaN
   0.430939    0.535935    0.611958       2.2012   NaN        NaN  NaN  NaN
   0.463807    0.568804    0.644827       2.23407    2.36494  NaN  NaN  NaN
   ⋮                                 ⋱               ⋮                  
   0.430939    0.535935    0.611958     NaN        NaN        NaN  NaN  NaN
   0.397726    0.502722    0.578745     NaN        NaN        NaN  NaN  NaN
   0.364207    0.469204    0.545227     NaN        NaN        NaN  NaN  NaN
   0.330424    0.435421    0.511444  …  NaN        NaN        NaN  NaN  NaN
   0.296416    0.401412    0.477436     NaN        NaN        NaN  NaN  NaN
   0.262223    0.36722     0.443243     NaN        NaN        NaN  NaN  NaN
   0.227887    0.332883    0.408907       1.99815  NaN        NaN  NaN  NaN
   0.193448    0.298444    0.374468       1.96371  NaN        NaN  NaN  NaN
 NaN         NaN         NaN         …  NaN        NaN        NaN  NaN  NaN

If you want a zonal average over a specific region, you can just mask it out

Basin zonal average

This is experimental at this stage and relies on OceanBasins.jl. You can create basin masks using this package with

using OceanBasins
OCEANS = oceanpolygons()
basins = sum(i*isbasin(latvec(grd), lonvec(grd), OCEANS) for (i,isbasin) in enumerate([isindian2, ispacific2, isatlantic2, isantarctic]))
plothorizontalslice(basins, grd, depth=0, seriestype=:heatmap, color=:lightrainbow)
Example block output

and you can mask a specific region with the mask keyword argument

mPAC = ispacific(latvec(grd), lonvec(grd), OCEANS)
plotzonalaverage(dummy, grd, mask=mPAC)
Example block output

Meridional slices

Just as you should expect at this stage, you can plot a meridional slice with

plotmeridionalslice(dummy, grd, lon=-30)
Example block output

Depth profiles

Sometimes you want a profile at a given station or location

plotdepthprofile(dummy, grd, lonlat=(-30,30))
Example block output

This page was generated using Literate.jl.