Skip to content

Instantly share code, notes, and snippets.

View briochemc's full-sized avatar

Benoît Pasquier briochemc

View GitHub Profile
using Makie
using AbstractPlotting
using FileIO, Colors
# Load World Ocean Atlas 2D fields for PO₄, Si(OH)₄, and NO₄
using WorldOceanAtlasTools
lat, lon, PO₄_2D = WorldOceanAtlasTools.WOA13_surface_map("p", 0, "1°")
lat, lon, NO₄_2D = WorldOceanAtlasTools.WOA13_surface_map("n", 0, "1°")
lat, lon, SiOH₄_2D = WorldOceanAtlasTools.WOA13_surface_map("i", 0, "1°")
# Add the image layer to each plot
using AIBECS, Plots
grd, TOCIM1 = OCIM1.load()
T(p) = TOCIM1
function G(x,p)
@unpack τ, z₀ = p
return @. 1 - x / τ * (z < z₀)
end
z = depthvec(grd)
F, ∇ₓF = state_function_and_Jacobian(T, G)
struct IdealAgeParameters{U} <: AbstractParameters{U}
using Luxor, Colors
function main(fname)
Drawing(600, 600, fname)
origin()
circle(O, 290, :clip)
sethue("white")
paint()
colors = [Luxor.julia_blue, Luxor.julia_red, Luxor.julia_green, Luxor.julia_purple]
using AIBECS, ModelingToolkit, LinearAlgebra
# dispatch for sparse matrices
Base.:*(A::SparseMatrixCSC{Operation,S}, x::StridedVector{Operation}) where {S} =
(T = Operation; mul!(similar(x, T, A.m), A, x, true, false))
Base.:*(A::SparseMatrixCSC{Tx,S}, x::StridedVector{Operation}) where {Tx,S} =
(T = LinearAlgebra.promote_op(LinearAlgebra.matprod, Operation, Tx); mul!(similar(x, T, A.m), A, x, true, false))
Base.:*(A::SparseMatrixCSC{Operation,S}, x::StridedVector{Tx}) where {Tx,S} =
(T = LinearAlgebra.promote_op(LinearAlgebra.matprod, Operation, Tx); mul!(similar(x, T, A.m), A, x, true, false))
@briochemc
briochemc / covid19.jl
Last active April 2, 2020 06:37 — forked from mbauman/covid19.jl
using HTTP, CSV, Plots, DataFrames, Dates
# Download the data
df = CSV.read(IOBuffer(String(HTTP.get("https://covid.ourworldindata.org/data/total_cases.csv").body)), normalizenames=true)
# Plotting function
function doit(df, countries, alignment)
cp = get_color_palette(:auto, plot_color(:white), length(countries))
plot(legend=false)
for (i,country) in enumerate(countries)
@briochemc
briochemc / Automatic-figure-sizing-1.svg
Last active April 24, 2020 14:21
svg files for ProPlot Julia examples
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NEIGHBORS_MAP = {
0: (0, 0, 0, 0, 1, 0, 1, 0, 0, 0),
1: (0, 0, 0, 0, 0, 0, 1, 0, 1, 0),
2: (0, 0, 0, 0, 0, 0, 0, 1, 0, 1),
3: (0, 0, 0, 0, 1, 0, 0, 0, 1, 0),
4: (1, 0, 0, 1, 0, 0, 0, 0, 0, 1),
5: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
6: (1, 1, 0, 0, 0, 0, 0, 1, 0, 0),
7: (0, 0, 1, 0, 0, 0, 1, 0, 0, 0),
8: (0, 1, 0, 1, 0, 0, 0, 0, 0 ,0),
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@briochemc
briochemc / dancing_cubes.jl
Last active June 27, 2020 08:41 — forked from jkrumbiegel/dancing_cubes.jl
Dancing cubes
using AbstractPlotting
using MakieLayout
using GLMakie; GLMakie.activate!()
GLMakie.GLFW.WindowHint(GLMakie.GLFW.FLOATING, 1)
using LinearAlgebra
##
scene = Scene(center = false, raw = true, resolution = (800, 800))
@briochemc
briochemc / nothing.jl
Created July 6, 2020 04:37
gifs for tuto
# Just trying stuff